Rules.make.template 3.41 KB
Newer Older
dumoda01's avatar
dumoda01 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#$Id: Rules.make,v 1.17 2006-10-26 13:12:46 kbk Exp $

SHELL   = /bin/sh

# The compilation mode is obtained from $COMPILATION_MODE - 
# default production - else debug or profiling
ifndef COMPILATION_MODE
compilation=production
else
compilation=$(COMPILATION_MODE)
endif

# Force this here. Could be done in bashrc.
#FORTRAN_COMPILER=PGF90
dumoda01's avatar
dumoda01 committed
15 16
#FORTRAN_COMPILER=GFORTRAN
FORTRAN_COMPILER=IFORT
dumoda01's avatar
dumoda01 committed
17 18 19 20 21

DEFINES=-DNUDGE_VEL
DEFINES=-D$(FORTRAN_COMPILER)

# What do we include in this compilation
dumoda01's avatar
dumoda01 committed
22 23 24 25 26 27 28 29 30 31
NetCDF   = true
SEDIMENT = false
SEAGRASS = false
BIO      = true

FEATURES     =
FEATURE_LIBS =
EXTRA_LIBS   =
INCDIRS	     =
LDFLAGS	     =
dumoda01's avatar
dumoda01 committed
32 33

# If we want NetCDF - where are the include files and the library
dumoda01's avatar
dumoda01 committed
34 35
NETCDFINC    = /usr/local/include 
NETCDFLIBDIR = /usr/local/lib
dumoda01's avatar
dumoda01 committed
36 37

ifdef NETCDFINC
dumoda01's avatar
dumoda01 committed
38
INCDIRS     += -I$(NETCDFINC)
dumoda01's avatar
dumoda01 committed
39 40
endif
ifdef NETCDFLIBNAME
dumoda01's avatar
dumoda01 committed
41
NETCDFLIB    = $(NETCDFLIBNAME)
dumoda01's avatar
dumoda01 committed
42
else
dumoda01's avatar
dumoda01 committed
43
NETCDFLIB    = -lnetcdf
dumoda01's avatar
dumoda01 committed
44 45
endif
ifdef NETCDFLIBDIR
dumoda01's avatar
dumoda01 committed
46
LDFLAGS     += -L$(NETCDFLIBDIR)
dumoda01's avatar
dumoda01 committed
47 48 49 50 51 52 53
endif

# phony targets
.PHONY: clean realclean distclean dummy

# Top of this version of GOTM.
ifndef GOTMDIR
dumoda01's avatar
dumoda01 committed
54
GOTMDIR := $(HOME)/gotm_ismer
dumoda01's avatar
dumoda01 committed
55 56
endif

dumoda01's avatar
dumoda01 committed
57
CPP	 = /usr/bin/cpp
dumoda01's avatar
dumoda01 committed
58 59 60 61

# Here you can put defines for the [c|f]pp - some will also be set depending
# on compilation mode.
ifeq ($(NetCDF),true)
dumoda01's avatar
dumoda01 committed
62 63
DEFINES      += -DNETCDF_FMT
EXTRA_LIBS   += $(NETCDFLIB)
dumoda01's avatar
dumoda01 committed
64 65
endif
ifeq ($(SEDIMENT),true)
dumoda01's avatar
dumoda01 committed
66 67
DEFINES      += -DSEDIMENT
FEATURES     +=  extras/sediment
dumoda01's avatar
dumoda01 committed
68 69 70
FEATURE_LIBS += -lsediment$(buildtype)
endif
ifeq ($(SEAGRASS),true)
dumoda01's avatar
dumoda01 committed
71 72
DEFINES      += -DSEAGRASS
FEATURES     +=  extras/seagrass
dumoda01's avatar
dumoda01 committed
73 74 75
FEATURE_LIBS += -lseagrass$(buildtype)
endif
ifeq ($(BIO),true)
dumoda01's avatar
dumoda01 committed
76 77
DEFINES      += -DBIO
FEATURES     +=  extras/bio
dumoda01's avatar
dumoda01 committed
78 79 80 81 82 83 84 85 86 87
FEATURE_LIBS += -lbio$(buildtype)
endif

# Directory related settings.

ifndef BINDIR
BINDIR	= $(GOTMDIR)/bin
endif

ifndef LIBDIR
dumoda01's avatar
dumoda01 committed
88
LIBDIR += $(GOTMDIR)/lib/$(FORTRAN_COMPILER)
dumoda01's avatar
dumoda01 committed
89 90 91 92 93 94
endif

ifndef MODDIR
#MODDIR	= $(GOTMDIR)/modules
MODDIR	= $(GOTMDIR)/modules/$(FORTRAN_COMPILER)
endif
dumoda01's avatar
dumoda01 committed
95
INCDIRS	+= -I/usr/local/include -I$(GOTMDIR)/include -I$(MODDIR)
dumoda01's avatar
dumoda01 committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

# Normaly this should not be changed - unless you want something very specific.

# The Fortran compiler is determined from the EV FORTRAN_COMPILER - options 
# sofar NAG(linux), FUJITSU(Linux), DECF90 (OSF1 and likely Linux on alpha),
# SunOS, PGF90 - Portland Group Fortran Compiler (on Intel Linux).

# Sets options for debug compilation
ifeq ($(compilation),debug)
buildtype = _debug
DEFINES += -DDEBUG $(STATIC)
FLAGS   = $(DEBUG_FLAGS) 
endif

# Sets options for profiling compilation
ifeq ($(compilation),profiling)
buildtype = _prof
DEFINES += -DPROFILING $(STATIC)
FLAGS   = $(PROF_FLAGS) 
endif

# Sets options for production compilation
ifeq ($(compilation),production)
buildtype = _prod
DEFINES += -DPRODUCTION $(STATIC)
FLAGS   = $(PROD_FLAGS) 
endif

include $(GOTMDIR)/compilers/compiler.$(FORTRAN_COMPILER)

#DEFINES += -DREAL_4B=$(REAL_4B)
#ifeq ($(FORTRAN_COMPILER),XLF)
#DEFINES:=-WF,"$(DEFINES)"
#DEFINES=-WF,"-DXLF -DNETCDF_FMT -DSEAGRASS -DFORTRAN95 -DPRODUCTION -DREAL_4B=real\(4\)"
#endif

# For making the source code documentation.
PROTEX	= protex -b -n -s

.SUFFIXES:
.SUFFIXES: .F90

LINKDIR	= -L$(LIBDIR)

CPPFLAGS	= $(DEFINES) $(INCDIRS)
FFLAGS  	= $(DEFINES) $(FLAGS) $(MODULES) $(INCDIRS) $(EXTRAS)
F90FLAGS  	= $(FFLAGS)
LDFLAGS		+= $(FFLAGS) $(LINKDIR)

#
# Common rules
#
ifeq  ($(can_do_F90),true)
%.o: %.F90
	$(FC) $(F90FLAGS) $(EXTRA_FFLAGS) -c $< -o $@
else
%.f90: %.F90
#	$(CPP) $(CPPFLAGS) $< -o $@
	$(F90_to_f90)
%.o: %.f90
	$(FC) $(F90FLAGS) $(EXTRA_FFLAGS) -c $< -o $@
endif