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