response: fix handling of pipelined identity responses
[kcar.git] / GNUmakefile
blobf880f265a9debc92dd173836cbda201f1074156f
1 # use GNU Make to run tests in parallel, and without depending on RubyGems
2 all::
3 RUBY = ruby
4 RAKE = rake
5 RAGEL = ragel
6 GIT_URL = git://git.bogomips.org/kcar.git
7 RLFLAGS = -G2
9 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
10 @./GIT-VERSION-GEN
11 -include GIT-VERSION-FILE
12 -include local.mk
13 ifeq ($(DLEXT),) # "so" for Linux
14 DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
15 endif
16 ifeq ($(RUBY_VERSION),)
17 RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
18 endif
20 install: $(bins)
21 $(prep_setup_rb)
22 $(RM) -r .install-tmp
23 mkdir .install-tmp
24 cp -p bin/* .install-tmp
25 $(RUBY) setup.rb all
26 $(RM) $^
27 mv .install-tmp/* bin/
28 $(RM) -r .install-tmp
29 $(prep_setup_rb)
31 setup_rb_files := .config InstalledFiles
32 prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
34 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)
40 $(RM) .manifest
41 $(MAKE) .manifest
43 .manifest:
44 (git ls-files && \
45 for i in $@ $(pkg_extra) $(man1_paths); \
46 do echo $$i; done) | LC_ALL=C sort > $@+
47 cmp $@+ $@ || mv $@+ $@
48 $(RM) $@+
50 NEWS: GIT-VERSION-FILE
51 $(RAKE) -s news_rdoc > $@+
52 mv $@+ $@
54 latest: NEWS
55 @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
57 SINCE =
58 ChangeLog: LOG_VERSION = \
59 $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
60 echo $(GIT_VERSION) || git describe)
61 ifneq ($(SINCE),)
62 ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
63 endif
64 ChangeLog: GIT-VERSION-FILE
65 @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
66 @echo >> $@+
67 git log $(log_range) | sed -e 's/^/ /' >> $@+
68 mv $@+ $@
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"/>
75 # using rdoc 2.5.x
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/
80 $(RUBY) -i -p -e \
81 '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
82 doc/ChangeLog.html
83 $(RUBY) -i -p -e \
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
89 ifneq ($(VERSION),)
90 rfproject := rainbows
91 rfpackage := kcar
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)
99 $(release_changes):
100 $(RAKE) -s release_changes > $@+
101 $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
102 $(release_notes):
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
107 verify:
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)^{}`
114 fix-perms:
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
118 gem: $(pkggem)
120 install-gem: $(pkggem)
121 gem install $(CURDIR)/$<
123 $(pkggem): manifest fix-perms
124 gem build $(rfpackage).gemspec
125 mkdir -p pkg
126 mv $(@F) $@
128 $(pkgtgz): distdir = $(basename $@)
129 $(pkgtgz): HEAD = v$(VERSION)
130 $(pkgtgz): manifest fix-perms
131 @test -n "$(distdir)"
132 $(RM) -r $(distdir)
133 mkdir -p $(distdir)
134 tar c `cat .manifest` | (cd $(distdir) && tar x)
135 cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
136 mv $@+ $@
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
146 gem push $(pkggem)
147 # in case of gem downloads from RubyForge releases page
148 -rubyforge add_file \
149 $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
150 else
151 gem install-gem: GIT-VERSION-FILE
152 $(MAKE) $@ VERSION=$(GIT_VERSION)
153 endif
155 ext := ext/kcar/kcar_ext.$(DLEXT)
156 hdr := $(wildcard $(addprefix ext/kcar/,*.h))
157 ragel: $(ext)
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
165 $(MAKE) -C $(@D)
167 all:: test
169 build: $(ext)
170 test_units := $(wildcard test/test_*.rb)
171 test: test-unit
172 test-unit: $(test_units)
173 $(test_units): build
174 $(RUBY) -w -I lib:ext/kcar $@
176 # this requires GNU coreutils variants
177 publish_doc:
178 -git set-file-times
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
184 $(MAKE) doc_gz
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\)$$')
192 doc_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)