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)
49 bup_cmds := cmd/bup-python\
50 $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
51 $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
53 bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) $(bup_cmds)
55 all: $(bup_deps) Documentation/all $(current_sampledata)
60 Documentation/all: $(bup_deps)
62 $(current_sampledata):
63 t/configure-sampledata --setup
65 define install-python-bin
67 sed -e '1 s|.*|#!$(bup_python)|; 2,/^# end of bup preamble$$/d' $1 > $2; \
73 MANDIR=$(DESTDIR)$(PREFIX)/share/man
74 DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/bup
75 BINDIR=$(DESTDIR)$(PREFIX)/bin
76 LIBDIR=$(DESTDIR)$(PREFIX)/lib/bup
78 $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
79 $(LIBDIR)/bup $(LIBDIR)/cmd \
80 $(LIBDIR)/web $(LIBDIR)/web/static
81 [ ! -e Documentation/.docs-available ] || \
85 [ ! -e Documentation/.docs-available ] || \
87 Documentation/*.html \
89 $(call install-python-bin,bup,"$(BINDIR)/bup")
91 for cmd in $$(ls cmd/bup-* | grep -v cmd/bup-python); do \
92 $(call install-python-bin,"$$cmd","$(LIBDIR)/$$cmd") \
100 $(INSTALL) -pm 0644 \
102 $(LIBDIR)/web/static/
103 $(INSTALL) -pm 0644 \
112 config/config.h: config/config.vars
114 lib/bup/_helpers$(SOEXT): \
116 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
119 LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" "$(bup_python)" csetup.py build
120 cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
123 @echo "Something has gone wrong; $@ should already exist."
124 @echo 'Check "./configure-version --update"'
130 runtests: runtests-python runtests-cmdline
132 # The "pwd -P" here may not be appropriate in the long run, but we
133 # need it until we settle the relevant drecurse/exclusion questions:
134 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
135 runtests-python: all t/tmp
136 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
137 "$(bup_python)" wvtest.py t/t*.py lib/*/t/t*.py 2>&1 \
138 | tee -a t/tmp/test-log/$$$$.log
142 t/test-split-join.sh \
146 t/test-compression.sh \
148 t/test-index-clear.sh \
149 t/test-index-check-device.sh \
154 t/test-restore-map-owner.sh \
155 t/test-restore-single-file.sh \
156 t/test-rm-between-index-and-save.sh \
157 t/test-sparse-files.sh \
158 t/test-command-without-init-fails.sh \
159 t/test-redundant-saves.sh \
160 t/test-save-creates-no-unrefs.sh \
161 t/test-save-restore-excludes.sh \
162 t/test-save-strip-graft.sh \
163 t/test-import-duplicity.sh \
164 t/test-import-rdiff-backup.sh \
169 # The "pwd -P" here may not be appropriate in the long run, but we
170 # need it until we settle the relevant drecurse/exclusion questions:
171 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
172 tmp-target-run-test%: all t/tmp
173 $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
174 t/test$* 2>&1 | tee -a t/tmp/test-log/$$$$.log
176 runtests-cmdline: $(subst t/test,tmp-target-run-test,$(cmdline_tests))
179 PATH=/bin:/usr/bin $(MAKE) test
182 if test -e t/tmp/test-log; then rm -r t/tmp/test-log; fi
183 mkdir -p t/tmp/test-log
184 ./wvtest watch --no-counts $(MAKE) runtests-python runtests-cmdline
185 ./wvtest report t/tmp/test-log/*.log
189 cmd/python-cmd.sh: config/config.vars Makefile
190 printf "#!/bin/sh\nexec %q \"\$$@\"" "$(bup_python)" \
191 >> cmd/python-cmd.sh.$$PPID.tmp
192 chmod u+x cmd/python-cmd.sh.$$PPID.tmp
193 mv cmd/python-cmd.sh.$$PPID.tmp cmd/python-cmd.sh
195 cmd/bup-%: cmd/%-cmd.py
199 cmd/bup-%: cmd/%-cmd.sh
203 # update the local 'man' and 'html' branches with pregenerated output files, for
204 # people who don't have pandoc (and maybe to aid in google searches or something)
205 export-docs: Documentation/all
206 git update-ref refs/heads/man origin/man '' 2>/dev/null || true
207 git update-ref refs/heads/html origin/html '' 2>/dev/null || true
209 GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
210 rm -f $${GIT_INDEX_FILE} && \
211 git add -f Documentation/*.1 && \
212 git update-ref refs/heads/man \
213 $$(echo "Autogenerated man pages for $$(git describe --always)" \
214 | git commit-tree $$(git write-tree --prefix=Documentation) \
215 -p refs/heads/man) && \
216 rm -f $${GIT_INDEX_FILE} && \
217 git add -f Documentation/*.html && \
218 git update-ref refs/heads/html \
219 $$(echo "Autogenerated html pages for $$(git describe --always)" \
220 | git commit-tree $$(git write-tree --prefix=Documentation) \
223 # push the pregenerated doc files to origin/man and origin/html
224 push-docs: export-docs
225 git push origin man html
227 # import pregenerated doc files from origin/man and origin/html, in case you
228 # don't have pandoc but still want to be able to install the docs.
229 import-docs: Documentation/clean
230 $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
231 $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
233 clean: Documentation/clean config/clean
234 rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
235 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
236 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
237 bup bup-* cmd/bup-* \
240 testfs.img lib/bup/t/testfs.img
241 if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
242 if test -e t/mnt; then rm -r t/mnt; fi
243 if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
244 # FIXME: migrate these to t/mnt/
245 if test -e lib/bup/t/testfs; \
246 then umount lib/bup/t/testfs || true; fi
247 rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
248 if test -e t/tmp; then t/force-delete t/tmp; fi
249 ./configure-version --clean
250 t/configure-sampledata --clean