max_body: remove extraneous debug message
[rainbows.git] / GNUmakefile
blob42c21622159ef43fc791321eca18c312cf6b507d
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/rainbows.git
6 ISOLATE_CONFIG = config/isolate.rb
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 # rake takes forever to start
20 isolate: tmp/gems/$(RUBY_VERSION)/.isolate
21 tmp/gems/$(RUBY_VERSION)/.isolate: $(ISOLATE_CONFIG)
22 ISOLATE_CONFIG=$(ISOLATE_CONFIG) $(RAKE) isolate
23 > $@
25 base_bins := rainbows
26 bins := $(addprefix bin/, $(base_bins))
27 man1_bins := $(addsuffix .1, $(base_bins))
28 man1_paths := $(addprefix man/man1/, $(man1_bins))
30 install: $(bins)
31 $(prep_setup_rb)
32 $(RM) -r .install-tmp
33 mkdir .install-tmp
34 cp -p bin/* .install-tmp
35 $(RUBY) setup.rb all
36 $(RM) $^
37 mv .install-tmp/* bin/
38 $(RM) -r .install-tmp
39 $(prep_setup_rb)
41 setup_rb_files := .config InstalledFiles
42 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
44 clean:
45 -$(MAKE) -C $(ext) clean
46 -$(MAKE) -C Documentation clean
47 $(RM) $(setup_rb_files) $(t_log)
49 man:
50 $(MAKE) -C Documentation install-man
52 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
53 manifest: $(pkg_extra) man
54 $(RM) .manifest
55 $(MAKE) .manifest
57 .manifest:
58 (git ls-files && \
59 for i in $@ $(pkg_extra) $(man1_paths); \
60 do echo $$i; done) | LC_ALL=C sort > $@+
61 cmp $@+ $@ || mv $@+ $@
62 $(RM) $@+
64 NEWS: GIT-VERSION-FILE
65 $(RAKE) -s news_rdoc > $@+
66 mv $@+ $@
68 SINCE = 0.90.0
69 ChangeLog: LOG_VERSION = \
70 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
71 echo $(GIT_VERSION) || git describe)
72 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
73 ChangeLog: GIT-VERSION-FILE
74 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
75 @echo >> $@+
76 git log $(log_range) | sed -e 's/^/ /' >> $@+
77 mv $@+ $@
79 news_atom := http://rainbows.rubyforge.org/NEWS.atom.xml
80 cgit_atom := http://git.bogomips.org/cgit/rainbows.git/atom/?h=master
81 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
82 type="application/atom+xml"/>
84 # using rdoc 2.4.1+
85 doc: .document NEWS ChangeLog
86 for i in $(man1_bins); do > $$i; done
87 find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
88 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
89 install -m644 COPYING doc/COPYING
90 install -m644 $(shell grep '^[A-Z]' .document) doc/
91 $(MAKE) -C Documentation install-html install-man
92 install -m644 $(man1_paths) doc/
93 cd doc && for i in $(base_bins); do \
94 sed -e '/"documentation">/r man1/'$$i'.1.html' \
95 < $${i}_1.html > tmp && mv tmp $${i}_1.html; done
96 $(RUBY) -i -p -e \
97 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
98 doc/ChangeLog.html
99 $(RUBY) -i -p -e \
100 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
101 doc/NEWS.html doc/README.html
102 $(RAKE) -s news_atom > doc/NEWS.atom.xml
103 cd doc && ln README.html tmp && mv tmp index.html
104 $(MAKE) -C Documentation comparison.html
105 $(RUBY) -i -p -e \
106 '$$_.gsub!(/INCLUDE/){File.read("Documentation/comparison.html")}' \
107 doc/Summary.html
108 cat Documentation/comparison.css >> doc/rdoc.css
109 $(RM) $(man1_bins)
111 ifneq ($(VERSION),)
112 rfproject := rainbows
113 rfpackage := rainbows
114 pkggem := pkg/$(rfpackage)-$(VERSION).gem
115 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
116 release_notes := release_notes-$(VERSION)
117 release_changes := release_changes-$(VERSION)
119 release-notes: $(release_notes)
120 release-changes: $(release_changes)
121 $(release_changes):
122 $(RAKE) -s release_changes > $@+
123 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
124 $(release_notes):
125 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
126 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
128 # ensures we're actually on the tagged $(VERSION), only used for release
129 verify:
130 test x"$(shell umask)" = x0022
131 git rev-parse --verify refs/tags/v$(VERSION)^{}
132 git diff-index --quiet HEAD^0
133 test `git rev-parse --verify HEAD^0` = \
134 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
136 fix-perms:
137 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
138 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
140 gem: $(pkggem)
142 install-gem: $(pkggem)
143 gem install $(CURDIR)/$<
145 $(pkggem): manifest fix-perms
146 gem build $(rfpackage).gemspec
147 mkdir -p pkg
148 mv $(@F) $@
150 $(pkgtgz): distdir = $(basename $@)
151 $(pkgtgz): HEAD = v$(VERSION)
152 $(pkgtgz): manifest fix-perms
153 @test -n "$(distdir)"
154 $(RM) -r $(distdir)
155 mkdir -p $(distdir)
156 tar c `cat .manifest` | (cd $(distdir) && tar x)
157 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
158 mv $@+ $@
160 package: $(pkgtgz) $(pkggem)
162 release: verify package $(release_notes) $(release_changes)
163 # make tgz release on RubyForge
164 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
165 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
166 # push gem to Gemcutter
167 gem push $(pkggem)
168 # in case of gem downloads from RubyForge releases page
169 -rubyforge add_file \
170 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
171 else
172 gem install-gem: GIT-VERSION-FILE
173 $(MAKE) $@ VERSION=$(GIT_VERSION)
174 endif
176 all:: test
177 test:
178 $(MAKE) -C t
180 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test