1 # use GNU Make to run tests in parallel, and without depending on RubyGems
6 GIT_URL
= git
://git.bogomips.org
/kcar.git
10 GIT-VERSION-FILE
: .FORCE-GIT-VERSION-FILE
12 -include GIT-VERSION-FILE
14 ifeq ($(DLEXT
),) # "so" for Linux
15 DLEXT
:= $(shell $(RUBY
) -rrbconfig
-e
'puts Config::CONFIG["DLEXT"]')
17 ifeq ($(RUBY_VERSION
),)
18 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
25 cp
-p bin
/* .install-tmp
28 mv .install-tmp
/* bin
/
32 setup_rb_files
:= .config InstalledFiles
33 prep_setup_rb
:= @
-$(RM
) $(setup_rb_files
);$(MAKE
) -C
$(ext
) clean
36 -$(MAKE
) -C ext
/kcar
clean
37 $(RM
) $(setup_rb_files
) ext
/kcar
/Makefile
39 pkg_extra
:= GIT-VERSION-FILE NEWS ChangeLog ext
/kcar
/kcar.c
40 manifest
: $(pkg_extra
)
46 for i in
$@
$(pkg_extra
) $(man1_paths
); \
47 do echo
$$i; done
) | LC_ALL
=C
sort > $@
+
48 cmp
$@
+ $@ || mv
$@
+ $@
51 NEWS
: GIT-VERSION-FILE
52 $(RAKE
) -s news_rdoc
> $@
+
56 @awk
'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
59 ChangeLog
: LOG_VERSION
= \
60 $(shell git rev-parse
-q
"$(GIT_VERSION)" >/dev
/null
2>&1 && \
61 echo
$(GIT_VERSION
) || git describe
)
63 ChangeLog
: log_range
= v
$(SINCE
)..
$(LOG_VERSION
)
65 ChangeLog
: GIT-VERSION-FILE
66 @echo
"ChangeLog from $(GIT_URL) ($(log_range))" > $@
+
68 git log
$(log_range
) | sed
-e
's/^/ /' >> $@
+
71 news_atom
:= http
://bogomips.org
/kcar
/NEWS.atom.xml
72 cgit_atom
:= http
://git.bogomips.org
/cgit
/kcar.git
/atom
/?h
=master
73 atom
= <link rel
="alternate" title
="Atom feed" href
="$(1)" \
74 type
="application/atom+xml"/>
77 doc
: .document NEWS ChangeLog
78 rdoc
-a
-t
"$(shell sed -ne '1s/^= //p' README)"
79 install -m644 COPYING doc
/COPYING
80 install -m644
$(shell grep
'^[A-Z]' .document
) doc
/
82 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
85 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
86 doc
/NEWS.html doc
/README.html
87 $(RAKE
) -s news_atom
> doc
/NEWS.atom.xml
88 cd doc
&& ln README.html tmp
&& mv tmp index.html
93 pkggem
:= pkg
/$(rfpackage
)-$(VERSION
).gem
94 pkgtgz
:= pkg
/$(rfpackage
)-$(VERSION
).tgz
95 release_notes
:= release_notes-
$(VERSION
)
96 release_changes
:= release_changes-
$(VERSION
)
98 release-notes
: $(release_notes
)
99 release-changes
: $(release_changes
)
101 $(RAKE
) -s release_changes
> $@
+
102 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
104 GIT_URL
=$(GIT_URL
) $(RAKE
) -s release_notes
> $@
+
105 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
107 # ensures we're actually on the tagged $(VERSION), only used for release
109 test x
"$(shell umask)" = x0022
110 git rev-parse
--verify refs
/tags/v
$(VERSION
)^
{}
111 git diff-index
--quiet HEAD^
0
112 test `git rev-parse --verify HEAD^0` = \
113 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
116 -git ls-tree
-r HEAD | awk
'/^100644 / {print $$NF}' | xargs chmod
644
117 -git ls-tree
-r HEAD | awk
'/^100755 / {print $$NF}' | xargs chmod
755
121 install-gem
: $(pkggem
)
122 gem
install $(CURDIR
)/$<
124 $(pkggem
): manifest fix-perms
125 gem build
$(rfpackage
).gemspec
129 $(pkgtgz
): distdir
= $(basename $@
)
130 $(pkgtgz
): HEAD
= v
$(VERSION
)
131 $(pkgtgz
): manifest fix-perms
132 @
test -n
"$(distdir)"
135 tar c
`cat .manifest` |
(cd
$(distdir
) && tar x
)
136 cd pkg
&& tar c
$(basename $(@F
)) | gzip
-9 > $(@F
)+
139 package
: $(pkgtgz
) $(pkggem
)
141 test-release
: verify package
$(release_notes
) $(release_changes
)
142 release
: verify package
$(release_notes
) $(release_changes
)
143 # make tgz release on RubyForge
144 rubyforge add_release
-f
-n
$(release_notes
) -a
$(release_changes
) \
145 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkgtgz
)
146 # push gem to Gemcutter
148 # in case of gem downloads from RubyForge releases page
149 -rubyforge add_file \
150 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkggem
)
152 gem install-gem
: GIT-VERSION-FILE
153 $(MAKE
) $@ VERSION
=$(GIT_VERSION
)
156 ext
:= ext
/kcar
/kcar_ext.
$(DLEXT
)
157 hdr
:= $(wildcard $(addprefix ext
/kcar
/,*.h
))
159 ext
/kcar
/Makefile
: ext
/kcar
/extconf.rb
160 cd
$(@D
) && $(RUBY
) extconf.rb
162 ext
/kcar
/kcar.c
: ext
/kcar
/kcar.rl ext
/kcar
/kcar_http_common.rl
163 cd
$(@D
) && $(RAGEL
) kcar.rl
-C
$(RLFLAGS
) -o
$(@F
)
165 $(ext
): ext
/kcar
/kcar.c
$(hdr
) ext
/kcar
/Makefile
171 test_units
:= $(wildcard test/test_
*.rb
)
173 test-unit
: $(test_units
)
175 $(RUBY
) -w
-I lib
:ext
/kcar
$@
177 # this requires GNU coreutils variants
180 $(RM
) -r doc ChangeLog NEWS
181 $(MAKE
) doc LOG_VERSION
=$(shell git tag
-l | tail
-1)
182 $(MAKE
) -s latest
> doc
/LATEST
183 find doc
/images doc
/js
-type f | \
184 TZ
=UTC xargs touch
-d
'1970-01-01 00:00:00' doc
/rdoc.css
186 chmod
644 $$(find doc
-type f
)
187 $(RSYNC
) -av doc
/ dcvr
:/srv
/bogomips
/kcar
/
188 git ls-files | xargs touch
190 # Create gzip variants of the same timestamp as the original so nginx
191 # "gzip_static on" can serve the gzipped versions directly.
192 doc_gz
: docs
= $(shell find doc
-type f
! -regex
'^.*\.\(gif\|jpg\|png\|gz\)$$')
194 touch doc
/NEWS.atom.xml
-d
"$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
195 for i in
$(docs
); do \
196 gzip
--rsyncable
-9 < $$i > $$i.gz
; touch
-r
$$i $$i.gz
; done
198 .PHONY
: .FORCE-GIT-VERSION-FILE doc manifest man
test $(test_units
)