Rainbows! 0.90.1
[rainbows.git] / GNUmakefile
blob8c6b88d28c59f01bf30b8a60a6db9e98930fc9a9
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
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 -include GIT-VERSION-FILE
10 -include local.mk
11 ifeq ($(DLEXT),) # "so" for Linux
12 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
13 endif
14 ifeq ($(RUBY_VERSION),)
15 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
16 endif
18 base_bins := rainbows
19 bins := $(addprefix bin/, $(base_bins))
20 man1_bins := $(addsuffix .1, $(base_bins))
21 man1_paths := $(addprefix man/man1/, $(man1_bins))
23 install: $(bins)
24 $(prep_setup_rb)
25 $(RM) -r .install-tmp
26 mkdir .install-tmp
27 cp -p bin/* .install-tmp
28 $(RUBY) setup.rb all
29 $(RM) $^
30 mv .install-tmp/* bin/
31 $(RM) -r .install-tmp
32 $(prep_setup_rb)
34 setup_rb_files := .config InstalledFiles
35 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
37 clean:
38 -$(MAKE) -C $(ext) clean
39 -$(MAKE) -C Documentation clean
40 $(RM) $(setup_rb_files) $(t_log)
42 man:
43 $(MAKE) -C Documentation install-man
45 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
46 manifest: $(pkg_extra) man
47 $(RM) .manifest
48 $(MAKE) .manifest
50 .manifest:
51 (git ls-files && \
52 for i in $@ $(pkg_extra) $(man1_paths); \
53 do echo $$i; done) | LC_ALL=C sort > $@+
54 cmp $@+ $@ || mv $@+ $@
55 $(RM) $@+
57 NEWS: GIT-VERSION-FILE
58 $(RAKE) -s news_rdoc > $@+
59 mv $@+ $@
61 SINCE = 0.9.0
62 ChangeLog: LOG_VERSION = \
63 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
64 echo $(GIT_VERSION) || git describe)
65 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
66 ChangeLog: GIT-VERSION-FILE
67 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
68 @echo >> $@+
69 git log $(log_range) | sed -e 's/^/ /' >> $@+
70 mv $@+ $@
72 news_atom := http://rainbows.rubyforge.org/NEWS.atom.xml
73 cgit_atom := http://git.bogomips.org/cgit/rainbows.git/atom/?h=master
74 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
75 type="application/atom+xml"/>
77 # using rdoc 2.4.1+
78 doc: .document NEWS ChangeLog
79 for i in $(man1_bins); do > $$i; done
80 find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
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 := rainbows
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) $(pkgtgz)
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