#  Makefile for the hybrid molecular dynamics simulation with
#  pure gauge SU3
#  MIMD version 3
#

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

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"'
# The quotation marks are necessary, as is the "../pure_gauge", since
# some compilations will be done in another directory

# Choose one of the lattice layout algorithms:

OBJECTS=control.o updategauge.o relax.o monte.o measure.o \
	setup.o setup_basic.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 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_intelsim.o 
#MACHINE_DEP = com_intel.o
MACHINE_DEP = com_vanilla.o

#Library for multinode communication and information functions
#ILIB= /usr/local/lib/bsimlib.a		#preon.physics.arizona.edu
#ILIB= -node		#Intel machine
ILIB=                #vanilla

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

#CFLAGS= -g -f $(INCLDIR) -DPROTO	#MIPS
#CFLAGS= -g -fsingle $(INCLDIR) 	#Sun
CFLAGS= -O4 -DPROTO $(INCLDIR) $(LATDEF)   #gnu c compiler
#CFLAGS = -non_shared -O4 -std1 -arch ev6 -DFAST -DPROTO $(INCLDIR) $(LATDEF) -float	#Dec alpha compiler
#CFLAGS =  -O4 -std1 -arch ev6 -DFAST -DPROTO $(INCLDIR) -float	#Dec alpha compiler
#CFLAGS =  -O4 -std1 -DFAST -DPROTO $(INCLDIR) -float	#Dec alpha compiler
#CFLAGS = -O  -DFAST -DPROTO $(INCLDIR) 	#Dec alpha compiler
#CFLAGS = -g -Wall -DFAST -DPROTO $(INCLDIR) 	#Dec alpha compiler

COMPILER = cc	#generic, for simulator
#COMPILER = gcc	#Intel Green Hills compiler (SDSC only)
#COMPILER = icc	#Intel pgcc

DEFINES = -DCAN_DO_ALLOCA    # can do alloca


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

$(OBJECTS) $(EXTRA_OBJECTS) : $(HEADERS)
su3_ahiggs::
	make -f Make_vanilla target "TARGET= su3_ahiggs" \
	"DEFINES= -DHIGGS -DSSE_INLINE" "EXTRA_OBJECTS= $(HOBJECTS)"

su3_gauge::
	make -f Make_vanilla target "TARGET= su3_gauge" \
	"DEFINES= " "EXTRA_OBJECTS= setcouplings_gauge.o"

su3_4d::
	make -f Make_vanilla target "TARGET= su3_4d" \
	"DEFINES= -DDIMENSION=4 -DP4 -DSSE -DSSE_INLINE" \
	"EXTRA_OBJECTS= setcouplings_gauge.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 
com_vanilla.o: ../generic/com_vanilla.c $(HEADERS)
	$(COMPILER) $(CFLAGS) -c $(LATDEF) $(DEFINES) ../generic/com_vanilla.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 $(TARGET) $(DEFINES) \
        $(OBJECTS) $(MACHINE_DEP) $(EXTRA_OBJECTS) $(QCDLIB) $(ILIB) -lm



