1 # use GNU Make to run tests in parallel, and without depending on RubyGems
5 GIT_URL
= git
://git.bogomips.org
/ruby_io_splice.git
9 GIT-VERSION-FILE
: .FORCE-GIT-VERSION-FILE
11 -include GIT-VERSION-FILE
13 ifeq ($(DLEXT
),) # "so" for Linux
14 DLEXT
:= $(shell $(RUBY
) -rrbconfig
-e
'puts Config::CONFIG["DLEXT"]')
16 ifeq ($(RUBY_VERSION
),)
17 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
24 cp
-p bin
/* .install-tmp
27 mv .install-tmp
/* bin
/
31 setup_rb_files
:= .config InstalledFiles
32 prep_setup_rb
:= @
-$(RM
) $(setup_rb_files
);$(MAKE
) -C
$(ext
) clean
35 -$(MAKE
) -C ext
/io_splice
clean
36 $(RM
) $(setup_rb_files
) ext
/io_splice
/Makefile
38 pkg_extra
:= GIT-VERSION-FILE NEWS ChangeLog
39 manifest
: $(pkg_extra
)
45 for i in
$@
$(pkg_extra
); \
46 do echo
$$i; done
) | LC_ALL
=C
sort > $@
+
47 cmp
$@
+ $@ || mv
$@
+ $@
50 NEWS
: GIT-VERSION-FILE
51 $(RAKE
) -s news_rdoc
> $@
+
55 ChangeLog
: LOG_VERSION
= \
56 $(shell git rev-parse
-q
"$(GIT_VERSION)" >/dev
/null
2>&1 && \
57 echo
$(GIT_VERSION
) || git describe
)
59 ChangeLog
: log_range
= v
$(SINCE
)..
$(LOG_VERSION
)
61 ChangeLog
: GIT-VERSION-FILE
62 @echo
"ChangeLog from $(GIT_URL) ($(log_range))" > $@
+
64 git log
$(log_range
) | sed
-e
's/^/ /' >> $@
+
67 news_atom
:= http
://bogomips.org
/ruby_io_splice
/NEWS.atom.xml
68 cgit_atom
:= http
://git.bogomips.org
/cgit
/ruby_io_splice.git
/atom
/?h
=master
69 atom
= <link rel
="alternate" title
="Atom feed" href
="$(1)" \
70 type
="application/atom+xml"/>
72 # using rdoc 2.5.x + workaround patch here:
73 # rubyforge.org/tracker/index.php?func=detail&aid=28230&group_id=627&atid=2472
74 doc
: .document NEWS ChangeLog
75 rdoc
-a
-t
"$(shell sed -ne '1s/^= //p' README)"
76 install -m644 COPYING doc
/COPYING
77 install -m644
$(shell grep
'^[A-Z]' .document
) doc
/
78 cd doc
&& for i in
$(base_bins
); do \
79 html
=$$(echo
$$i | sed
's/\.rb/_rb/')_1.html
; \
80 sed
-e
'/"documentation">/r man1/'$$i'.1.html' \
81 < $$html > tmp
&& mv tmp
$$html; done
83 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
86 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
87 doc
/NEWS.html doc
/README.html
88 $(RAKE
) -s news_atom
> doc
/NEWS.atom.xml
89 cd doc
&& ln README.html tmp
&& mv tmp index.html
92 @awk
'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
94 # publishes docs to http://bogomips.org/ruby_io_splice/,
97 $(RM
) -r doc ChangeLog NEWS
98 $(MAKE
) doc LOG_VERSION
=$(shell git tag
-l | tail
-1)
99 awk
'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
101 find doc
/images doc
/js
-type f | \
102 TZ
=UTC xargs touch
-d
'1970-01-01 00:00:01' doc
/rdoc.css
104 chmod
644 $$(find doc
-type f
)
105 $(RSYNC
) -av doc
/ bogomips.org
:/srv
/bogomips
/ruby_io_splice
/
106 git ls-files | xargs touch
108 # Create gzip variants of the same timestamp as the original so nginx
109 # "gzip_static on" can serve the gzipped versions directly.
110 doc_gz
: docs
= $(shell find doc
-type f
! -regex
'^.*\.\(gif\|jpg\|png\|gz\)$$')
112 touch doc
/NEWS.atom.xml
-d
"$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
113 for i in
$(docs
); do \
114 gzip
--rsyncable
-9 < $$i > $$i.gz
; touch
-r
$$i $$i.gz
; done
118 rfpackage
:= io_splice
119 pkggem
:= pkg
/$(rfpackage
)-$(VERSION
).gem
120 pkgtgz
:= pkg
/$(rfpackage
)-$(VERSION
).tgz
121 release_notes
:= release_notes-
$(VERSION
)
122 release_changes
:= release_changes-
$(VERSION
)
124 release-notes
: $(release_notes
)
125 release-changes
: $(release_changes
)
127 $(RAKE
) -s release_changes
> $@
+
128 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
130 GIT_URL
=$(GIT_URL
) $(RAKE
) -s release_notes
> $@
+
131 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
133 # ensures we're actually on the tagged $(VERSION), only used for release
135 test x
"$(shell umask)" = x0022
136 git rev-parse
--verify refs
/tags/v
$(VERSION
)^
{}
137 git diff-index
--quiet HEAD^
0
138 test `git rev-parse --verify HEAD^0` = \
139 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
142 -git ls-tree
-r HEAD | awk
'/^100644 / {print $$NF}' | xargs chmod
644
143 -git ls-tree
-r HEAD | awk
'/^100755 / {print $$NF}' | xargs chmod
755
147 install-gem
: $(pkggem
)
148 gem
install $(CURDIR
)/$<
150 $(pkggem
): manifest fix-perms
151 gem build
$(rfpackage
).gemspec
155 $(pkgtgz
): distdir
= $(basename $@
)
156 $(pkgtgz
): HEAD
= v
$(VERSION
)
157 $(pkgtgz
): manifest fix-perms
158 @
test -n
"$(distdir)"
161 tar c
`cat .manifest` |
(cd
$(distdir
) && tar x
)
162 cd pkg
&& tar c
$(basename $(@F
)) | gzip
-9 > $(@F
)+
165 package
: $(pkgtgz
) $(pkggem
)
167 test-release
: verify package
$(release_notes
) $(release_changes
)
168 release
: verify package
$(release_notes
) $(release_changes
)
169 # make tgz release on RubyForge
170 rubyforge add_release
-f
-n
$(release_notes
) -a
$(release_changes
) \
171 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkgtgz
)
172 # push gem to Gemcutter
174 # in case of gem downloads from RubyForge releases page
175 -rubyforge add_file \
176 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkggem
)
178 gem install-gem
: GIT-VERSION-FILE
179 $(MAKE
) $@ VERSION
=$(GIT_VERSION
)
182 ext
:= ext
/io_splice
/io_splice_ext.
$(DLEXT
)
183 ext
/io_splice
/Makefile
: ext
/io_splice
/extconf.rb
184 cd
$(@D
) && $(RUBY
) extconf.rb
185 $(ext
): $(wildcard $(addprefix ext
/io_splice
/,*.c
*.h
)) ext
/io_splice
/Makefile
193 $(RCOV
) -I lib
:ext
/io_splice
$(test_unit
)
195 test_unit
:= $(wildcard test/test_
*.rb
)
197 $(RUBY
) -I lib
:ext
/io_splice
$@
$(TEST_UNIT_OPTS
)
198 test-unit
: $(test_unit
)
200 .PHONY
: .FORCE-GIT-VERSION-FILE doc manifest man
test $(test_unit
)