include Makefile.defs

#defines
TARGETDIR=.
DEBUG=0

ifeq ($(DEBUG),1) 
DEFINES+= -DDEBUG -g
endif

default: bench

#GENERIC
VPATH= libraries/ arch_mpi/ include/
ARCHDIR=arch_mpi/
#CC		= mpicc
#LD		= mpicc
#CFLAGS = $(DEFINES) -O2 -DARCH=0 -I./include  
#LDFLAGS = -lm
.c.o:
	$(CC) $(CFLAGS) $< -c -o $(patsubst %.c,%.o,$<)



#top level headers
HEADER =		\
	config.h 	\
	complex.h 	\
	su3.h 		\
	macros.h 	\
	machine.h 	\
	comdefs.h 	\
	generic.h 	\
	generic_wilson.h \
	io_lat.h 	\
	includes.h 	\
	lattice.h




#top level sources
SOURCE:=	     	\
	control.c       \
	setup.c         \
	io_helpers.c    \
	check_unitarity.c \
	d_plaq4.c       \
	make_lattice.c  \
	fermion_stuff.c \
	mt19937-64.c	\
	random.c	\
	mult_fmat.c	\
	congrad.c	

#subdir sources and headers
include libraries/module.mk
include $(ARCHDIR)/module.mk


OBJECT:=                        \
	$(patsubst %.c,%.o,$(filter %.c,$(SOURCE)))     \
	$(patsubst %.asm,%.o,$(filter %.asm,$(SOURCE))) \
	$(patsubst %.f,%.o,$(filter %.f,$(SOURCE)))

$(OBJECT): $(HEADER) Makefile

#targets
bench: $(OBJECT)
	$(LD) -o $(TARGETDIR)/$@ $(OBJECT) $(ARPACK) $(LDFLAGS)

kernel: $(OBJECT)
	$(AR) $(ARFLAGS) ../kernel_E.a $(OBJECT)

clean:
	rm -f ./*.o ./*.a ./*/*.o ./*~ ./*/*~ bench ../kernel_E.a
