#
# 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   = -c -I$(INCPATH) -fno-second-underscore
LDFLAGS  = -L$(LIBPATH) -L/usr/X11R6/lib64
TARGET   = direct_$(GARCH)

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

all:	$(TARGET)

direct_$(GARCH):	direct.o $(LIBPATH)/lib$(GARCH)5.a $(HIBLIB)
			$(FC) $(LDFLAGS) -o $@ direct.o -l$(GARCH)5 $(LINKHIB) -lm

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

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

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