#
# Makefile
#
# test_nx

#NEXUS_DIR = /tmp_mnt/nfs/mcs-homes17/ludban/nexus4dalek
NEXUS_DIR = /tmp_mnt/nfs/ccst-homes9/ludban/nexus4quad-mpi

include $(NEXUS_DIR)/lib/makefile_header

MY_CFLAGS = -I$(includedir) $(ALL_CFLAGS) -g
MY_LDFLAGS = -L$(libdir) -lnexus$(nexus_flavor) $(ALL_LDFLAGS) $(ALL_LIBS)

HEADERS = report.h message.h testnode.h epdata.h big_test.h

#

all: big_test

#

test: random.o test_nx
	./test_nx -n

#

random_cfg.h:
	cd Random; \
	make test
#	$(PURIFY) $(LD) $(MY_CFLAGS) -o rand_config rand_config.c; \
#	./rand_config > random_cfg.h; \
#	$(PURIFY) $(LD) $(MY_CFLAGS) -o random_test random_test.c random.c; \
#	./random_test > test.out; \
#	diff good.out test.out

random.o:	random_cfg.h
	rm -f random.c random.h random_cfg.h
	ln -s Random/random.c random.c;
	ln -s Random/random.h random.h;
	ln -s Random/random_cfg.h random_cfg.h;
	$(CC) $(MY_CFLAGS) -c random.c

#

report.o:	report.h report.c
	$(CC) $(MY_CFLAGS) -c report.c

#

message_nx.o:	message.h message.c
	$(CC) $(MY_CFLAGS) -c message.c
	mv -f message.o message_nx.o

#

testnode.o:	testnode.h testnode.c
	$(CC) $(MY_CFLAGS) -c testnode.c

#

epdata.o:	$(HEADERS) epdata.c
	$(CC) $(MY_CFLAGS) -c epdata.c

#

handlers.o:	$(HEADERS) debug.h \
		handlers.h handlers.c
	$(CC) $(MY_CFLAGS) -c handlers.c

#

wrappers.o:	$(HEADERS) debug.h handlers.h \
		wrappers.h wrappers.c
	$(CC) $(MY_CFLAGS) -c wrappers.c

#

run_test.o:	$(HEADERS) gen_type.c gen_data.c wrappers.h \
			run_test.h run_test.c
	$(CC) $(MY_CFLAGS) -c run_test.c

#

remote.o:	remote.h remote.c
	$(CC) $(MY_CFLAGS) -c remote.c

#

matches.o:	matches.h matches.c
	$(CC) $(MY_CFLAGS) -c matches.c

group.o:	$(HEADERS) matches.h \
			group.h group.c
	$(CC) $(MY_CFLAGS) -c group.c

#

big_test.o:	$(HEADERS) message.h group.h \
		remote.h handlers.h wrappers.h \
		group.h big_test.c
	$(CC) $(MY_CFLAGS) -c big_test.c

#

big_test:	random.o report.o message_nx.o testnode.o \
		epdata.o run_test.o remote.o group.o handlers.o \
		matches.o wrappers.o big_test.o
	$(PURIFY) $(LD) random.o report.o message_nx.o testnode.o \
		epdata.o run_test.o remote.o group.o handlers.o \
		wrappers.o matches.o big_test.o \
		$(MY_LDFLAGS) -o big_test

#

clean:
	rm -f *.o random* *~

clean_dist:	clean
	rm -f random.o
	rm -f big_test
	cd Random; make clean
