doc: updates for RDoc 2.5.x
[ruby_posix_mq.git] / GNUmakefile
blob3a31c44304a8327ee4c7b5bd1a9a072aee0c9ce5
1 # use GNU Make to run tests in parallel, and without depending on RubyGems
2 all::
3 RUBY = ruby
4 RAKE = rake
5 GIT_URL = git://git.bogomips.org/ruby_posix_mq.git
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 -include GIT-VERSION-FILE
10 -include local.mk
11 ifeq ($(DLEXT),) # "so" for Linux
12 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
13 endif
14 ifeq ($(RUBY_VERSION),)
15 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
16 endif
18 base_bins := posix-mq-rb
19 bins := $(addprefix bin/, $(base_bins))
20 man1_rdoc := $(addsuffix _1, $(base_bins))
21 man1_bins := $(addsuffix .1, $(base_bins))
22 man1_paths := $(addprefix man/man1/, $(man1_bins))
24 install: $(bins)
25 $(prep_setup_rb)
26 $(RM) -r .install-tmp
27 mkdir .install-tmp
28 cp -p bin/* .install-tmp
29 $(RUBY) setup.rb all
30 $(RM) $^
31 mv .install-tmp/* bin/
32 $(RM) -r .install-tmp
33 $(prep_setup_rb)
35 setup_rb_files := .config InstalledFiles
36 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
38 clean:
39 -$(MAKE) -C ext/posix_mq clean
40 $(RM) $(setup_rb_files) ext/posix_mq/Makefile
42 man:
43 $(MAKE) -C Documentation install-man
45 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
46 manifest: $(pkg_extra) man
47 $(RM) .manifest
48 $(MAKE) .manifest
50 .manifest:
51 (git ls-files && \
52 for i in $@ $(pkg_extra) $(man1_paths); \
53 do echo $$i; done) | LC_ALL=C sort > $@+
54 cmp $@+ $@ || mv $@+ $@
55 $(RM) $@+
57 NEWS: GIT-VERSION-FILE
58 $(RAKE) -s news_rdoc > $@+
59 mv $@+ $@
61 SINCE =
62 ChangeLog: LOG_VERSION = \
63 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
64 echo $(GIT_VERSION) || git describe)
65 ifneq ($(SINCE),)
66 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
67 endif
68 ChangeLog: GIT-VERSION-FILE
69 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
70 @echo >> $@+
71 git log $(log_range) | sed -e 's/^/ /' >> $@+
72 mv $@+ $@
74 news_atom := http://bogomips.org/ruby_posix_mq/NEWS.atom.xml
75 cgit_atom := http://git.bogomips.org/cgit/ruby_posix_mq.git/atom/?h=master
76 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
77 type="application/atom+xml"/>
79 # using rdoc 2.5.x+
80 doc: .document NEWS ChangeLog
81 for i in $(man1_rdoc); do > $$i; done
82 rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
83 install -m644 COPYING doc/COPYING
84 install -m644 $(shell grep '^[A-Z]' .document) doc/
85 $(MAKE) -C Documentation install-html install-man
86 install -m644 $(man1_paths) doc/
87 cd doc && for i in $(base_bins); do \
88 html=$$(echo $$i | sed 's/\.rb/_rb/')_1.html; \
89 sed -e '/"documentation">/r man1/'$$i'.1.html' \
90 < $$html > tmp && mv tmp $$html; done
91 $(RUBY) -i -p -e \
92 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
93 doc/ChangeLog.html
94 $(RUBY) -i -p -e \
95 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
96 doc/NEWS.html doc/README.html
97 $(RAKE) -s news_atom > doc/NEWS.atom.xml
98 cd doc && ln README.html tmp && mv tmp index.html
99 $(RM) $(man1_rdoc)
101 ifneq ($(VERSION),)
102 rfproject := qrp
103 rfpackage := posix_mq
104 pkggem := pkg/$(rfpackage)-$(VERSION).gem
105 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
106 release_notes := release_notes-$(VERSION)
107 release_changes := release_changes-$(VERSION)
109 release-notes: $(release_notes)
110 release-changes: $(release_changes)
111 $(release_changes):
112 $(RAKE) -s release_changes > $@+
113 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
114 $(release_notes):
115 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
116 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
118 # ensures we're actually on the tagged $(VERSION), only used for release
119 verify:
120 test x"$(shell umask)" = x0022
121 git rev-parse --verify refs/tags/v$(VERSION)^{}
122 git diff-index --quiet HEAD^0
123 test `git rev-parse --verify HEAD^0` = \
124 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
126 fix-perms:
127 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
128 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
130 gem: $(pkggem)
132 install-gem: $(pkggem)
133 gem install $(CURDIR)/$<
135 $(pkggem): manifest fix-perms
136 gem build $(rfpackage).gemspec
137 mkdir -p pkg
138 mv $(@F) $@
140 $(pkgtgz): distdir = $(basename $@)
141 $(pkgtgz): HEAD = v$(VERSION)
142 $(pkgtgz): manifest fix-perms
143 @test -n "$(distdir)"
144 $(RM) -r $(distdir)
145 mkdir -p $(distdir)
146 tar c `cat .manifest` | (cd $(distdir) && tar x)
147 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
148 mv $@+ $@
150 package: $(pkgtgz) $(pkggem)
152 test-release: verify package $(release_notes) $(release_changes)
153 release: verify package $(release_notes) $(release_changes)
154 # make tgz release on RubyForge
155 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
156 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
157 # push gem to Gemcutter
158 gem push $(pkggem)
159 # in case of gem downloads from RubyForge releases page
160 -rubyforge add_file \
161 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
162 else
163 gem install-gem: GIT-VERSION-FILE
164 $(MAKE) $@ VERSION=$(GIT_VERSION)
165 endif
167 ext := ext/posix_mq/posix_mq_ext.$(DLEXT)
168 ext/posix_mq/Makefile: ext/posix_mq/extconf.rb
169 cd $(@D) && $(RUBY) extconf.rb
170 $(ext): $(wildcard $(addprefix ext/posix_mq/,*.c *.h)) ext/posix_mq/Makefile
171 $(MAKE) -C $(@D)
173 all:: test
175 build: $(ext)
176 test: test-unit
177 test-unit: build
178 $(RUBY) -I lib:ext/posix_mq test/test_posix_mq.rb
180 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test