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