]> arthur.barton.de Git - bup.git/blobdiff - Makefile
main: fix problem when redirecting to newliner on MacOS X.
[bup.git] / Makefile
index 5b4fd4dc617c6b8b71248e751d8baa0d16aa577f..40cae28223c0d55b49a6085164877bef36747fb0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,51 +1,79 @@
-CFLAGS=-Wall -g -O2 -Werror -I/usr/include/python2.5 -g -fPIC
+OS:=$(shell uname | sed 's/[-_].*//')
+CFLAGS=-Wall -g -O2 -Werror $(PYINCLUDE) -g
+ifneq ($(OS),CYGWIN)
+  CFLAGS += -fPIC
+endif
+SHARED=-shared
+SOEXT:=.so
 
-default: all
+ifeq (${OS},Darwin)
+  MACHINE:=$(shell arch)
+  CFLAGS += -arch $(MACHINE)
+  SHARED = -dynamiclib
+endif
+ifeq ($(OS),CYGWIN)
+  LDFLAGS += -L/usr/bin
+  EXT:=.exe
+  SOEXT:=.dll
+endif
 
-all: bup-split bup-join bup-save bup randomgen chashsplit.so
+default: all
 
-randomgen: randomgen.o
+all: cmds bup lib/bup/_hashsplit$(SOEXT) \
+       Documentation/all
+       
+%/all:
+       $(MAKE) -C $* all
+       
+%/clean:
+       $(MAKE) -C $* clean
 
-chashsplit.so: chashsplitmodule.o
-       $(CC) -shared -o $@ $<
+lib/bup/_hashsplit$(SOEXT): lib/bup/_hashsplit.c lib/bup/csetup.py
+       @rm -f $@
+       cd lib/bup && python csetup.py build
+       cp lib/bup/build/*/_hashsplit$(SOEXT) lib/bup/
        
-runtests: all
+runtests: all runtests-python runtests-cmdline
+
+runtests-python:
        ./wvtest.py $(wildcard t/t*.py)
        
 runtests-cmdline: all
-       @echo "Testing \"$@\" in Makefile:"
-       ./bup split --bench -b <testfile1 >tags1
-       ./bup split -b testfile2 >tags2
-       diff -u tags1 tags2 || true
-       wc -c testfile1 testfile2
-       wc -l tags1 tags2
-       ./bup join $$(cat tags1) >out1
-       ./bup join <tags2 >out2
-       diff -u testfile1 out1
-       diff -u testfile2 out2
-       
-test: all runtests-cmdline
+       t/test.sh
+       
+stupid:
+       PATH=/bin:/usr/bin $(MAKE) test
+       
+test: all
        ./wvtestrun $(MAKE) runtests
 
 %: %.o
-       gcc -o $@ $< $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) (LDFLAGS) -o $@ $^ $(LIBS)
        
-bup: bup.py
+bup: main.py
+       rm -f $@
+       ln -s $< $@
+       
+cmds: $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py))
+
+cmd/bup-%: cmd/%-cmd.py
        rm -f $@
-       ln -s $^ $@
+       ln -s $*-cmd.py $@
        
-bup-%: cmd-%.py
+%: %.py
        rm -f $@
-       ln -s $^ $@
+       ln -s $< $@
        
 bup-%: cmd-%.sh
        rm -f $@
-       ln -s $^ $@
+       ln -s $< $@
        
 %.o: %.c
-       gcc -c -o $@ $^ $(CPPFLAGS) $(CFLAGS)
+       gcc -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
 
-clean:
-       rm -f *.o *.so *~ .*~ *.pyc */*.pyc */*~ \
-               bup bup-split bup-join bup-save randomgen \
-               out[12] tags[12]
+clean: Documentation/clean
+       rm -f *.o *.so */*/*.so *.dll *.exe .*~ *~ */*~ */*/*~ \
+               *.pyc */*.pyc */*/*.pyc\
+               bup bup-* cmd/bup-* randomgen memtest \
+               out[12] out2[tc] tags[12] tags2[tc]
+       rm -rf *.tmp build lib/bup/build