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