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