#CFLAGS_DBG=-Wall -O0 -g3 
#CFLAGS_COORDT=-DCDT_COORD_T=double -Dcdt_precision=1000000.0

LIBRND_PREFIX=/usr/local

CFLAGS=$(CFLAGS_DBG) $(CFLAGS_COORDT) $(CFLAGS_LIBCDTR) -I. -I.. -I../.. -I$(LIBRND_PREFIX)/include/librnd4/librnd/src_3rd
LDFLAGS=-lm $(LDFLAGS_LIBCDTR)

OBJS= cdt.o point.o edge.o triangle.o debug.o
LIBA=libcdtr.a

DEP_OBJS=$(OBJS)

cdt_test: cdt_test.o $(OBJS)

include Makefile.dep
include Makefile.comp

$(LIBA): $(OBJS)
	@touch $(LIBA)
	@rm $(LIBA)
	@ar ru $(LIBA) $(OBJS)
	-ar s $(LIBA)
	-ranlib $(LIBA)

cdt_test.o: cdt_test.c
	$(CC) $(CFLAGS) -c cdt_test.c -o $@

test:
	cd regression && ./Test.sh

# not portable; run this only if you have gcc installed
dep:
	for o in $(DEP_OBJS); do gcc -MT $$o -MM $${o%%.o}.c  $(CFLAGS); done > Makefile.dep
	for o in $(DEP_OBJS); do echo "$$o: $${o%%.o}.c"; echo '	$$(CC) $$(CFLAGS) -c -o ' "$$o $${o%%.o}.c"; echo ""; done > Makefile.comp

clean:
	-touch $(LIBA) $(OBJS) cdt_test.o cdt_test
	-rm $(LIBA) $(OBJS) cdt_test.o cdt_test
