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 CFLAGS := -O2 -Wall -Werror -Wformat=2 $(CFLAGS)
33 CFLAGS := -Wno-unknown-pragmas -Wsign-compare $(CFLAGS)
34 CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS)
44 test_tmp := $(CURDIR)/test/tmp
47 initial_setup := $(shell dev/update-checkout-info lib/bup/checkout_info.py $(isok))
48 initial_setup := $(call shout,$(initial_setup),update-checkout-info failed))
49 clean_paths += lib/bup/checkout_info.py
52 configure config/configure config/configure.inc \
53 $(wildcard config/*.in)
54 MAKE="$(MAKE)" ./configure
56 # On some platforms, Python.h and readline.h fight over the
57 # _XOPEN_SOURCE version, i.e. -Werror crashes on a mismatch, so for
58 # now, we're just going to let Python's version win.
60 ifneq ($(strip $(bup_readline_cflags)),)
61 readline_cflags += $(bup_readline_cflags)
62 readline_xopen := $(filter -D_XOPEN_SOURCE=%,$(readline_cflags))
63 readline_xopen := $(subst -D_XOPEN_SOURCE=,,$(readline_xopen))
64 readline_cflags := $(filter-out -D_XOPEN_SOURCE=%,$(readline_cflags))
65 readline_cflags += $(addprefix -DBUP_RL_EXPECTED_XOPEN_SOURCE=,$(readline_xopen))
66 CFLAGS += $(readline_cflags)
69 LDFLAGS += $(bup_readline_ldflags)
71 ifeq ($(bup_have_libacl),1)
72 CFLAGS += $(bup_libacl_cflags)
73 LDFLAGS += $(bup_libacl_ldflags)
76 bup_ext_cmds := lib/cmd/bup-import-rdiff-backup lib/cmd/bup-import-rsnapshot
78 bup_deps := lib/bup/_helpers$(SOEXT) lib/cmd/bup
80 all: dev/bup-exec dev/bup-python dev/python $(bup_deps) Documentation/all \
83 $(current_sampledata):
84 dev/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) $(dest_libdir)/bup/cmd $(dest_libdir)/cmd \
112 $(dest_libdir)/web/static
113 test -z "$(man_roff)" || install -d $(dest_mandir)/man1
114 test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
115 test -z "$(man_html)" || install -d $(dest_docdir)
116 test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
117 $(INSTALL) -pm 0755 lib/cmd/bup "$(dest_libdir)/cmd/bup"
118 $(INSTALL) -pm 0755 $(bup_ext_cmds) "$(dest_libdir)/cmd/"
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 lib/bup/*.py $(dest_libdir)/bup/
123 $(INSTALL) -pm 0644 lib/bup/cmd/*.py $(dest_libdir)/bup/cmd/
124 $(INSTALL) -pm 0755 \
127 $(INSTALL) -pm 0644 \
129 $(dest_libdir)/web/static/
130 $(INSTALL) -pm 0644 \
133 if test -e lib/bup/checkout_info.py; then \
134 $(INSTALL) -pm 0644 lib/bup/checkout_info.py \
135 $(dest_libdir)/bup/source_info.py; \
137 ! grep -qF '$$Format' lib/bup/source_info.py; \
138 $(INSTALL) -pm 0644 lib/bup/source_info.py $(dest_libdir)/bup/; \
141 config/config.h: config/config.vars
142 clean_paths += config/config.h.tmp
144 dev/python: dev/python.c config/config.h
145 $(CC) $(bup_python_cflags_embed) $< $(bup_python_ldflags_embed) -o $@-proposed
146 dev/validate-python $@-proposed
148 clean_paths += dev/python dev/python-proposed
150 dev/bup-exec: lib/cmd/bup.c config/config.h
151 $(CC) $(bup_python_cflags_embed) $< $(bup_python_ldflags_embed) -fPIC \
152 -D BUP_DEV_BUP_EXEC=1 -o $@
153 clean_paths += dev/bup-exec
155 dev/bup-python: lib/cmd/bup.c config/config.h
156 $(CC) $(bup_python_cflags_embed) $< $(bup_python_ldflags_embed) -fPIC \
157 -D BUP_DEV_BUP_PYTHON=1 -o $@
158 clean_paths += dev/bup-python
160 lib/cmd/bup: lib/cmd/bup.c config/config.h
161 $(CC) $(bup_python_cflags_embed) $< $(bup_python_ldflags_embed) -fPIC -o $@
162 clean_paths += lib/cmd/bup
164 helper_src := config/config.h lib/bup/bupsplit.h lib/bup/bupsplit.c
165 helper_src += lib/bup/_helpers.c
167 lib/bup/_helpers$(SOEXT): dev/python $(helper_src)
168 $(CC) $(bup_python_cflags) $(CFLAGS) -shared -fPIC $(helper_src) \
169 $(bup_python_ldflags) $(LDFLAGS) -o $@
170 clean_paths += lib/bup/_helpers$(SOEXT)
175 # MAKEFLAGS must not be in an immediate := assignment
176 parallel_opt = $(lastword $(filter -j%,$(MAKEFLAGS)))
177 get_parallel_n = $(patsubst -j%,%,$(parallel_opt))
178 maybe_specific_n = $(if $(filter -j%,$(parallel_opt)),-n$(get_parallel_n))
179 xdist_opt = $(if $(filter -j,$(parallel_opt)),-nauto,$(maybe_specific_n))
181 test: all test/tmp dev/python
182 if test yes = $$(dev/python -c "import xdist; print('yes')" 2>/dev/null); then \
183 (set -x; ./pytest $(xdist_opt);) \
189 PATH=/bin:/usr/bin $(MAKE) test
194 if test yes = $$(dev/python -c "import xdist; print('yes')" 2>/dev/null); then \
195 (set -x; ./pytest $(xdist_opt) -m release;) \
197 (set -x; ./pytest -m release;) \
200 long-test: export BUP_TEST_LEVEL=11
203 long-check: export BUP_TEST_LEVEL=11
208 $(MAKE) clean && BUP_PYTHON_CONFIG=python3-config $(MAKE) check
209 $(MAKE) clean && BUP_PYTHON_CONFIG=python2.7-config $(MAKE) check
211 .PHONY: Documentation/all
212 Documentation/all: $(man_roff) $(man_html)
214 Documentation/substvars: $(bup_deps)
215 # FIXME: real temp file
216 set -e; bup_ver=$$(./bup version); \
217 echo "s,%BUP_VERSION%,$$bup_ver,g" > $@.tmp; \
218 echo "s,%BUP_DATE%,$$bup_ver,g" >> $@.tmp
221 Documentation/%.1: Documentation/%.md Documentation/substvars
222 $(pf); sed -f Documentation/substvars $< \
223 | $(PANDOC) -s -r markdown -w man -o $@
225 Documentation/%.html: Documentation/%.md Documentation/substvars
226 $(pf); sed -f Documentation/substvars $< \
227 | $(PANDOC) -s -r markdown -w html -o $@
229 .PHONY: Documentation/clean
231 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
233 # Note: this adds commits containing the current manpages in roff and
234 # html format to the man and html branches respectively. The version
235 # is determined by "git describe --always".
236 .PHONY: update-doc-branches
237 update-doc-branches: Documentation/all
238 dev/update-doc-branches refs/heads/man refs/heads/html
240 # push the pregenerated doc files to origin/man and origin/html
241 push-docs: export-docs
242 git push origin man html
244 # import pregenerated doc files from origin/man and origin/html, in case you
245 # don't have pandoc but still want to be able to install the docs.
246 import-docs: Documentation/clean
247 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
248 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
250 clean: Documentation/clean
251 cd config && rm -rf config.var
253 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
254 rm -rf $(clean_paths) .pytest_cache
255 find . -name __pycache__ -exec rm -rf {} +
256 if test -e test/mnt; then dev/cleanup-mounts-under test/mnt; fi
257 if test -e test/mnt; then rm -r test/mnt; fi
258 if test -e test/tmp; then dev/cleanup-mounts-under test/tmp; fi
259 # FIXME: migrate these to test/mnt/
260 if test -e test/int/testfs; \
261 then umount test/int/testfs || true; fi
262 rm -rf test/int/testfs test/int/testfs.img testfs.img
263 if test -e test/tmp; then dev/force-delete test/tmp; fi
264 dev/configure-sampledata --clean