]> arthur.barton.de Git - bup.git/blob - Makefile
Don't have ./bup depend on main.py, etc.
[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 bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
17
18 .PHONY: all
19 all: $(bup_deps) Documentation/all
20         t/configure-sampledata --setup
21
22 bup:
23         ln -s main.py bup
24
25 Documentation/all: $(bup_deps)
26
27 INSTALL=install
28 PYTHON=python
29 PREFIX=/usr
30 MANDIR=$(DESTDIR)$(PREFIX)/share/man
31 DOCDIR=$(DESTDIR)$(PREFIX)/share/doc/bup
32 BINDIR=$(DESTDIR)$(PREFIX)/bin
33 LIBDIR=$(DESTDIR)$(PREFIX)/lib/bup
34 install: all
35         $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
36                 $(LIBDIR)/bup $(LIBDIR)/cmd \
37                 $(LIBDIR)/web $(LIBDIR)/web/static
38         [ ! -e Documentation/.docs-available ] || \
39           $(INSTALL) -m 0644 \
40                 Documentation/*.1 \
41                 $(MANDIR)/man1
42         [ ! -e Documentation/.docs-available ] || \
43           $(INSTALL) -m 0644 \
44                 Documentation/*.html \
45                 $(DOCDIR)
46         $(INSTALL) -pm 0755 bup $(BINDIR)
47         $(INSTALL) -pm 0755 \
48                 cmd/bup-* \
49                 $(LIBDIR)/cmd
50         $(INSTALL) -pm 0644 \
51                 lib/bup/*.py \
52                 $(LIBDIR)/bup
53         $(INSTALL) -pm 0755 \
54                 lib/bup/*$(SOEXT) \
55                 $(LIBDIR)/bup
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 # This must be completely atomic since it may be run (often) in
81 # parallel when "-j" is specified, either via targets here, or via
82 # tests that use an install tree as data.
83 .PHONY: lib/bup/_version.py
84 lib/bup/_version.py:
85         rm -f $@.tmp-$$$$ \
86         && ./format-subst.pl $@.pre > $@.tmp-$$$$ \
87         && (if ! test -e $@ || ! cmp $@ $@.tmp-$$$$; then mv $@.tmp-$$$$ $@; fi) \
88         && rm -f $@.tmp-$$$$
89
90 t/tmp:
91         mkdir t/tmp
92
93 runtests: runtests-python runtests-cmdline
94
95 runtests-python: all t/tmp
96         TMPDIR="$(test_tmp)" $(PYTHON) wvtest.py t/t*.py lib/*/t/t*.py
97
98 cmdline_tests := \
99   t/test-fuse.sh \
100   t/test-drecurse.sh \
101   t/test-cat-file.sh \
102   t/test-compression.sh \
103   t/test-fsck.sh \
104   t/test-index-clear.sh \
105   t/test-index-check-device.sh \
106   t/test-ls.sh \
107   t/test-meta.sh \
108   t/test-on.sh \
109   t/test-restore-map-owner.sh \
110   t/test-restore-single-file.sh \
111   t/test-rm-between-index-and-save.sh \
112   t/test-sparse-files.sh \
113   t/test-command-without-init-fails.sh \
114   t/test-redundant-saves.sh \
115   t/test-save-creates-no-unrefs.sh \
116   t/test-save-restore-excludes.sh \
117   t/test-save-strip-graft.sh \
118   t/test-import-duplicity.sh \
119   t/test-import-rdiff-backup.sh \
120   t/test-xdev.sh \
121   t/test.sh
122
123 # For parallel runs.
124 tmp-target-run-test-%: all t/tmp
125         TMPDIR="$(test_tmp)" t/test-$*
126
127 runtests-cmdline: $(subst t/test-,tmp-target-run-test-,$(cmdline_tests))
128
129 stupid:
130         PATH=/bin:/usr/bin $(MAKE) test
131
132 test: all
133         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests-python runtests-cmdline
134
135 check: test
136
137 cmds: \
138     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
139     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
140
141 cmd/bup-%: cmd/%-cmd.py
142         rm -f $@
143         ln -s $*-cmd.py $@
144
145 cmd/bup-%: cmd/%-cmd.sh
146         rm -f $@
147         ln -s $*-cmd.sh $@
148
149 # update the local 'man' and 'html' branches with pregenerated output files, for
150 # people who don't have pandoc (and maybe to aid in google searches or something)
151 export-docs: Documentation/all
152         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
153         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
154         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
155         rm -f $${GIT_INDEX_FILE} && \
156         git add -f Documentation/*.1 && \
157         git update-ref refs/heads/man \
158                 $$(echo "Autogenerated man pages for $$(git describe --always)" \
159                     | git commit-tree $$(git write-tree --prefix=Documentation) \
160                                 -p refs/heads/man) && \
161         rm -f $${GIT_INDEX_FILE} && \
162         git add -f Documentation/*.html && \
163         git update-ref refs/heads/html \
164                 $$(echo "Autogenerated html pages for $$(git describe --always)" \
165                     | git commit-tree $$(git write-tree --prefix=Documentation) \
166                                 -p refs/heads/html)
167
168 # push the pregenerated doc files to origin/man and origin/html
169 push-docs: export-docs
170         git push origin man html
171
172 # import pregenerated doc files from origin/man and origin/html, in case you
173 # don't have pandoc but still want to be able to install the docs.
174 import-docs: Documentation/clean
175         git archive origin/html | (cd Documentation; tar -xvf -)
176         git archive origin/man | (cd Documentation; tar -xvf -)
177
178 clean: Documentation/clean config/clean
179         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
180                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
181                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
182                 bup bup-* cmd/bup-* \
183                 lib/bup/_version.py lib/bup/_version.py.tmp-* \
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         t/configure-sampledata --clean