doc: update URLs to point to YHBT.net
[ruby_io_splice.git] / pkg.mk
blob628830da36d0f7400e4eb1f52bf55327117476d1
1 RUBY = ruby
2 RAKE = rake
3 RSYNC = rsync
4 OLDDOC = olddoc
5 RDOC = rdoc
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 -include GIT-VERSION-FILE
10 -include local.mk
11 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
12 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
13 RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
14 lib := lib
16 ext := $(firstword $(wildcard ext/*))
17 ifneq ($(ext),)
18 ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
19 ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
20 ext_src := $(wildcard $(ext)/*.c $(ext_h))
21 ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
22 ext_d := $(ext_pfx)/$(ext)/.d
23 $(ext)/extconf.rb: $(wildcard $(ext)/*.h)
24 @>> $@
25 $(ext_d):
26 @mkdir -p $(@D)
27 @> $@
28 $(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
29 install -m 644 $< $@
30 $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
31 $(RM) -f $(@D)/*.o
32 cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
33 ext_sfx := _ext.$(DLEXT)
34 ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
35 $(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
36 @echo $^ == $@
37 $(MAKE) -C $(@D)
38 lib := $(lib):$(ext_pfx)/$(ext)
39 build: $(ext_dl)
40 else
41 build:
42 endif
44 pkg_extra += GIT-VERSION-FILE NEWS LATEST
45 NEWS: GIT-VERSION-FILE .olddoc.yml
46 $(OLDDOC) prepare
47 LATEST: NEWS
49 manifest:
50 $(RM) .manifest
51 $(MAKE) .manifest
53 .manifest: $(pkg_extra)
54 (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
55 LC_ALL=C sort > $@+
56 cmp $@+ $@ || mv $@+ $@
57 $(RM) $@+
59 doc:: .document .olddoc.yml $(pkg_extra) $(PLACEHOLDERS)
60 -find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
61 -find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
62 $(RM) -r doc
63 $(RDOC) -f dark216
64 $(OLDDOC) merge
65 install -m644 COPYING doc/COPYING
66 install -m644 NEWS doc/NEWS
67 install -m644 NEWS.atom.xml doc/NEWS.atom.xml
68 install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
70 ifneq ($(VERSION),)
71 pkggem := pkg/$(rfpackage)-$(VERSION).gem
72 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
74 # ensures we're actually on the tagged $(VERSION), only used for release
75 verify:
76 test x"$(shell umask)" = x0022
77 git rev-parse --verify refs/tags/v$(VERSION)^{}
78 git diff-index --quiet HEAD^0
79 test $$(git rev-parse --verify HEAD^0) = \
80 $$(git rev-parse --verify refs/tags/v$(VERSION)^{})
82 fix-perms:
83 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
84 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
86 gem: $(pkggem)
88 install-gem: $(pkggem)
89 gem install --local $(CURDIR)/$<
91 $(pkggem): manifest fix-perms
92 gem build $(rfpackage).gemspec
93 mkdir -p pkg
94 mv $(@F) $@
96 $(pkgtgz): distdir = $(basename $@)
97 $(pkgtgz): HEAD = v$(VERSION)
98 $(pkgtgz): manifest fix-perms
99 @test -n "$(distdir)"
100 $(RM) -r $(distdir)
101 mkdir -p $(distdir)
102 tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
103 cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
104 mv $@+ $@
106 package: $(pkgtgz) $(pkggem)
108 release:: verify package
109 # push gem to RubyGems.org
110 gem push $(pkggem)
111 else
112 gem install-gem: GIT-VERSION-FILE
113 $(MAKE) $@ VERSION=$(GIT_VERSION)
114 endif
116 all:: check
117 test_units := $(wildcard test/test_*.rb)
118 test: check
119 check: test-unit
120 test-unit: $(test_units)
121 $(test_units): build
122 $(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
124 # this requires GNU coreutils variants
125 ifneq ($(RSYNC_DEST),)
126 publish_doc:
127 -git set-file-times
128 $(MAKE) doc
129 $(MAKE) doc_gz
130 $(RSYNC) -av doc/ $(RSYNC_DEST)/
131 git ls-files | xargs touch
132 endif
134 # Create gzip variants of the same timestamp as the original so nginx
135 # "gzip_static on" can serve the gzipped versions directly.
136 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
137 doc_gz:
138 for i in $(docs); do \
139 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
140 check-warnings:
141 @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
142 do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
144 ifneq ($(PLACEHOLDERS),)
145 $(PLACEHOLDERS):
146 echo olddoc_placeholder > $@
147 endif
149 .PHONY: all .FORCE-GIT-VERSION-FILE doc check test $(test_units) manifest
150 .PHONY: check-warnings