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