]> arthur.barton.de Git - bup.git/blob - Makefile
Don't touch correct target xattrs; remove inappropriate target xattrs.
[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         t/test-meta.sh
80
81 stupid:
82         PATH=/bin:/usr/bin $(MAKE) test
83
84 test: all
85         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests
86
87 check: test
88
89 bup: main.py
90         rm -f $@
91         ln -s $< $@
92
93 cmds: \
94     $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
95     $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
96
97 cmd/bup-%: cmd/%-cmd.py
98         rm -f $@
99         ln -s $*-cmd.py $@
100
101 %: %.py
102         rm -f $@
103         ln -s $< $@
104
105 bup-%: cmd-%.sh
106         rm -f $@
107         ln -s $< $@
108
109 cmd/bup-%: cmd/%-cmd.sh
110         rm -f $@
111         ln -s $*-cmd.sh $@
112
113 # update the local 'man' and 'html' branches with pregenerated output files, for
114 # people who don't have pandoc (and maybe to aid in google searches or something)
115 export-docs: Documentation/all
116         git update-ref refs/heads/man origin/man '' 2>/dev/null || true
117         git update-ref refs/heads/html origin/html '' 2>/dev/null || true
118         GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
119         rm -f $${GIT_INDEX_FILE} && \
120         git add -f Documentation/*.1 && \
121         git update-ref refs/heads/man \
122                 $$(echo "Autogenerated man pages for $$(git describe)" \
123                     | git commit-tree $$(git write-tree --prefix=Documentation) \
124                                 -p refs/heads/man) && \
125         rm -f $${GIT_INDEX_FILE} && \
126         git add -f Documentation/*.html && \
127         git update-ref refs/heads/html \
128                 $$(echo "Autogenerated html pages for $$(git describe)" \
129                     | git commit-tree $$(git write-tree --prefix=Documentation) \
130                                 -p refs/heads/html)
131
132 # push the pregenerated doc files to origin/man and origin/html
133 push-docs: export-docs
134         git push origin man html
135
136 # import pregenerated doc files from origin/man and origin/html, in case you
137 # don't have pandoc but still want to be able to install the docs.
138 import-docs: Documentation/clean
139         git archive origin/html | (cd Documentation; tar -xvf -)
140         git archive origin/man | (cd Documentation; tar -xvf -)
141
142 clean: Documentation/clean
143         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll *.exe \
144                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
145                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
146                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
147                 out[12] out2[tc] tags[12] tags2[tc] \
148                 testfs.img lib/bup/t/testfs.img
149         rm -rf *.tmp t/*.tmp lib/*/*/*.tmp build lib/bup/build
150         if test -e testfs; then rmdir testfs; fi
151         if test -e lib/bup/t/testfs; then rmdir lib/bup/t/testfs; fi