2 MAKEFLAGS += --warn-undefined-variables
9 # See config/config.vars.in (sets bup_python_config, among other things)
10 include config/config.vars
15 && echo " ok" || echo " no"
18 # If ok, strip trailing " ok" and return the output, otherwise, error
20 $(if $(subst ok,,$(lastword $(1))),$(error $(2)),$(shell x="$(1)"; echo $${x%???}))
23 sampledata_rev := $(shell dev/configure-sampledata --revision $(isok))
25 $(call shout,$(sampledata_rev),Could not parse sampledata revision)
27 current_sampledata := test/sampledata/var/rev/v$(sampledata_rev)
29 os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok))
30 os := $(call shout,$(os),Unable to determine OS)
32 # Satisfy --warn-undefined-variables
38 bup_shared_cflags := -O2 -Wall -Werror -Wformat=2
39 bup_shared_cflags := -Wno-unused-command-line-argument $(bup_shared_cflags)
40 bup_shared_cflags := -Wno-unknown-pragmas -Wsign-compare $(bup_shared_cflags)
41 bup_shared_cflags := -D_FILE_OFFSET_BITS=64 $(bup_shared_cflags)
51 test_tmp := $(CURDIR)/test/tmp
54 initial_setup := $(shell dev/update-checkout-info lib/bup/checkout_info.py $(isok))
55 initial_setup := $(call shout,$(initial_setup),update-checkout-info failed))
56 clean_paths += lib/bup/checkout_info.py
59 configure config/configure config/configure.inc \
60 $(wildcard config/*.in)
61 MAKE="$(MAKE)" ./configure
63 # On some platforms, Python.h and readline.h fight over the
64 # _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
65 # now, we're just going to let Python's version win.
67 helpers_cflags := $(bup_python_cflags) $(bup_shared_cflags)
68 helpers_ldflags := $(bup_python_ldflags) $(bup_shared_ldflags)
70 ifneq ($(strip $(bup_readline_cflags)),)
71 readline_cflags += $(bup_readline_cflags)
72 readline_xopen := $(filter -D_XOPEN_SOURCE=%,$(readline_cflags))
73 readline_xopen := $(subst -D_XOPEN_SOURCE=,,$(readline_xopen))
74 readline_cflags := $(filter-out -D_XOPEN_SOURCE=%,$(readline_cflags))
75 readline_cflags += $(addprefix -DBUP_RL_EXPECTED_XOPEN_SOURCE=,$(readline_xopen))
76 helpers_cflags += $(readline_cflags)
79 helpers_ldflags += $(bup_readline_ldflags)
81 ifeq ($(bup_have_libacl),1)
82 helpers_cflags += $(bup_libacl_cflags)
83 helpers_ldflags += $(bup_libacl_ldflags)
86 bup_ext_cmds := lib/cmd/bup-import-rdiff-backup lib/cmd/bup-import-rsnapshot
88 bup_deps := lib/bup/_helpers$(soext) lib/cmd/bup
90 all: dev/bup-exec dev/bup-python dev/python $(bup_deps) Documentation/all \
93 $(current_sampledata):
94 dev/configure-sampledata --setup
96 PANDOC ?= $(shell type -p pandoc)
99 $(shell echo "Warning: pandoc not found; skipping manpage generation" 1>&2)
102 man_md := $(wildcard Documentation/*.md)
105 man_roff := $(patsubst %.md,%.1,$(man_md))
106 man_html := $(patsubst %.md,%.html,$(man_md))
110 MANDIR=$(PREFIX)/share/man
111 DOCDIR=$(PREFIX)/share/doc/bup
113 LIBDIR=$(PREFIX)/lib/bup
115 dest_mandir := $(DESTDIR)$(MANDIR)
116 dest_docdir := $(DESTDIR)$(DOCDIR)
117 dest_bindir := $(DESTDIR)$(BINDIR)
118 dest_libdir := $(DESTDIR)$(LIBDIR)
121 $(INSTALL) -d $(dest_bindir) $(dest_libdir)/bup/cmd $(dest_libdir)/cmd \
122 $(dest_libdir)/web/static
123 test -z "$(man_roff)" || install -d $(dest_mandir)/man1
124 test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
125 test -z "$(man_html)" || install -d $(dest_docdir)
126 test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
127 $(INSTALL) -pm 0755 lib/cmd/bup "$(dest_libdir)/cmd/bup"
128 $(INSTALL) -pm 0755 $(bup_ext_cmds) "$(dest_libdir)/cmd/"
129 cd "$(dest_bindir)" && \
130 ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
132 $(INSTALL) -pm 0644 lib/bup/*.py $(dest_libdir)/bup/
133 $(INSTALL) -pm 0644 lib/bup/cmd/*.py $(dest_libdir)/bup/cmd/
134 $(INSTALL) -pm 0755 \
137 $(INSTALL) -pm 0644 \
139 $(dest_libdir)/web/static/
140 $(INSTALL) -pm 0644 \
143 if test -e lib/bup/checkout_info.py; then \
144 $(INSTALL) -pm 0644 lib/bup/checkout_info.py \
145 $(dest_libdir)/bup/source_info.py; \
147 ! grep -qF '$$Format' lib/bup/source_info.py; \
148 $(INSTALL) -pm 0644 lib/bup/source_info.py $(dest_libdir)/bup/; \
151 embed_cflags := $(bup_python_cflags_embed) $(bup_shared_cflags)
152 embed_ldflags := $(bup_python_ldflags_embed) $(bup_shared_ldflags)
154 config/config.h: config/config.vars
155 clean_paths += config/config.h.tmp
157 cc_bin = $(CC) $(embed_cflags) $(CFLAGS) $^ $(embed_ldflags) $(LDFLAGS) -fPIE \
160 clean_paths += dev/python-proposed
161 dev/python-proposed: dev/python.c config/config.h
165 clean_paths += dev/python
166 dev/python: dev/python-proposed
167 dev/validate-python $@-proposed
170 clean_paths += dev/bup-exec
171 dev/bup-exec: CFLAGS += -D BUP_DEV_BUP_EXEC=1
172 dev/bup-exec: lib/cmd/bup.c config/config.h
175 clean_paths += dev/bup-python
176 dev/bup-python: CFLAGS += -D BUP_DEV_BUP_PYTHON=1
177 dev/bup-python: lib/cmd/bup.c config/config.h
180 clean_paths += lib/cmd/bup
181 lib/cmd/bup: lib/cmd/bup.c config/config.h
184 clean_paths += lib/bup/_helpers$(soext)
185 lib/bup/_helpers$(soext): lib/bup/_helpers.c lib/bup/bupsplit.c
186 $(CC) $(helpers_cflags) $(CFLAGS) -shared -fPIC $^ \
187 $(helpers_ldflags) $(LDFLAGS) $(OUTPUT_OPTION)
192 # MAKEFLAGS must not be in an immediate := assignment
193 parallel_opt = $(lastword $(filter -j%,$(MAKEFLAGS)))
194 get_parallel_n = $(patsubst -j%,%,$(parallel_opt))
195 maybe_specific_n = $(if $(filter -j%,$(parallel_opt)),-n$(get_parallel_n))
196 xdist_opt = $(if $(filter -j,$(parallel_opt)),-nauto,$(maybe_specific_n))
198 test: all test/tmp dev/python
199 if test yes = "$$(dev/python -c 'import xdist; print("yes")' 2>/dev/null)"; then \
200 (set -x; ./pytest $(xdist_opt);) \
202 (set -x; ./pytest;) \
206 PATH=/bin:/usr/bin $(MAKE) test
211 if test yes = $$(dev/python -c "import xdist; print('yes')" 2>/dev/null); then \
212 (set -x; ./pytest $(xdist_opt) -m release;) \
214 (set -x; ./pytest -m release;) \
217 long-test: export BUP_TEST_LEVEL=11
220 long-check: export BUP_TEST_LEVEL=11
225 $(MAKE) clean && BUP_PYTHON_CONFIG=python3-config $(MAKE) check
226 $(MAKE) clean && BUP_PYTHON_CONFIG=python2.7-config $(MAKE) check
228 .PHONY: Documentation/all
229 Documentation/all: $(man_roff) $(man_html)
231 Documentation/substvars: $(bup_deps)
232 # FIXME: real temp file
233 set -e; bup_ver=$$(./bup version); \
234 echo "s,%BUP_VERSION%,$$bup_ver,g" > $@.tmp; \
235 echo "s,%BUP_DATE%,$$bup_ver,g" >> $@.tmp
238 Documentation/%.1: Documentation/%.md Documentation/substvars
239 $(pf); sed -f Documentation/substvars $< \
240 | $(PANDOC) -s -r markdown -w man -o $@
242 Documentation/%.html: Documentation/%.md Documentation/substvars
243 $(pf); sed -f Documentation/substvars $< \
244 | $(PANDOC) -s -r markdown -w html -o $@
246 .PHONY: Documentation/clean
248 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
250 # Note: this adds commits containing the current manpages in roff and
251 # html format to the man and html branches respectively. The version
252 # is determined by "git describe --always".
253 .PHONY: update-doc-branches
254 update-doc-branches: Documentation/all
255 dev/update-doc-branches refs/heads/man refs/heads/html
257 # push the pregenerated doc files to origin/man and origin/html
258 push-docs: export-docs
259 git push origin man html
261 # import pregenerated doc files from origin/man and origin/html, in case you
262 # don't have pandoc but still want to be able to install the docs.
263 import-docs: Documentation/clean
264 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
265 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
267 clean: Documentation/clean
268 cd config && rm -rf config.var
270 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
271 rm -rf $(clean_paths) .pytest_cache
272 find . -name __pycache__ -exec rm -rf {} +
273 if test -e test/mnt; then dev/cleanup-mounts-under test/mnt; fi
274 if test -e test/mnt; then rm -r test/mnt; fi
275 if test -e test/tmp; then dev/cleanup-mounts-under test/tmp; fi
276 # FIXME: migrate these to test/mnt/
277 if test -e test/int/testfs; \
278 then umount test/int/testfs || true; fi
279 rm -rf test/int/testfs test/int/testfs.img testfs.img
280 if test -e test/tmp; then dev/force-delete test/tmp; fi
281 dev/configure-sampledata --clean