]> arthur.barton.de Git - bup.git/blob - Makefile
wvtestrun: move to wvtest and add "run" argument
[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
98
99 cmdline_tests := \
100   t/test-fuse.sh \
101   t/test-drecurse.sh \
102   t/test-cat-file.sh \
103   t/test-compression.sh \
104   t/test-fsck.sh \
105   t/test-index-clear.sh \
106   t/test-index-check-device.sh \
107   t/test-ls.sh \
108   t/test-meta.sh \
109   t/test-on.sh \
110   t/test-restore-map-owner.sh \
111   t/test-restore-single-file.sh \
112   t/test-rm-between-index-and-save.sh \
113   t/test-sparse-files.sh \
114   t/test-command-without-init-fails.sh \
115   t/test-redundant-saves.sh \
116   t/test-save-creates-no-unrefs.sh \
117   t/test-save-restore-excludes.sh \
118   t/test-save-strip-graft.sh \
119   t/test-import-duplicity.sh \
120   t/test-import-rdiff-backup.sh \
121   t/test-xdev.sh \
122   t/test.sh
123
124 # For parallel runs.
125 tmp-target-run-test%: all t/tmp
126         TMPDIR="$(test_tmp)" t/test$*
127
128 runtests-cmdline: $(subst t/test,tmp-target-run-test,$(cmdline_tests))
129
130 stupid:
131         PATH=/bin:/usr/bin $(MAKE) test
132
133 test: all
134         ./wvtest run $(MAKE) PYTHON=$(PYTHON) runtests-python runtests-cmdline
135
136 check: test
137
138 cmds: \
139     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
140     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
141
142 cmd/bup-%: cmd/%-cmd.py
143         rm -f $@
144         ln -s $*-cmd.py $@
145
146 cmd/bup-%: cmd/%-cmd.sh
147         rm -f $@
148         ln -s $*-cmd.sh $@
149
150 # update the local 'man' and 'html' branches with pregenerated output files, for
151 # people who don't have pandoc (and maybe to aid in google searches or something)
152 export-docs: Documentation/all
153         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
154         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
155         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
156         rm -f $${GIT_INDEX_FILE} && \
157         git add -f Documentation/*.1 && \
158         git update-ref refs/heads/man \
159                 $$(echo "Autogenerated man pages for $$(git describe --always)" \
160                     | git commit-tree $$(git write-tree --prefix=Documentation) \
161                                 -p refs/heads/man) && \
162         rm -f $${GIT_INDEX_FILE} && \
163         git add -f Documentation/*.html && \
164         git update-ref refs/heads/html \
165                 $$(echo "Autogenerated html pages for $$(git describe --always)" \
166                     | git commit-tree $$(git write-tree --prefix=Documentation) \
167                                 -p refs/heads/html)
168
169 # push the pregenerated doc files to origin/man and origin/html
170 push-docs: export-docs
171         git push origin man html
172
173 # import pregenerated doc files from origin/man and origin/html, in case you
174 # don't have pandoc but still want to be able to install the docs.
175 import-docs: Documentation/clean
176         git archive origin/html | (cd Documentation; tar -xvf -)
177         git archive origin/man | (cd Documentation; tar -xvf -)
178
179 clean: Documentation/clean config/clean
180         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
181                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
182                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
183                 bup bup-* cmd/bup-* \
184                 randomgen memtest \
185                 testfs.img lib/bup/t/testfs.img
186         if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
187         if test -e t/mnt; then rm -r t/mnt; fi
188         if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
189         # FIXME: migrate these to t/mnt/
190         if test -e lib/bup/t/testfs; \
191           then umount lib/bup/t/testfs || true; fi
192         rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
193         if test -e t/tmp; then t/force-delete t/tmp; fi
194         ./configure-version --clean
195         t/configure-sampledata --clean