-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile.sample_cap
165 lines (135 loc) · 5.67 KB
/
makefile.sample_cap
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
# 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)
include makefile.model
CAP_OBJS := sample_cap.o
CAP_LIB := libsample_cap.a
CAP_MK := sample_cap.mk
CAP_DEP_FRONT := sample_cap_mod
CAP_MODS := sample_cap_mod.mod
CAP_VERS := version
ifeq ($(DEBUG),on)
ESMF_F90COMPILEOPTS += -g -traceback
ESMF_CXXCOMPILEOPTS += -g -traceback
ESMF_F90COMPILECPPFLAGS += -DDEBUG
ESMF_CXXCOMPILECPPFLAGS += -DDEBUG
endif
################################################################################
################################################################################
# -----------------------------------------------------------------------------
# Compiler Arguments
# -----------------------------------------------------------------------------
.SUFFIXES: .f90 .F90 .c .C
%.o : %.f90
@echo $(HR)
@echo "Compiling $@"
$(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) $(ESMF_F90COMPILEFREENOCPP) $<
%.o : %.F90
@echo $(HR)
@echo "Compiling $@"
$(ESMF_F90COMPILER) -c $(ESMF_F90COMPILEOPTS) $(ESMF_F90COMPILEPATHS) $(ESMF_F90COMPILEFREECPP) $(ESMF_F90COMPILECPPFLAGS) -DESMF_VERSION_MAJOR=$(ESMF_VERSION_MAJOR) $<
%.o : %.c
@echo $(HR)
@echo "Compiling $@"
$(ESMF_CXXCOMPILER) -c $(ESMF_CXXCOMPILEOPTS) $(ESMF_CXXCOMPILEPATHSLOCAL) $(ESMF_CXXCOMPILEPATHS) $(ESMF_CXXCOMPILECPPFLAGS) $<
%.o : %.C
@echo $(HR)
@echo "Compiling $@"
$(ESMF_CXXCOMPILER) -c $(ESMF_CXXCOMPILEOPTS) $(ESMF_CXXCOMPILEPATHSLOCAL) $(ESMF_CXXCOMPILEPATHS) $(ESMF_CXXCOMPILECPPFLAGS) $<
# -----------------------------------------------------------------------------
# Build Targets
# -----------------------------------------------------------------------------
nuopc: $(CAP_LIB) nuopcinstall
$(CAP_LIB): $(CAP_OBJS) $(MODEL_LIB)
@echo $(HR)
@echo "Building NUOPC Cap Library"
ar cruT $@ $^
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
$(CAP_OBJS): $(MODEL_LIB) $(MODEL_MODS)
# -----------------------------------------------------------------------------
# Install Library, Modules, and Makefile Fragment
# -----------------------------------------------------------------------------
ifndef DESTDIR
DESTDIR := $(DIR)
endif
ifdef INSTDIR
INSTPATH = $(abspath $(DESTDIR)/$(INSTDIR))
else
INSTPATH = $(abspath $(DESTDIR))
endif
nuopcinstall: $(INSTPATH) \
$(addprefix $(INSTPATH)/,$(CAP_MODS)) \
$(addprefix $(INSTPATH)/,$(CAP_LIB)) \
$(addprefix $(INSTPATH)/,$(CAP_MK)) \
$(addprefix $(INSTPATH)/,$(CAP_VERS))
$(INSTPATH):
@echo $(HR)
@echo "Creating Installation Directory $@"
@mkdir -p $(INSTPATH)
$(addprefix $(INSTPATH)/,$(CAP_MODS)): $(CAP_MODS)
@echo $(HR)
@echo "Installing Module Files"
@cp $(CAP_MODS) $(INSTPATH)
$(addprefix $(INSTPATH)/,$(CAP_LIB)): $(CAP_LIB)
@echo $(HR)
@echo "Installing Library File"
@cp $(CAP_LIB) $(INSTPATH)
$(addprefix $(INSTPATH)/,$(CAP_MK)):
@echo $(HR)
@echo "Generating NUOPC Makefile Fragment"
@echo "# ESMF self-describing build dependency makefile fragment" > $@
@echo "" >> $@
@echo "ESMF_DEP_FRONT = $(CAP_DEP_FRONT)" >> $@
@echo "ESMF_DEP_INCPATH = $(INSTPATH)" >> $@
@echo "ESMF_DEP_CMPL_OBJS = " >> $@
@echo "ESMF_DEP_LINK_OBJS = $(INSTPATH)/$(CAP_LIB)" >> $@
@echo "ESMF_DEP_SHRD_PATH = " >> $@
@echo "ESMF_DEP_SHRD_LIBS = " >> $@
@echo $(HR)
$(addprefix $(INSTPATH)/,$(CAP_VERS)):
@echo "Generating Version Information"
@echo "# NUOPC Cap Version" > $@
@if [ -d .svn ]; then \
echo "SVN Repository" > $@; \
svn info . | grep URL >> $@; \
svn info . | grep "Last Changed Rev" >> $@; \
fi
@if [ -d .git ]; then \
echo "Git Repository" > $@; \
git show . | grep -m 1 "commit " >> $@; \
git show . | grep -m 1 "Author: " >> $@; \
git show . | grep -m 1 "Date: " >> $@; \
fi
# -----------------------------------------------------------------------------
# Clean Targets
# -----------------------------------------------------------------------------
.PHONY: nuopcclean
nuopcclean: clean
@echo $(HR)
@echo "Removing NUOPC Files"
rm -f $(CAP_LIB) $(CAP_OBJS) $(CAP_MODS) $(CAP_MK) $(CAP_VERS)