SRCS := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))
DEPS := $(patsubst %.c,%.d,$(SRCS))

COMPILE ?= g++ -g -Wall -c
LINK ?= g++ -g -Wall
MAKEDEP ?= g++ -M

all: ../TreeArrange $(DEPS) $(OBJS)

clean: 
	rm -f *~ *.o *.d main


MAINOBJECTS=../shared/read_data.o ../shared/dictionary.o opt.o main.o tsp.o distance.o reoptions.o opt2.o

../TreeArrange: $(MAINOBJECTS)
	$(LINK) $(MAINOBJECTS) -o ../TreeArrange

%d:%c
	$(MAKEDEP) $< > $@
	$(MAKEDEP) $< | sed s/\\.o/.d/ >> $@

%.o: %.c
	$(COMPILE) $<


-include $(DEPS)
