]> arthur.barton.de Git - bup.git/blob - Makefile
Makefile: avoid using -Werror with clang for now.
[bup.git] / Makefile
1 OS:=$(shell uname | sed 's/[-_].*//')
2
3 ifeq ($(shell $(CC) --version | grep clang),)
4         CFLAGS := -Wall -Werror -O2 $(PYINCLUDE) $(CFLAGS)
5 else # clang
6         CFLAGS := -Wall -O2 $(PYINCLUDE) $(CFLAGS)
7 endif
8
9 SOEXT:=.so
10
11 ifeq ($(OS),CYGWIN)
12   SOEXT:=.dll
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 $(LIBDIR)/tornado \
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/tornado/*.py \
55                 $(LIBDIR)/tornado
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 .PHONY: lib/bup/_version.py
81 lib/bup/_version.py:
82         rm -f $@ $@.new
83         ./format-subst.pl $@.pre >$@.new
84         mv $@.new $@
85
86 runtests: all runtests-python runtests-cmdline
87
88 runtests-python: all
89         $(PYTHON) wvtest.py \
90                 $(wildcard t/t*.py) \
91                 $(filter-out lib/bup/t/tmetadata.py,$(wildcard lib/*/t/t*.py))
92         $(PYTHON) wvtest.py lib/bup/t/tmetadata.py
93
94 runtests-cmdline: all
95         t/test-cat-file.sh
96         t/test-index-check-device.sh
97         t/test-meta.sh
98         t/test-restore-map-owner.sh
99         t/test-restore-single-file.sh
100         t/test-rm-between-index-and-save.sh
101         t/test-command-without-init-fails.sh
102         t/test-redundant-saves.sh
103         t/test.sh
104
105 stupid:
106         PATH=/bin:/usr/bin $(MAKE) test
107
108 test: all
109         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests
110
111 check: test
112
113 bup: main.py
114         rm -f $@
115         ln -s $< $@
116
117 cmds: \
118     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
119     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
120
121 cmd/bup-%: cmd/%-cmd.py
122         rm -f $@
123         ln -s $*-cmd.py $@
124
125 %: %.py
126         rm -f $@
127         ln -s $< $@
128
129 bup-%: cmd-%.sh
130         rm -f $@
131         ln -s $< $@
132
133 cmd/bup-%: cmd/%-cmd.sh
134         rm -f $@
135         ln -s $*-cmd.sh $@
136
137 # update the local 'man' and 'html' branches with pregenerated output files, for
138 # people who don't have pandoc (and maybe to aid in google searches or something)
139 export-docs: Documentation/all
140         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
141         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
142         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
143         rm -f $${GIT_INDEX_FILE} && \
144         git add -f Documentation/*.1 && \
145         git update-ref refs/heads/man \
146                 $$(echo "Autogenerated man pages for $$(git describe)" \
147                     | git commit-tree $$(git write-tree --prefix=Documentation) \
148                                 -p refs/heads/man) && \
149         rm -f $${GIT_INDEX_FILE} && \
150         git add -f Documentation/*.html && \
151         git update-ref refs/heads/html \
152                 $$(echo "Autogenerated html pages for $$(git describe)" \
153                     | git commit-tree $$(git write-tree --prefix=Documentation) \
154                                 -p refs/heads/html)
155
156 # push the pregenerated doc files to origin/man and origin/html
157 push-docs: export-docs
158         git push origin man html
159
160 # import pregenerated doc files from origin/man and origin/html, in case you
161 # don't have pandoc but still want to be able to install the docs.
162 import-docs: Documentation/clean
163         git archive origin/html | (cd Documentation; tar -xvf -)
164         git archive origin/man | (cd Documentation; tar -xvf -)
165
166 clean: Documentation/clean config/clean
167         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll lib/*/*.dll *.exe \
168                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
169                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
170                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
171                 out[12] out2[tc] tags[12] tags2[tc] \
172                 testfs.img lib/bup/t/testfs.img
173         umount t/mnt/* || true
174         if test -e t/mnt; then rm -r t/mnt; fi
175         # FIXME: migrate these to t/mnt/
176         if test -e bupmeta.tmp/testfs; \
177           then umount bupmeta.tmp/testfs || true; fi
178         if test -e lib/bup/t/testfs; \
179           then umount lib/bup/t/testfs || true; fi
180         if test -e bupmeta.tmp/testfs-limited; \
181           then umount bupmeta.tmp/testfs-limited || true; fi
182         rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
183         if test -e t/tmp; then rm -r t/tmp; fi
184         t/configure-sampledata --clean