srcdir = .
top_srcdir = .
abs_top_srcdir = /home/jacob/Job/Prace/kernel_D_soft/kernel_D_update2
top_builddir =  .
abs_top_builddir = /home/jacob/Job/Prace/kernel_D_soft/kernel_D_update2
builddir = .
prefix = /home/jacob
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
program_transform_name = s,x,x,
subdir = .

AR = ar
RANLIB = ranlib
CC = mpicc
CCDEP = gcc
CFLAGS = -std=c99 -fopenmp  -pedantic -Wall
LDFLAGS =  -L${HOME}/lib -L${top_builddir}/lib 
DEPFLAGS = -MM
CPPFLAGS =  
CCLD = mpicc
LEX = flex
AUTOCONF = autoconf
LIBS = -loperator -linit -llinalg /usr/lib/lapack/liblapack.so.3 /usr/lib/libblas.so.3 /usr/lib/x86_64-linux-gnu/libgomp.so.1  -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lgfortran -lm -lquadmath -lm
SHELL = /bin/bash
OPTARGS = -O
SOPTARGS = -O
DEFS = -DHAVE_CONFIG_H
GPUDIR = 
USESUBDIRS = operator linalg
NVCC = 
GPUMPICOMPILER = 

INCLUDES =  -I$(HOME)/include/ -I. -I${abs_top_builddir}/  -I${abs_top_srcdir}/ -I/include/ -I/include/
LINK = $(CCLD) -o $@ ${LDFLAGS}

COMPILE = ${CC} ${DEFS} ${INCLUDES} -o $@ ${CFLAGS}

SMODULES = 

MODULES = read_input gamma measure_gauge_action start \
	expo matrix_utils get_staples update_backward_gauge \
	measure_rectangles get_rectangle_staples  \
	test/check_geometry test/check_xchange \
	test/overlaptests \
	invert_eo invert_doublet_eo update_gauge \
	getopt sighandler reweighting_factor \
	source_generation boundary update_tm ranlxd  \
	mpi_init deriv_Sb deriv_Sb_D_psi ranlxs \
	geometry_eo invert_overlap aligned_malloc \
	prepare_source chebyshev_polynomial_nd Ptilde_nd  \
	reweighting_factor_nd rnd_gauge_trafo \
	update_momenta integrator  phmc \
	little_D block operator \
	temporalgauge spinor_fft X_psi P_M_eta \
	jacobi fatal_error invert_clover_eo gettime  \
	

## the GPU modules (all .cu files in $GPUDIR)
GPUSOURCES := $(wildcard $(srcdir)/$(GPUDIR)/*.cu)
GPUOBJECTS := $(patsubst $(srcdir)/$(GPUDIR)/%.cu, $(GPUDIR)/%.o, $(GPUSOURCES))

#GPUSOURCES_C := $(wildcard $(srcdir)/$(GPUDIR)/*.c)
#GPUOBJECTS_C := $(patsubst $(srcdir)/$(GPUDIR)/%.c, $(GPUDIR)/%.o, $(GPUSOURCES_C))

NOOPTMOD = test/check_xchange test/check_geometry

PROGRAMS = benchmark

ALLOBJ = ${MODULES} ${PROGRAMS} ${SMODULES}
SUBDIRS = ${USESUBDIRS}

# delete the default suffix rules
.SUFFIXES:

# need to build modules before subdirs!
all: Makefile dep $(SUBDIRS) benchmark

$(SUBDIRS):
	$(MAKE) --directory=$@

# run the GIT-VERSION-GEN script to generate version information in git_hash.h
# making sure that we run in the correct directory
${top_srcdir}/git_hash.h:
	@ ( cd . && sh GIT-VERSION-GEN )

-include $(addsuffix .d,$(ALLOBJ))

include ${top_srcdir}/Makefile.global

${top_srcdir}/read_input.c: ${top_srcdir}/read_input.l
ifneq (,$(findstring lex,${LEX}))
	${LEX} -Ptmlqcd -i -t ${top_srcdir}/read_input.l > ${top_srcdir}/read_input.c
else
	$(error Unable to find (f)lex, read_input.c not built. Please install (f)lex!)
endif

$(addsuffix .o,$(filter-out ${NOOPTMOD},${MODULES})): %.o: ${srcdir}/%.c %.d Makefile $(abs_top_builddir)/config.h
	${COMPILE} ${OPTARGS} -c $<

#here we don't need optimisation
$(addsuffix .o,$(filter ${NOOPTMOD},${MODULES})): %.o: ${srcdir}/%.c %.d Makefile $(abs_top_builddir)/config.h
	${COMPILE} -c $<

${addsuffix .o, ${SMODULES}}: %.o: ${srcdir}/%.c %.d Makefile $(abs_top_builddir)/config.h
	${COMPILE} ${SOPTARGS} -c $<

${addsuffix .o, ${PROGRAMS}}: %.o: ${srcdir}/%.c %.d Makefile $(abs_top_builddir)/config.h ${top_srcdir}/git_hash.h
	${COMPILE} ${OPTARGS} -c $<

${PROGRAMS}: %: %.o $(SUBDIRS)
	 ${LINK} $@.o $(GPUOBJECTS) $(GPUOBJECTS_C) $(LIBS)

# The rules for unit tests are kept in a separate file for tidyness
include ${top_srcdir}/Makefile.tests

dep: $(addsuffix .d,$(ALLOBJ))
	@ echo "...dependency files built"

compile-clean: compile-clean-recursive Makefile
	rm -f *.o *.d test/*.o test/*.d tests/*.o tests/*.d

clean: clean-recursive Makefile
	rm -f benchmark *.o *.d test/*.o test/*.d tests/*.o tests/*.d

distclean: distclean-recursive Makefile
	rm -f benchmark *.o *.d *~ Makefile config.log config.status fixed_volume.h
	rm -f config.h

.PHONY: all ${SUBDIRS} ${top_srcdir}/git_hash.h clean compile-clean distclean dep install \
	all-recursive all-debug-recursive all-profile-recursive \
	clean-recursive distclean-recursive \
	compile-clean-recursive
