1 # use GNU Make to run tests in parallel, and without depending on RubyGems
7 GIT_URL
= git
://git.bogomips.org
/zbatery.git
9 GIT-VERSION-FILE
: .FORCE-GIT-VERSION-FILE
11 -include GIT-VERSION-FILE
13 ifeq ($(DLEXT
),) # "so" for Linux
14 DLEXT
:= $(shell $(RUBY
) -rrbconfig
-e
'puts Config::CONFIG["DLEXT"]')
16 ifeq ($(RUBY_VERSION
),)
17 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
19 RUBY_ENGINE
:= $(shell $(RUBY
) -e
'puts((RUBY_ENGINE rescue "ruby"))')
22 bins
:= $(addprefix bin
/, $(base_bins
))
23 man1_rdoc
:= $(addsuffix _1
, $(base_bins
))
24 man1_bins
:= $(addsuffix .1, $(base_bins
))
25 man1_paths
:= $(addprefix man
/man1
/, $(man1_bins
))
31 cp
-p bin
/* .install-tmp
34 mv .install-tmp
/* bin
/
38 setup_rb_files
:= .config InstalledFiles
39 prep_setup_rb
:= @
-$(RM
) $(setup_rb_files
);$(MAKE
) -C
$(ext
) clean
42 -$(MAKE
) -C
$(ext
) clean
43 -$(MAKE
) -C Documentation
clean
44 $(RM
) $(setup_rb_files
) $(t_log
)
47 $(MAKE
) -C Documentation install-man
49 pkg_extra
:= GIT-VERSION-FILE NEWS ChangeLog
50 manifest
: $(pkg_extra
) man
56 for i in
$@
$(pkg_extra
) $(man1_paths
); \
57 do echo
$$i; done
) | LC_ALL
=C
sort > $@
+
58 cmp
$@
+ $@ || mv
$@
+ $@
61 NEWS
: GIT-VERSION-FILE
62 $(RAKE
) -s news_rdoc
> $@
+
66 ChangeLog
: LOG_VERSION
= \
67 $(shell git rev-parse
-q
"$(GIT_VERSION)" >/dev
/null
2>&1 && \
68 echo
$(GIT_VERSION
) || git describe
)
70 ChangeLog
: log_range
= v
$(SINCE
)..
$(LOG_VERSION
)
72 ChangeLog
: GIT-VERSION-FILE
73 @echo
"ChangeLog from $(GIT_URL) ($(log_range))" > $@
+
75 git log
$(log_range
) | sed
-e
's/^/ /' >> $@
+
78 news_atom
:= http
://zbatery.bogomip.org
/NEWS.atom.xml
79 cgit_atom
:= http
://git.bogomips.org
/cgit
/zbatery.git
/atom
/?h
=master
80 atom
= <link rel
="alternate" title
="Atom feed" href
="$(1)" \
81 type
="application/atom+xml"/>
84 doc
: .document NEWS ChangeLog
85 for i in
$(man1_rdoc
); do echo
> $$i; done
86 find bin lib
-type f
-name
'*.rbc' -exec
rm -f
'{}' ';'
87 rdoc
-t
"$(shell sed -ne '1s/^= //p' README)"
88 install -m644 COPYING doc
/COPYING
89 install -m644
$(shell grep
'^[A-Z]' .document
) doc
/
90 $(MAKE
) -C Documentation install-html install-man
91 install -m644
$(man1_paths
) doc
/
92 cd doc
&& for i in
$(base_bins
); do \
93 $(RM
) 1.html
$${i}.1.html
; \
94 sed
-e
'/"documentation">/r man1/'$$i'.1.html' \
95 < $${i}_1.html
> tmp
&& mv tmp
$${i}_1.html
; \
96 ln
$${i}_1.html
$${i}.1.html
; \
99 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
102 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
103 doc
/NEWS.html doc
/README.html
104 $(RAKE
) -s news_atom
> doc
/NEWS.atom.xml
105 cd doc
&& ln README.html tmp
&& mv tmp index.html
108 # publishes docs to http://zbatery.bogomip.org/
111 $(RM
) -r doc ChangeLog NEWS
112 $(MAKE
) doc LOG_VERSION
=$(shell git tag
-l | tail
-1)
113 awk
'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
115 find doc
/images doc
/js
-type f | \
116 TZ
=UTC xargs touch
-d
'1970-01-01 00:00:01' doc
/rdoc.css
118 chmod
644 $$(find doc
-type f
)
119 $(RSYNC
) -av doc
/ zbatery.bogomip.org
:/srv
/zbatery
/
120 git ls-files | xargs touch
122 # Create gzip variants of the same timestamp as the original so nginx
123 # "gzip_static on" can serve the gzipped versions directly.
124 doc_gz
: docs
= $(shell find doc
-type f
! -regex
'^.*\.\(gif\|jpg\|png\|gz\)$$')
126 touch doc
/NEWS.atom.xml
-d
"$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
127 for i in
$(docs
); do \
128 gzip
--rsyncable
-9 < $$i > $$i.gz
; touch
-r
$$i $$i.gz
; done
131 rfproject
:= rainbows
133 pkggem
:= pkg
/$(rfpackage
)-$(VERSION
).gem
134 pkgtgz
:= pkg
/$(rfpackage
)-$(VERSION
).tgz
135 release_notes
:= release_notes-
$(VERSION
)
136 release_changes
:= release_changes-
$(VERSION
)
138 release-notes
: $(release_notes
)
139 release-changes
: $(release_changes
)
141 $(RAKE
) -s release_changes
> $@
+
142 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
144 GIT_URL
=$(GIT_URL
) $(RAKE
) -s release_notes
> $@
+
145 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
147 # ensures we're actually on the tagged $(VERSION), only used for release
149 test x
"$(shell umask)" = x0022
150 git rev-parse
--verify refs
/tags/v
$(VERSION
)^
{}
151 git diff-index
--quiet HEAD^
0
152 test `git rev-parse --verify HEAD^0` = \
153 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
156 -git ls-tree
-r HEAD | awk
'/^100644 / {print $$NF}' | xargs chmod
644
157 -git ls-tree
-r HEAD | awk
'/^100755 / {print $$NF}' | xargs chmod
755
161 install-gem
: $(pkggem
)
162 gem
install $(CURDIR
)/$<
164 $(pkggem
): manifest fix-perms
165 gem build
$(rfpackage
).gemspec
169 $(pkgtgz
): distdir
= $(basename $@
)
170 $(pkgtgz
): HEAD
= v
$(VERSION
)
171 $(pkgtgz
): manifest fix-perms
172 @
test -n
"$(distdir)"
175 tar c
`cat .manifest` |
(cd
$(distdir
) && tar x
)
176 cd pkg
&& tar c
$(basename $(@F
)) | gzip
-9 > $(@F
)+
179 package
: $(pkgtgz
) $(pkggem
)
181 release
: verify package
$(release_notes
) $(release_changes
)
182 # make tgz release on RubyForge
183 rubyforge add_release
-f
-n
$(release_notes
) -a
$(release_changes
) \
184 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkgtgz
)
185 # push gem to RubyGems.org
187 # in case of gem downloads from RubyForge releases page
188 -rubyforge add_file \
189 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkggem
)
190 $(RAKE
) raa_update VERSION
=$(VERSION
)
191 $(RAKE
) fm_update VERSION
=$(VERSION
)
193 gem install-gem
: GIT-VERSION-FILE
194 $(MAKE
) $@ VERSION
=$(GIT_VERSION
)
201 .PHONY
: .FORCE-GIT-VERSION-FILE doc manifest man
test