doc: RDoc cleanups, split out LICENSE file
[clogger.git] / GNUmakefile
blob4addaf2958a2a1467b1f618e068fca892d65bba5
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_unit := $(wildcard test/test_*.rb)
26 test-unit: $(test_unit)
28 ifeq ($(CLOGGER_PURE),)
29 $(test_unit): export RUBYLIB := ext/clogger_ext:lib
30 $(test_unit): ext/clogger_ext/clogger.$(DLEXT)
31 else
32 $(test_unit): export RUBYLIB := lib
33 endif
35 $(test_unit):
36 $(RUBY) $@
38 test-ext:
39 $(MAKE) test-unit
41 test-pure:
42 CLOGGER_PURE=t $(MAKE) test-unit
44 test: test-ext test-pure
46 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
47 manifest: $(pkg_extra)
48 $(RM) .manifest
49 $(MAKE) .manifest
51 .manifest:
52 (git ls-files && \
53 for i in $@ $(pkg_extra); \
54 do echo $$i; done) | LC_ALL=C sort > $@+
55 cmp $@+ $@ || mv $@+ $@
56 $(RM) $@+
58 NEWS: GIT-VERSION-FILE .manifest
59 $(RAKE) -s news_rdoc > $@+
60 mv $@+ $@
62 SINCE = 0.3.2
63 ChangeLog: log_range = $(shell test -n "$(SINCE)" && echo v$(SINCE)..)
64 ChangeLog: GIT-VERSION-FILE
65 @echo "ChangeLog from $(GIT_URL) ($(SINCE)..$(GIT_VERSION))" > $@+
66 @echo >> $@+
67 git log $(log_range) | sed -e 's/^/ /' >> $@+
68 mv $@+ $@
70 news_atom := http://clogger.rubyforge.org/NEWS.atom.xml
71 cgit_atom := http://git.bogomips.org/cgit/clogger.git/atom/?h=master
72 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
73 type="application/atom+xml"/>
75 doc: .document NEWS ChangeLog
76 rdoc -a -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 # publishes docs to http://clogger.rubyforge.org/
89 # this preserves timestamps as best as possible to help HTTP caches out
90 # git set-file-times is here: http://git-scm.org/gitwiki/ExampleScripts
91 publish_doc:
92 git set-file-times
93 $(RM) -r doc
94 $(MAKE) doc
95 rsync -av doc/ rubyforge.org:/var/www/gforge-projects/clogger/
96 git ls-files | xargs touch
98 ifneq ($(VERSION),)
99 rfproject := clogger
100 rfpackage := clogger
101 pkggem := pkg/$(rfpackage)-$(VERSION).gem
102 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
103 release_notes := release_notes-$(VERSION)
104 release_changes := release_changes-$(VERSION)
106 release-notes: $(release_notes)
107 release-changes: $(release_changes)
108 $(release_changes):
109 $(RAKE) -s release_changes > $@+
110 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
111 $(release_notes):
112 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
113 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
115 # ensures we're actually on the tagged $(VERSION), only used for release
116 verify:
117 test x"$(shell umask)" = x0022
118 git rev-parse --verify refs/tags/v$(VERSION)^{}
119 git diff-index --quiet HEAD^0
120 test `git rev-parse --verify HEAD^0` = \
121 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
123 fix-perms:
124 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
125 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
127 gem: $(pkggem)
129 install-gem: $(pkggem)
130 gem install $(CURDIR)/$<
132 $(pkggem): manifest fix-perms
133 gem build $(rfpackage).gemspec
134 mkdir -p pkg
135 mv $(@F) $@
137 $(pkgtgz): distdir = $(basename $@)
138 $(pkgtgz): HEAD = v$(VERSION)
139 $(pkgtgz): manifest fix-perms
140 @test -n "$(distdir)"
141 $(RM) -r $(distdir)
142 mkdir -p $(distdir)
143 tar c `cat .manifest` | (cd $(distdir) && tar x)
144 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
145 mv $@+ $@
147 package: $(pkgtgz) $(pkggem)
149 release: verify package $(release_notes) $(release_changes)
150 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
151 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
152 gem push $(pkggem)
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 .PHONY: .FORCE-GIT-VERSION-FILE test doc manifest
161 .PHONY: test test-ext test-pure $(test_unit)