centralize body => IO conversion logic
[rainbows.git] / GNUmakefile
blob32a1b8c4bed85c467a784c426fc7bc6df1fed9c9
1 # use GNU Make to run tests in parallel, and without depending on RubyGems
2 all::
3 RUBY = ruby
4 RAKE = rake
5 RSYNC = rsync
6 GIT_URL = git://git.bogomips.org/rainbows.git
8 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
9 @./GIT-VERSION-GEN
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 := rainbows
20 bins := $(addprefix bin/, $(base_bins))
21 man1_rdoc := $(addsuffix _1, $(base_bins))
22 man1_bins := $(addsuffix .1, $(base_bins))
23 man1_paths := $(addprefix man/man1/, $(man1_bins))
25 install: $(bins)
26 $(prep_setup_rb)
27 $(RM) -r .install-tmp
28 mkdir .install-tmp
29 cp -p bin/* .install-tmp
30 $(RUBY) setup.rb all
31 $(RM) $^
32 mv .install-tmp/* bin/
33 $(RM) -r .install-tmp
34 $(prep_setup_rb)
36 setup_rb_files := .config InstalledFiles
37 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
39 clean:
40 -$(MAKE) -C $(ext) clean
41 -$(MAKE) -C Documentation clean
42 $(RM) $(setup_rb_files) $(t_log)
44 man:
45 $(MAKE) -C Documentation install-man
47 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
48 manifest: $(pkg_extra) man
49 $(RM) .manifest
50 $(MAKE) .manifest
52 .manifest:
53 (git ls-files && \
54 for i in $@ $(pkg_extra) $(man1_paths); \
55 do echo $$i; done) | LC_ALL=C sort > $@+
56 cmp $@+ $@ || mv $@+ $@
57 $(RM) $@+
59 NEWS: GIT-VERSION-FILE
60 $(RAKE) -s news_rdoc > $@+
61 mv $@+ $@
63 SINCE = 0.92.0
64 ChangeLog: LOG_VERSION = \
65 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
66 echo $(GIT_VERSION) || git describe)
67 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
68 ChangeLog: GIT-VERSION-FILE
69 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
70 @echo >> $@+
71 git log $(log_range) | sed -e 's/^/ /' >> $@+
72 mv $@+ $@
74 news_atom := http://rainbows.rubyforge.org/NEWS.atom.xml
75 cgit_atom := http://git.bogomips.org/cgit/rainbows.git/atom/?h=master
76 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
77 type="application/atom+xml"/>
79 # using rdoc 2.5.x+
80 doc: .document NEWS ChangeLog
81 for i in $(man1_rdoc); do echo > $$i; done
82 find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
83 rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
84 install -m644 COPYING doc/COPYING
85 install -m644 $(shell grep '^[A-Z]' .document) doc/
86 $(MAKE) -C Documentation install-html install-man
87 install -m644 $(man1_paths) doc/
88 cd doc && for i in $(base_bins); do \
89 $(RM) 1.html $${i}.1.html; \
90 sed -e '/"documentation">/r man1/'$$i'.1.html' \
91 < $${i}_1.html > tmp && mv tmp $${i}_1.html; \
92 ln $${i}_1.html $${i}.1.html; \
93 done
94 $(RUBY) -i -p -e \
95 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
96 doc/ChangeLog.html
97 $(RUBY) -i -p -e \
98 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
99 doc/NEWS.html doc/README.html
100 $(RAKE) -s news_atom > doc/NEWS.atom.xml
101 cd doc && ln README.html tmp && mv tmp index.html
102 $(MAKE) -C Documentation comparison.html
103 $(RUBY) -i -p -e \
104 '$$_.gsub!(/INCLUDE/){File.read("Documentation/comparison.html")}' \
105 doc/Summary.html
106 cat Documentation/comparison.css >> doc/rdoc.css
107 $(RM) $(man1_rdoc)
109 # publishes docs to http://rainbows.rubyforge.org
110 publish_doc: NEWS
111 -git set-file-times
112 $(RM) -r doc ChangeLog NEWS
113 $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
114 awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
115 < NEWS > doc/LATEST
116 -find doc/images doc/js -type f | \
117 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/ rubyforge.org:/var/www/gforge-projects/rainbows/
120 git ls-files | xargs touch
122 ifneq ($(VERSION),)
123 rfproject := rainbows
124 rfpackage := rainbows
125 pkggem := pkg/$(rfpackage)-$(VERSION).gem
126 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
127 release_notes := release_notes-$(VERSION)
128 release_changes := release_changes-$(VERSION)
130 release-notes: $(release_notes)
131 release-changes: $(release_changes)
132 $(release_changes):
133 $(RAKE) -s release_changes > $@+
134 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
135 $(release_notes):
136 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
137 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
139 # ensures we're actually on the tagged $(VERSION), only used for release
140 verify:
141 test x"$(shell umask)" = x0022
142 git rev-parse --verify refs/tags/v$(VERSION)^{}
143 git diff-index --quiet HEAD^0
144 test `git rev-parse --verify HEAD^0` = \
145 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
147 fix-perms:
148 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
149 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
151 gem: $(pkggem)
153 install-gem: $(pkggem)
154 gem install $(CURDIR)/$<
156 $(pkggem): manifest fix-perms
157 gem build $(rfpackage).gemspec
158 mkdir -p pkg
159 mv $(@F) $@
161 $(pkgtgz): distdir = $(basename $@)
162 $(pkgtgz): HEAD = v$(VERSION)
163 $(pkgtgz): manifest fix-perms
164 @test -n "$(distdir)"
165 $(RM) -r $(distdir)
166 mkdir -p $(distdir)
167 tar c `cat .manifest` | (cd $(distdir) && tar x)
168 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
169 mv $@+ $@
171 package: $(pkgtgz) $(pkggem)
173 release: verify package $(release_notes) $(release_changes)
174 # make tgz release on RubyForge
175 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
176 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
177 # push gem to RubyGems.org
178 gem push $(pkggem)
179 # in case of gem downloads from RubyForge releases page
180 -rubyforge add_file \
181 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
182 $(RAKE) raa_update VERSION=$(VERSION)
183 $(RAKE) fm_update VERSION=$(VERSION)
184 else
185 gem install-gem: GIT-VERSION-FILE
186 $(MAKE) $@ VERSION=$(GIT_VERSION)
187 endif
189 all:: test
190 test:
191 $(MAKE) -C t
193 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test