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