clogger 0.2.0
[clogger.git] / GNUmakefile
blob010b879f22fb2acc4d089c9de7ca44b434118995
1 all:: test
2 RUBY = ruby
3 RAKE = rake
4 GIT_URL = git://git.bogomips.org/clogger.git
6 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
7 @./GIT-VERSION-GEN
8 -include GIT-VERSION-FILE
9 -include local.mk
11 ifeq ($(DLEXT),) # "so" for Linux
12 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
13 endif
15 ext/clogger_ext/Makefile: ext/clogger_ext/clogger.c ext/clogger_ext/extconf.rb
16 cd ext/clogger_ext && $(RUBY) extconf.rb
18 ext/clogger_ext/clogger.$(DLEXT): ext/clogger_ext/Makefile
19 $(MAKE) -C ext/clogger_ext
21 clean:
22 -$(MAKE) -C ext/clogger_ext clean
23 $(RM) ext/clogger_ext/Makefile lib/clogger_ext.$(DLEXT)
25 test-ext: ext/clogger_ext/clogger.$(DLEXT)
26 $(RUBY) -Iext/clogger_ext:lib test/test_clogger.rb
28 test-pure:
29 CLOGGER_PURE=t $(RUBY) -Ilib test/test_clogger.rb
31 test: test-ext test-pure
33 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
34 manifest: $(pkg_extra)
35 $(RM) .manifest
36 $(MAKE) .manifest
38 .manifest:
39 (git ls-files && \
40 for i in $@ $(pkg_extra); \
41 do echo $$i; done) | LC_ALL=C sort > $@+
42 cmp $@+ $@ || mv $@+ $@
43 $(RM) $@+
45 NEWS: GIT-VERSION-FILE .manifest
46 $(RAKE) -s news_rdoc > $@+
47 mv $@+ $@
49 SINCE = 0.0.7
50 ChangeLog: log_range = $(shell test -n "$(SINCE)" && echo v$(SINCE)..)
51 ChangeLog: GIT-VERSION-FILE
52 @echo "ChangeLog from $(GIT_URL) ($(SINCE)..$(GIT_VERSION))" > $@+
53 @echo >> $@+
54 git log $(log_range) | sed -e 's/^/ /' >> $@+
55 mv $@+ $@
57 news_atom := http://clogger.rubyforge.org/NEWS.atom.xml
58 cgit_atom := http://git.bogomips.org/cgit/clogger.git/atom/?h=master
59 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
60 type="application/atom+xml"/>
62 doc: .document NEWS ChangeLog
63 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
64 install -m644 COPYING doc/COPYING
65 install -m644 $(shell grep '^[A-Z]' .document) doc/
66 $(RUBY) -i -p -e \
67 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
68 doc/ChangeLog.html
69 $(RUBY) -i -p -e \
70 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
71 doc/NEWS.html doc/README.html
72 $(RAKE) -s news_atom > doc/NEWS.atom.xml
73 cd doc && ln README.html tmp && mv tmp index.html
75 # publishes docs to http://clogger.rubyforge.org/
76 # this preserves timestamps as best as possible to help HTTP caches out
77 # git set-file-times is here: http://git-scm.org/gitwiki/ExampleScripts
78 publish_doc:
79 git set-file-times
80 $(RM) -r doc
81 $(MAKE) doc
82 rsync -av doc/ rubyforge.org:/var/www/gforge-projects/clogger/
83 git ls-files | xargs touch
85 ifneq ($(VERSION),)
86 rfproject := clogger
87 rfpackage := clogger
88 pkggem := pkg/$(rfpackage)-$(VERSION).gem
89 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
90 release_notes := release_notes-$(VERSION)
91 release_changes := release_changes-$(VERSION)
93 release-notes: $(release_notes)
94 release-changes: $(release_changes)
95 $(release_changes):
96 $(RAKE) -s release_changes > $@+
97 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
98 $(release_notes):
99 GIT_URL=$(GIT_URL) $(RUBY) -s release_notes > $@+
100 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
102 # ensures we're actually on the tagged $(VERSION), only used for release
103 verify:
104 test x"$(shell umask)" = x0022
105 git rev-parse --verify refs/tags/v$(VERSION)^{}
106 git diff-index --quiet HEAD^0
107 test `git rev-parse --verify HEAD^0` = \
108 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
110 fix-perms:
111 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
112 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
114 gem: $(pkggem)
116 install-gem: $(pkggem)
117 gem install $(CURDIR)/$<
119 $(pkggem): manifest fix-perms
120 gem build $(rfpackage).gemspec
121 mkdir -p pkg
122 mv $(@F) $@
124 $(pkgtgz): distdir = $(basename $@)
125 $(pkgtgz): HEAD = v$(VERSION)
126 $(pkgtgz): manifest fix-perms
127 @test -n "$(distdir)"
128 $(RM) -r $(distdir)
129 mkdir -p $(distdir)
130 tar c `cat .manifest` | (cd $(distdir) && tar x)
131 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
132 mv $@+ $@
134 package: $(pkgtgz) $(pkggem)
136 release: verify package $(release_notes) $(release_changes)
137 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
138 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
139 gem push $(pkggem)
140 rubyforge add_file \
141 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
142 else
143 gem install-gem: GIT-VERSION-FILE
144 $(MAKE) $@ VERSION=$(GIT_VERSION)
145 endif
147 .PHONY: .FORCE-GIT-VERSION-FILE test doc manifest