include ../Makefile.defs

# MPI C compiler
# MPI_CC = mpcc_r       #IBM RS6000

#Where the complex and su3 libraries are
LIBDIR = ../libraries
GENERIC = ../generic
INCLDIR = -I$(GENERIC) -I$(LIBDIR)

HEADERS= $(LIBDIR)/complex.h $(LIBDIR)/su3.h $(GENERIC)/comdefs.h $(GENERIC)/generic.h $(GENERIC)/generic_su3.h lattice.h 

# include file defining site structure, etc., for compiling generic code */
LATDEF =  -DLATDEF='"../su3h_n/lattice.h"'

OBJECTS=control.o updategauge.o relax.o monte.o measure.o \
	setup.o setup_basic.o timers.o \
        reunitarize.o staples_su3.o \
	layout.o io_lattice.o \
	mersenne_inline.o parameter_io.o timecheck.o \
	random_su3P.o 
# check_unitarity.o   is not used
# correlation.o 

HOBJECTS=updatehiggs.o Xoverrelax.o Goverrelax.o HBHiggs.o adjmat_operations.o \
	setcouplings_higgs.o \
        multican.o smooth_field_su3adjoint.o block_field_su3adjoint.o \
	block_lattice.o correlation.o smooth_link_su3.o block_link_su3.o \
	gaussian_ran.o

MACHINE_DEP = com_mpi.o

#Libraries for complex numbers and su3 functions
QCDLIB = $(LIBDIR)/su3.a $(LIBDIR)/complex.a 

#PABS -DHIGGS added
CFLAGS += -DMPI -DFAST $(INCLDIR) $(LATDEF) -DTIMERS -DHIGGS

COMPILER = $(MPI_CC)

.SUFFIXES:
.SUFFIXES: .o .t3e .c .y .l .s

.c.o:
	$(COMPILER) $(CFLAGS) -c  $(DEFINES) $*.c 
.s.o:
	$(COMPILER) $(CFLAGS) -c  $(DEFINES) $*.s

$(OBJECTS) $(EXTRA_OBJECTS) : $(HEADERS)

su3_ahiggs::
	$(MAKE) target "MYTARGET= su3_ahiggs" \
	"DEFINES= -DHIGGS" "EXTRA_OBJECTS= $(HOBJECTS)"

su3_gauge::
	$(MAKE) target "MYTARGET= su3_gauge" \
	"EXTRA_OBJECTS= setcouplings_gauge.o"

su3_4d::
	$(MAKE) target "MYTARGET= su3_4d" \
	"DEFINES= -DDIMENSION=4" \
	"EXTRA_OBJECTS= setcouplings_gauge.o ploop.o"

clean:
	$(RM) -f *.o

# Choose one of the lattice layout algorithms:
layout.o: ../generic/layout.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/layout.c 
reunitarize.o: ../generic/reunitarize.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/reunitarize.c 
timers.o: ../generic/timers.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/timers.c
com_mpi.o: ../generic/com_mpi.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/com_mpi.c
mersenne_inline.o: ../generic/mersenne_inline.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/mersenne_inline.c
setup_basic.o: ../generic/setup_basic.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/setup_basic.c
staples_su3.o: ../generic/staples_su3.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/staples_su3.c
random_su3P.o: ../generic/random_su3P.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/random_su3P.c
parameter_io.o: ../generic/parameter_io.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/parameter_io.c
timecheck.o: ../generic/timecheck.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/timecheck.c

gaussian_ran.o: ../generic/gaussian_ran.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/gaussian_ran.c

block_lattice.o: ../generic/block_lattice.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/block_lattice.c
smooth_field_su3adjoint.o: ../generic/smooth_field_su3adjoint.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/smooth_field_su3adjoint.c
smooth_link_su3.o: ../generic/smooth_link_su3.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/smooth_link_su3.c
block_field_su3adjoint.o: ../generic/block_field_su3adjoint.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/block_field_su3adjoint.c
block_link_su3.o: ../generic/block_link_su3.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/block_link_su3.c

target: $(OBJECTS) $(MACHINE_DEP) $(EXTRA_OBJECTS) $(QCDLIB)
	$(COMPILER) $(CFLAGS) -o $(MYTARGET) $(DEFINES) \
        $(OBJECTS) $(MACHINE_DEP) $(EXTRA_OBJECTS) $(QCDLIB) $(LDFLAGS)

kernel-objects: $(OBJECTS) $(MACHINE_DEP) $(HOBJECTS) $(QCDLIB) 
		echo "mache kernel_B"