]> arthur.barton.de Git - bup.git/blob - Makefile
make install: don't fail if documentation couldn't be built.
[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/_hashsplit$(SOEXT) cmds
25
26 Documentation/all: bup
27
28 INSTALL=install
29 MANDIR=$(DESTDIR)/usr/share/man
30 DOCDIR=$(DESTDIR)/usr/share/doc/bup
31 BINDIR=$(DESTDIR)/usr/bin
32 LIBDIR=$(DESTDIR)/usr/lib/bup
33 install: all
34         $(INSTALL) -d $(MANDIR)/man1 $(DOCDIR) $(BINDIR) \
35                 $(LIBDIR)/bup $(LIBDIR)/cmd
36         [ ! -e Documentation/.docs-available ] || \
37           $(INSTALL) -o 0 -g 0 -m 0644 \
38                 $(wildcard Documentation/*.1) \
39                 $(MANDIR)/man1
40         [ ! -e Documentation/.docs-available ] || \
41           $(INSTALL) -o 0 -g 0 -m 0644 \
42                 $(wildcard Documentation/*.html) \
43                 $(DOCDIR)
44         $(INSTALL) -o 0 -g 0 -m 0755 bup $(BINDIR)
45         $(INSTALL) -o 0 -g 0 -m 0755 \
46                 $(wildcard cmd/bup-*) \
47                 $(LIBDIR)/cmd
48         $(INSTALL) -o 0 -g 0 -m 0644 \
49                 $(wildcard lib/bup/*.so lib/bup/*.py) \
50                 $(LIBDIR)/bup
51         
52 %/all:
53         $(MAKE) -C $* all
54         
55 %/clean:
56         $(MAKE) -C $* clean
57
58 lib/bup/_hashsplit$(SOEXT): lib/bup/_hashsplit.c lib/bup/csetup.py
59         @rm -f $@
60         cd lib/bup && python csetup.py build
61         cp lib/bup/build/*/_hashsplit$(SOEXT) lib/bup/
62
63 .PHONY: lib/bup/_version.py
64 lib/bup/_version.py:
65         rm -f $@ $@.new
66         ./format-subst.pl $@.pre >$@.new
67         mv $@.new $@
68         
69 runtests: all runtests-python runtests-cmdline
70
71 runtests-python:
72         ./wvtest.py $(wildcard t/t*.py)
73         
74 runtests-cmdline: all
75         t/test.sh
76         
77 stupid:
78         PATH=/bin:/usr/bin $(MAKE) test
79         
80 test: all
81         ./wvtestrun $(MAKE) runtests
82
83 %: %.o
84         $(CC) $(CFLAGS) (LDFLAGS) -o $@ $^ $(LIBS)
85         
86 bup: main.py
87         rm -f $@
88         ln -s $< $@
89         
90 cmds: $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py))
91
92 cmd/bup-%: cmd/%-cmd.py
93         rm -f $@
94         ln -s $*-cmd.py $@
95         
96 %: %.py
97         rm -f $@
98         ln -s $< $@
99         
100 bup-%: cmd-%.sh
101         rm -f $@
102         ln -s $< $@
103         
104 %.o: %.c
105         gcc -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
106
107 clean: Documentation/clean
108         rm -f *.o *.so */*/*.so *.dll *.exe .*~ *~ */*~ */*/*~ \
109                 *.pyc */*.pyc */*/*.pyc \
110                 bup bup-* cmd/bup-* lib/bup/_version.py randomgen memtest \
111                 out[12] out2[tc] tags[12] tags2[tc]
112         rm -rf *.tmp build lib/bup/build