simplify examples for 1.0.0 API
[ruby_io_splice.git] / GNUmakefile
blobf0baf7133ebb7a058db9d7cd00c93a7911036182
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_io_splice.git
6 RSYNC = rsync
8 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
9 @./GIT-VERSION-GEN
10 -include GIT-VERSION-FILE
11 -include local.mk
12 ifeq ($(DLEXT),) # "so" for Linux
13 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
14 endif
15 ifeq ($(RUBY_VERSION),)
16 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
17 endif
19 install: $(bins)
20 $(prep_setup_rb)
21 $(RM) -r .install-tmp
22 mkdir .install-tmp
23 cp -p bin/* .install-tmp
24 $(RUBY) setup.rb all
25 $(RM) $^
26 mv .install-tmp/* bin/
27 $(RM) -r .install-tmp
28 $(prep_setup_rb)
30 setup_rb_files := .config InstalledFiles
31 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
33 clean:
34 -$(MAKE) -C ext/io_splice clean
35 $(RM) $(setup_rb_files) ext/io_splice/Makefile
37 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
38 manifest: $(pkg_extra)
39 $(RM) .manifest
40 $(MAKE) .manifest
42 .manifest:
43 (git ls-files && \
44 for i in $@ $(pkg_extra); \
45 do echo $$i; done) | LC_ALL=C sort > $@+
46 cmp $@+ $@ || mv $@+ $@
47 $(RM) $@+
49 NEWS: GIT-VERSION-FILE
50 $(RAKE) -s news_rdoc > $@+
51 mv $@+ $@
53 SINCE =
54 ChangeLog: LOG_VERSION = \
55 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
56 echo $(GIT_VERSION) || git describe)
57 ifneq ($(SINCE),)
58 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
59 endif
60 ChangeLog: GIT-VERSION-FILE
61 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
62 @echo >> $@+
63 git log $(log_range) | sed -e 's/^/ /' >> $@+
64 mv $@+ $@
66 news_atom := http://bogomips.org/ruby_io_splice/NEWS.atom.xml
67 cgit_atom := http://git.bogomips.org/cgit/ruby_io_splice.git/atom/?h=master
68 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
69 type="application/atom+xml"/>
71 # using rdoc 2.5.x + workaround patch here:
72 # rubyforge.org/tracker/index.php?func=detail&aid=28230&group_id=627&atid=2472
73 doc: .document NEWS ChangeLog
74 rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
75 install -m644 COPYING doc/COPYING
76 install -m644 $(shell grep '^[A-Z]' .document) doc/
77 cd doc && for i in $(base_bins); do \
78 html=$$(echo $$i | sed 's/\.rb/_rb/')_1.html; \
79 sed -e '/"documentation">/r man1/'$$i'.1.html' \
80 < $$html > tmp && mv tmp $$html; done
81 $(RUBY) -i -p -e \
82 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
83 doc/ChangeLog.html
84 $(RUBY) -i -p -e \
85 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
86 doc/NEWS.html doc/README.html
87 $(RAKE) -s news_atom > doc/NEWS.atom.xml
88 cd doc && ln README.html tmp && mv tmp index.html
90 latest: NEWS
91 @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
93 # publishes docs to http://bogomips.org/ruby_io_splice/,
94 publish_doc:
95 -git set-file-times
96 $(RM) -r doc ChangeLog NEWS
97 $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
98 awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
99 NEWS > doc/LATEST
100 find doc/images doc/js -type f | \
101 TZ=UTC xargs touch -d '1970-01-01 00:00:01' doc/rdoc.css
102 $(MAKE) doc_gz
103 chmod 644 $$(find doc -type f)
104 $(RSYNC) -av doc/ bogomips.org:/srv/bogomips/ruby_io_splice/
105 git ls-files | xargs touch
107 # Create gzip variants of the same timestamp as the original so nginx
108 # "gzip_static on" can serve the gzipped versions directly.
109 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
110 doc_gz:
111 touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
112 for i in $(docs); do \
113 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
115 ifneq ($(VERSION),)
116 rfproject := qrp
117 rfpackage := io_splice
118 pkggem := pkg/$(rfpackage)-$(VERSION).gem
119 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
120 release_notes := release_notes-$(VERSION)
121 release_changes := release_changes-$(VERSION)
123 release-notes: $(release_notes)
124 release-changes: $(release_changes)
125 $(release_changes):
126 $(RAKE) -s release_changes > $@+
127 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
128 $(release_notes):
129 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
130 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
132 # ensures we're actually on the tagged $(VERSION), only used for release
133 verify:
134 test x"$(shell umask)" = x0022
135 git rev-parse --verify refs/tags/v$(VERSION)^{}
136 git diff-index --quiet HEAD^0
137 test `git rev-parse --verify HEAD^0` = \
138 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
140 fix-perms:
141 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
142 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
144 gem: $(pkggem)
146 install-gem: $(pkggem)
147 gem install $(CURDIR)/$<
149 $(pkggem): manifest fix-perms
150 gem build $(rfpackage).gemspec
151 mkdir -p pkg
152 mv $(@F) $@
154 $(pkgtgz): distdir = $(basename $@)
155 $(pkgtgz): HEAD = v$(VERSION)
156 $(pkgtgz): manifest fix-perms
157 @test -n "$(distdir)"
158 $(RM) -r $(distdir)
159 mkdir -p $(distdir)
160 tar c `cat .manifest` | (cd $(distdir) && tar x)
161 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
162 mv $@+ $@
164 package: $(pkgtgz) $(pkggem)
166 test-release: verify package $(release_notes) $(release_changes)
167 release: verify package $(release_notes) $(release_changes)
168 # make tgz release on RubyForge
169 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
170 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
171 # push gem to Gemcutter
172 gem push $(pkggem)
173 # in case of gem downloads from RubyForge releases page
174 -rubyforge add_file \
175 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
176 else
177 gem install-gem: GIT-VERSION-FILE
178 $(MAKE) $@ VERSION=$(GIT_VERSION)
179 endif
181 ext := ext/io_splice/io_splice_ext.$(DLEXT)
182 ext/io_splice/Makefile: ext/io_splice/extconf.rb
183 cd $(@D) && $(RUBY) extconf.rb
184 $(ext): $(wildcard $(addprefix ext/io_splice/,*.c *.h)) ext/io_splice/Makefile
185 $(MAKE) -C $(@D)
187 all:: test
189 build: $(ext)
190 test: test-unit
191 test-unit: build
192 $(RUBY) -I lib:ext/io_splice test/test_io_splice.rb
194 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test