update README
[upr.git] / GNUmakefile
blob6a395d136b86fe93b58e1d297ab55745c31242c4
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/upr.git
7 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8 @./GIT-VERSION-GEN
9 -include GIT-VERSION-FILE
10 -include local.mk
11 ifdef ruby
12 ifeq ($(RUBY),ruby)
13 $(warning ruby variable is deprecated, use RUBY instead)
14 RUBY = $(ruby)
15 endif
16 endif
17 ifeq ($(RUBY_VERSION),)
18 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
19 endif
21 base_bins := upr-drb
22 bins := $(addprefix bin/, $(base_bins))
24 install: $(bins)
25 $(prep_setup_rb)
26 $(RM) -r .install-tmp
27 mkdir .install-tmp
28 cp -p bin/* .install-tmp
29 $(RUBY) setup.rb all
30 $(RM) $^
31 mv .install-tmp/* bin/
32 $(RM) -r .install-tmp
33 $(prep_setup_rb)
35 setup_rb_files := .config InstalledFiles
36 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
38 clean:
39 -$(MAKE) -C $(ext) clean
40 $(RM) $(setup_rb_files) $(t_log)
42 pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
43 manifest: $(pkg_extra)
44 $(RM) .manifest
45 $(MAKE) .manifest
47 .manifest:
48 (git ls-files && \
49 for i in $@ $(pkg_extra); \
50 do echo $$i; done) | LC_ALL=C sort > $@+
51 cmp $@+ $@ || mv $@+ $@
52 $(RM) $@+
54 NEWS: GIT-VERSION-FILE
55 $(rake) -s news_rdoc > $@+
56 mv $@+ $@
58 SINCE =
59 ChangeLog: log_range = $(shell test -n "$(SINCE)" && echo v$(SINCE)..)
60 ChangeLog: GIT-VERSION-FILE
61 @echo "ChangeLog from $(GIT_URL) ($(SINCE)..$(GIT_VERSION))" > $@+
62 @echo >> $@+
63 git log $(log_range) | sed -e 's/^/ /' >> $@+
64 mv $@+ $@
66 news_atom := http://upr.bogomips.org/NEWS.atom.xml
67 cgit_atom := http://git.bogomips.org/cgit/upr.git/atom/?h=master
68 atom = <link rel="alternate" title="Atom feed" href="$(1)" \
69 type="application/atom+xml"/>
71 # using rdoc 2.4.1+
72 doc: .document NEWS ChangeLog
73 rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
74 install -m644 COPYING doc/COPYING
75 install -m644 $(shell grep '^[A-Z]' .document) doc/
76 $(RUBY) -i -p -e \
77 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
78 doc/ChangeLog.html
79 $(RUBY) -i -p -e \
80 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
81 doc/NEWS.html doc/README.html
82 $(rake) -s news_atom > doc/NEWS.atom.xml
83 cd doc && ln README.html tmp && mv tmp index.html
85 ifneq ($(VERSION),)
86 rfproject := rainbows
87 rfpackage := upr
88 pkggem := pkg/$(rfpackage)-$(VERSION).gem
89 pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
90 release_notes := release_notes-$(VERSION)
91 release_changes := release_changes-$(VERSION)
93 release-notes: $(release_notes)
94 release-changes: $(release_changes)
95 $(release_changes):
96 $(rake) -s release_changes > $@+
97 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
98 $(release_notes):
99 GIT_URL=$(GIT_URL) $(rake) -s release_notes > $@+
100 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
102 # ensures we're actually on the tagged $(VERSION), only used for release
103 verify:
104 test x"$(shell umask)" = x0022
105 git rev-parse --verify refs/tags/v$(VERSION)^{}
106 git diff-index --quiet HEAD^0
107 test `git rev-parse --verify HEAD^0` = \
108 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
110 fix-perms:
111 -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
112 -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
114 gem: $(pkggem)
116 install-gem: $(pkggem)
117 gem install $(CURDIR)/$<
119 $(pkggem): manifest fix-perms
120 gem build $(rfpackage).gemspec
121 mkdir -p pkg
122 mv $(@F) $@
124 $(pkgtgz): distdir = $(basename $@)
125 $(pkgtgz): HEAD = v$(VERSION)
126 $(pkgtgz): manifest fix-perms
127 @test -n "$(distdir)"
128 $(RM) -r $(distdir)
129 mkdir -p $(distdir)
130 tar c `cat .manifest` | (cd $(distdir) && tar x)
131 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
132 mv $@+ $@
134 package: $(pkgtgz) $(pkggem)
136 release: verify package $(release_notes) $(release_changes)
137 rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
138 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
139 rubyforge add_file \
140 $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
141 else
142 gem install-gem: GIT-VERSION-FILE
143 $(MAKE) $@ VERSION=$(GIT_VERSION)
144 endif
146 all::
148 # no tests :<
150 .PHONY: .FORCE-GIT-VERSION-FILE doc manifest test