]> arthur.barton.de Git - bup.git/blob - Makefile
config: more config stuff to config/ subdir, call it from Makefile.
[bup.git] / Makefile
1 OS:=$(shell uname | sed 's/[-_].*//')
2 CFLAGS:=-Wall -O2 -Werror $(PYINCLUDE)
3 SOEXT:=.so
4
5 ifeq ($(OS),CYGWIN)
6   SOEXT:=.dll
7 endif
8
9 default: all
10
11 all: bup Documentation/all
12
13 bup: lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
14
15 Documentation/all: bup
16
17 INSTALL=install
18 PYTHON=python
19 MANDIR=$(DESTDIR)/usr/share/man
20 DOCDIR=$(DESTDIR)/usr/share/doc/bup
21 BINDIR=$(DESTDIR)/usr/bin
22 LIBDIR=$(DESTDIR)/usr/lib/bup
23 install: all
24         $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
25                 $(LIBDIR)/bup $(LIBDIR)/cmd $(LIBDIR)/tornado \
26                 $(LIBDIR)/web $(LIBDIR)/web/static
27         [ ! -e Documentation/.docs-available ] || \
28           $(INSTALL) -m 0644 \
29                 Documentation/*.1 \
30                 $(MANDIR)/man1
31         [ ! -e Documentation/.docs-available ] || \
32           $(INSTALL) -m 0644 \
33                 Documentation/*.html \
34                 $(DOCDIR)
35         $(INSTALL) -m 0755 bup $(BINDIR)
36         $(INSTALL) -m 0755 \
37                 cmd/bup-* \
38                 $(LIBDIR)/cmd
39         $(INSTALL) -m 0644 \
40                 lib/bup/*.py \
41                 $(LIBDIR)/bup
42         $(INSTALL) -m 0755 \
43                 lib/bup/*$(SOEXT) \
44                 $(LIBDIR)/bup
45         $(INSTALL) -m 0644 \
46                 lib/tornado/*.py \
47                 $(LIBDIR)/tornado
48         $(INSTALL) -m 0644 \
49                 lib/web/static/* \
50                 $(LIBDIR)/web/static/
51         $(INSTALL) -m 0644 \
52                 lib/web/*.html \
53                 $(LIBDIR)/web/
54 %/all:
55         $(MAKE) -C $* all
56
57 %/clean:
58         $(MAKE) -C $* clean
59         
60 config/config.h: config/Makefile config/configure config/configure.inc \
61                 $(wildcard config/*.in)
62         cd config && make config.h
63
64 lib/bup/_helpers$(SOEXT): \
65                 config/config.h \
66                 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
67         @rm -f $@
68         cd lib/bup && \
69         LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
70         cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
71
72 .PHONY: lib/bup/_version.py
73 lib/bup/_version.py:
74         rm -f $@ $@.new
75         ./format-subst.pl $@.pre >$@.new
76         mv $@.new $@
77
78 runtests: all runtests-python runtests-cmdline
79
80 runtests-python:
81         $(PYTHON) wvtest.py t/t*.py lib/*/t/t*.py
82
83 runtests-cmdline: all
84         t/test.sh
85         t/test-meta.sh
86
87 stupid:
88         PATH=/bin:/usr/bin $(MAKE) test
89
90 test: all
91         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests
92
93 check: test
94
95 bup: main.py
96         rm -f $@
97         ln -s $< $@
98
99 cmds: \
100     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
101     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
102
103 cmd/bup-%: cmd/%-cmd.py
104         rm -f $@
105         ln -s $*-cmd.py $@
106
107 %: %.py
108         rm -f $@
109         ln -s $< $@
110
111 bup-%: cmd-%.sh
112         rm -f $@
113         ln -s $< $@
114
115 cmd/bup-%: cmd/%-cmd.sh
116         rm -f $@
117         ln -s $*-cmd.sh $@
118
119 # update the local 'man' and 'html' branches with pregenerated output files, for
120 # people who don't have pandoc (and maybe to aid in google searches or something)
121 export-docs: Documentation/all
122         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
123         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
124         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
125         rm -f $${GIT_INDEX_FILE} && \
126         git add -f Documentation/*.1 && \
127         git update-ref refs/heads/man \
128                 $$(echo "Autogenerated man pages for $$(git describe)" \
129                     | git commit-tree $$(git write-tree --prefix=Documentation) \
130                                 -p refs/heads/man) && \
131         rm -f $${GIT_INDEX_FILE} && \
132         git add -f Documentation/*.html && \
133         git update-ref refs/heads/html \
134                 $$(echo "Autogenerated html pages for $$(git describe)" \
135                     | git commit-tree $$(git write-tree --prefix=Documentation) \
136                                 -p refs/heads/html)
137
138 # push the pregenerated doc files to origin/man and origin/html
139 push-docs: export-docs
140         git push origin man html
141
142 # import pregenerated doc files from origin/man and origin/html, in case you
143 # don't have pandoc but still want to be able to install the docs.
144 import-docs: Documentation/clean
145         git archive origin/html | (cd Documentation; tar -xvf -)
146         git archive origin/man | (cd Documentation; tar -xvf -)
147
148 # tgit.py plays with permissions on lib/bup/t/pybuptest.tmp, so we should
149 # ensure that we can delete the directory before doing it.
150 clean: Documentation/clean
151         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll *.exe \
152                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
153                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
154                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
155                 out[12] out2[tc] tags[12] tags2[tc] \
156                 testfs.img lib/bup/t/testfs.img
157         rm -rf *.tmp t/*.tmp lib/*/*/*.tmp build lib/bup/build
158         if test -e testfs; then rmdir testfs; fi
159         if test -e lib/bup/t/testfs; then rmdir lib/bup/t/testfs; fi