]> arthur.barton.de Git - bup.git/blob - Makefile
Rename _hashsplit.so to _faster.so, and move bupsplit into its own source file.
[bup.git] / Makefile
1 OS:=$(shell uname | sed 's/[-_].*//')
2 CFLAGS=-Wall -g -O2 -Werror $(PYINCLUDE) -g
3 ifneq ($(OS),CYGWIN)
4   CFLAGS += -fPIC
5 endif
6 SHARED=-shared
7 SOEXT:=.so
8
9 ifeq (${OS},Darwin)
10   MACHINE:=$(shell arch)
11   CFLAGS += -arch $(MACHINE)
12   SHARED = -dynamiclib
13 endif
14 ifeq ($(OS),CYGWIN)
15   LDFLAGS += -L/usr/bin
16   EXT:=.exe
17   SOEXT:=.dll
18 endif
19
20 default: all
21
22 all: bup Documentation/all
23
24 bup: lib/bup/_version.py lib/bup/_faster$(SOEXT) cmds
25
26 Documentation/all: bup
27
28 INSTALL=install
29 PYTHON=python
30 MANDIR=$(DESTDIR)/usr/share/man
31 DOCDIR=$(DESTDIR)/usr/share/doc/bup
32 BINDIR=$(DESTDIR)/usr/bin
33 LIBDIR=$(DESTDIR)/usr/lib/bup
34 install: all
35         $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
36                 $(LIBDIR)/bup $(LIBDIR)/cmd $(LIBDIR)/tornado \
37                 $(LIBDIR)/web
38         [ ! -e Documentation/.docs-available ] || \
39           $(INSTALL) -m 0644 \
40                 $(wildcard Documentation/*.1) \
41                 $(MANDIR)/man1
42         [ ! -e Documentation/.docs-available ] || \
43           $(INSTALL) -m 0644 \
44                 $(wildcard Documentation/*.html) \
45                 $(DOCDIR)
46         $(INSTALL) -m 0755 bup $(BINDIR)
47         $(INSTALL) -m 0755 \
48                 $(wildcard cmd/bup-*) \
49                 $(LIBDIR)/cmd
50         $(INSTALL) -m 0644 \
51                 $(wildcard lib/bup/*.so lib/bup/*.py) \
52                 $(LIBDIR)/bup
53         $(INSTALL) -m 0644 \
54                 $(wildcard lib/tornado/*.py) \
55                 $(LIBDIR)/tornado
56         $(INSTALL) -m 0644 \
57                 $(wildcard lib/web/*) \
58                 $(LIBDIR)/web
59 %/all:
60         $(MAKE) -C $* all
61
62 %/clean:
63         $(MAKE) -C $* clean
64
65 lib/bup/_faster$(SOEXT): \
66                 lib/bup/bupsplit.c lib/bup/_faster.c lib/bup/csetup.py
67         @rm -f $@
68         cd lib/bup && $(PYTHON) csetup.py build
69         cp lib/bup/build/*/_faster$(SOEXT) lib/bup/
70
71 .PHONY: lib/bup/_version.py
72 lib/bup/_version.py:
73         rm -f $@ $@.new
74         ./format-subst.pl $@.pre >$@.new
75         mv $@.new $@
76
77 runtests: all runtests-python runtests-cmdline
78
79 runtests-python:
80         $(PYTHON) wvtest.py $(wildcard t/t*.py lib/*/t/t*.py)
81
82 runtests-cmdline: all
83         t/test.sh
84
85 stupid:
86         PATH=/bin:/usr/bin $(MAKE) test
87
88 test: all
89         ./wvtestrun $(MAKE) PYTHON=$(PYTHON) runtests
90
91 check: test
92
93 %: %.o
94         $(CC) $(CFLAGS) (LDFLAGS) -o $@ $^ $(LIBS)
95
96 bup: main.py
97         rm -f $@
98         ln -s $< $@
99
100 cmds: $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py))
101
102 cmd/bup-%: cmd/%-cmd.py
103         rm -f $@
104         ln -s $*-cmd.py $@
105
106 %: %.py
107         rm -f $@
108         ln -s $< $@
109
110 bup-%: cmd-%.sh
111         rm -f $@
112         ln -s $< $@
113
114 %.o: %.c
115         gcc -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
116
117 clean: Documentation/clean
118         rm -f *.o lib/*/*.o *.so lib/*/*.so *.dll *.exe \
119                 .*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
120                 *.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
121                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
122                 out[12] out2[tc] tags[12] tags2[tc]
123         rm -rf *.tmp t/*.tmp lib/*/*/*.tmp build lib/bup/build