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