# CHARMM 26 makefile for GNU compilers (Linux or elsewhere)
ROOT = rootdir
SRC = $(ROOT)/source
FLX = $(ROOT)/tool/preflx
GMS = $(ROOT)/tool/gmscomp_g95
LIB = $(ROOT)/lib/g95
EXEC = $(ROOT)/exec/g95
CC = gcc -Dnographics -Dnographics -O -Dgnu -DLINUX $(I8DUM2)
# Note that CC on line 8 and GLIB on line 10, sorry
GLIB =  
CPP = /bin/cat
CCPP = g++ -Dgnu
INCLUDE = 
ADDLIB = 
ADDLIB := $(ADDLIB) $(GLIB)
QLIB =
ENDIAN =

ifdef MBOND
#  Which compiler is this for??? (mfc)
  MBONDFLG = -fno-automatic -finit-local-zero -O -Wall -Wsurprising -W -DCHARMM
  INCLUDE = -I../../source/moldyn
endif

# options for compilation with APBS
ifdef APBS
# these must be defined: APBS_LIB, IAPBS_LIB and APBS_BLAS
ADDLIB := $(ADDLIB) $(IAPBS_LIB)/iapbs.a \
        -L$(APBS_LIB) -lapbsmainroutines -lapbs -lmaloc $(APBS_BLAS)
endif

RANLIB = ranlib
.SUFFIXES: .fcm .src .o
VPATH = fcm

FC = g95
LD = g95

FC := $(FC) $(INCLUDE)


FC0 = $(FC) -c -O0
FC1 = $(FC) -c -O1
FC2 = $(FC) -c -O2
FC3 = $(FC) -c -O3
FCR = $(FC) -c -g 
FCD = $(FC) -c -g -O0 
FCRD = $(FC) -c -g -V -O0 

ifdef DEBUG
  FC0 = $(FCD)
  FC1 = $(FCD)
  FC2 = $(FCD)
  FC3 = $(FCD)
  LD  = g95 -g
endif

OBJS = \
        $(LIB)/charmm_main.o \
        $(LIB)/help.o \
        $(LIB)/iniall.o \
        $(LIB)/miscom.o \
        $(LIB)/usersb.o
LIBS = \
	$(LIB)/adumb.a \
	$(LIB)/cadint.a \
	$(LIB)/cff.a \
	$(LIB)/correl.a \
	$(LIB)/dimb.a \
	$(LIB)/dynamc.a \
	$(LIB)/energy.a \
	$(LIB)/gamint.a \
	$(LIB)/gukint.a \
	$(LIB)/gener.a \
	$(LIB)/graphics.a \
	$(LIB)/image.a \
	$(LIB)/io.a \
	$(LIB)/machdep.a \
	$(LIB)/manip.a \
	$(LIB)/mbond.a \
	$(LIB)/mc.a \
	$(LIB)/minmiz.a \
	$(LIB)/misc.a \
	$(LIB)/mmff.a \
	$(LIB)/moldyn.a \
	$(LIB)/molvib.a \
	$(LIB)/nbonds.a \
	$(LIB)/pert.a \
	$(LIB)/quantum.a \
	$(LIB)/rxncor.a \
	$(LIB)/shapes.a \
	$(LIB)/solvation.a \
	$(LIB)/util.a \
	$(LIB)/vibran.a

$(EXEC)/charmm : $(LIBS) $(OBJS)
	$(LD) -o charmm.exe $(LIB)/*.o $(LIBS) $(LIBS) $(LIBS) $(ADDLIB) $(QLIB) $(MSGLIB)
