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