trap and noop SIGWINCH, too
[zbatery.git] / GNUmakefile
blob8655ca84bc6f39f56cd171c455e122a3aa31052f
1 # use GNU Make to run tests in parallel, and without depending on RubyGems
2 all::
3 RUBY = ruby
4 RAKE = rake
5 GIT_URL = git://git.bogomips.org/zbatery.git
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 RUBY = ruby
10 -include GIT-VERSION-FILE
11 -include local.mk
12 ifeq ($(DLEXT),) # "so" for Linux
13 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
14 endif
15 ifeq ($(RUBY_VERSION),)
16 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
17 endif
19 base_bins := zbatery
20 bins := $(addprefix bin/, $(base_bins))
21 man1_bins := $(addsuffix .1, $(base_bins))
22 man1_paths := $(addprefix man/man1/, $(man1_bins))
24 install: $(bins)
25 $(prep_setup_rb)
26 $(RM) -r .install-tmp
27 mkdir .install-tmp
28 cp -p bin/* .install-tmp
29 $(RUBY) setup.rb all
30 $(RM) $^
31 mv .install-tmp/* bin/
32 $(RM) -r .install-tmp
33 $(prep_setup_rb)
35 setup_rb_files := .config InstalledFiles
36 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
38 clean:
39 -$(MAKE) -C $(ext) clean
40 -$(MAKE) -C Documentation clean
41 $(RM) $(setup_rb_files) $(t_log)
43 man:
44 $(MAKE) -C Documentation install-man
46 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
47 manifest: $(pkg_extra) man
48 $(RM) .manifest
49 $(MAKE) .manifest
51 .manifest:
52 (git ls-files && \
53 for i in $@ $(pkg_extra) $(man1_paths); \
54 do echo $$i; done) | LC_ALL=C sort > $@+
55 cmp $@+ $@ || mv $@+ $@
56 $(RM) $@+
58 NEWS: GIT-VERSION-FILE
59 $(RAKE) -s news_rdoc > $@+
60 mv $@+ $@
62 SINCE = 0.5.0
63 ChangeLog: LOG_VERSION = \
64 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
65 echo $(GIT_VERSION) || git describe)
66 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
67 ChangeLog: GIT-VERSION-FILE
68 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
69 @echo >> $@+
70 git log $(log_range) | sed -e 's/^/ /' >> $@+
71 mv $@+ $@
73 news_atom := http://zbatery.bogomips.org.org/NEWS.atom.xml
74 cgit_atom := http://git.bogomips.org/cgit/zbatery.git/atom/?h=master
75 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
76 type="application/atom+xml"/>
78 # using rdoc 2.4.1+
79 doc: .document NEWS ChangeLog
80 for i in $(man1_bins); do > $$i; done
81 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
82 install -m644 COPYING doc/COPYING
83 install -m644 $(shell grep '^[A-Z]' .document) doc/
84 $(MAKE) -C Documentation install-html install-man
85 install -m644 $(man1_paths) doc/
86 cd doc && for i in $(base_bins); do \
87 sed -e '/"documentation">/r man1/'$$i'.1.html' \
88 < $${i}_1.html > tmp && mv tmp $${i}_1.html; done
89 $(RUBY) -i -p -e \
90 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
91 doc/ChangeLog.html
92 $(RUBY) -i -p -e \
93 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
94 doc/NEWS.html doc/README.html
95 $(RAKE) -s news_atom > doc/NEWS.atom.xml
96 cd doc && ln README.html tmp && mv tmp index.html
97 $(MAKE) -C Documentation comparison.html
98 $(RUBY) -i -p -e \
99 '$$_.gsub!(/INCLUDE/){File.read("Documentation/comparison.html")}' \
100 doc/Summary.html
101 cat Documentation/comparison.css >> doc/rdoc.css
102 $(RM) $(man1_bins)
104 ifneq ($(VERSION),)
105 rfproject := rainbows
106 rfpackage := zbatery
107 pkggem := pkg/$(rfpackage)-$(VERSION).gem
108 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
109 release_notes := release_notes-$(VERSION)
110 release_changes := release_changes-$(VERSION)
112 release-notes: $(release_notes)
113 release-changes: $(release_changes)
114 $(release_changes):
115 $(RAKE) -s release_changes > $@+
116 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
117 $(release_notes):
118 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
119 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
121 # ensures we're actually on the tagged $(VERSION), only used for release
122 verify:
123 test x"$(shell umask)" = x0022
124 git rev-parse --verify refs/tags/v$(VERSION)^{}
125 git diff-index --quiet HEAD^0
126 test `git rev-parse --verify HEAD^0` = \
127 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
129 fix-perms:
130 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
131 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
133 gem: $(pkggem)
135 install-gem: $(pkggem)
136 gem install $(CURDIR)/$<
138 $(pkggem): manifest fix-perms
139 gem build $(rfpackage).gemspec
140 mkdir -p pkg
141 mv $(@F) $@
143 $(pkgtgz): distdir = $(basename $@)
144 $(pkgtgz): HEAD = v$(VERSION)
145 $(pkgtgz): manifest fix-perms
146 @test -n "$(distdir)"
147 $(RM) -r $(distdir)
148 mkdir -p $(distdir)
149 tar c `cat .manifest` | (cd $(distdir) && tar x)
150 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
151 mv $@+ $@
153 package: $(pkgtgz) $(pkggem)
155 release: verify package $(release_notes) $(release_changes)
156 # make tgz release on RubyForge
157 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
158 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
159 # push gem to Gemcutter
160 gem push $(pkggem)
161 # in case of gem downloads from RubyForge releases page
162 -rubyforge add_file \
163 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
164 else
165 gem install-gem: GIT-VERSION-FILE
166 $(MAKE) $@ VERSION=$(GIT_VERSION)
167 endif
169 all:: test
170 test:
171 $(MAKE) -C t
173 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test