allow IO(-ish) objects as descriptor arguments
[ruby_io_splice.git] / GNUmakefile
blob63b9cf349ba99e18ebac2db60b63b836de568413
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
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 install: $(bins)
19 $(prep_setup_rb)
20 $(RM) -r .install-tmp
21 mkdir .install-tmp
22 cp -p bin/* .install-tmp
23 $(RUBY) setup.rb all
24 $(RM) $^
25 mv .install-tmp/* bin/
26 $(RM) -r .install-tmp
27 $(prep_setup_rb)
29 setup_rb_files := .config InstalledFiles
30 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
32 clean:
33 -$(MAKE) -C ext/io_splice clean
34 $(RM) $(setup_rb_files) ext/io_splice/Makefile
36 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
37 manifest: $(pkg_extra)
38 $(RM) .manifest
39 $(MAKE) .manifest
41 .manifest:
42 (git ls-files && \
43 for i in $@ $(pkg_extra) $(man1_paths); \
44 do echo $$i; done) | LC_ALL=C sort > $@+
45 cmp $@+ $@ || mv $@+ $@
46 $(RM) $@+
48 NEWS: GIT-VERSION-FILE
49 $(RAKE) -s news_rdoc > $@+
50 mv $@+ $@
52 SINCE =
53 ChangeLog: LOG_VERSION = \
54 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
55 echo $(GIT_VERSION) || git describe)
56 ifneq ($(SINCE),)
57 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
58 endif
59 ChangeLog: GIT-VERSION-FILE
60 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
61 @echo >> $@+
62 git log $(log_range) | sed -e 's/^/ /' >> $@+
63 mv $@+ $@
65 news_atom := http://bogomips.org/ruby_io_splice/NEWS.atom.xml
66 cgit_atom := http://git.bogomips.org/cgit/ruby_io_splice.git/atom/?h=master
67 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
68 type="application/atom+xml"/>
70 # using rdoc 2.5.x + workaround patch here:
71 # rubyforge.org/tracker/index.php?func=detail&aid=28230&group_id=627&atid=2472
72 doc: .document NEWS ChangeLog
73 rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
74 install -m644 COPYING doc/COPYING
75 install -m644 $(shell grep '^[A-Z]' .document) doc/
76 cd doc && for i in $(base_bins); do \
77 html=$$(echo $$i | sed 's/\.rb/_rb/')_1.html; \
78 sed -e '/"documentation">/r man1/'$$i'.1.html' \
79 < $$html > tmp && mv tmp $$html; done
80 $(RUBY) -i -p -e \
81 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
82 doc/ChangeLog.html
83 $(RUBY) -i -p -e \
84 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
85 doc/NEWS.html doc/README.html
86 $(RAKE) -s news_atom > doc/NEWS.atom.xml
87 cd doc && ln README.html tmp && mv tmp index.html
89 ifneq ($(VERSION),)
90 rfproject := qrp
91 rfpackage := io_splice
92 pkggem := pkg/$(rfpackage)-$(VERSION).gem
93 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
94 release_notes := release_notes-$(VERSION)
95 release_changes := release_changes-$(VERSION)
97 release-notes: $(release_notes)
98 release-changes: $(release_changes)
99 $(release_changes):
100 $(RAKE) -s release_changes > $@+
101 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
102 $(release_notes):
103 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
104 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
106 # ensures we're actually on the tagged $(VERSION), only used for release
107 verify:
108 test x"$(shell umask)" = x0022
109 git rev-parse --verify refs/tags/v$(VERSION)^{}
110 git diff-index --quiet HEAD^0
111 test `git rev-parse --verify HEAD^0` = \
112 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
114 fix-perms:
115 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
116 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
118 gem: $(pkggem)
120 install-gem: $(pkggem)
121 gem install $(CURDIR)/$<
123 $(pkggem): manifest fix-perms
124 gem build $(rfpackage).gemspec
125 mkdir -p pkg
126 mv $(@F) $@
128 $(pkgtgz): distdir = $(basename $@)
129 $(pkgtgz): HEAD = v$(VERSION)
130 $(pkgtgz): manifest fix-perms
131 @test -n "$(distdir)"
132 $(RM) -r $(distdir)
133 mkdir -p $(distdir)
134 tar c `cat .manifest` | (cd $(distdir) && tar x)
135 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
136 mv $@+ $@
138 package: $(pkgtgz) $(pkggem)
140 test-release: verify package $(release_notes) $(release_changes)
141 release: verify package $(release_notes) $(release_changes)
142 # make tgz release on RubyForge
143 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
144 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
145 # push gem to Gemcutter
146 gem push $(pkggem)
147 # in case of gem downloads from RubyForge releases page
148 -rubyforge add_file \
149 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
150 else
151 gem install-gem: GIT-VERSION-FILE
152 $(MAKE) $@ VERSION=$(GIT_VERSION)
153 endif
155 ext := ext/io_splice/io_splice_ext.$(DLEXT)
156 ext/io_splice/Makefile: ext/io_splice/extconf.rb
157 cd $(@D) && $(RUBY) extconf.rb
158 $(ext): $(wildcard $(addprefix ext/io_splice/,*.c *.h)) ext/io_splice/Makefile
159 $(MAKE) -C $(@D)
161 all:: test
163 build: $(ext)
164 test: test-unit
165 test-unit: build
166 $(RUBY) -I lib:ext/io_splice test/test_io_splice.rb
168 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test