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 dev/configure-sampledata --revision $(isok))
24 $(call shout,$(sampledata_rev),Could not parse sampledata revision)
26 current_sampledata := test/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 := -O2 -Wall -Werror -Wformat=2 $(CFLAGS)
32 CFLAGS := -Wno-unknown-pragmas -Wsign-compare $(CFLAGS)
33 CFLAGS := -D_FILE_OFFSET_BITS=64 $(PYINCLUDE) $(CFLAGS)
43 test_tmp := $(CURDIR)/test/tmp
46 initial_setup := $(shell dev/update-checkout-info lib/bup/checkout_info.py $(isok))
47 initial_setup := $(call shout,$(initial_setup),update-checkout-info failed))
50 configure config/configure config/configure.inc \
51 $(wildcard config/*.in)
52 MAKE="$(MAKE)" ./configure
54 # On some platforms, Python.h and readline.h fight over the
55 # _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
56 # now, we're just going to let Python's version win.
58 ifneq ($(strip $(bup_readline_cflags)),)
59 readline_cflags += $(bup_readline_cflags)
60 readline_xopen := $(filter -D_XOPEN_SOURCE=%,$(readline_cflags))
61 readline_xopen := $(subst -D_XOPEN_SOURCE=,,$(readline_xopen))
62 readline_cflags := $(filter-out -D_XOPEN_SOURCE=%,$(readline_cflags))
63 readline_cflags += $(addprefix -DBUP_RL_EXPECTED_XOPEN_SOURCE=,$(readline_xopen))
64 CFLAGS += $(readline_cflags)
67 LDFLAGS += $(bup_readline_ldflags)
69 ifeq ($(bup_have_libacl),1)
70 CFLAGS += $(bup_libacl_cflags)
71 LDFLAGS += $(bup_libacl_ldflags)
74 bup_ext_cmds := lib/cmd/bup-import-rdiff-backup lib/cmd/bup-import-rsnapshot
76 config/bin/python: config/config.vars
78 bup_deps := lib/bup/_helpers$(SOEXT)
80 all: $(bup_deps) Documentation/all $(current_sampledata)
82 $(current_sampledata):
83 dev/configure-sampledata --setup
85 PANDOC ?= $(shell type -p pandoc)
88 $(shell echo "Warning: pandoc not found; skipping manpage generation" 1>&2)
91 man_md := $(wildcard Documentation/*.md)
94 man_roff := $(patsubst %.md,%.1,$(man_md))
95 man_html := $(patsubst %.md,%.html,$(man_md))
99 MANDIR=$(PREFIX)/share/man
100 DOCDIR=$(PREFIX)/share/doc/bup
102 LIBDIR=$(PREFIX)/lib/bup
104 dest_mandir := $(DESTDIR)$(MANDIR)
105 dest_docdir := $(DESTDIR)$(DOCDIR)
106 dest_bindir := $(DESTDIR)$(BINDIR)
107 dest_libdir := $(DESTDIR)$(LIBDIR)
110 $(INSTALL) -d $(dest_bindir) $(dest_libdir)/bup/cmd $(dest_libdir)/cmd \
111 $(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 dev/install-python-script lib/cmd/bup "$(dest_libdir)/cmd/bup"
117 $(INSTALL) -pm 0755 $(bup_ext_cmds) "$(dest_libdir)/cmd/"
118 cd "$(dest_bindir)" && \
119 ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
121 $(INSTALL) -pm 0644 lib/bup/*.py $(dest_libdir)/bup/
122 $(INSTALL) -pm 0644 lib/bup/cmd/*.py $(dest_libdir)/bup/cmd/
123 $(INSTALL) -pm 0755 \
126 $(INSTALL) -pm 0644 \
128 $(dest_libdir)/web/static/
129 $(INSTALL) -pm 0644 \
132 if test -e lib/bup/checkout_info.py; then \
133 $(INSTALL) -pm 0644 lib/bup/checkout_info.py \
134 $(dest_libdir)/bup/source_info.py; \
136 ! grep -qF '$$Format' lib/bup/source_info.py; \
137 $(INSTALL) -pm 0644 lib/bup/source_info.py $(dest_libdir)/bup/; \
140 config/config.h: config/config.vars
142 lib/bup/_helpers$(SOEXT): \
143 config/config.h lib/bup/bupsplit.h \
144 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
146 cd lib/bup && $(cfg_py) csetup.py build "$(CFLAGS)" "$(LDFLAGS)"
147 # Make sure there's just the one file we expect before we copy it.
149 "import glob; assert(len(glob.glob('lib/bup/build/*/_helpers*$(SOEXT)')) == 1)"
150 cp lib/bup/build/*/_helpers*$(SOEXT) "$@"
155 ifeq (yes,$(shell config/bin/python -c "import xdist; print('yes')" 2>/dev/null))
156 # MAKEFLAGS must not be in an immediate := assignment
157 parallel_opt = $(lastword $(filter -j%,$(MAKEFLAGS)))
158 get_parallel_n = $(patsubst -j%,%,$(parallel_opt))
159 maybe_specific_n = $(if $(filter -j%,$(parallel_opt)),-n$(get_parallel_n))
160 xdist_opt = $(if $(filter -j,$(parallel_opt)),-nauto,$(maybe_specific_n))
166 ./pytest $(xdist_opt)
169 PATH=/bin:/usr/bin $(MAKE) test
174 ./pytest $(xdist_opt) -m release
176 long-test: export BUP_TEST_LEVEL=11
179 long-check: export BUP_TEST_LEVEL=11
184 $(MAKE) clean && PYTHON=python3 $(MAKE) check
185 $(MAKE) clean && PYTHON=python2 $(MAKE) check
187 .PHONY: Documentation/all
188 Documentation/all: $(man_roff) $(man_html)
190 Documentation/substvars: $(bup_deps)
191 # FIXME: real temp file
192 set -e; bup_ver=$$(./bup version); \
193 echo "s,%BUP_VERSION%,$$bup_ver,g" > $@.tmp; \
194 echo "s,%BUP_DATE%,$$bup_ver,g" >> $@.tmp
197 Documentation/%.1: Documentation/%.md Documentation/substvars
198 $(pf); sed -f Documentation/substvars $< \
199 | $(PANDOC) -s -r markdown -w man -o $@
201 Documentation/%.html: Documentation/%.md Documentation/substvars
202 $(pf); sed -f Documentation/substvars $< \
203 | $(PANDOC) -s -r markdown -w html -o $@
205 .PHONY: Documentation/clean
207 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
209 # Note: this adds commits containing the current manpages in roff and
210 # html format to the man and html branches respectively. The version
211 # is determined by "git describe --always".
212 .PHONY: update-doc-branches
213 update-doc-branches: Documentation/all
214 dev/update-doc-branches refs/heads/man refs/heads/html
216 # push the pregenerated doc files to origin/man and origin/html
217 push-docs: export-docs
218 git push origin man html
220 # import pregenerated doc files from origin/man and origin/html, in case you
221 # don't have pandoc but still want to be able to install the docs.
222 import-docs: Documentation/clean
223 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
224 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
226 clean: Documentation/clean config/bin/python
227 cd config && rm -rf config.var
228 cd config && rm -f *~ .*~ \
229 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
230 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
231 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
232 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
233 lib/bup/checkout_info.py \
235 testfs.img test/int/testfs.img
236 if test -e test/mnt; then dev/cleanup-mounts-under test/mnt; fi
237 if test -e test/mnt; then rm -r test/mnt; fi
238 if test -e test/tmp; then dev/cleanup-mounts-under test/tmp; fi
239 # FIXME: migrate these to test/mnt/
240 if test -e test/int/testfs; \
241 then umount test/int/testfs || true; fi
242 rm -rf *.tmp *.tmp.meta test/*.tmp lib/*/*/*.tmp build lib/bup/build test/int/testfs
243 if test -e test/tmp; then dev/force-delete test/tmp; fi
244 dev/configure-sampledata --clean
245 # Remove last so that cleanup tools can depend on it