5 # See config/config.vars.in (sets bup_python, among other things)
6 include config/config.vars
11 && echo " ok" || echo " no"
14 # If ok, strip trailing " ok" and return the output, otherwise, error
16 $(if $(subst ok,,$(lastword $(1))),$(error $(2)),$(shell x="$(1)"; echo $${x%???}))
19 sampledata_rev := $(shell t/configure-sampledata --revision $(isok))
21 $(call shout,$(sampledata_rev),Could not parse sampledata revision)
23 current_sampledata := t/sampledata/var/rev/v$(sampledata_rev)
25 os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok))
26 os := $(call shout,$(os),Unable to determine OS)
28 CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS)
29 CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS)
39 test_tmp := $(CURDIR)/t/tmp
42 initial_setup := $(shell ./configure-version --update $(isok))
43 initial_setup := $(call shout,$(initial_setup),Version configuration failed))
45 config/config.vars: configure config/configure config/configure.inc \
46 $(wildcard config/*.in)
47 MAKE="$(MAKE)" ./configure
49 bup_cmds := cmd/bup-python\
50 $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
51 $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
53 bup_deps := bup lib/bup/_checkout.py lib/bup/_helpers$(SOEXT) $(bup_cmds)
55 all: $(bup_deps) Documentation/all $(current_sampledata)
60 $(current_sampledata):
61 t/configure-sampledata --setup
63 define install-python-bin
65 sed -e '1 s|.*|#!$(bup_python)|; 2,/^# end of bup preamble$$/d' $1 > $2; \
69 PANDOC ?= $(shell type -p pandoc)
72 $(shell echo "Warning: pandoc not found; skipping manpage generation" 1>&2)
75 man_md := $(wildcard Documentation/*.md)
78 man_roff := $(patsubst %.md,%.1,$(man_md))
79 man_html := $(patsubst %.md,%.html,$(man_md))
83 MANDIR=$(PREFIX)/share/man
84 DOCDIR=$(PREFIX)/share/doc/bup
86 LIBDIR=$(PREFIX)/lib/bup
88 dest_mandir := $(DESTDIR)$(MANDIR)
89 dest_docdir := $(DESTDIR)$(DOCDIR)
90 dest_bindir := $(DESTDIR)$(BINDIR)
91 dest_libdir := $(DESTDIR)$(LIBDIR)
94 $(INSTALL) -d $(dest_bindir) \
95 $(dest_libdir)/bup $(dest_libdir)/cmd \
96 $(dest_libdir)/web $(dest_libdir)/web/static
97 test -z "$(man_roff)" || install -d $(dest_mandir)/man1
98 test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
99 test -z "$(man_html)" || install -d $(dest_docdir)
100 test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
101 $(call install-python-bin,bup,"$(dest_bindir)/bup")
103 for cmd in $$(ls cmd/bup-* | grep -v cmd/bup-python); do \
104 $(call install-python-bin,"$$cmd","$(dest_libdir)/$$cmd") \
106 $(INSTALL) -pm 0644 \
109 $(INSTALL) -pm 0755 \
112 $(INSTALL) -pm 0644 \
114 $(dest_libdir)/web/static/
115 $(INSTALL) -pm 0644 \
119 config/config.h: config/config.vars
121 lib/bup/_helpers$(SOEXT): \
123 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
126 LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" "$(bup_python)" csetup.py build
127 cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
129 lib/bup/_checkout.py:
130 @if grep -F '$Format' lib/bup/_release.py \
131 && ! test -e lib/bup/_checkout.py; then \
132 echo "Something has gone wrong; $@ should already exist."; \
133 echo 'Check "./configure-version --update"'; \
140 runtests: runtests-python runtests-cmdline
142 # The "pwd -P" here may not be appropriate in the long run, but we
143 # need it until we settle the relevant drecurse/exclusion questions:
144 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
145 runtests-python: all t/tmp
146 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
147 "$(bup_python)" wvtest.py t/t*.py lib/*/t/t*.py 2>&1 \
148 | tee -a t/tmp/test-log/$$$$.log
151 t/test-save-restore \
152 t/test-packsizelimit \
160 t/test-split-join.sh \
164 t/test-compression.sh \
166 t/test-index-clear.sh \
167 t/test-index-check-device.sh \
172 t/test-restore-map-owner.sh \
173 t/test-restore-single-file.sh \
174 t/test-rm-between-index-and-save.sh \
175 t/test-save-with-valid-parent.sh \
176 t/test-sparse-files.sh \
177 t/test-command-without-init-fails.sh \
178 t/test-redundant-saves.sh \
179 t/test-save-creates-no-unrefs.sh \
180 t/test-save-restore-excludes.sh \
181 t/test-save-strip-graft.sh \
182 t/test-import-duplicity.sh \
183 t/test-import-rdiff-backup.sh \
188 # The "pwd -P" here may not be appropriate in the long run, but we
189 # need it until we settle the relevant drecurse/exclusion questions:
190 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
191 tmp-target-run-test%: all t/tmp
192 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
193 t/test$* 2>&1 | tee -a t/tmp/test-log/$$$$.log
195 runtests-cmdline: $(subst t/test,tmp-target-run-test,$(cmdline_tests))
198 PATH=/bin:/usr/bin $(MAKE) test
201 if test -e t/tmp/test-log; then rm -r t/tmp/test-log; fi
202 mkdir -p t/tmp/test-log
203 ./wvtest watch --no-counts \
204 $(MAKE) runtests-python runtests-cmdline 2>t/tmp/test-log/$$$$.log
205 ./wvtest report t/tmp/test-log/*.log
210 ./wvtest run t/test-release-archive.sh
212 cmd/python-cmd.sh: config/config.vars Makefile
213 printf "#!/bin/sh\nexec %q \"\$$@\"" "$(bup_python)" \
214 >> cmd/python-cmd.sh.$$PPID.tmp
215 chmod +x cmd/python-cmd.sh.$$PPID.tmp
216 mv cmd/python-cmd.sh.$$PPID.tmp cmd/python-cmd.sh
218 cmd/bup-%: cmd/%-cmd.py
222 cmd/bup-%: cmd/%-cmd.sh
226 .PHONY: Documentation/all
227 Documentation/all: $(man_roff) $(man_html)
229 Documentation/substvars: $(bup_deps)
230 echo "s,%BUP_VERSION%,$$(./bup version --tag),g" > $@
231 echo "s,%BUP_DATE%,$$(./bup version --date),g" >> $@
233 Documentation/%.1: Documentation/%.md Documentation/substvars
234 $(pf); sed -f Documentation/substvars $< \
235 | $(PANDOC) -s -r markdown -w man -o $@
237 Documentation/%.html: Documentation/%.md Documentation/substvars
238 $(pf); sed -f Documentation/substvars $< \
239 | $(PANDOC) -s -r markdown -w html -o $@
241 .PHONY: Documentation/clean
243 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
245 # update the local 'man' and 'html' branches with pregenerated output files, for
246 # people who don't have pandoc (and maybe to aid in google searches or something)
247 export-docs: Documentation/all
248 git update-ref refs/heads/man origin/man '' 2>/dev/null || true
249 git update-ref refs/heads/html origin/html '' 2>/dev/null || true
251 GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
252 rm -f $${GIT_INDEX_FILE} && \
253 git add -f Documentation/*.1 && \
254 git update-ref refs/heads/man \
255 $$(echo "Autogenerated man pages for $$(git describe --always)" \
256 | git commit-tree $$(git write-tree --prefix=Documentation) \
257 -p refs/heads/man) && \
258 rm -f $${GIT_INDEX_FILE} && \
259 git add -f Documentation/*.html && \
260 git update-ref refs/heads/html \
261 $$(echo "Autogenerated html pages for $$(git describe --always)" \
262 | git commit-tree $$(git write-tree --prefix=Documentation) \
265 # push the pregenerated doc files to origin/man and origin/html
266 push-docs: export-docs
267 git push origin man html
269 # import pregenerated doc files from origin/man and origin/html, in case you
270 # don't have pandoc but still want to be able to install the docs.
271 import-docs: Documentation/clean
272 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
273 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
275 clean: Documentation/clean cmd/bup-python
276 cd config && rm -f *~ .*~ \
277 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
278 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
279 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
280 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
283 testfs.img lib/bup/t/testfs.img
284 if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
285 if test -e t/mnt; then rm -r t/mnt; fi
286 if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
287 # FIXME: migrate these to t/mnt/
288 if test -e lib/bup/t/testfs; \
289 then umount lib/bup/t/testfs || true; fi
290 rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
291 if test -e t/tmp; then t/force-delete t/tmp; fi
292 ./configure-version --clean
293 t/configure-sampledata --clean
294 # Remove last so that cleanup tools can depend on it
295 rm -f cmd/bup-* cmd/python-cmd.sh