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 # On some platforms, Python.h and readline.h fight over the
50 # _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
51 # now, we're just going to let Python's version win.
52 readline_cflags += $(shell pkg-config readline --cflags)
53 readline_xopen := $(filter -D_XOPEN_SOURCE=%,$(readline_cflags))
54 readline_xopen := $(subst -D_XOPEN_SOURCE=,,$(readline_xopen))
55 ifneq ($(readline_xopen),600)
56 $(error "Unexpected pkg-config readline _XOPEN_SOURCE --cflags $(readline_cflags)")
58 readline_cflags := $(filter-out -D_XOPEN_SOURCE=%,$(readline_cflags))
59 readline_cflags += $(addprefix -DBUP_RL_EXPECTED_XOPEN_SOURCE=,$(readline_xopen))
61 CFLAGS += $(readline_cflags)
62 LDFLAGS += $(shell pkg-config readline --libs)
64 bup_cmds := cmd/bup-python \
65 $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
66 $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
68 bup_deps := lib/bup/_checkout.py lib/bup/_helpers$(SOEXT) $(bup_cmds)
70 all: $(bup_deps) Documentation/all $(current_sampledata)
72 $(current_sampledata):
73 t/configure-sampledata --setup
76 bup_libdir="$script_home/../lib" # bup_libdir will be adjusted during install
78 define install-bup-python
80 sed -e 's|.*# bup_libdir will be adjusted during install|bup_libdir="$$script_home/.."|' $1 > $2; \
84 PANDOC ?= $(shell type -p pandoc)
87 $(shell echo "Warning: pandoc not found; skipping manpage generation" 1>&2)
90 man_md := $(wildcard Documentation/*.md)
93 man_roff := $(patsubst %.md,%.1,$(man_md))
94 man_html := $(patsubst %.md,%.html,$(man_md))
98 MANDIR=$(PREFIX)/share/man
99 DOCDIR=$(PREFIX)/share/doc/bup
101 LIBDIR=$(PREFIX)/lib/bup
103 dest_mandir := $(DESTDIR)$(MANDIR)
104 dest_docdir := $(DESTDIR)$(DOCDIR)
105 dest_bindir := $(DESTDIR)$(BINDIR)
106 dest_libdir := $(DESTDIR)$(LIBDIR)
109 $(INSTALL) -d $(dest_bindir) \
110 $(dest_libdir)/bup $(dest_libdir)/cmd \
111 $(dest_libdir)/web $(dest_libdir)/web/static
112 test -z "$(man_roff)" || install -d $(dest_mandir)/man1
113 test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
114 test -z "$(man_html)" || install -d $(dest_docdir)
115 test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
116 $(INSTALL) -pm 0755 cmd/bup $(dest_libdir)/cmd/
117 $(INSTALL) -pm 0755 cmd/bup-* $(dest_libdir)/cmd/
118 $(call install-bup-python,cmd/bup-python,"$(dest_libdir)/cmd/bup-python")
119 cd "$(dest_bindir)" && \
120 ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
122 $(INSTALL) -pm 0644 \
125 $(INSTALL) -pm 0755 \
128 $(INSTALL) -pm 0644 \
130 $(dest_libdir)/web/static/
131 $(INSTALL) -pm 0644 \
135 config/config.h: config/config.vars
137 lib/bup/_helpers$(SOEXT): \
138 config/config.h lib/bup/bupsplit.h \
139 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
141 cd lib/bup && $(bup_python) csetup.py build "$(CFLAGS)" "$(LDFLAGS)"
142 # Make sure there's just the one file we expect before we copy it.
144 "import glob; assert(len(glob.glob('lib/bup/build/*/_helpers*$(SOEXT)')) == 1)"
145 cp lib/bup/build/*/_helpers*$(SOEXT) "$@"
147 lib/bup/_checkout.py:
148 @if grep -F '$Format' lib/bup/_release.py \
149 && ! test -e lib/bup/_checkout.py; then \
150 echo "Something has gone wrong; $@ should already exist."; \
151 echo 'Check "./configure-version --update"'; \
158 runtests: runtests-python runtests-cmdline
161 lib/bup/t/tbloom.py \
162 lib/bup/t/tclient.py \
164 lib/bup/t/thashsplit.py \
165 lib/bup/t/thelpers.py \
166 lib/bup/t/tindex.py \
167 lib/bup/t/tmetadata.py \
168 lib/bup/t/toptions.py \
169 lib/bup/t/tresolve.py \
170 lib/bup/t/tshquote.py \
175 # The "pwd -P" here may not be appropriate in the long run, but we
176 # need it until we settle the relevant drecurse/exclusion questions:
177 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
178 runtests-python: all t/tmp
179 mkdir -p t/tmp/test-log
180 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
181 ./wvtest.py $(python_tests) 2>&1 \
182 | tee -a t/tmp/test-log/$$$$.log
188 t/test-command-without-init-fails.sh \
189 t/test-compression.sh \
195 t/test-import-duplicity.sh \
196 t/test-import-rdiff-backup.sh \
198 t/test-index-check-device.sh \
199 t/test-index-clear.sh \
206 t/test-packsizelimit \
208 t/test-redundant-saves.sh \
209 t/test-restore-map-owner.sh \
210 t/test-restore-single-file.sh \
212 t/test-rm-between-index-and-save.sh \
213 t/test-save-creates-no-unrefs.sh \
214 t/test-save-restore \
216 t/test-save-restore-excludes.sh \
217 t/test-save-strip-graft.sh \
218 t/test-save-with-valid-parent.sh \
219 t/test-sparse-files.sh \
220 t/test-split-join.sh \
224 ifeq "2" "$(bup_python_majver)"
226 # web: needs more careful attention, path bytes round-trips, reprs, etc.
231 tmp-target-run-test-get-%: all t/tmp
232 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
233 t/test-get $* 2>&1 | tee -a t/tmp/test-log/$$$$.log
235 test_get_targets += \
236 tmp-target-run-test-get-replace \
237 tmp-target-run-test-get-universal \
238 tmp-target-run-test-get-ff \
239 tmp-target-run-test-get-append \
240 tmp-target-run-test-get-pick \
241 tmp-target-run-test-get-new-tag \
242 tmp-target-run-test-get-unnamed
245 # The "pwd -P" here may not be appropriate in the long run, but we
246 # need it until we settle the relevant drecurse/exclusion questions:
247 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
248 tmp-target-run-test%: all t/tmp
249 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
250 t/test$* 2>&1 | tee -a t/tmp/test-log/$$$$.log
252 runtests-cmdline: $(test_get_targets) $(subst t/test,tmp-target-run-test,$(cmdline_tests))
255 PATH=/bin:/usr/bin $(MAKE) test
258 if test -e t/tmp/test-log; then rm -r t/tmp/test-log; fi
259 mkdir -p t/tmp/test-log
260 ./wvtest watch --no-counts \
261 $(MAKE) runtests 2>t/tmp/test-log/$$$$.log
262 ./wvtest report t/tmp/test-log/*.log
267 ./wvtest run t/test-release-archive.sh
269 cmd/bup-python: cmd/python-cmd.sh config/config.var/bup-python
270 "$$(cat config/config.var/bup-python)" dev/replace -l '@bup_python@' \
271 "$$(dev/shquote < config/config.var/bup-python)" \
272 < "$<" > "$@".$$PPID.tmp
273 chmod +x "$@".$$PPID.tmp
274 mv "$@".$$PPID.tmp "$@"
276 long-test: export BUP_TEST_LEVEL=11
279 long-check: export BUP_TEST_LEVEL=11
285 && PYTHON=python3 BUP_ALLOW_UNEXPECTED_PYTHON_VERSION=true $(MAKE) check
287 && PYTHON=python2 $(MAKE) check
289 cmd/bup-%: cmd/%-cmd.py
293 cmd/bup-%: cmd/%-cmd.sh
297 .PHONY: Documentation/all
298 Documentation/all: $(man_roff) $(man_html)
300 Documentation/substvars: $(bup_deps)
301 echo "s,%BUP_VERSION%,$$(./bup version --tag),g" > $@
302 echo "s,%BUP_DATE%,$$(./bup version --date),g" >> $@
304 Documentation/%.1: Documentation/%.md Documentation/substvars
305 $(pf); sed -f Documentation/substvars $< \
306 | $(PANDOC) -s -r markdown -w man -o $@
308 Documentation/%.html: Documentation/%.md Documentation/substvars
309 $(pf); sed -f Documentation/substvars $< \
310 | $(PANDOC) -s -r markdown -w html -o $@
312 .PHONY: Documentation/clean
314 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
316 # Note: this adds commits containing the current manpages in roff and
317 # html format to the man and html branches respectively. The version
318 # is determined by "git describe --always".
319 .PHONY: update-doc-branches
320 update-doc-branches: Documentation/all
321 dev/update-doc-branches refs/heads/man refs/heads/html
323 # push the pregenerated doc files to origin/man and origin/html
324 push-docs: export-docs
325 git push origin man html
327 # import pregenerated doc files from origin/man and origin/html, in case you
328 # don't have pandoc but still want to be able to install the docs.
329 import-docs: Documentation/clean
330 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
331 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
333 clean: Documentation/clean cmd/bup-python
334 cd config && rm -f *~ .*~ \
335 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
336 cd config && rm -rf config.var
337 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
338 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
339 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
341 testfs.img lib/bup/t/testfs.img
342 for x in $$(ls cmd/*-cmd.py cmd/*-cmd.sh | grep -vF python-cmd.sh | cut -b 5-); do \
343 echo "cmd/bup-$${x%-cmd.*}"; \
344 done | xargs -t rm -f
345 if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
346 if test -e t/mnt; then rm -r t/mnt; fi
347 if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
348 # FIXME: migrate these to t/mnt/
349 if test -e lib/bup/t/testfs; \
350 then umount lib/bup/t/testfs || true; fi
351 rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
352 if test -e t/tmp; then t/force-delete t/tmp; fi
353 ./configure-version --clean
354 t/configure-sampledata --clean
355 # Remove last so that cleanup tools can depend on it