Allow options to be added to "use"
[rainbows.git] / GNUmakefile
blob1b61fe06b822eea219d38b66cee1d29ffa26fc5a
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.5.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 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
81 install -m644 COPYING doc/COPYING
82 install -m644 $(shell grep '^[A-Z]' .document) doc/
83 $(MAKE) -C Documentation install-html install-man
84 install -m644 $(man1_paths) doc/
85 cd doc && for i in $(base_bins); do \
86 sed -e '/"documentation">/r man1/'$$i'.1.html' \
87 < $${i}_1.html > tmp && mv tmp $${i}_1.html; done
88 $(RUBY) -i -p -e \
89 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
90 doc/ChangeLog.html
91 $(RUBY) -i -p -e \
92 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
93 doc/NEWS.html doc/README.html
94 $(RAKE) -s news_atom > doc/NEWS.atom.xml
95 cd doc && ln README.html tmp && mv tmp index.html
96 $(MAKE) -C Documentation comparison.html
97 $(RUBY) -i -p -e \
98 '$$_.gsub!(/INCLUDE/){File.read("Documentation/comparison.html")}' \
99 doc/Summary.html
100 cat Documentation/comparison.css >> doc/rdoc.css
101 $(RM) $(man1_bins)
103 ifneq ($(VERSION),)
104 rfproject := rainbows
105 rfpackage := rainbows
106 pkggem := pkg/$(rfpackage)-$(VERSION).gem
107 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
108 release_notes := release_notes-$(VERSION)
109 release_changes := release_changes-$(VERSION)
111 release-notes: $(release_notes)
112 release-changes: $(release_changes)
113 $(release_changes):
114 $(RAKE) -s release_changes > $@+
115 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
116 $(release_notes):
117 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
118 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
120 # ensures we're actually on the tagged $(VERSION), only used for release
121 verify:
122 test x"$(shell umask)" = x0022
123 git rev-parse --verify refs/tags/v$(VERSION)^{}
124 git diff-index --quiet HEAD^0
125 test `git rev-parse --verify HEAD^0` = \
126 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
128 fix-perms:
129 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
130 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
132 gem: $(pkggem)
134 install-gem: $(pkggem)
135 gem install $(CURDIR)/$<
137 $(pkggem): manifest fix-perms
138 gem build $(rfpackage).gemspec
139 mkdir -p pkg
140 mv $(@F) $@
142 $(pkgtgz): distdir = $(basename $@)
143 $(pkgtgz): HEAD = v$(VERSION)
144 $(pkgtgz): manifest fix-perms
145 @test -n "$(distdir)"
146 $(RM) -r $(distdir)
147 mkdir -p $(distdir)
148 tar c `cat .manifest` | (cd $(distdir) && tar x)
149 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
150 mv $@+ $@
152 package: $(pkgtgz) $(pkggem)
154 release: verify package $(release_notes) $(release_changes)
155 # make tgz release on RubyForge
156 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
157 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
158 # push gem to Gemcutter
159 gem push $(pkggem)
160 # in case of gem downloads from RubyForge releases page
161 -rubyforge add_file \
162 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
163 else
164 gem install-gem: GIT-VERSION-FILE
165 $(MAKE) $@ VERSION=$(GIT_VERSION)
166 endif
168 all:: test
169 test:
170 $(MAKE) -C t
172 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test