command-line option parsing
[local-openid.git] / GNUmakefile
blobb20efba795d04898d2f9d519c31683efcecf1b07
1 all::
2 RUBY = ruby
3 RAKE = rake
4 RSYNC = rsync
5 GIT_URL = git://git.bogomips.org/local-openid.git
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 -include GIT-VERSION-FILE
11 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
12 manifest: $(pkg_extra)
13 $(RM) .manifest
14 $(MAKE) .manifest
16 .manifest:
17 (git ls-files && \
18 for i in $@ $(pkg_extra) $(man1_paths); \
19 do echo $$i; done) | LC_ALL=C sort > $@+
20 cmp $@+ $@ || mv $@+ $@
21 $(RM) $@+
23 NEWS: GIT-VERSION-FILE
24 $(RAKE) -s news_rdoc > $@+
25 mv $@+ $@
27 SINCE = 0.1.0
28 ChangeLog: LOG_VERSION = \
29 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
30 echo $(GIT_VERSION) || git describe)
31 ifneq ($(SINCE),)
32 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
33 endif
34 ChangeLog: GIT-VERSION-FILE
35 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
36 @echo >> $@+
37 git log $(log_range) | sed -e 's/^/ /' >> $@+
38 mv $@+ $@
40 news_atom := http://bogomips.org/local-openid/NEWS.atom.xml
41 cgit_atom := http://git.bogomips.org/cgit/local-openid.git/atom/?h=master
42 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
43 type="application/atom+xml"/>
45 doc: .document NEWS ChangeLog
46 find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
47 rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
48 install -m644 COPYING doc/COPYING
49 install -m644 $(shell grep '^[A-Z]' .document) doc/
50 $(RUBY) -i -p -e \
51 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
52 doc/ChangeLog.html
53 $(RUBY) -i -p -e \
54 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
55 doc/NEWS.html doc/README.html
56 $(RAKE) -s news_atom > doc/NEWS.atom.xml
57 cd doc && ln README.html tmp && mv tmp index.html
59 publish_doc:
60 -git set-file-times
61 $(RM) -r doc ChangeLog NEWS
62 $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
63 @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
64 < NEWS > doc/LATEST
65 find doc/images doc/js -type f | \
66 TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
67 $(MAKE) doc_gz
68 chmod 644 $$(find doc -type f)
69 $(RSYNC) -av --delete doc/ bogomips.org:/srv/bogomips/local-openid/
70 git ls-files | xargs touch
72 ifneq ($(VERSION),)
73 rfproject := qrp
74 rfpackage := local-openid
75 pkggem := pkg/$(rfpackage)-$(VERSION).gem
76 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
77 release_notes := release_notes-$(VERSION)
78 release_changes := release_changes-$(VERSION)
80 release-notes: $(release_notes)
81 release-changes: $(release_changes)
82 $(release_changes):
83 $(RAKE) -s release_changes > $@+
84 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
85 $(release_notes):
86 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
87 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
89 # ensures we're actually on the tagged $(VERSION), only used for release
90 verify:
91 test x"$(shell umask)" = x0022
92 git rev-parse --verify refs/tags/v$(VERSION)^{}
93 git diff-index --quiet HEAD^0
94 test `git rev-parse --verify HEAD^0` = \
95 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
97 fix-perms:
98 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
99 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
101 gem: $(pkggem)
103 install-gem: $(pkggem)
104 gem install $(CURDIR)/$<
106 $(pkggem): manifest fix-perms
107 gem build $(rfpackage).gemspec
108 mkdir -p pkg
109 mv $(@F) $@
111 $(pkgtgz): distdir = $(basename $@)
112 $(pkgtgz): HEAD = v$(VERSION)
113 $(pkgtgz): manifest fix-perms
114 @test -n "$(distdir)"
115 $(RM) -r $(distdir)
116 mkdir -p $(distdir)
117 tar cf - `cat .manifest` | (cd $(distdir) && tar xf -)
118 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
119 mv $@+ $@
121 package: $(pkgtgz) $(pkggem)
123 test-release: verify package $(release_notes) $(release_changes)
124 release: verify package $(release_notes) $(release_changes)
125 # make tgz release on RubyForge
126 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
127 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
128 # push gem to Gemcutter
129 gem push $(pkggem)
130 # in case of gem downloads from RubyForge releases page
131 -rubyforge add_file \
132 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
133 else
134 gem install-gem: GIT-VERSION-FILE
135 $(MAKE) $@ VERSION=$(GIT_VERSION)
136 endif
138 # Create gzip variants of the same timestamp as the original so nginx
139 # "gzip_static on" can serve the gzipped versions directly.
140 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
141 doc_gz:
142 touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
143 for i in $(docs); do \
144 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
145 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest