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 := lib/bup/_checkout.py lib/bup/_helpers$(SOEXT) $(bup_cmds)
55 all: $(bup_deps) Documentation/all $(current_sampledata)
57 $(current_sampledata):
58 t/configure-sampledata --setup
61 bup_libdir="$script_home/../lib" # bup_libdir will be adjusted during install
63 define install-bup-python
65 sed -e 's|.*# bup_libdir will be adjusted during install|bup_libdir="$$script_home/.."|' $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 $(INSTALL) -pm 0755 cmd/bup $(dest_libdir)/cmd/
102 $(INSTALL) -pm 0755 cmd/bup-* $(dest_libdir)/cmd/
103 $(call install-bup-python,cmd/bup-python,"$(dest_libdir)/cmd/bup-python")
104 cd "$(dest_bindir)" && \
105 ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
107 $(INSTALL) -pm 0644 \
110 $(INSTALL) -pm 0755 \
113 $(INSTALL) -pm 0644 \
115 $(dest_libdir)/web/static/
116 $(INSTALL) -pm 0644 \
120 config/config.h: config/config.vars
122 lib/bup/_helpers$(SOEXT): \
124 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
127 LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" "$(bup_python)" csetup.py build
128 # Make sure there's just the one file we expect before we copy it.
130 "import glob; assert(len(glob.glob('lib/bup/build/*/_helpers*$(SOEXT)')) == 1)"
131 cp lib/bup/build/*/_helpers*$(SOEXT) "$@"
133 lib/bup/_checkout.py:
134 @if grep -F '$Format' lib/bup/_release.py \
135 && ! test -e lib/bup/_checkout.py; then \
136 echo "Something has gone wrong; $@ should already exist."; \
137 echo 'Check "./configure-version --update"'; \
144 runtests: runtests-python runtests-cmdline
147 lib/bup/t/thashsplit.py \
148 lib/bup/t/toptions.py \
149 lib/bup/t/tshquote.py \
153 ifeq "2" "$(bup_python_majver)"
155 lib/bup/t/tbloom.py \
156 lib/bup/t/tclient.py \
158 lib/bup/t/thelpers.py \
159 lib/bup/t/tindex.py \
160 lib/bup/t/tmetadata.py \
161 lib/bup/t/tresolve.py \
165 # The "pwd -P" here may not be appropriate in the long run, but we
166 # need it until we settle the relevant drecurse/exclusion questions:
167 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
168 runtests-python: all t/tmp
169 mkdir -p t/tmp/test-log
170 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
171 ./wvtest.py $(python_tests) 2>&1 \
172 | tee -a t/tmp/test-log/$$$$.log
176 ifeq "2" "$(bup_python_majver)"
180 t/test-save-restore \
181 t/test-packsizelimit \
189 t/test-split-join.sh \
193 t/test-compression.sh \
195 t/test-index-clear.sh \
196 t/test-index-check-device.sh \
202 t/test-restore-map-owner.sh \
203 t/test-restore-single-file.sh \
204 t/test-rm-between-index-and-save.sh \
205 t/test-save-with-valid-parent.sh \
206 t/test-sparse-files.sh \
207 t/test-command-without-init-fails.sh \
208 t/test-redundant-saves.sh \
209 t/test-save-creates-no-unrefs.sh \
210 t/test-save-restore-excludes.sh \
211 t/test-save-strip-graft.sh \
212 t/test-import-duplicity.sh \
213 t/test-import-rdiff-backup.sh \
218 tmp-target-run-test-get-%: all t/tmp
219 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
220 t/test-get $* 2>&1 | tee -a t/tmp/test-log/$$$$.log
224 ifeq "2" "$(bup_python_majver)"
225 test_get_targets += \
226 tmp-target-run-test-get-replace \
227 tmp-target-run-test-get-universal \
228 tmp-target-run-test-get-ff \
229 tmp-target-run-test-get-append \
230 tmp-target-run-test-get-pick \
231 tmp-target-run-test-get-new-tag \
232 tmp-target-run-test-get-unnamed
236 # The "pwd -P" here may not be appropriate in the long run, but we
237 # need it until we settle the relevant drecurse/exclusion questions:
238 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
239 tmp-target-run-test%: all t/tmp
240 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
241 t/test$* 2>&1 | tee -a t/tmp/test-log/$$$$.log
243 runtests-cmdline: $(test_get_targets) $(subst t/test,tmp-target-run-test,$(cmdline_tests))
246 PATH=/bin:/usr/bin $(MAKE) test
249 if test -e t/tmp/test-log; then rm -r t/tmp/test-log; fi
250 mkdir -p t/tmp/test-log
251 ./wvtest watch --no-counts \
252 $(MAKE) runtests 2>t/tmp/test-log/$$$$.log
253 ./wvtest report t/tmp/test-log/*.log
258 ./wvtest run t/test-release-archive.sh
260 cmd/bup-python: cmd/python-cmd.sh config/config.vars Makefile
261 head -n -1 $< > "$@".$$PPID.tmp
262 printf "exec %q \"\$$@\"\n" "$(bup_python)" >> "$@".$$PPID.tmp
263 chmod +x "$@".$$PPID.tmp
264 mv "$@".$$PPID.tmp "$@"
266 long-test: export BUP_TEST_LEVEL=11
269 long-check: export BUP_TEST_LEVEL=11
275 && PYTHON=python3 BUP_ALLOW_UNEXPECTED_PYTHON_VERSION=true $(MAKE) check
277 && PYTHON=python2 $(MAKE) check
279 cmd/bup-%: cmd/%-cmd.py
283 cmd/bup-%: cmd/%-cmd.sh
287 .PHONY: Documentation/all
288 Documentation/all: $(man_roff) $(man_html)
290 Documentation/substvars: $(bup_deps)
291 echo "s,%BUP_VERSION%,$$(./bup version --tag),g" > $@
292 echo "s,%BUP_DATE%,$$(./bup version --date),g" >> $@
294 Documentation/%.1: Documentation/%.md Documentation/substvars
295 $(pf); sed -f Documentation/substvars $< \
296 | $(PANDOC) -s -r markdown -w man -o $@
298 Documentation/%.html: Documentation/%.md Documentation/substvars
299 $(pf); sed -f Documentation/substvars $< \
300 | $(PANDOC) -s -r markdown -w html -o $@
302 .PHONY: Documentation/clean
304 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
306 # Note: this adds commits containing the current manpages in roff and
307 # html format to the man and html branches respectively. The version
308 # is determined by "git describe --always".
309 .PHONY: update-doc-branches
310 update-doc-branches: Documentation/all
311 dev/update-doc-branches refs/heads/man refs/heads/html
313 # push the pregenerated doc files to origin/man and origin/html
314 push-docs: export-docs
315 git push origin man html
317 # import pregenerated doc files from origin/man and origin/html, in case you
318 # don't have pandoc but still want to be able to install the docs.
319 import-docs: Documentation/clean
320 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
321 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
323 clean: Documentation/clean cmd/bup-python
324 cd config && rm -f *~ .*~ \
325 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
326 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
327 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
328 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
330 testfs.img lib/bup/t/testfs.img
331 for x in $$(ls cmd/*-cmd.py cmd/*-cmd.sh | grep -vF python-cmd.sh | cut -b 5-); do \
332 echo "cmd/bup-$${x%-cmd.*}"; \
333 done | xargs -t rm -f
334 if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
335 if test -e t/mnt; then rm -r t/mnt; fi
336 if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
337 # FIXME: migrate these to t/mnt/
338 if test -e lib/bup/t/testfs; \
339 then umount lib/bup/t/testfs || true; fi
340 rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
341 if test -e t/tmp; then t/force-delete t/tmp; fi
342 ./configure-version --clean
343 t/configure-sampledata --clean
344 # Remove last so that cleanup tools can depend on it