1 # use GNU Make to run tests in parallel, and without depending on RubyGems
5 GIT_URL
= git
://git.bogomips.org
/metropolis.git
8 GIT-VERSION-FILE
: .FORCE-GIT-VERSION-FILE
10 -include GIT-VERSION-FILE
12 ifeq ($(RUBY_VERSION
),)
13 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
20 cp
-p bin
/* .install-tmp
23 mv .install-tmp
/* bin
/
27 setup_rb_files
:= .config InstalledFiles
28 prep_setup_rb
:= @
-$(RM
) $(setup_rb_files
);$(MAKE
) -C
$(ext
) clean
31 $(RM
) $(setup_rb_files
)
33 pkg_extra
:= GIT-VERSION-FILE NEWS ChangeLog
34 manifest
: $(pkg_extra
)
40 for i in
$@
$(pkg_extra
) $(man1_paths
); \
41 do echo
$$i; done
) | LC_ALL
=C
sort > $@
+
42 cmp
$@
+ $@ || mv
$@
+ $@
45 NEWS
: GIT-VERSION-FILE
46 $(RAKE
) -s news_rdoc
> $@
+
50 @awk
'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
53 ChangeLog
: LOG_VERSION
= \
54 $(shell git rev-parse
-q
"$(GIT_VERSION)" >/dev
/null
2>&1 && \
55 echo
$(GIT_VERSION
) || git describe
)
57 ChangeLog
: log_range
= v
$(SINCE
)..
$(LOG_VERSION
)
59 ChangeLog
: GIT-VERSION-FILE
60 @echo
"ChangeLog from $(GIT_URL) ($(log_range))" > $@
+
62 git log
$(log_range
) | sed
-e
's/^/ /' >> $@
+
65 news_atom
:= http
://metropolis.bogomips.org
/NEWS.atom.xml
66 cgit_atom
:= http
://git.bogomips.org
/cgit
/metropolis.git
/atom
/?h
=master
67 atom
= <link rel
="alternate" title
="Atom feed" href
="$(1)" \
68 type
="application/atom+xml"/>
71 doc
: .document NEWS ChangeLog
72 rdoc
-t
"$(shell sed -ne '1s/^= //p' README)"
73 install -m644 COPYING doc
/COPYING
74 install -m644
$(shell grep
'^[A-Z]' .document
) doc
/
76 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
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
86 rfpackage
:= metropolis
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
)
95 $(RAKE
) -s release_changes
> $@
+
96 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
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
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)^{}`
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
115 install-gem
: $(pkggem
)
116 gem
install $(CURDIR
)/$<
118 $(pkggem
): manifest fix-perms
119 gem build
$(rfpackage
).gemspec
123 $(pkgtgz
): distdir
= $(basename $@
)
124 $(pkgtgz
): HEAD
= v
$(VERSION
)
125 $(pkgtgz
): manifest fix-perms
126 @
test -n
"$(distdir)"
129 tar cf
- `cat .manifest` |
(cd
$(distdir
) && tar x
)
130 cd pkg
&& tar cf
- $(basename $(@F
)) | gzip
-9 > $(@F
)+
133 package
: $(pkgtgz
) $(pkggem
)
135 test-release
: verify package
$(release_notes
) $(release_changes
)
136 release
: verify package
$(release_notes
) $(release_changes
)
137 # make tgz release on RubyForge
138 rubyforge add_release
-f
-n
$(release_notes
) -a
$(release_changes
) \
139 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkgtgz
)
140 # push gem to RubyGems.org
142 # in case of gem downloads from RubyForge releases page
143 -rubyforge add_file \
144 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkggem
)
145 $(RAKE
) raa_update VERSION
=$(VERSION
)
146 $(RAKE
) publish_news VERSION
=$(VERSION
)
148 gem install-gem
: GIT-VERSION-FILE
149 $(MAKE
) $@ VERSION
=$(GIT_VERSION
)
154 test_units
:= $(wildcard test/test_
*.rb
)
156 test-unit
: $(test_units
)
160 # this requires GNU coreutils variants
163 $(RM
) -r doc ChangeLog NEWS
164 $(MAKE
) doc LOG_VERSION
=$(shell git tag
-l | tail
-1)
165 $(MAKE
) -s latest
> doc
/LATEST
166 find doc
/images doc
/js
-type f | \
167 TZ
=UTC xargs touch
-d
'1970-01-01 00:00:00' doc
/rdoc.css
169 chmod
644 $$(find doc
-type f
)
170 $(RSYNC
) -av doc
/ metropolis.bogomips.org
:/srv
/metropolis
/
171 git ls-files | xargs touch
173 # Create gzip variants of the same timestamp as the original so nginx
174 # "gzip_static on" can serve the gzipped versions directly.
175 doc_gz
: docs
= $(shell find doc
-type f
! -regex
'^.*\.\(gif\|jpg\|png\|gz\)$$')
177 touch doc
/NEWS.atom.xml
-d
"$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
178 for i in
$(docs
); do \
179 gzip
--rsyncable
-9 < $$i > $$i.gz
; touch
-r
$$i $$i.gz
; done
181 .PHONY
: .FORCE-GIT-VERSION-FILE doc manifest man
test $(test_units
)