common Rainbows.accept method
[rainbows.git] / GNUmakefile
blob105241ad140cc049de99264651d916f27afa5e89
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 ifdef ruby
12 ifeq ($(RUBY),ruby)
13 $(warning ruby variable is deprecated, use RUBY instead)
14 RUBY = $(ruby)
15 endif
16 endif
17 ifeq ($(DLEXT),) # "so" for Linux
18 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
19 endif
20 ifeq ($(RUBY_VERSION),)
21 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
22 endif
24 base_bins := rainbows
25 bins := $(addprefix bin/, $(base_bins))
26 man1_bins := $(addsuffix .1, $(base_bins))
27 man1_paths := $(addprefix man/man1/, $(man1_bins))
29 install: $(bins)
30 $(prep_setup_rb)
31 $(RM) -r .install-tmp
32 mkdir .install-tmp
33 cp -p bin/* .install-tmp
34 $(RUBY) setup.rb all
35 $(RM) $^
36 mv .install-tmp/* bin/
37 $(RM) -r .install-tmp
38 $(prep_setup_rb)
40 setup_rb_files := .config InstalledFiles
41 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
43 clean:
44 -$(MAKE) -C $(ext) clean
45 -$(MAKE) -C Documentation clean
46 $(RM) $(setup_rb_files) $(t_log)
48 man:
49 $(MAKE) -C Documentation install-man
51 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
52 manifest: $(pkg_extra) man
53 $(RM) .manifest
54 $(MAKE) .manifest
56 .manifest:
57 (git ls-files && \
58 for i in $@ $(pkg_extra) $(man1_paths); \
59 do echo $$i; done) | LC_ALL=C sort > $@+
60 cmp $@+ $@ || mv $@+ $@
61 $(RM) $@+
63 NEWS: GIT-VERSION-FILE
64 $(rake) -s news_rdoc > $@+
65 mv $@+ $@
67 SINCE = 0.5.0
68 ChangeLog: LOG_VERSION = \
69 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
70 echo $(GIT_VERSION) || git describe)
71 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
72 ChangeLog: GIT-VERSION-FILE
73 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
74 @echo >> $@+
75 git log $(log_range) | sed -e 's/^/ /' >> $@+
76 mv $@+ $@
78 news_atom := http://rainbows.rubyforge.org/NEWS.atom.xml
79 cgit_atom := http://git.bogomips.org/cgit/rainbows.git/atom/?h=master
80 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
81 type="application/atom+xml"/>
83 # using rdoc 2.4.1+
84 doc: .document NEWS ChangeLog
85 for i in $(man1_bins); do > $$i; done
86 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
87 install -m644 COPYING doc/COPYING
88 install -m644 $(shell grep '^[A-Z]' .document) doc/
89 $(MAKE) -C Documentation install-html install-man
90 install -m644 $(man1_paths) doc/
91 cd doc && for i in $(base_bins); do \
92 sed -e '/"documentation">/r man1/'$$i'.1.html' \
93 < $${i}_1.html > tmp && mv tmp $${i}_1.html; 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_bins)
109 ifneq ($(VERSION),)
110 rfproject := rainbows
111 rfpackage := rainbows
112 pkggem := pkg/$(rfpackage)-$(VERSION).gem
113 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
114 release_notes := release_notes-$(VERSION)
115 release_changes := release_changes-$(VERSION)
117 release-notes: $(release_notes)
118 release-changes: $(release_changes)
119 $(release_changes):
120 $(rake) -s release_changes > $@+
121 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
122 $(release_notes):
123 GIT_URL=$(GIT_URL) $(rake) -s release_notes > $@+
124 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
126 # ensures we're actually on the tagged $(VERSION), only used for release
127 verify:
128 test x"$(shell umask)" = x0022
129 git rev-parse --verify refs/tags/v$(VERSION)^{}
130 git diff-index --quiet HEAD^0
131 test `git rev-parse --verify HEAD^0` = \
132 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
134 fix-perms:
135 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
136 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
138 gem: $(pkggem)
140 install-gem: $(pkggem)
141 gem install $(CURDIR)/$<
143 $(pkggem): manifest fix-perms
144 gem build $(rfpackage).gemspec
145 mkdir -p pkg
146 mv $(@F) $@
148 $(pkgtgz): distdir = $(basename $@)
149 $(pkgtgz): HEAD = v$(VERSION)
150 $(pkgtgz): manifest fix-perms
151 @test -n "$(distdir)"
152 $(RM) -r $(distdir)
153 mkdir -p $(distdir)
154 tar c `cat .manifest` | (cd $(distdir) && tar x)
155 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
156 mv $@+ $@
158 package: $(pkgtgz) $(pkggem)
160 release: verify package $(release_notes) $(release_changes)
161 # make tgz release on RubyForge
162 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
163 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
164 # push gem to Gemcutter
165 gem push $(pkggem)
166 # in case of gem downloads from RubyForge releases page
167 -rubyforge add_file \
168 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
169 else
170 gem install-gem: GIT-VERSION-FILE
171 $(MAKE) $@ VERSION=$(GIT_VERSION)
172 endif
174 all:: test
175 test:
176 $(MAKE) -C t
178 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test