2 MAKEFLAGS += --warn-undefined-variables
7 # See config/config.vars.in (sets bup_python, among other things)
8 -include config/config.vars
11 cfg_py := $(CURDIR)/config/bin/python
14 && echo " ok" || echo " no"
17 # If ok, strip trailing " ok" and return the output, otherwise, error
19 $(if $(subst ok,,$(lastword $(1))),$(error $(2)),$(shell x="$(1)"; echo $${x%???}))
22 sampledata_rev := $(shell t/configure-sampledata --revision $(isok))
24 $(call shout,$(sampledata_rev),Could not parse sampledata revision)
26 current_sampledata := t/sampledata/var/rev/v$(sampledata_rev)
28 os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok))
29 os := $(call shout,$(os),Unable to determine OS)
31 CFLAGS := -Wall -Wformat=2 -O2 -Werror -Wno-unknown-pragmas $(CFLAGS)
32 CFLAGS := -D_FILE_OFFSET_BITS=64 $(PYINCLUDE) $(CFLAGS)
42 test_tmp := $(CURDIR)/t/tmp
45 initial_setup := $(shell dev/update-checkout-info lib/bup/checkout_info.py $(isok))
46 initial_setup := $(call shout,$(initial_setup),update-checkout-info failed))
49 configure config/configure config/configure.inc \
50 $(wildcard config/*.in)
51 MAKE="$(MAKE)" ./configure
53 # On some platforms, Python.h and readline.h fight over the
54 # _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
55 # now, we're just going to let Python's version win.
57 ifneq ($(strip $(bup_readline_cflags)),)
58 readline_cflags += $(bup_readline_cflags)
59 readline_xopen := $(filter -D_XOPEN_SOURCE=%,$(readline_cflags))
60 readline_xopen := $(subst -D_XOPEN_SOURCE=,,$(readline_xopen))
61 readline_cflags := $(filter-out -D_XOPEN_SOURCE=%,$(readline_cflags))
62 readline_cflags += $(addprefix -DBUP_RL_EXPECTED_XOPEN_SOURCE=,$(readline_xopen))
63 CFLAGS += $(readline_cflags)
66 LDFLAGS += $(bup_readline_ldflags)
68 ifeq ($(bup_have_libacl),1)
69 CFLAGS += $(bup_libacl_cflags)
70 LDFLAGS += $(bup_libacl_ldflags)
73 config/bin/python: config/config.vars
76 $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
77 $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
79 bup_deps := lib/bup/_helpers$(SOEXT) $(bup_cmds)
81 all: $(bup_deps) Documentation/all $(current_sampledata)
83 $(current_sampledata):
84 t/configure-sampledata --setup
86 PANDOC ?= $(shell type -p pandoc)
89 $(shell echo "Warning: pandoc not found; skipping manpage generation" 1>&2)
92 man_md := $(wildcard Documentation/*.md)
95 man_roff := $(patsubst %.md,%.1,$(man_md))
96 man_html := $(patsubst %.md,%.html,$(man_md))
100 MANDIR=$(PREFIX)/share/man
101 DOCDIR=$(PREFIX)/share/doc/bup
103 LIBDIR=$(PREFIX)/lib/bup
105 dest_mandir := $(DESTDIR)$(MANDIR)
106 dest_docdir := $(DESTDIR)$(DOCDIR)
107 dest_bindir := $(DESTDIR)$(BINDIR)
108 dest_libdir := $(DESTDIR)$(LIBDIR)
111 $(INSTALL) -d $(dest_bindir) \
112 $(dest_libdir)/bup $(dest_libdir)/cmd \
113 $(dest_libdir)/web $(dest_libdir)/web/static
114 test -z "$(man_roff)" || install -d $(dest_mandir)/man1
115 test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
116 test -z "$(man_html)" || install -d $(dest_docdir)
117 test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
118 dev/install-python-script lib/cmd/bup "$(dest_libdir)/cmd/bup"
120 for cmd in $$(ls cmd/bup-*); do \
121 dev/install-python-script "$$cmd" "$(dest_libdir)/$$cmd"; \
123 cd "$(dest_bindir)" && \
124 ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
126 $(INSTALL) -pm 0644 \
129 $(INSTALL) -pm 0755 \
132 $(INSTALL) -pm 0644 \
134 $(dest_libdir)/web/static/
135 $(INSTALL) -pm 0644 \
138 if test -e lib/bup/checkout_info.py; then \
139 $(INSTALL) -pm 0644 lib/bup/checkout_info.py \
140 $(dest_libdir)/bup/source_info.py; \
142 ! grep -qF '$$Format' lib/bup/source_info.py; \
143 $(INSTALL) -pm 0644 lib/bup/source_info.py $(dest_libdir)/bup/; \
147 $(INSTALL) -pm 0644 lib/bup/checkout_info.py $(dest_libdir)/bup/; \
149 config/config.h: config/config.vars
151 lib/bup/_helpers$(SOEXT): \
152 config/config.h lib/bup/bupsplit.h \
153 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
155 cd lib/bup && $(cfg_py) csetup.py build "$(CFLAGS)" "$(LDFLAGS)"
156 # Make sure there's just the one file we expect before we copy it.
158 "import glob; assert(len(glob.glob('lib/bup/build/*/_helpers*$(SOEXT)')) == 1)"
159 cp lib/bup/build/*/_helpers*$(SOEXT) "$@"
164 runtests: runtests-python runtests-cmdline
167 lib/bup/t/tbloom.py \
168 lib/bup/t/tclient.py \
170 lib/bup/t/thashsplit.py \
171 lib/bup/t/thelpers.py \
172 lib/bup/t/tindex.py \
173 lib/bup/t/tmetadata.py \
174 lib/bup/t/toptions.py \
175 lib/bup/t/tresolve.py \
176 lib/bup/t/tshquote.py \
181 # The "pwd -P" here may not be appropriate in the long run, but we
182 # need it until we settle the relevant drecurse/exclusion questions:
183 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
184 runtests-python: all t/tmp
185 mkdir -p t/tmp/test-log
186 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
187 ./wvtest.py $(python_tests) 2>&1 \
188 | tee -a t/tmp/test-log/$$$$.log
195 t/test-command-without-init-fails.sh \
196 t/test-compression.sh \
203 t/test-import-duplicity.sh \
204 t/test-import-rdiff-backup.sh \
206 t/test-index-check-device.sh \
207 t/test-index-clear.sh \
214 t/test-packsizelimit \
216 t/test-redundant-saves.sh \
217 t/test-restore-map-owner.sh \
218 t/test-restore-single-file.sh \
220 t/test-rm-between-index-and-save.sh \
221 t/test-save-creates-no-unrefs.sh \
222 t/test-save-restore \
224 t/test-save-restore-excludes.sh \
225 t/test-save-strip-graft.sh \
226 t/test-save-with-valid-parent.sh \
227 t/test-sparse-files.sh \
228 t/test-split-join.sh \
232 tmp-target-run-test-get-%: all t/tmp
233 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
234 t/test-get $* 2>&1 | tee -a t/tmp/test-log/$$$$.log
236 test_get_targets += \
237 tmp-target-run-test-get-replace \
238 tmp-target-run-test-get-universal \
239 tmp-target-run-test-get-ff \
240 tmp-target-run-test-get-append \
241 tmp-target-run-test-get-pick \
242 tmp-target-run-test-get-new-tag \
243 tmp-target-run-test-get-unnamed
246 # The "pwd -P" here may not be appropriate in the long run, but we
247 # need it until we settle the relevant drecurse/exclusion questions:
248 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
249 tmp-target-run-test%: all t/tmp
250 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
251 t/test$* 2>&1 | tee -a t/tmp/test-log/$$$$.log
253 runtests-cmdline: $(test_get_targets) $(subst t/test,tmp-target-run-test,$(cmdline_tests))
256 PATH=/bin:/usr/bin $(MAKE) test
259 if test -e t/tmp/test-log; then rm -r t/tmp/test-log; fi
260 mkdir -p t/tmp/test-log
261 ./wvtest watch --no-counts \
262 $(MAKE) runtests 2>t/tmp/test-log/$$$$.log
263 ./wvtest report t/tmp/test-log/*.log
268 ./wvtest run t/test-release-archive.sh
270 long-test: export BUP_TEST_LEVEL=11
273 long-check: export BUP_TEST_LEVEL=11
278 $(MAKE) clean && PYTHON=python3 $(MAKE) check
279 $(MAKE) clean && PYTHON=python2 $(MAKE) check
281 cmd/bup-%: cmd/%-cmd.py
285 cmd/bup-%: cmd/%-cmd.sh
289 .PHONY: Documentation/all
290 Documentation/all: $(man_roff) $(man_html)
292 Documentation/substvars: $(bup_deps)
293 echo "s,%BUP_VERSION%,$$(./bup version),g" > $@
294 echo "s,%BUP_DATE%,$$(./bup version --date),g" >> $@
296 Documentation/%.1: Documentation/%.md Documentation/substvars
297 $(pf); sed -f Documentation/substvars $< \
298 | $(PANDOC) -s -r markdown -w man -o $@
300 Documentation/%.html: Documentation/%.md Documentation/substvars
301 $(pf); sed -f Documentation/substvars $< \
302 | $(PANDOC) -s -r markdown -w html -o $@
304 .PHONY: Documentation/clean
306 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
308 # Note: this adds commits containing the current manpages in roff and
309 # html format to the man and html branches respectively. The version
310 # is determined by "git describe --always".
311 .PHONY: update-doc-branches
312 update-doc-branches: Documentation/all
313 dev/update-doc-branches refs/heads/man refs/heads/html
315 # push the pregenerated doc files to origin/man and origin/html
316 push-docs: export-docs
317 git push origin man html
319 # import pregenerated doc files from origin/man and origin/html, in case you
320 # don't have pandoc but still want to be able to install the docs.
321 import-docs: Documentation/clean
322 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
323 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
325 clean: Documentation/clean config/bin/python
326 cd config && rm -rf config.var
327 cd config && rm -f *~ .*~ \
328 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
329 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
330 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
331 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
332 lib/bup/checkout_info.py \
334 testfs.img lib/bup/t/testfs.img
335 for x in $$(ls cmd/*-cmd.py cmd/*-cmd.sh | grep -vF python-cmd.sh | cut -b 5-); do \
336 echo "cmd/bup-$${x%-cmd.*}"; \
337 done | xargs -t rm -f
338 if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
339 if test -e t/mnt; then rm -r t/mnt; fi
340 if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
341 # FIXME: migrate these to t/mnt/
342 if test -e lib/bup/t/testfs; \
343 then umount lib/bup/t/testfs || true; fi
344 rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
345 if test -e t/tmp; then t/force-delete t/tmp; fi
346 t/configure-sampledata --clean
347 # Remove last so that cleanup tools can depend on it