raindrops v0.3.0 - LGPL v2.1 and v3.0
[raindrops.git] / GNUmakefile
blobd1f96879c2c4b69daa60e9dc342c6c55f3952527
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/raindrops.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 install: $(bins)
20 $(prep_setup_rb)
21 $(RM) -r .install-tmp
22 mkdir .install-tmp
23 cp -p bin/* .install-tmp
24 $(RUBY) setup.rb all
25 $(RM) $^
26 mv .install-tmp/* bin/
27 $(RM) -r .install-tmp
28 $(prep_setup_rb)
30 setup_rb_files := .config InstalledFiles
31 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
33 clean:
34 -$(MAKE) -C ext/raindrops clean
35 $(RM) $(setup_rb_files) ext/raindrops/Makefile
37 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
38 manifest: $(pkg_extra)
39 $(RM) .manifest
40 $(MAKE) .manifest
42 .manifest:
43 (git ls-files && \
44 for i in $@ $(pkg_extra) $(man1_paths); \
45 do echo $$i; done) | LC_ALL=C sort > $@+
46 cmp $@+ $@ || mv $@+ $@
47 $(RM) $@+
49 NEWS: GIT-VERSION-FILE
50 $(RAKE) -s news_rdoc > $@+
51 mv $@+ $@
53 latest: NEWS
54 @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
56 SINCE = 0.2.1
57 ChangeLog: LOG_VERSION = \
58 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
59 echo $(GIT_VERSION) || git describe)
60 ifneq ($(SINCE),)
61 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
62 endif
63 ChangeLog: GIT-VERSION-FILE
64 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
65 @echo >> $@+
66 git log $(log_range) | sed -e 's/^/ /' >> $@+
67 mv $@+ $@
69 news_atom := http://raindrops.bogomips.org/NEWS.atom.xml
70 cgit_atom := http://git.bogomips.org/cgit/raindrops.git/atom/?h=master
71 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
72 type="application/atom+xml"/>
74 # using rdoc 2.5.x
75 doc: .document NEWS ChangeLog
76 for i in $(man1_bins); do > $$i; done
77 rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
78 install -m644 COPYING doc/COPYING
79 install -m644 $(shell grep '^[A-Z]' .document) doc/
80 cd doc && for i in $(base_bins); do \
81 html=$$(echo $$i | sed 's/\.rb/_rb/')_1.html; \
82 sed -e '/"documentation">/r man1/'$$i'.1.html' \
83 < $$html > tmp && mv tmp $$html; done
84 $(RUBY) -i -p -e \
85 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
86 doc/ChangeLog.html
87 $(RUBY) -i -p -e \
88 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
89 doc/NEWS.html doc/README.html
90 $(RAKE) -s news_atom > doc/NEWS.atom.xml
91 cd doc && ln README.html tmp && mv tmp index.html
92 $(RM) $(man1_bins)
94 ifneq ($(VERSION),)
95 rfproject := rainbows
96 rfpackage := raindrops
97 pkggem := pkg/$(rfpackage)-$(VERSION).gem
98 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
99 release_notes := release_notes-$(VERSION)
100 release_changes := release_changes-$(VERSION)
102 release-notes: $(release_notes)
103 release-changes: $(release_changes)
104 $(release_changes):
105 $(RAKE) -s release_changes > $@+
106 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
107 $(release_notes):
108 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
109 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
111 # ensures we're actually on the tagged $(VERSION), only used for release
112 verify:
113 test x"$(shell umask)" = x0022
114 git rev-parse --verify refs/tags/v$(VERSION)^{}
115 git diff-index --quiet HEAD^0
116 test `git rev-parse --verify HEAD^0` = \
117 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
119 fix-perms:
120 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
121 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
123 gem: $(pkggem)
125 install-gem: $(pkggem)
126 gem install $(CURDIR)/$<
128 $(pkggem): manifest fix-perms
129 gem build $(rfpackage).gemspec
130 mkdir -p pkg
131 mv $(@F) $@
133 $(pkgtgz): distdir = $(basename $@)
134 $(pkgtgz): HEAD = v$(VERSION)
135 $(pkgtgz): manifest fix-perms
136 @test -n "$(distdir)"
137 $(RM) -r $(distdir)
138 mkdir -p $(distdir)
139 tar c `cat .manifest` | (cd $(distdir) && tar x)
140 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
141 mv $@+ $@
143 package: $(pkgtgz) $(pkggem)
145 test-release: verify package $(release_notes) $(release_changes)
146 release: verify package $(release_notes) $(release_changes)
147 # make tgz release on RubyForge
148 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
149 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
150 # push gem to Gemcutter
151 gem push $(pkggem)
152 # in case of gem downloads from RubyForge releases page
153 -rubyforge add_file \
154 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
155 else
156 gem install-gem: GIT-VERSION-FILE
157 $(MAKE) $@ VERSION=$(GIT_VERSION)
158 endif
160 ext := ext/raindrops/raindrops_ext.$(DLEXT)
161 ext/raindrops/Makefile: ext/raindrops/extconf.rb
162 cd $(@D) && $(RUBY) extconf.rb
163 $(ext): $(wildcard $(addprefix ext/raindrops/,*.c *.h)) ext/raindrops/Makefile
164 $(MAKE) -C $(@D)
166 all:: test
168 export STRESS BENCHMARK
169 build: $(ext)
170 test_units := $(wildcard test/test_*.rb)
171 test: test-unit
172 test-unit: $(test_units)
173 $(test_units): build
174 $(RUBY) -I lib:ext/raindrops $@
176 # this requires GNU coreutils variants
177 publish_doc:
178 -git set-file-times
179 $(RM) -r doc ChangeLog NEWS
180 $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
181 $(MAKE) -s latest > doc/LATEST
182 find doc/images doc/js -type f | \
183 TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
184 tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
185 $(MAKE) doc_gz
186 chmod 644 $$(find doc -type f)
187 $(RSYNC) -av doc/ raindrops.bogomips.org:/srv/raindrops/
188 git ls-files | xargs touch
190 # Create gzip variants of the same timestamp as the original so nginx
191 # "gzip_static on" can serve the gzipped versions directly.
192 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
193 doc_gz:
194 touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
195 for i in $(docs); do \
196 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
198 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units)