-CFLAGS=-Wall -g -O2 -Werror -I/usr/include/python2.5 -g -fPIC
+OS:=$(shell uname | sed 's/[-_].*//')
+MACHINE:=$(shell uname -m)
+CFLAGS=-Wall -g -O2 -Werror $(PYINCLUDE) -g
+ifneq ($(OS),CYGWIN)
+ CFLAGS += -fPIC
+endif
+SHARED=-shared
+SOEXT:=.so
+
+ifeq (${OS},Darwin)
+ CFLAGS += -arch $(MACHINE)
+ SHARED = -dynamiclib
+endif
+ifeq ($(OS),CYGWIN)
+ LDFLAGS += -L/usr/bin
+ EXT:=.exe
+ SOEXT:=.dll
+endif
default: all
-all: bup-split bup-join bup randomgen hashsplit.so
+all: bup-split bup-join bup-save bup-init bup-server bup-index bup-tick \
+ bup-midx \
+ bup memtest randomgen$(EXT) _hashsplit$(SOEXT)
-randomgen: randomgen.o
+randomgen$(EXT): randomgen.o
+ $(CC) $(CFLAGS) -o $@ $<
-hashsplit.so: hashsplitmodule.o
- $(CC) -shared -o $@ $<
+_hashsplit$(SOEXT): _hashsplit.c csetup.py
+ @rm -f $@
+ python csetup.py build
+ cp build/*/_hashsplit.so .
-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 -b <testfile1 >tags1
- ./bup split -b testfile2 >tags2
- diff -u tags1 tags2 || true
- wc -c testfile1 testfile2
- wc -l tags1 tags2
- ./bup join <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
rm -f $@
- ln -s $^ $@
+ ln -s $< $@
bup-%: cmd-%.py
rm -f $@
- ln -s $^ $@
+ ln -s $< $@
+
+%: %.py
+ rm -f $@
+ 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 \
- bup bup-split bup-join randomgen \
- out[12] tags[12]
+ rm -f *.o *.so *.dll *.exe *~ .*~ *.pyc */*.pyc */*~ \
+ bup bup-* randomgen memtest \
+ out[12] out2[tc] tags[12] tags2[tc]
+ rm -rf *.tmp build