inotify: release GVL during Inotify#close on 1.9
[sleepy_penguin.git] / pkg.mk
bloba09196d91259fc687022fbb041c22557e490ec6e
1 RUBY = ruby
2 RAKE = rake
3 RSYNC = rsync
4 WRONGDOC = wrongdoc
6 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
7 @./GIT-VERSION-GEN
8 -include GIT-VERSION-FILE
9 -include local.mk
10 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
11 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
12 RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
13 lib := lib
15 ifeq ($(shell test -f script/isolate_for_tests && echo t),t)
16 isolate_libs := tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION)/isolate.mk
17 $(isolate_libs): script/isolate_for_tests
18 @$(RUBY) script/isolate_for_tests
19 -include $(isolate_libs)
20 lib := $(lib):$(ISOLATE_LIBS)
21 endif
23 ext := $(firstword $(wildcard ext/*))
24 ifneq ($(ext),)
25 ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
26 ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
27 ext_src := $(wildcard $(ext)/*.c $(ext_h))
28 ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
29 ext_d := $(ext_pfx)/$(ext)/.d
30 $(ext)/extconf.rb: $(wildcard $(ext)/*.h)
31 @>> $@
32 $(ext_d):
33 @mkdir -p $(@D)
34 @> $@
35 $(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
36 install -m 644 $< $@
37 $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
38 $(RM) -f $(@D)/*.o
39 cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb
40 ext_sfx := _ext.$(DLEXT)
41 ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
42 $(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
43 @echo $^ == $@
44 $(MAKE) -C $(@D)
45 lib := $(lib):$(ext_pfx)/$(ext)
46 build: $(ext_dl)
47 endif
49 pkg_extra += GIT-VERSION-FILE NEWS ChangeLog LATEST
50 ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
51 $(WRONGDOC) prepare
52 NEWS LATEST: ChangeLog
54 manifest:
55 $(RM) .manifest
56 $(MAKE) .manifest
58 .manifest: $(pkg_extra)
59 (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
60 LC_ALL=C sort > $@+
61 cmp $@+ $@ || mv $@+ $@
62 $(RM) $@+
64 doc:: .document .wrongdoc.yml $(pkg_extra)
65 -find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
66 -find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
67 $(RM) -r doc
68 $(WRONGDOC) all
69 install -m644 COPYING doc/COPYING
70 install -m644 $(shell grep '^[A-Z]' .document) doc/
72 ifneq ($(VERSION),)
73 pkggem := pkg/$(rfpackage)-$(VERSION).gem
74 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
75 release_notes := release_notes-$(VERSION)
76 release_changes := release_changes-$(VERSION)
78 release-notes: $(release_notes)
79 release-changes: $(release_changes)
80 $(release_changes):
81 $(WRONGDOC) release_changes > $@+
82 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
83 $(release_notes):
84 $(WRONGDOC) release_notes > $@+
85 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
87 # ensures we're actually on the tagged $(VERSION), only used for release
88 verify:
89 test x"$(shell umask)" = x0022
90 git rev-parse --verify refs/tags/v$(VERSION)^{}
91 git diff-index --quiet HEAD^0
92 test $$(git rev-parse --verify HEAD^0) = \
93 $$(git rev-parse --verify refs/tags/v$(VERSION)^{})
95 fix-perms:
96 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
97 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
99 gem: $(pkggem)
101 install-gem: $(pkggem)
102 gem install $(CURDIR)/$<
104 $(pkggem): manifest fix-perms
105 gem build $(rfpackage).gemspec
106 mkdir -p pkg
107 mv $(@F) $@
109 $(pkgtgz): distdir = $(basename $@)
110 $(pkgtgz): HEAD = v$(VERSION)
111 $(pkgtgz): manifest fix-perms
112 @test -n "$(distdir)"
113 $(RM) -r $(distdir)
114 mkdir -p $(distdir)
115 tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
116 cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
117 mv $@+ $@
119 package: $(pkgtgz) $(pkggem)
121 test-release:: verify package $(release_notes) $(release_changes)
122 # make tgz release on RubyForge
123 @echo rubyforge add_release -f \
124 -n $(release_notes) -a $(release_changes) \
125 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
126 @echo gem push $(pkggem)
127 @echo rubyforge add_file \
128 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
129 release:: verify package $(release_notes) $(release_changes)
130 # make tgz release on RubyForge
131 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
132 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
133 # push gem to RubyGems.org
134 gem push $(pkggem)
135 # in case of gem downloads from RubyForge releases page
136 rubyforge add_file \
137 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
138 else
139 gem install-gem: GIT-VERSION-FILE
140 $(MAKE) $@ VERSION=$(GIT_VERSION)
141 endif
143 all:: test
144 test_units := $(wildcard test/test_*.rb)
145 test: test-unit
146 test-unit: $(test_units)
147 $(test_units): build
148 $(RUBY) -I $(lib) $@
150 # this requires GNU coreutils variants
151 ifneq ($(RSYNC_DEST),)
152 publish_doc:
153 -git set-file-times
154 $(MAKE) doc
155 find doc/images -type f | \
156 TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
157 $(MAKE) doc_gz
158 $(RSYNC) -av doc/ $(RSYNC_DEST)/
159 git ls-files | xargs touch
160 endif
162 # Create gzip variants of the same timestamp as the original so nginx
163 # "gzip_static on" can serve the gzipped versions directly.
164 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
165 doc_gz:
166 for i in $(docs); do \
167 gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
169 .PHONY: all .FORCE-GIT-VERSION-FILE doc test $(test_units) manifest