expand Kgio::*#kgio_read! documentation
[kgio.git] / GNUmakefile
blobf6c2ebb8d615c6da53d420cb4241ff89c8183542
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
6 GIT_URL = git://git.bogomips.org/kgio.git
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:
20 $(prep_setup_rb)
21 $(RM) -r .install-tmp
22 mkdir .install-tmp
23 $(RUBY) setup.rb all
24 $(RM) $^
25 $(RM) -r .install-tmp
26 $(prep_setup_rb)
28 setup_rb_files := .config InstalledFiles
29 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
31 clean:
32 -$(MAKE) -C ext/kgio clean
33 $(RM) $(setup_rb_files) ext/kgio/Makefile
35 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
36 manifest: $(pkg_extra)
37 $(RM) .manifest
38 $(MAKE) .manifest
40 .manifest:
41 (git ls-files && \
42 for i in $@ $(pkg_extra) $(man1_paths); \
43 do echo $$i; done) | LC_ALL=C sort > $@+
44 cmp $@+ $@ || mv $@+ $@
45 $(RM) $@+
47 NEWS: GIT-VERSION-FILE
48 $(RAKE) -s news_rdoc > $@+
49 mv $@+ $@
51 latest: NEWS
52 @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
54 SINCE =
55 ChangeLog: LOG_VERSION = \
56 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
57 echo $(GIT_VERSION) || git describe)
58 ifneq ($(SINCE),)
59 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
60 endif
61 ChangeLog: GIT-VERSION-FILE
62 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
63 @echo >> $@+
64 git log $(log_range) | sed -e 's/^/ /' >> $@+
65 mv $@+ $@
67 news_atom := http://unicorn.bogomips.org/kgio/NEWS.atom.xml
68 cgit_atom := http://git.bogomips.org/cgit/kgio.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
73 doc: .document NEWS ChangeLog
74 rdoc -t "$(shell sed -ne '1s/^= //p' README)"
75 install -m644 COPYING doc/COPYING
76 install -m644 $(shell grep '^[A-Z]' .document) doc/
77 $(RUBY) -i -p -e \
78 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
79 doc/ChangeLog.html
80 $(RUBY) -i -p -e \
81 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
82 doc/NEWS.html doc/README.html
83 $(RAKE) -s news_atom > doc/NEWS.atom.xml
84 cd doc && ln README.html tmp && mv tmp index.html
86 ifneq ($(VERSION),)
87 rfproject := rainbows
88 rfpackage := kgio
89 pkggem := pkg/$(rfpackage)-$(VERSION).gem
90 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
91 release_notes := release_notes-$(VERSION)
92 release_changes := release_changes-$(VERSION)
94 release-notes: $(release_notes)
95 release-changes: $(release_changes)
96 $(release_changes):
97 $(RAKE) -s release_changes > $@+
98 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
99 $(release_notes):
100 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
101 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
103 # ensures we're actually on the tagged $(VERSION), only used for release
104 verify:
105 test x"$(shell umask)" = x0022
106 git rev-parse --verify refs/tags/v$(VERSION)^{}
107 git diff-index --quiet HEAD^0
108 test `git rev-parse --verify HEAD^0` = \
109 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
111 fix-perms:
112 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
113 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
115 gem: $(pkggem)
117 install-gem: $(pkggem)
118 gem install $(CURDIR)/$<
120 $(pkggem): manifest fix-perms
121 gem build $(rfpackage).gemspec
122 mkdir -p pkg
123 mv $(@F) $@
125 $(pkgtgz): distdir = $(basename $@)
126 $(pkgtgz): HEAD = v$(VERSION)
127 $(pkgtgz): manifest fix-perms
128 @test -n "$(distdir)"
129 $(RM) -r $(distdir)
130 mkdir -p $(distdir)
131 tar cf - `cat .manifest` | (cd $(distdir) && tar xf -)
132 cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
133 mv $@+ $@
135 package: $(pkgtgz) $(pkggem)
137 test-release: verify package $(release_notes) $(release_changes)
138 release: verify package $(release_notes) $(release_changes)
139 # make tgz release on RubyForge
140 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
141 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
142 # push gem to Gemcutter
143 gem push $(pkggem)
144 # in case of gem downloads from RubyForge releases page
145 -rubyforge add_file \
146 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
147 $(RAKE) raa_update VERSION=$(VERSION)
148 $(RAKE) publish_news VERSION=$(VERSION)
149 else
150 gem install-gem: GIT-VERSION-FILE
151 $(MAKE) $@ VERSION=$(GIT_VERSION)
152 endif
154 ext := ext/kgio/kgio_ext.$(DLEXT)
155 ext/kgio/Makefile: ext/kgio/extconf.rb
156 cd $(@D) && $(RUBY) extconf.rb
158 $(ext): $(wildcard ext/kgio/*.[ch] ext/kgio/*/*.h) ext/kgio/Makefile
159 $(MAKE) -C $(@D)
161 all:: test
163 build: $(ext)
164 test_units := $(wildcard test/test_*.rb)
165 test: test-unit
166 test-unit: $(test_units)
167 $(test_units): build
168 $(RUBY) -I lib:ext/kgio $@
170 # this requires GNU coreutils variants
171 publish_doc:
172 -git set-file-times
173 $(RM) -r doc ChangeLog NEWS
174 $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
175 $(MAKE) -s latest > doc/LATEST
176 find doc/images doc/js -type f | \
177 TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
178 $(MAKE) doc_gz
179 chmod 644 $$(find doc -type f)
180 $(RSYNC) -av doc/ unicorn.bogomips.org:/srv/unicorn/kgio/
181 git ls-files | xargs touch
183 # Create gzip variants of the same timestamp as the original so nginx
184 # "gzip_static on" can serve the gzipped versions directly.
185 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
186 doc_gz:
187 touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
188 for i in $(docs); do \
189 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
191 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units)