rdoc: enable webcvs links for cgit
[ruby-tdb.git] / GNUmakefile
blobd8fe7c6b9e21d0b42a89dc3773ec3c3b11c881d8
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/ruby-tdb.git
7 CGIT_URL = http://git.bogomips.org/cgit/ruby-tdb.git
9 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
10 @./GIT-VERSION-GEN
11 -include GIT-VERSION-FILE
12 -include local.mk
13 ifeq ($(DLEXT),) # "so" for Linux
14 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
15 endif
16 ifeq ($(RUBY_VERSION),)
17 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
18 endif
20 install:
21 $(prep_setup_rb)
22 $(RM) -r .install-tmp
23 mkdir .install-tmp
24 $(RUBY) setup.rb all
25 $(RM) $^
26 $(RM) -r .install-tmp
27 $(prep_setup_rb)
29 setup_rb_files := .config InstalledFiles
30 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
32 clean:
33 -$(MAKE) -C ext/tdb clean
34 $(RM) $(setup_rb_files) ext/tdb/Makefile
36 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
37 manifest: $(pkg_extra)
38 $(RM) .manifest
39 $(MAKE) .manifest
41 .manifest:
42 (git ls-files && \
43 for i in $@ $(pkg_extra) $(man1_paths); \
44 do echo $$i; done) | LC_ALL=C sort > $@+
45 cmp $@+ $@ || mv $@+ $@
46 $(RM) $@+
48 NEWS: GIT-VERSION-FILE
49 $(RAKE) -s news_rdoc > $@+
50 mv $@+ $@
52 latest: NEWS
53 @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
55 SINCE =
56 ChangeLog: LOG_VERSION = \
57 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
58 echo $(GIT_VERSION) || git describe)
59 ifneq ($(SINCE),)
60 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
61 endif
62 ChangeLog: GIT-VERSION-FILE
63 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
64 @echo >> $@+
65 git log $(log_range) | sed -e 's/^/ /' >> $@+
66 mv $@+ $@
68 news_atom := http://bogomips.org/ruby-tdb/NEWS.atom.xml
69 cgit_atom := $(CGIT_URL)/atom/?h=master
70 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
71 type="application/atom+xml"/>
73 # using rdoc 2.5.x
74 doc: .document NEWS ChangeLog
75 rdoc --webcvs=$(CGIT_URL)/tree/%s \
76 -t "$(shell sed -ne '1s/^= //p' README)"
77 install -m644 COPYING doc/COPYING
78 install -m644 $(shell grep '^[A-Z]' .document) doc/
79 $(RUBY) -i -p -e \
80 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
81 doc/ChangeLog.html
82 $(RUBY) -i -p -e \
83 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
84 doc/NEWS.html doc/README.html
85 $(RAKE) -s news_atom > doc/NEWS.atom.xml
86 cd doc && ln README.html tmp && mv tmp index.html
88 ifneq ($(VERSION),)
89 rfproject := qrp
90 rfpackage := tdb
91 pkggem := pkg/$(rfpackage)-$(VERSION).gem
92 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
93 release_notes := release_notes-$(VERSION)
94 release_changes := release_changes-$(VERSION)
96 release-notes: $(release_notes)
97 release-changes: $(release_changes)
98 $(release_changes):
99 $(RAKE) -s release_changes > $@+
100 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
101 $(release_notes):
102 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
103 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
105 # ensures we're actually on the tagged $(VERSION), only used for release
106 verify:
107 test x"$(shell umask)" = x0022
108 git rev-parse --verify refs/tags/v$(VERSION)^{}
109 git diff-index --quiet HEAD^0
110 test `git rev-parse --verify HEAD^0` = \
111 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
113 fix-perms:
114 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
115 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
117 gem: $(pkggem)
119 install-gem: $(pkggem)
120 gem install $(CURDIR)/$<
122 $(pkggem): manifest fix-perms
123 gem build $(rfpackage).gemspec
124 mkdir -p pkg
125 mv $(@F) $@
127 $(pkgtgz): distdir = $(basename $@)
128 $(pkgtgz): HEAD = v$(VERSION)
129 $(pkgtgz): manifest fix-perms
130 @test -n "$(distdir)"
131 $(RM) -r $(distdir)
132 mkdir -p $(distdir)
133 tar cf - `cat .manifest` | (cd $(distdir) && tar xf -)
134 cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
135 mv $@+ $@
137 package: $(pkgtgz) $(pkggem)
139 test-release: verify package $(release_notes) $(release_changes)
140 release: verify package $(release_notes) $(release_changes)
141 # make tgz release on RubyForge
142 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
143 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
144 # push gem to RubyGems.org
145 gem push $(pkggem)
146 # in case of gem downloads from RubyForge releases page
147 -rubyforge add_file \
148 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
149 $(RAKE) raa_update VERSION=$(VERSION)
150 else
151 gem install-gem: GIT-VERSION-FILE
152 $(MAKE) $@ VERSION=$(GIT_VERSION)
153 endif
155 ext := ext/tdb/tdb_ext.$(DLEXT)
156 ext/tdb/Makefile: ext/tdb/extconf.rb
157 cd $(@D) && $(RUBY) extconf.rb $(EXTCONF_ARGS)
159 $(ext): $(wildcard ext/tdb/*.[ch] ext/tdb/*/*.h) ext/tdb/Makefile
160 $(MAKE) -C $(@D)
162 all:: test
164 build: $(ext)
165 test_units := $(wildcard test/test_*.rb)
166 test: test-unit
167 test-unit: $(test_units)
168 $(test_units): build
169 $(RUBY) -I lib:ext/tdb $@
171 # this requires GNU coreutils variants
172 publish_doc:
173 -git set-file-times
174 $(RM) -r doc ChangeLog NEWS
175 $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
176 $(MAKE) -s latest > doc/LATEST
177 find doc/images doc/js -type f | \
178 TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
179 $(MAKE) doc_gz
180 chmod 644 $$(find doc -type f)
181 $(RSYNC) -av doc/ bogomips.org:/srv/bogomips/ruby-tdb/
182 git ls-files | xargs touch
184 # Create gzip variants of the same timestamp as the original so nginx
185 # "gzip_static on" can serve the gzipped versions directly.
186 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
187 doc_gz:
188 touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
189 for i in $(docs); do \
190 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
192 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units)