1 # use GNU Make to run tests in parallel, and without depending on RubyGems
6 GIT_URL
= git
://git.bogomips.org
/kcar.git
9 GIT-VERSION-FILE
: .FORCE-GIT-VERSION-FILE
11 -include GIT-VERSION-FILE
13 ifeq ($(DLEXT
),) # "so" for Linux
14 DLEXT
:= $(shell $(RUBY
) -rrbconfig
-e
'puts Config::CONFIG["DLEXT"]')
16 ifeq ($(RUBY_VERSION
),)
17 RUBY_VERSION
:= $(shell $(RUBY
) -e
'puts RUBY_VERSION')
24 cp
-p bin
/* .install-tmp
27 mv .install-tmp
/* bin
/
31 setup_rb_files
:= .config InstalledFiles
32 prep_setup_rb
:= @
-$(RM
) $(setup_rb_files
);$(MAKE
) -C
$(ext
) clean
35 -$(MAKE
) -C ext
/kcar
clean
36 $(RM
) $(setup_rb_files
) ext
/kcar
/Makefile
38 pkg_extra
:= GIT-VERSION-FILE NEWS ChangeLog ext
/kcar
/kcar.c
39 manifest
: $(pkg_extra
)
45 for i in
$@
$(pkg_extra
) $(man1_paths
); \
46 do echo
$$i; done
) | LC_ALL
=C
sort > $@
+
47 cmp
$@
+ $@ || mv
$@
+ $@
50 NEWS
: GIT-VERSION-FILE
51 $(RAKE
) -s news_rdoc
> $@
+
55 @awk
'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
58 ChangeLog
: LOG_VERSION
= \
59 $(shell git rev-parse
-q
"$(GIT_VERSION)" >/dev
/null
2>&1 && \
60 echo
$(GIT_VERSION
) || git describe
)
62 ChangeLog
: log_range
= v
$(SINCE
)..
$(LOG_VERSION
)
64 ChangeLog
: GIT-VERSION-FILE
65 @echo
"ChangeLog from $(GIT_URL) ($(log_range))" > $@
+
67 git log
$(log_range
) | sed
-e
's/^/ /' >> $@
+
70 news_atom
:= http
://bogomips.org
/kcar
/NEWS.atom.xml
71 cgit_atom
:= http
://git.bogomips.org
/cgit
/kcar.git
/atom
/?h
=master
72 atom
= <link rel
="alternate" title
="Atom feed" href
="$(1)" \
73 type
="application/atom+xml"/>
76 doc
: .document NEWS ChangeLog
77 rdoc
-a
-t
"$(shell sed -ne '1s/^= //p' README)"
78 install -m644 COPYING doc
/COPYING
79 install -m644
$(shell grep
'^[A-Z]' .document
) doc
/
81 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
84 '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
85 doc
/NEWS.html doc
/README.html
86 $(RAKE
) -s news_atom
> doc
/NEWS.atom.xml
87 cd doc
&& ln README.html tmp
&& mv tmp index.html
92 pkggem
:= pkg
/$(rfpackage
)-$(VERSION
).gem
93 pkgtgz
:= pkg
/$(rfpackage
)-$(VERSION
).tgz
94 release_notes
:= release_notes-
$(VERSION
)
95 release_changes
:= release_changes-
$(VERSION
)
97 release-notes
: $(release_notes
)
98 release-changes
: $(release_changes
)
100 $(RAKE
) -s release_changes
> $@
+
101 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
103 GIT_URL
=$(GIT_URL
) $(RAKE
) -s release_notes
> $@
+
104 $(VISUAL
) $@
+ && test -s
$@
+ && mv
$@
+ $@
106 # ensures we're actually on the tagged $(VERSION), only used for release
108 test x
"$(shell umask)" = x0022
109 git rev-parse
--verify refs
/tags/v
$(VERSION
)^
{}
110 git diff-index
--quiet HEAD^
0
111 test `git rev-parse --verify HEAD^0` = \
112 `git rev-parse --verify refs/tags/v$(VERSION)^{}`
115 -git ls-tree
-r HEAD | awk
'/^100644 / {print $$NF}' | xargs chmod
644
116 -git ls-tree
-r HEAD | awk
'/^100755 / {print $$NF}' | xargs chmod
755
120 install-gem
: $(pkggem
)
121 gem
install $(CURDIR
)/$<
123 $(pkggem
): manifest fix-perms
124 gem build
$(rfpackage
).gemspec
128 $(pkgtgz
): distdir
= $(basename $@
)
129 $(pkgtgz
): HEAD
= v
$(VERSION
)
130 $(pkgtgz
): manifest fix-perms
131 @
test -n
"$(distdir)"
134 tar c
`cat .manifest` |
(cd
$(distdir
) && tar x
)
135 cd pkg
&& tar c
$(basename $(@F
)) | gzip
-9 > $(@F
)+
138 package
: $(pkgtgz
) $(pkggem
)
140 test-release
: verify package
$(release_notes
) $(release_changes
)
141 release
: verify package
$(release_notes
) $(release_changes
)
142 # make tgz release on RubyForge
143 rubyforge add_release
-f
-n
$(release_notes
) -a
$(release_changes
) \
144 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkgtgz
)
145 # push gem to Gemcutter
147 # in case of gem downloads from RubyForge releases page
148 -rubyforge add_file \
149 $(rfproject
) $(rfpackage
) $(VERSION
) $(pkggem
)
151 gem install-gem
: GIT-VERSION-FILE
152 $(MAKE
) $@ VERSION
=$(GIT_VERSION
)
155 ext
:= ext
/kcar
/kcar_ext.
$(DLEXT
)
156 hdr
:= $(wildcard $(addprefix ext
/kcar
/,*.h
))
158 ext
/kcar
/Makefile
: ext
/kcar
/extconf.rb
159 cd
$(@D
) && $(RUBY
) extconf.rb
161 ext
/kcar
/kcar.c
: ext
/kcar
/kcar.rl ext
/kcar
/kcar_http_common.rl
162 cd
$(@D
) && $(RAGEL
) kcar.rl
-C
$(RLFLAGS
) -o
$(@F
)
164 $(ext
): ext
/kcar
/kcar.c
$(hdr
) ext
/kcar
/Makefile
170 test_units
:= $(wildcard test/test_
*.rb
)
172 test-unit
: $(test_units
)
174 $(RUBY
) -w
-I lib
:ext
/kcar
$@
176 # this requires GNU coreutils variants
179 $(RM
) -r doc ChangeLog NEWS
180 $(MAKE
) doc LOG_VERSION
=$(shell git tag
-l | tail
-1)
181 $(MAKE
) -s latest
> doc
/LATEST
182 find doc
/images doc
/js
-type f | \
183 TZ
=UTC xargs touch
-d
'1970-01-01 00:00:00' doc
/rdoc.css
185 chmod
644 $$(find doc
-type f
)
186 rsync
-av doc
/ dcvr
:/srv
/bogomips
/kcar
/
187 git ls-files | xargs touch
189 # Create gzip variants of the same timestamp as the original so nginx
190 # "gzip_static on" can serve the gzipped versions directly.
191 doc_gz
: docs
= $(shell find doc
-type f
! -regex
'^.*\.\(gif\|jpg\|png\|gz\)$$')
193 touch doc
/NEWS.atom.xml
-d
"$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
194 for i in
$(docs
); do \
195 gzip
--rsyncable
-9 < $$i > $$i.gz
; touch
-r
$$i $$i.gz
; done
197 .PHONY
: .FORCE-GIT-VERSION-FILE doc manifest man
test $(test_units
)