]> arthur.barton.de Git - bup.git/blob - Makefile
Makefile: Fix 'clean' rule
[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 lib/bup/_helpers$(SOEXT): \
61                 lib/bup/bupsplit.c lib/bup/_helpers.c lib/bup/csetup.py
62         @rm -f $@
63         cd lib/bup && LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
64         cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
65
66 .PHONY: lib/bup/_version.py
67 lib/bup/_version.py:
68         rm -f $@ $@.new
69         ./format-subst.pl $@.pre >$@.new
70         mv $@.new $@
71
72 runtests: all runtests-python runtests-cmdline
73
74 runtests-python:
75         $(PYTHON) wvtest.py t/t*.py lib/*/t/t*.py
76
77 runtests-cmdline: all
78         t/test.sh
79
80 stupid:
81         PATH=/bin:/usr/bin $(MAKE) test
82
83 test: all
84         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests
85
86 check: test
87
88 bup: main.py
89         rm -f $@
90         ln -s $< $@
91
92 cmds: \
93     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
94     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
95
96 cmd/bup-%: cmd/%-cmd.py
97         rm -f $@
98         ln -s $*-cmd.py $@
99
100 %: %.py
101         rm -f $@
102         ln -s $< $@
103
104 bup-%: cmd-%.sh
105         rm -f $@
106         ln -s $< $@
107
108 cmd/bup-%: cmd/%-cmd.sh
109         rm -f $@
110         ln -s $*-cmd.sh $@
111
112 # update the local 'man' and 'html' branches with pregenerated output files, for
113 # people who don't have pandoc (and maybe to aid in google searches or something)
114 export-docs: Documentation/all
115         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
116         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
117         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
118         rm -f $${GIT_INDEX_FILE} && \
119         git add -f Documentation/*.1 && \
120         git update-ref refs/heads/man \
121                 $$(echo "Autogenerated man pages for $$(git describe)" \
122                     | git commit-tree $$(git write-tree --prefix=Documentation) \
123                                 -p refs/heads/man) && \
124         rm -f $${GIT_INDEX_FILE} && \
125         git add -f Documentation/*.html && \
126         git update-ref refs/heads/html \
127                 $$(echo "Autogenerated html pages for $$(git describe)" \
128                     | git commit-tree $$(git write-tree --prefix=Documentation) \
129                                 -p refs/heads/html)
130
131 # push the pregenerated doc files to origin/man and origin/html
132 push-docs: export-docs
133         git push origin man html
134
135 # import pregenerated doc files from origin/man and origin/html, in case you
136 # don't have pandoc but still want to be able to install the docs.
137 import-docs: Documentation/clean
138         git archive origin/html | (cd Documentation; tar -xvf -)
139         git archive origin/man | (cd Documentation; tar -xvf -)
140
141 # tgit.py plays with permissions on lib/bup/t/pybuptest.tmp, so we should
142 # ensure that we can delete the directory before doing it.
143 clean: Documentation/clean
144         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll *.exe \
145                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
146                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
147                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
148                 out[12] out2[tc] tags[12] tags2[tc]
149         [ -d lib/bup/t/pybuptest.tmp ] && chmod u+rwx lib/bup/t/pybuptest.tmp || true
150         rm -rf *.tmp t/*.tmp lib/*/*/*.tmp build lib/bup/build