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 config/bin/python: config/config.vars
77 $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
78 $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
80 bup_deps := lib/bup/_helpers$(SOEXT) $(bup_cmds)
82 all: $(bup_deps) Documentation/all $(current_sampledata)
84 $(current_sampledata):
85 dev/configure-sampledata --setup
87 PANDOC ?= $(shell type -p pandoc)
90 $(shell echo "Warning: pandoc not found; skipping manpage generation" 1>&2)
93 man_md := $(wildcard Documentation/*.md)
96 man_roff := $(patsubst %.md,%.1,$(man_md))
97 man_html := $(patsubst %.md,%.html,$(man_md))
101 MANDIR=$(PREFIX)/share/man
102 DOCDIR=$(PREFIX)/share/doc/bup
104 LIBDIR=$(PREFIX)/lib/bup
106 dest_mandir := $(DESTDIR)$(MANDIR)
107 dest_docdir := $(DESTDIR)$(DOCDIR)
108 dest_bindir := $(DESTDIR)$(BINDIR)
109 dest_libdir := $(DESTDIR)$(LIBDIR)
112 $(INSTALL) -d $(dest_bindir) \
113 $(dest_libdir)/bup $(dest_libdir)/cmd \
114 $(dest_libdir)/web $(dest_libdir)/web/static
115 test -z "$(man_roff)" || install -d $(dest_mandir)/man1
116 test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
117 test -z "$(man_html)" || install -d $(dest_docdir)
118 test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
119 dev/install-python-script lib/cmd/bup "$(dest_libdir)/cmd/bup"
121 for cmd in $$(ls cmd/bup-*); do \
122 dev/install-python-script "$$cmd" "$(dest_libdir)/$$cmd"; \
124 cd "$(dest_bindir)" && \
125 ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
127 $(INSTALL) -pm 0644 \
130 $(INSTALL) -pm 0755 \
133 $(INSTALL) -pm 0644 \
135 $(dest_libdir)/web/static/
136 $(INSTALL) -pm 0644 \
139 if test -e lib/bup/checkout_info.py; then \
140 $(INSTALL) -pm 0644 lib/bup/checkout_info.py \
141 $(dest_libdir)/bup/source_info.py; \
143 ! grep -qF '$$Format' lib/bup/source_info.py; \
144 $(INSTALL) -pm 0644 lib/bup/source_info.py $(dest_libdir)/bup/; \
147 config/config.h: config/config.vars
149 lib/bup/_helpers$(SOEXT): \
150 config/config.h lib/bup/bupsplit.h \
151 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
153 cd lib/bup && $(cfg_py) csetup.py build "$(CFLAGS)" "$(LDFLAGS)"
154 # Make sure there's just the one file we expect before we copy it.
156 "import glob; assert(len(glob.glob('lib/bup/build/*/_helpers*$(SOEXT)')) == 1)"
157 cp lib/bup/build/*/_helpers*$(SOEXT) "$@"
166 PATH=/bin:/usr/bin $(MAKE) test
173 long-test: export BUP_TEST_LEVEL=11
176 long-check: export BUP_TEST_LEVEL=11
181 $(MAKE) clean && PYTHON=python3 $(MAKE) check
182 $(MAKE) clean && PYTHON=python2 $(MAKE) check
184 cmd/bup-%: cmd/%-cmd.py
188 cmd/bup-%: cmd/%-cmd.sh
192 .PHONY: Documentation/all
193 Documentation/all: $(man_roff) $(man_html)
195 Documentation/substvars: $(bup_deps)
196 echo "s,%BUP_VERSION%,$$(./bup version),g" > $@
197 echo "s,%BUP_DATE%,$$(./bup version --date),g" >> $@
199 Documentation/%.1: Documentation/%.md Documentation/substvars
200 $(pf); sed -f Documentation/substvars $< \
201 | $(PANDOC) -s -r markdown -w man -o $@
203 Documentation/%.html: Documentation/%.md Documentation/substvars
204 $(pf); sed -f Documentation/substvars $< \
205 | $(PANDOC) -s -r markdown -w html -o $@
207 .PHONY: Documentation/clean
209 cd Documentation && rm -f *~ .*~ *.[0-9] *.html substvars
211 # Note: this adds commits containing the current manpages in roff and
212 # html format to the man and html branches respectively. The version
213 # is determined by "git describe --always".
214 .PHONY: update-doc-branches
215 update-doc-branches: Documentation/all
216 dev/update-doc-branches refs/heads/man refs/heads/html
218 # push the pregenerated doc files to origin/man and origin/html
219 push-docs: export-docs
220 git push origin man html
222 # import pregenerated doc files from origin/man and origin/html, in case you
223 # don't have pandoc but still want to be able to install the docs.
224 import-docs: Documentation/clean
225 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
226 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
228 clean: Documentation/clean config/bin/python
229 cd config && rm -rf config.var
230 cd config && rm -f *~ .*~ \
231 ${CONFIGURE_DETRITUS} ${CONFIGURE_FILES} ${GENERATED_FILES}
232 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
233 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
234 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
235 lib/bup/checkout_info.py \
237 testfs.img test/int/testfs.img
238 for x in $$(ls cmd/*-cmd.py cmd/*-cmd.sh | grep -vF python-cmd.sh | cut -b 5-); do \
239 echo "cmd/bup-$${x%-cmd.*}"; \
240 done | xargs -t rm -f
241 if test -e test/mnt; then dev/cleanup-mounts-under test/mnt; fi
242 if test -e test/mnt; then rm -r test/mnt; fi
243 if test -e test/tmp; then dev/cleanup-mounts-under test/tmp; fi
244 # FIXME: migrate these to test/mnt/
245 if test -e test/int/testfs; \
246 then umount test/int/testfs || true; fi
247 rm -rf *.tmp *.tmp.meta test/*.tmp lib/*/*/*.tmp build lib/bup/build test/int/testfs
248 if test -e test/tmp; then dev/force-delete test/tmp; fi
249 dev/configure-sampledata --clean
250 # Remove last so that cleanup tools can depend on it