#
# This is a makefile for GRAPE-DR.
# For other architectures, set GARCH and HIB as follows:
#
#          GRAPE-DR   GRAPE-7   GRAPE-6BX     GRAPE-6A   Phantom-GRAPE-5
# GARCH    gdr        g7        g6bx          g6a        pg5
# HIB      hib        hib       g6bxhib       -          -
#
# For GRAPE-DR, GRAPE-7 and GRAPE-6BX, set HIBLIB
# and LINKHIB as follows:
#   HIBLIB   = $(LIBPATH)/lib$(HIB).a
#   LINKHIB  = -l$(HIB)
#
# For Phantom-GRAPE-5 with OpenMP enabled, set LDFLAGS and CFLAGS as follows:
#   LDFLAGS += -fopenmp
#   CFLAGS += -fopenmp
#
# For CUDA G5/G6, set LDFLAGS and CFLAGS as follows:
#   LDFLAGS += -L$(cudapath)/lib -lcudart
# Here, 'cudapath' and 'cudasdkpath' denotes the path which
# CUDA Toolkit and SDK are installed into.
# By default, numerical format 'double single' is used.
# For single-precision, use '-lcuda5s' instead of '-cuda5'.
#
# An architecuture-independent makefile can be found at Makefile.generic.
#

GARCH    = gdr
HIB      = hib
INCPATH  = ../../include
LIBPATH  = ../../lib
FC       = gfortran
FFLAGS   = -O3 -c -I$(INCPATH) -fno-second-underscore
LDFLAGS  = -L$(LIBPATH) -L/usr/X11R6/lib64
TARGET   = s8f_$(GARCH)
OBJECT   = sticky8.o cpu.o lagrad.o

HIBLIB   = $(LIBPATH)/lib$(HIB).a
LINKHIB  = -l$(HIB)

all:	$(TARGET)

s8f_$(GARCH):	$(OBJECT) $(LIBPATH)/lib$(GARCH)6.a $(HIBLIB)
		$(FC) $(LDFLAGS) $(OBJECT) -o $@ -l$(GARCH)6 $(LINKHIB) -lm

sticky8.o:	sticky8.F
		$(FC) $(FFLAGS) -o $@ sticky8.F

clean:
		-rm *.o $(TARGET) s8f_*

bak:
	-tar cvfz sticky8.tar.gz ./*.[hcCfF] ./*.pl ./*.csh ./*.awk
