Thread* models: cleanup timeout management
[rainbows.git] / GNUmakefile
blob9d385abf0549ac7cfdee6b860e91d4f3ad902ccb
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/rainbows.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 base_bins := rainbows
19 bins := $(addprefix bin/, $(base_bins))
20 man1_bins := $(addsuffix .1, $(base_bins))
21 man1_paths := $(addprefix man/man1/, $(man1_bins))
23 install: $(bins)
24 $(prep_setup_rb)
25 $(RM) -r .install-tmp
26 mkdir .install-tmp
27 cp -p bin/* .install-tmp
28 $(ruby) setup.rb all
29 $(RM) $^
30 mv .install-tmp/* bin/
31 $(RM) -r .install-tmp
32 $(prep_setup_rb)
34 setup_rb_files := .config InstalledFiles
35 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
37 clean:
38 -$(MAKE) -C $(ext) clean
39 -$(MAKE) -C Documentation clean
40 $(RM) $(setup_rb_files) $(t_log)
42 man:
43 $(MAKE) -C Documentation install-man
45 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
46 manifest: $(pkg_extra) man
47 $(RM) .manifest
48 $(MAKE) .manifest
50 .manifest:
51 (git ls-files && \
52 for i in $@ $(pkg_extra) $(man1_paths); \
53 do echo $$i; done) | LC_ALL=C sort > $@+
54 cmp $@+ $@ || mv $@+ $@
55 $(RM) $@+
57 NEWS: GIT-VERSION-FILE
58 $(rake) -s news_rdoc > $@+
59 mv $@+ $@
61 SINCE =
62 ChangeLog: log_range = $(shell test -n "$(SINCE)" && echo v$(SINCE)..)
63 ChangeLog: GIT-VERSION-FILE
64 @echo "ChangeLog from $(GIT_URL) ($(SINCE)..$(GIT_VERSION))" > $@+
65 @echo >> $@+
66 git log $(log_range) | sed -e 's/^/ /' >> $@+
67 mv $@+ $@
69 news_atom := http://rainbows.rubyforge.org/NEWS.atom.xml
70 cgit_atom := http://git.bogomips.org/cgit/rainbows.git/atom/?h=master
71 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
72 type="application/atom+xml"/>
74 # using rdoc 2.4.1+
75 doc: .document NEWS ChangeLog
76 for i in $(man1_bins); do > $$i; done
77 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
78 install -m644 COPYING doc/COPYING
79 install -m644 $(shell grep '^[A-Z]' .document) doc/
80 $(MAKE) -C Documentation install-html install-man
81 install -m644 $(man1_paths) doc/
82 cd doc && for i in $(base_bins); do \
83 sed -e '/"documentation">/r man1/'$$i'.1.html' \
84 < $${i}_1.html > tmp && mv tmp $${i}_1.html; done
85 $(ruby) -i -p -e \
86 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
87 doc/ChangeLog.html
88 $(ruby) -i -p -e \
89 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
90 doc/NEWS.html doc/README.html
91 $(rake) -s news_atom > doc/NEWS.atom.xml
92 cd doc && ln README.html tmp && mv tmp index.html
93 $(RM) $(man1_bins)
95 ifneq ($(VERSION),)
96 rfproject := rainbows
97 rfpackage := rainbows
98 pkggem := pkg/$(rfpackage)-$(VERSION).gem
99 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
100 release_notes := release_notes-$(VERSION)
101 release_changes := release_changes-$(VERSION)
103 release-notes: $(release_notes)
104 release-changes: $(release_changes)
105 $(release_changes):
106 $(rake) -s release_changes > $@+
107 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
108 $(release_notes):
109 GIT_URL=$(GIT_URL) $(rake) -s release_notes > $@+
110 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
112 # ensures we're actually on the tagged $(VERSION), only used for release
113 verify:
114 test x"$(shell umask)" = x0022
115 git rev-parse --verify refs/tags/v$(VERSION)^{}
116 git diff-index --quiet HEAD^0
117 test `git rev-parse --verify HEAD^0` = \
118 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
120 fix-perms:
121 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
122 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
124 gem: $(pkggem)
126 install-gem: $(pkggem)
127 gem install $(CURDIR)/$<
129 $(pkggem): manifest fix-perms
130 gem build $(rfpackage).gemspec
131 mkdir -p pkg
132 mv $(@F) $@
134 $(pkgtgz): distdir = $(basename $@)
135 $(pkgtgz): HEAD = v$(VERSION)
136 $(pkgtgz): manifest fix-perms
137 @test -n "$(distdir)"
138 $(RM) -r $(distdir)
139 mkdir -p $(distdir)
140 tar c `cat .manifest` | (cd $(distdir) && tar x)
141 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
142 mv $@+ $@
144 package: $(pkgtgz) $(pkggem)
146 release: verify package $(release_notes) $(release_changes)
147 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
148 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
149 rubyforge add_file \
150 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
151 else
152 gem install-gem: GIT-VERSION-FILE
153 $(MAKE) $@ VERSION=$(GIT_VERSION)
154 endif
156 all:: test
157 test:
158 $(MAKE) -C t
160 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test