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