TOP=../..
CONFIG=$(TOP)/config/default
include $(CONFIG)

cg-tests = \
     u1f1 \
     u1fr \
     urf1 \
     urfr

dd-tests =\
     test-DD \
     test-DD0 \
     test-DD-d1 \
     test-DD-1 \
     test-conj \
     test-conj1 \
     test-conj2 \
     test-conj2d \
     test-conj0 \
     test-conj-1 \
     test-conj-2 \
     test-conjD-1

programs=\
     $(dd-tests) \
     $(cg-tests:%=test-%) \
     t_dwf_cg

.PHONY: all clean realclean

all: $(programs)

clean:
	$(RM) $(programs:%=%.o) *~ make-dump cout-* cerr-* core.*

realclean: clean
	$(RM) $(programs)

$(dd-tests): %: %.c
	$(CC) $(CFLAGS) -I. -o $@ $< $(TOP)/dwf.o $(LDFLAGS) $(LIBS)

$(cg-tests:%=test-%): test-%: %.c cg.c cg.h
	$(CC) $(CFLAGS) -I. -o $@ cg.c $< $(TOP)/dwf.o $(LDFLAGS) $(LIBS)

$(programs): $(TOP)/dwf.o $(TOP)/sse-dwf-cg.h ./lattice.c

t_dwf_cg: $(TOP)/dwf.o $(TOP)/sse-dwf-cg.h  t_dwf_cg.o
	$(CC) $(CFLAGS) -I. -o $@ t_dwf_cg.o $(TOP)/dwf.o $(LDFLAGS) $(LIBS)

$(TOP)/dwf.o $(TOP)/sse-dwf-cg.h:
	make -C$(TOP) compile

