-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile.app
174 lines (147 loc) · 6.77 KB
/
makefile.app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# GNU Makefile template for user ESMF application
################################################################################
################################################################################
## This Makefile must be able to find the "esmf.mk" Makefile fragment in the ##
## 'include' line below. Following the ESMF User's Guide, a complete ESMF ##
## installation should ensure that a single environment variable "ESMFMKFILE" ##
## is made available on the system. This variable should point to the ##
## "esmf.mk" file. ##
## ##
## This example Makefile uses the "ESMFMKFILE" environment variable. ##
## ##
## If you notice that this Makefile cannot find variable ESMFMKFILE then ##
## please contact the person responsible for the ESMF installation on your ##
## system. ##
## As a work-around you can simply hardcode the path to "esmf.mk" in the ##
## include line below. However, doing so will render this Makefile a lot less ##
## flexible and non-portable. ##
################################################################################
HR := ========================================
HR := $(HR)$(HR)
COMMA := ,
DIR := $(CURDIR)
ifneq ($(origin ESMFMKFILE), environment)
$(error Environment variable ESMFMKFILE was not set.)
endif
include $(ESMFMKFILE)
DRIVER_OBJS := sample_driver.o
DRIVER_MODS := sample_driver_mod.mod
APP_OBJS := sample_app.o
APP_EXE := sample_app.exe
ifeq ($(DEBUG),on)
ESMF_F90COMPILEOPTS += -g -traceback
ESMF_CXXCOMPILEOPTS += -g -traceback
ESMF_F90COMPILECPPFLAGS += -DDEBUG
ESMF_CXXCOMPILECPPFLAGS += -DDEBUG
endif
# -----------------------------------------------------------------------------
# Makefile fragments
# -----------------------------------------------------------------------------
DEP_FRONTS :=
DEP_INCS :=
DEP_CMPL_OBJS :=
DEP_LINK_OBJS :=
DEP_SHRD_PATH :=
DEP_SHRD_LIBS :=
ifdef COMP1_MK
include $(COMP1_MK)
DEP_FRONTS += -DCOMP1_MOD=$(ESMF_DEP_FRONT)
DEP_INCS += $(addprefix -I, $(ESMF_DEP_INCPATH))
DEP_CMPL_OBJS += $(ESMF_DEP_CMPL_OBJS)
DEP_LINK_OBJS += $(ESMF_DEP_LINK_OBJS)
DEP_SHRD_PATH += $(addprefix -L, $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_PATH += $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_LIBS += $(addprefix -l, $(ESMF_DEP_SHRD_LIBS))
endif
ifdef COMP2_MK
include $(COMP2_MK)
DEP_FRONTS += -DCOMP2_MOD=$(ESMF_DEP_FRONT)
DEP_INCS += $(addprefix -I, $(ESMF_DEP_INCPATH))
DEP_CMPL_OBJS += $(ESMF_DEP_CMPL_OBJS)
DEP_LINK_OBJS += $(ESMF_DEP_LINK_OBJS)
DEP_SHRD_PATH += $(addprefix -L, $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_PATH += $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_LIBS += $(addprefix -l, $(ESMF_DEP_SHRD_LIBS))
endif
ifdef COMP3_MK
include $(COMP3_MK)
DEP_FRONTS += -DCOMP3_MOD=$(ESMF_DEP_FRONT)
DEP_INCS += $(addprefix -I, $(ESMF_DEP_INCPATH))
DEP_CMPL_OBJS += $(ESMF_DEP_CMPL_OBJS)
DEP_LINK_OBJS += $(ESMF_DEP_LINK_OBJS)
DEP_SHRD_PATH += $(addprefix -L, $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_PATH += $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_LIBS += $(addprefix -l, $(ESMF_DEP_SHRD_LIBS))
endif
ifdef COMP4_MK
include $(COMP4_MK)
DEP_FRONTS += -DCOMP4_MOD=$(ESMF_DEP_FRONT)
DEP_INCS += $(addprefix -I, $(ESMF_DEP_INCPATH))
DEP_CMPL_OBJS += $(ESMF_DEP_CMPL_OBJS)
DEP_LINK_OBJS += $(ESMF_DEP_LINK_OBJS)
DEP_SHRD_PATH += $(addprefix -L, $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_PATH += $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_LIBS += $(addprefix -l, $(ESMF_DEP_SHRD_LIBS))
endif
ifdef COMP5_MK
include $(COMP5_MK)
DEP_FRONTS += -DCOMP5_MOD=$(ESMF_DEP_FRONT)
DEP_INCS += $(addprefix -I, $(ESMF_DEP_INCPATH))
DEP_CMPL_OBJS += $(ESMF_DEP_CMPL_OBJS)
DEP_LINK_OBJS += $(ESMF_DEP_LINK_OBJS)
DEP_SHRD_PATH += $(addprefix -L, $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_PATH += $(addprefix -Wl$(COMMA)-rpath$(COMMA), $(ESMF_DEP_SHRD_PATH))
DEP_SHRD_LIBS += $(addprefix -l, $(ESMF_DEP_SHRD_LIBS))
endif
################################################################################
################################################################################
# -----------------------------------------------------------------------------
# Compiler Arguments
# -----------------------------------------------------------------------------
.SUFFIXES: .f90 .F90 .c .C
%.o : %.f90
@echo $(HR)
@echo "Compiling $@"
$(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) $(DEP_FRONTS) $(DEP_INCS) $(ESMF_F90COMPILEFREENOCPP) $<
%.o : %.F90
@echo $(HR)
@echo "Compiling $@"
$(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) $(DEP_FRONTS) $(DEP_INCS) $(ESMF_F90COMPILEFREECPP) $(ESMF_F90COMPILECPPFLAGS) -DESMF_VERSION_MAJOR=$(ESMF_VERSION_MAJOR) $<
%.o : %.c
@echo $(HR)
@echo "Compiling $@"
$(ESMF_CXXCOMPILER) -c $(ESMF_CXXCOMPILEOPTS) $(ESMF_CXXCOMPILEPATHSLOCAL) $(DEP_FRONTS) $(DEP_INCS) $(ESMF_CXXCOMPILEPATHS) $(ESMF_CXXCOMPILECPPFLAGS) $<
%.o : %.C
@echo $(HR)
@echo "Compiling $@"
$(ESMF_CXXCOMPILER) -c $(ESMF_CXXCOMPILEOPTS) $(ESMF_CXXCOMPILEPATHSLOCAL) $(DEP_FRONTS) $(DEP_INCS) $(ESMF_CXXCOMPILEPATHS) $(ESMF_CXXCOMPILECPPFLAGS) $<
# -----------------------------------------------------------------------------
# Build Targets
# -----------------------------------------------------------------------------
all: $(APP_EXE)
$(APP_EXE): $(APP_OBJS) $(DRIVER_OBJS) $(DEP_LINK_OBJS)
@echo $(HR)
@echo "Building Executable"
$(ESMF_F90LINKER) $(ESMF_F90LINKOPTS) -o $@ $^ $(ESMF_F90LINKPATHS) $(ESMF_F90LINKRPATHS) $(DEP_SHRD_PATH) $(DEP_SHRD_LIBS) $(ESMF_F90ESMFLINKLIBS)
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
$(APP_OBJS): $(DRIVER_OBJS)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
.PHONY: dust clean distclean info
dust:
@echo $(HR)
@echo "Removing Output Files"
rm -f PET*.ESMF_LogFile *.nc out err core
clean:
@echo $(HR)
@echo "Removing Application Files "
rm -f $(APP_EXE) $(APP_OBJS) $(APP_MODS) $(DRIVER_OBJS) $(DRIVER_MODS)
distclean: dust clean
info:
@echo ==================================================================
@echo ESMFMKFILE=$(ESMFMKFILE)
@echo ==================================================================
@cat $(ESMFMKFILE)
@echo ==================================================================