avoid unnecessary syscalls in handshake
[sunshowers.git] / GNUmakefile
blobcf9a2587f3d3e82697b5bb63a425033127ca627d
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/sunshowers.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:
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) clean
34 $(RM) $(setup_rb_files) $(t_log)
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); \
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://rainbows.rubyforge.org/sunshowers/NEWS.atom.xml
66 cgit_atom := http://git.bogomips.org/cgit/sunshowers.git/atom/?h=master
67 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
68 type="application/atom+xml"/>
70 # using rdoc 2.4.1+
71 doc: .document NEWS ChangeLog
72 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
73 install -m644 COPYING doc/COPYING
74 install -m644 $(shell grep '^[A-Z]' .document) doc/
75 $(RUBY) -i -p -e \
76 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
77 doc/ChangeLog.html
78 $(RUBY) -i -p -e \
79 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
80 doc/NEWS.html doc/README.html
81 $(RAKE) -s news_atom > doc/NEWS.atom.xml
82 cd doc && ln README.html tmp && mv tmp index.html
84 ifneq ($(VERSION),)
85 rfproject := rainbows
86 rfpackage := sunshowers
87 pkggem := pkg/$(rfpackage)-$(VERSION).gem
88 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
89 release_notes := release_notes-$(VERSION)
90 release_changes := release_changes-$(VERSION)
92 release-notes: $(release_notes)
93 release-changes: $(release_changes)
94 $(release_changes):
95 $(RAKE) -s release_changes > $@+
96 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
97 $(release_notes):
98 GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
99 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
101 # ensures we're actually on the tagged $(VERSION), only used for release
102 verify:
103 test x"$(shell umask)" = x0022
104 git rev-parse --verify refs/tags/v$(VERSION)^{}
105 git diff-index --quiet HEAD^0
106 test `git rev-parse --verify HEAD^0` = \
107 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
109 fix-perms:
110 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
111 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
113 gem: $(pkggem)
115 install-gem: $(pkggem)
116 gem install $(CURDIR)/$<
118 $(pkggem): manifest fix-perms
119 gem build $(rfpackage).gemspec
120 mkdir -p pkg
121 mv $(@F) $@
123 $(pkgtgz): distdir = $(basename $@)
124 $(pkgtgz): HEAD = v$(VERSION)
125 $(pkgtgz): manifest fix-perms
126 @test -n "$(distdir)"
127 $(RM) -r $(distdir)
128 mkdir -p $(distdir)
129 tar c `cat .manifest` | (cd $(distdir) && tar x)
130 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
131 mv $@+ $@
133 package: $(pkgtgz) $(pkggem)
135 release: verify package $(release_notes) $(release_changes)
136 # make tgz release on RubyForge
137 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
138 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
139 # push gem to Gemcutter
140 gem push $(pkggem)
141 # in case of gem downloads from RubyForge releases page
142 -rubyforge add_file \
143 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
144 else
145 gem install-gem: GIT-VERSION-FILE
146 $(MAKE) $@ VERSION=$(GIT_VERSION)
147 endif
149 all:: test
150 test: test-unit test-integration
151 TEST_UNIT := $(wildcard test/test_*.rb)
153 $(TEST_UNIT):
154 $(RUBY) -I lib $@
156 test-unit: $(TEST_UNIT)
158 test-integration:
159 $(MAKE) -C t
161 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(TEST_UNIT)