switch to wrongdoc for documentation
[ruby_posix_mq.git] / GNUmakefile
blobfe1b16013b612a2fdb56db484d5ac6012f47bcbd
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
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 html:
43 $(MAKE) -C Documentation install-$@
45 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog LATEST
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 ChangeLog: GIT-VERSION-FILE
58 wrongdoc prepare
60 doc: .document NEWS ChangeLog man html
61 for i in $(man1_rdoc); do > $$i; done
62 $(RM) -r doc
63 wrongdoc all
64 install -m644 COPYING doc/COPYING
65 install -m644 $(shell grep '^[A-Z]' .document) doc/
66 install -m644 $(man1_paths) doc/
67 $(RM) $(man1_rdoc)
69 ifneq ($(VERSION),)
70 rfproject := qrp
71 rfpackage := posix_mq
72 pkggem := pkg/$(rfpackage)-$(VERSION).gem
73 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
74 release_notes := release_notes-$(VERSION)
75 release_changes := release_changes-$(VERSION)
77 release-notes: $(release_notes)
78 release-changes: $(release_changes)
79 $(release_changes):
80 wrongdoc release_changes > $@+
81 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
82 $(release_notes):
83 wrongdoc release_notes > $@+
84 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
86 # ensures we're actually on the tagged $(VERSION), only used for release
87 verify:
88 test x"$(shell umask)" = x0022
89 git rev-parse --verify refs/tags/v$(VERSION)^{}
90 git diff-index --quiet HEAD^0
91 test `git rev-parse --verify HEAD^0` = \
92 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
94 fix-perms:
95 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
96 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
98 gem: $(pkggem)
100 install-gem: $(pkggem)
101 gem install $(CURDIR)/$<
103 $(pkggem): manifest fix-perms
104 gem build $(rfpackage).gemspec
105 mkdir -p pkg
106 mv $(@F) $@
108 $(pkgtgz): distdir = $(basename $@)
109 $(pkgtgz): HEAD = v$(VERSION)
110 $(pkgtgz): manifest fix-perms
111 @test -n "$(distdir)"
112 $(RM) -r $(distdir)
113 mkdir -p $(distdir)
114 tar c `cat .manifest` | (cd $(distdir) && tar x)
115 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
116 mv $@+ $@
118 package: $(pkgtgz) $(pkggem)
120 test-release: verify package $(release_notes) $(release_changes)
121 release: verify package $(release_notes) $(release_changes)
122 # make tgz release on RubyForge
123 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
124 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
125 # push gem to Gemcutter
126 gem push $(pkggem)
127 # in case of gem downloads from RubyForge releases page
128 -rubyforge add_file \
129 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
130 else
131 gem install-gem: GIT-VERSION-FILE
132 $(MAKE) $@ VERSION=$(GIT_VERSION)
133 endif
135 ext := ext/posix_mq/posix_mq_ext.$(DLEXT)
136 ext/posix_mq/Makefile: ext/posix_mq/extconf.rb
137 cd $(@D) && $(RUBY) extconf.rb
138 $(ext): $(wildcard $(addprefix ext/posix_mq/,*.c *.h)) ext/posix_mq/Makefile
139 $(MAKE) -C $(@D)
141 all:: test
143 build: $(ext)
144 test: test-unit
145 test-unit: build
146 $(RUBY) -I lib:ext/posix_mq test/test_posix_mq.rb
148 # publishes docs to http://bogomips.org/ruby_posix_mq/
149 publish_doc:
150 -git set-file-times
151 $(RM) -r doc
152 $(MAKE) doc
153 find doc/images -type f | \
154 TZ=UTC xargs touch -d '1970-01-01 00:00:03' doc/rdoc.css
155 $(MAKE) doc_gz
156 $(RSYNC) -av doc/ bogomips.org:/srv/bogomips/ruby_posix_mq/
157 git ls-files | xargs touch
159 # Create gzip variants of the same timestamp as the original so nginx
160 # "gzip_static on" can serve the gzipped versions directly.
161 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
162 doc_gz:
163 for i in $(docs); do \
164 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
166 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test html