]> arthur.barton.de Git - bup.git/blob - Makefile
"Fix" tests with differing logical/physical paths
[bup.git] / Makefile
1
2 SHELL := bash
3 pf := set -o pipefail
4
5 define isok
6   && echo " ok" || echo " no"
7 endef
8
9 # If ok, strip trailing " ok" and return the output, otherwise, error
10 define shout
11 $(if $(subst ok,,$(lastword $(1))),$(error $(2)),$(shell x="$(1)"; echo $${x%???}))
12 endef
13
14 sampledata_rev := $(shell t/configure-sampledata --revision $(isok))
15 sampledata_rev := \
16   $(call shout,$(sampledata_rev),Could not parse sampledata revision)
17
18 current_sampledata := t/sampledata/var/rev/v$(sampledata_rev)
19
20 os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok))
21 os := $(call shout,$(os),Unable to determine OS)
22
23 CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS)
24 CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS)
25 SOEXT:=.so
26
27 ifeq ($(os),CYGWIN)
28   SOEXT:=.dll
29 endif
30
31 ifdef TMPDIR
32   test_tmp := $(TMPDIR)
33 else
34   test_tmp := $(CURDIR)/t/tmp
35 endif
36
37 initial_setup := $(shell ./configure-version --update $(isok))
38 initial_setup := $(call shout,$(initial_setup),Version configuration failed))
39
40 bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
41
42 all: $(bup_deps) Documentation/all $(current_sampledata)
43
44 bup:
45         ln -s main.py bup
46
47 Documentation/all: $(bup_deps)
48
49 $(current_sampledata):
50         t/configure-sampledata --setup
51
52 # This needs to be a delayed assignment
53 PYTHON = $(shell cmd/bup-python -c 'import sys; print sys.executable')
54
55 define install-python-bin
56   set -e; \
57   sed -e '1 s|.*|#!$(PYTHON)|; 2,/^# end of bup preamble$$/d' $1 > $2; \
58   chmod 0755 $2;
59 endef
60
61 INSTALL=install
62 PREFIX=/usr
63 MANDIR=$(DESTDIR)$(PREFIX)/share/man
64 DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/bup
65 BINDIR=$(DESTDIR)$(PREFIX)/bin
66 LIBDIR=$(DESTDIR)$(PREFIX)/lib/bup
67 install: all
68         $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
69                 $(LIBDIR)/bup $(LIBDIR)/cmd \
70                 $(LIBDIR)/web $(LIBDIR)/web/static
71         [ ! -e Documentation/.docs-available ] || \
72           $(INSTALL) -m 0644 \
73                 Documentation/*.1 \
74                 $(MANDIR)/man1
75         [ ! -e Documentation/.docs-available ] || \
76           $(INSTALL) -m 0644 \
77                 Documentation/*.html \
78                 $(DOCDIR)
79         $(call install-python-bin,bup,"$(BINDIR)/bup")
80         set -e; \
81         for cmd in $$(ls cmd/bup-* | grep -v cmd/bup-python); do \
82           $(call install-python-bin,"$$cmd","$(LIBDIR)/$$cmd") \
83         done
84         $(INSTALL) -pm 0644 \
85                 lib/bup/*.py \
86                 $(LIBDIR)/bup
87         $(INSTALL) -pm 0755 \
88                 lib/bup/*$(SOEXT) \
89                 $(LIBDIR)/bup
90         $(INSTALL) -pm 0644 \
91                 lib/web/static/* \
92                 $(LIBDIR)/web/static/
93         $(INSTALL) -pm 0644 \
94                 lib/web/*.html \
95                 $(LIBDIR)/web/
96 %/all:
97         $(MAKE) -C $* all
98
99 %/clean:
100         $(MAKE) -C $* clean
101
102 config/config.h: config/Makefile config/configure config/configure.inc \
103                 $(wildcard config/*.in)
104         cd config && $(MAKE) config.h
105
106 lib/bup/_helpers$(SOEXT): \
107                 config/config.h \
108                 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
109         @rm -f $@
110         cd lib/bup && \
111         LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
112         cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
113
114 lib/bup/_version.py:
115         @echo "Something has gone wrong; $@ should already exist."
116         @echo 'Check "./configure-version --update"'
117         @false
118
119 t/tmp:
120         mkdir t/tmp
121
122 runtests: runtests-python runtests-cmdline
123
124 # The "pwd -P" here may not be appropriate in the long run, but we
125 # need it until we settle the relevant drecurse/exclusion questions:
126 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
127 runtests-python: all t/tmp
128         $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
129           $(PYTHON) wvtest.py t/t*.py lib/*/t/t*.py 2>&1 \
130             | tee -a t/tmp/test-log/$$$$.log
131
132 cmdline_tests := \
133   t/test-index.sh \
134   t/test-split-join.sh \
135   t/test-fuse.sh \
136   t/test-drecurse.sh \
137   t/test-cat-file.sh \
138   t/test-compression.sh \
139   t/test-fsck.sh \
140   t/test-index-clear.sh \
141   t/test-index-check-device.sh \
142   t/test-ls.sh \
143   t/test-tz.sh \
144   t/test-meta.sh \
145   t/test-on.sh \
146   t/test-restore-map-owner.sh \
147   t/test-restore-single-file.sh \
148   t/test-rm-between-index-and-save.sh \
149   t/test-sparse-files.sh \
150   t/test-command-without-init-fails.sh \
151   t/test-redundant-saves.sh \
152   t/test-save-creates-no-unrefs.sh \
153   t/test-save-restore-excludes.sh \
154   t/test-save-strip-graft.sh \
155   t/test-import-duplicity.sh \
156   t/test-import-rdiff-backup.sh \
157   t/test-xdev.sh \
158   t/test.sh
159
160 # For parallel runs.
161 # The "pwd -P" here may not be appropriate in the long run, but we
162 # need it until we settle the relevant drecurse/exclusion questions:
163 # https://groups.google.com/forum/#!topic/bup-list/9ke-Mbp10Q0
164 tmp-target-run-test%: all t/tmp
165         $(pf); cd $$(pwd -P); TMPDIR="$(test_tmp)" \
166           t/test$* 2>&1 | tee -a t/tmp/test-log/$$$$.log
167
168 runtests-cmdline: $(subst t/test,tmp-target-run-test,$(cmdline_tests))
169
170 stupid:
171         PATH=/bin:/usr/bin $(MAKE) test
172
173 test: all
174         if test -e t/tmp/test-log; then rm -r t/tmp/test-log; fi
175         mkdir -p t/tmp/test-log
176         ./wvtest watch --no-counts \
177           $(MAKE) PYTHON=$(PYTHON) runtests-python runtests-cmdline
178         ./wvtest report t/tmp/test-log/*.log
179
180 check: test
181
182 cmd/python-cmd.sh: config/configure config/configure.inc
183         ./configure
184
185 cmds: \
186     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
187     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
188
189 cmd/bup-%: cmd/%-cmd.py
190         rm -f $@
191         ln -s $*-cmd.py $@
192
193 cmd/bup-%: cmd/%-cmd.sh
194         rm -f $@
195         ln -s $*-cmd.sh $@
196
197 # update the local 'man' and 'html' branches with pregenerated output files, for
198 # people who don't have pandoc (and maybe to aid in google searches or something)
199 export-docs: Documentation/all
200         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
201         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
202         set -eo pipefail; \
203         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
204         rm -f $${GIT_INDEX_FILE} && \
205         git add -f Documentation/*.1 && \
206         git update-ref refs/heads/man \
207                 $$(echo "Autogenerated man pages for $$(git describe --always)" \
208                     | git commit-tree $$(git write-tree --prefix=Documentation) \
209                                 -p refs/heads/man) && \
210         rm -f $${GIT_INDEX_FILE} && \
211         git add -f Documentation/*.html && \
212         git update-ref refs/heads/html \
213                 $$(echo "Autogenerated html pages for $$(git describe --always)" \
214                     | git commit-tree $$(git write-tree --prefix=Documentation) \
215                                 -p refs/heads/html)
216
217 # push the pregenerated doc files to origin/man and origin/html
218 push-docs: export-docs
219         git push origin man html
220
221 # import pregenerated doc files from origin/man and origin/html, in case you
222 # don't have pandoc but still want to be able to install the docs.
223 import-docs: Documentation/clean
224         $(pf); git archive origin/html | (cd Documentation && tar -xvf -)
225         $(pf); git archive origin/man | (cd Documentation && tar -xvf -)
226
227 clean: Documentation/clean config/clean
228         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
229                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
230                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
231                 bup bup-* cmd/bup-* \
232                 cmd/python-cmd.sh \
233                 randomgen memtest \
234                 testfs.img lib/bup/t/testfs.img
235         if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
236         if test -e t/mnt; then rm -r t/mnt; fi
237         if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
238         # FIXME: migrate these to t/mnt/
239         if test -e lib/bup/t/testfs; \
240           then umount lib/bup/t/testfs || true; fi
241         rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
242         if test -e t/tmp; then t/force-delete t/tmp; fi
243         ./configure-version --clean
244         t/configure-sampledata --clean