]> arthur.barton.de Git - bup.git/blob - Makefile
Revert "Write the system ARG_MAX to an autogenerated config.py..."
[bup.git] / Makefile
1 OS:=$(shell uname | sed 's/[-_].*//')
2 CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(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 \
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/web/static/* \
55                 $(LIBDIR)/web/static/
56         $(INSTALL) -pm 0644 \
57                 lib/web/*.html \
58                 $(LIBDIR)/web/
59 %/all:
60         $(MAKE) -C $* all
61
62 %/clean:
63         $(MAKE) -C $* clean
64
65 config/config.h: config/Makefile config/configure config/configure.inc \
66                 $(wildcard config/*.in)
67         cd config && $(MAKE) config.h
68
69 lib/bup/_helpers$(SOEXT): \
70                 config/config.h \
71                 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
72         @rm -f $@
73         cd lib/bup && \
74         LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
75         cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
76
77 .PHONY: lib/bup/_version.py
78 lib/bup/_version.py:
79         rm -f $@ $@.new
80         ./format-subst.pl $@.pre >$@.new
81         mv $@.new $@
82
83 runtests: all runtests-python runtests-cmdline
84
85 runtests-python: all
86         test -e t/tmp || mkdir t/tmp
87         TMPDIR="$(test_tmp)" $(PYTHON) wvtest.py t/t*.py lib/*/t/t*.py
88
89 runtests-cmdline: all
90         test -e t/tmp || mkdir t/tmp
91         TMPDIR="$(test_tmp)" t/test-drecurse.sh
92         TMPDIR="$(test_tmp)" t/test-cat-file.sh
93         TMPDIR="$(test_tmp)" t/test-compression.sh
94         TMPDIR="$(test_tmp)" t/test-fsck.sh
95         TMPDIR="$(test_tmp)" t/test-index-clear.sh
96         TMPDIR="$(test_tmp)" t/test-index-check-device.sh
97         TMPDIR="$(test_tmp)" t/test-ls.sh
98         TMPDIR="$(test_tmp)" t/test-meta.sh
99         TMPDIR="$(test_tmp)" t/test-on.sh
100         TMPDIR="$(test_tmp)" t/test-restore-map-owner.sh
101         TMPDIR="$(test_tmp)" t/test-restore-single-file.sh
102         TMPDIR="$(test_tmp)" t/test-rm-between-index-and-save.sh
103         TMPDIR="$(test_tmp)" t/test-command-without-init-fails.sh
104         TMPDIR="$(test_tmp)" t/test-redundant-saves.sh
105         TMPDIR="$(test_tmp)" t/test-save-restore-excludes.sh
106         TMPDIR="$(test_tmp)" t/test-save-strip-graft.sh
107         TMPDIR="$(test_tmp)" t/test-import-rdiff-backup.sh
108         TMPDIR="$(test_tmp)" t/test-xdev.sh
109         TMPDIR="$(test_tmp)" t/test.sh
110
111 stupid:
112         PATH=/bin:/usr/bin $(MAKE) test
113
114 test: all
115         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests
116
117 check: test
118
119 bup: main.py
120         rm -f $@
121         ln -s $< $@
122
123 cmds: \
124     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
125     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
126
127 cmd/bup-%: cmd/%-cmd.py
128         rm -f $@
129         ln -s $*-cmd.py $@
130
131 %: %.py
132         rm -f $@
133         ln -s $< $@
134
135 bup-%: cmd-%.sh
136         rm -f $@
137         ln -s $< $@
138
139 cmd/bup-%: cmd/%-cmd.sh
140         rm -f $@
141         ln -s $*-cmd.sh $@
142
143 # update the local 'man' and 'html' branches with pregenerated output files, for
144 # people who don't have pandoc (and maybe to aid in google searches or something)
145 export-docs: Documentation/all
146         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
147         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
148         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
149         rm -f $${GIT_INDEX_FILE} && \
150         git add -f Documentation/*.1 && \
151         git update-ref refs/heads/man \
152                 $$(echo "Autogenerated man pages for $$(git describe)" \
153                     | git commit-tree $$(git write-tree --prefix=Documentation) \
154                                 -p refs/heads/man) && \
155         rm -f $${GIT_INDEX_FILE} && \
156         git add -f Documentation/*.html && \
157         git update-ref refs/heads/html \
158                 $$(echo "Autogenerated html pages for $$(git describe)" \
159                     | git commit-tree $$(git write-tree --prefix=Documentation) \
160                                 -p refs/heads/html)
161
162 # push the pregenerated doc files to origin/man and origin/html
163 push-docs: export-docs
164         git push origin man html
165
166 # import pregenerated doc files from origin/man and origin/html, in case you
167 # don't have pandoc but still want to be able to install the docs.
168 import-docs: Documentation/clean
169         git archive origin/html | (cd Documentation; tar -xvf -)
170         git archive origin/man | (cd Documentation; tar -xvf -)
171
172 clean: Documentation/clean config/clean
173         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
174                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
175                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
176                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
177                 testfs.img lib/bup/t/testfs.img
178         if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
179         if test -e t/mnt; then rm -r t/mnt; fi
180         if test -e t/tmp; then t/cleanup-mounts-under t/tmp; fi
181         # FIXME: migrate these to t/mnt/
182         if test -e bupmeta.tmp/testfs; \
183           then umount bupmeta.tmp/testfs || true; fi
184         if test -e lib/bup/t/testfs; \
185           then umount lib/bup/t/testfs || true; fi
186         if test -e bupmeta.tmp/testfs-limited; \
187           then umount bupmeta.tmp/testfs-limited || true; fi
188         rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
189         if test -e t/tmp; then t/force-delete t/tmp; fi
190         t/configure-sampledata --clean