]> arthur.barton.de Git - bup.git/blob - Makefile
Create t/sampledata/var/ and version it
[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 bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
21
22 all: $(bup_deps) Documentation/all $(current_sampledata)
23
24 bup:
25         ln -s main.py bup
26
27 Documentation/all: $(bup_deps)
28
29 $(current_sampledata):
30         t/configure-sampledata --setup
31
32 INSTALL=install
33 PYTHON=python
34 PREFIX=/usr
35 MANDIR=$(DESTDIR)$(PREFIX)/share/man
36 DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/bup
37 BINDIR=$(DESTDIR)$(PREFIX)/bin
38 LIBDIR=$(DESTDIR)$(PREFIX)/lib/bup
39 install: all
40         $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
41                 $(LIBDIR)/bup $(LIBDIR)/cmd \
42                 $(LIBDIR)/web $(LIBDIR)/web/static
43         [ ! -e Documentation/.docs-available ] || \
44           $(INSTALL) -m 0644 \
45                 Documentation/*.1 \
46                 $(MANDIR)/man1
47         [ ! -e Documentation/.docs-available ] || \
48           $(INSTALL) -m 0644 \
49                 Documentation/*.html \
50                 $(DOCDIR)
51         $(INSTALL) -pm 0755 bup $(BINDIR)
52         $(INSTALL) -pm 0755 \
53                 cmd/bup-* \
54                 $(LIBDIR)/cmd
55         $(INSTALL) -pm 0644 \
56                 lib/bup/*.py \
57                 $(LIBDIR)/bup
58         $(INSTALL) -pm 0755 \
59                 lib/bup/*$(SOEXT) \
60                 $(LIBDIR)/bup
61         $(INSTALL) -pm 0644 \
62                 lib/web/static/* \
63                 $(LIBDIR)/web/static/
64         $(INSTALL) -pm 0644 \
65                 lib/web/*.html \
66                 $(LIBDIR)/web/
67 %/all:
68         $(MAKE) -C $* all
69
70 %/clean:
71         $(MAKE) -C $* clean
72
73 config/config.h: config/Makefile config/configure config/configure.inc \
74                 $(wildcard config/*.in)
75         cd config && $(MAKE) config.h
76
77 lib/bup/_helpers$(SOEXT): \
78                 config/config.h \
79                 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
80         @rm -f $@
81         cd lib/bup && \
82         LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
83         cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
84
85 # This must be completely atomic since it may be run (often) in
86 # parallel when "-j" is specified, either via targets here, or via
87 # tests that use an install tree as data.
88 .PHONY: lib/bup/_version.py
89 lib/bup/_version.py:
90         rm -f $@.tmp-$$$$ \
91         && ./format-subst.pl $@.pre > $@.tmp-$$$$ \
92         && (if ! test -e $@ || ! cmp $@ $@.tmp-$$$$; then mv $@.tmp-$$$$ $@; fi) \
93         && rm -f $@.tmp-$$$$
94
95 t/tmp:
96         mkdir t/tmp
97
98 runtests: runtests-python runtests-cmdline
99
100 runtests-python: all t/tmp
101         TMPDIR="$(test_tmp)" $(PYTHON) wvtest.py t/t*.py lib/*/t/t*.py
102
103 cmdline_tests := \
104   t/test-fuse.sh \
105   t/test-drecurse.sh \
106   t/test-cat-file.sh \
107   t/test-compression.sh \
108   t/test-fsck.sh \
109   t/test-index-clear.sh \
110   t/test-index-check-device.sh \
111   t/test-ls.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-$*
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         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests-python runtests-cmdline
139
140 check: test
141
142 cmds: \
143     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
144     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
145
146 cmd/bup-%: cmd/%-cmd.py
147         rm -f $@
148         ln -s $*-cmd.py $@
149
150 cmd/bup-%: cmd/%-cmd.sh
151         rm -f $@
152         ln -s $*-cmd.sh $@
153
154 # update the local 'man' and 'html' branches with pregenerated output files, for
155 # people who don't have pandoc (and maybe to aid in google searches or something)
156 export-docs: Documentation/all
157         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
158         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
159         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
160         rm -f $${GIT_INDEX_FILE} && \
161         git add -f Documentation/*.1 && \
162         git update-ref refs/heads/man \
163                 $$(echo "Autogenerated man pages for $$(git describe --always)" \
164                     | git commit-tree $$(git write-tree --prefix=Documentation) \
165                                 -p refs/heads/man) && \
166         rm -f $${GIT_INDEX_FILE} && \
167         git add -f Documentation/*.html && \
168         git update-ref refs/heads/html \
169                 $$(echo "Autogenerated html pages for $$(git describe --always)" \
170                     | git commit-tree $$(git write-tree --prefix=Documentation) \
171                                 -p refs/heads/html)
172
173 # push the pregenerated doc files to origin/man and origin/html
174 push-docs: export-docs
175         git push origin man html
176
177 # import pregenerated doc files from origin/man and origin/html, in case you
178 # don't have pandoc but still want to be able to install the docs.
179 import-docs: Documentation/clean
180         git archive origin/html | (cd Documentation; tar -xvf -)
181         git archive origin/man | (cd Documentation; tar -xvf -)
182
183 clean: Documentation/clean config/clean
184         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
185                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
186                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
187                 bup bup-* cmd/bup-* \
188                 lib/bup/_version.py lib/bup/_version.py.tmp-* \
189                 randomgen memtest \
190                 testfs.img lib/bup/t/testfs.img
191         if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
192         if test -e t/mnt; then rm -r t/mnt; fi
193         if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
194         # FIXME: migrate these to t/mnt/
195         if test -e lib/bup/t/testfs; \
196           then umount lib/bup/t/testfs || true; fi
197         rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
198         if test -e t/tmp; then t/force-delete t/tmp; fi
199         t/configure-sampledata --clean