-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile.template
264 lines (239 loc) · 9.89 KB
/
Makefile.template
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#.........................................................................
# VERSION "$Id: Makefile.template 1 2017-06-10 18:05:20Z coats $"
# EDSS/Models-3 I/O API Version 3.2.
#.........................................................................
# COPYRIGHT
# (C) 1992-2002 MCNC and Carlie J. Coats, Jr., and
# (C) 2003-2004 by Baron Advanced Meteorological Systems,
# (C) 2005-2014 Carlie J. Coats, Jr., and
# (C) 2014- UNC Institute for the Environment
# Distributed under the GNU Lesser PUBLIC LICENSE version 2.1
# See file "LGPL.txt" for conditions of use.
#.........................................................................
# Usage:
# Either edit this Makefile to un-comment the options you want, or
# override the options by environment or command-line variables.
# For example:
#
# setenv BIN Linux2_x86_64ifort
# setenv BASEDIR /wherever/I-ve/un-tarred/the/code
# setenv CPLMODE nocpl
# make
#
# or:
#
# make BIN=Linux2_x86_64pg CPLMODE=pncf INSTALL=/foo/bar
#
#.........................................................................
# Environment/Command-line Variables:
#
# BIN machine/OS/compiler/mode type. Shows up as suffix
# for "$(IODIR)/Makeinclude.$(BIN)" to determine compilation
# flags, and in $(OBJDIR) and $(INSTALL) to determine
# binary directories
#
# INSTALL installation-directory root, used for "make install":
# "libioapi.a" and the tool executables will be installed
# in $(INSTALL)/$(BIN)
#
# LIBINST overrides $(INSTALL)/$(BIN) for libioapi.a
#
# BININST overrides $(INSTALL)/$(BIN) for M3TOOLS executables
#.........................................................................
# Directories:
#
# $(BASEDIR) is the root directory for the I/O API library source,
# the M3Tools and M3Test source,the HTML documentation,
# and the (machine/compiler/flag-specific) binary
# object/library/executable directories.
# $(HTMLDIR) is the web documentation
# $(IODIR) is the I/O API library source
# $(TOOLDIR) is the "M3TOOLS" source
# $(OBJDIR) is the current machine/compiler/flag-specific
# build-directory
# $(INSTALL) installation-directory root, used for "make install":
# "libioapi.a" and the tool executables will be installed
# in $(INSTALL)/$(BIN) object/library/executable directory
#.........................................................................
# Note On Library Versions and configuration:
#
# Environment variable "BIN" specifies library version up to
# link- and compile-flag compatibility. Dependecies upon machine,
# OS, and compiler are found in file "Makeinclude.$(BIN)".
# Command-line "make BIN=<something>..." overrides environment
# variable "% setenv BIN <something>" which overrides the
# make-variable default below.
#
# IN PARTICULAR, pay attention to the notes for various versions
# that may be built for Linux x86 with the Portland Group
# compilers: see comments in $(IODIR)/include 'MAKEINCLUDE'.Linux2_x86pg
#.........................................................................
# Special Make-targets
#
# configure: "Makefile"s, with the definitions indicated below.
# all: OBJDIR, FIXDIR, libioapi.a, and executables, with
# the current mode.
# lib: OBJDIR, FIXDIR, libioapi.a
# clean: remove .o's, libioapi.a, and executables from OBJDIR
# rmexe: remove executables from OBJDIR
# relink: rebuild executables from OBJDIR
# install: copy "libioapi.a" and executables to $(INSTDIR)
# dirs: make OBJDIR and FIXDIR directories
# fix: FIXDIR and extended-fixed-source INCLUDE-files
# gtar: GZipped tar-file of the source and docs
# nametest: test of name-mangling compatibility (requires that
# libnetcdff.a be manually placed into $(OBJDIR))
#
######################################################################
# ---------- Definitions for "make configure" ------------------
#
# VERSIONING DEFINITIONS: the preprocessor definitions in $(IOAPIDEFS)
# (below) govern I/O API behavior; versions with distinct combinations
# of these options are NOT library- nor object-compatible and should
# be built in *distinct* $(OBJDIR)s:
#
# Defining IOAPICPL turns on PVM-enabled "coupling mode" and
# requires "libpvm3.a" for linking.
#
# Defining IOAPI_PNCF turns on PnetCDF based distributed I/O
# and requires libpnetcdf.a and libmpi.a for linking; it should
# be used only with an MPI-based ${BIN} (e.g., Linux2_x86_64ifortmpi)
#
# Defining IOAPI_NCF4 turns on full netCDF-4 interfaces, including
# support for INTEGER*8 variables and attributes. It requires
# extra libraries for linking, which can be found by running the
# commands "nf-config --flibs" and "nc-config --libs"
#
# Defining IOAPI_NO_STDOUT suppresses WRITEs to the screen in
# routines INIT3(), M3MSG2(), M3MESG(), M3PARAG(), and M3ABORT().
# This also helps control the "double-printed-message" behavior
# caused by recent SGI compilers.
#
# Defining IO_360 creates the 360-day "global climate" version
# of the library.
#
# Defining BIN3_DEBUG turns on trace-messages for native-binary
# mode routines.
######################################################################
# ---------- Default/fall-back Definitions --------------------
# For POSIX "make", environment variables override these;
# variable setting on the command line ("make VAR=VALUE ...")
# overrides that.
#
# GNU "make" DOES NOT FOLLOW POSIX, AND INSTEAD DOES ITS OWN
# WRONG-HEADED THING, MAKING IT IMPOSSIBLE TO HAVE DEFAULTS
# THAT ARE THEN OVER-RIDDEN BY THE ENVIRONMENT !!
#
# BIN : Use 64-bit gcc/gfortran
# BASEDIR : source under this current directory
# INSTALL : installation directly under ${HOME}
# LIBINST : for installation of library
# BININST : for installation of m3tools executables
# CPLMODE : nocpl
# IOAPIDEFS : none (can override for climo-year, etc.
# PVMINCL : none
# NCFLIBS : assumes netCDF-4-style separate libs
#
#
# BIN = Linux2_x86_64
# BASEDIR = ${PWD}
# INSTALL = ${HOME}
# LIBINST = $(INSTALL)/$(BIN)
# BININST = $(INSTALL)/$(BIN)
# CPLMODE = nocpl
# IOAPIDEFS =
# PVMINCL =
# NCFLIBS = -lnetcdff -lnetcdf
#
# **** Variants ****
#
# BASEDIR = ${HOME}/ioapi-3.2 # fall-back to versioned source under this directory
#
# CPLMODE = cpl # turn on PVM coupling mode
# PVMINCL = $(PVM_ROOT)/conf/$(PVM_ARCH).def
# IOAPIDEFS = "-DIOAPICPL"
#
# CPLMODE = pncf # turn on PnetCDF distributed-file mode
# NCFLIBS = -lpnetcdf -lnetcdff -lnetcdf
# IOAPIDEFS = "-DIOAPI_PNCF"
#
# NCFLIBS = -lnetcdf # Assumes netcdf-3-style unified libs
# IOAPIDEFS = "-DIOAPI_PNCF"
#
# NCFLIBS = -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz # netcdf-4 with HDF but not DAP
# IOAPIDEFS = "-DIOAPI_NCF4"
#
# NCFLIBS = -lpnetcdf -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz # PnetCDF+netcdf-4 with HDF but not DAP
# IOAPIDEFS = "-DIOAPI_PNCF -DIOAPI_NCF4"
#
# NCFLIBS = "-lnetcdff -lnetcdf -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5 -lmfhdf -ldf -ljpeg -lm -lz -lcurl -lsz" # all-out netcdf-4
#
# NCFLIBS = "`nf-config --flibs` `nc-config --libs`" # general-case netcdf-4 with NetCDF "bin" in ${path}
#
# INSTALL = <installation base-directory> -- what GNU "configure" calls "--prefix=..."
# LIBINST = $(INSTALL)/lib
# BININST = $(INSTALL)/bin
# ---------- Edit-command used by "make configure" to customize the "*/Makefile*"
SEDCMD = \
-e 's|IOAPI_BASE|$(BASEDIR)|' \
-e 's|LIBINSTALL|$(LIBINST)|' \
-e 's|BININSTALL|$(BININST)|' \
-e 's|IOAPI_DEFS|$(IOAPIDEFS)|' \
-e 's|NCFLIBS|$(NCFLIBS)|' \
-e 's|MAKEINCLUDE|include $(IODIR)/Makeinclude|' \
-e 's|PVMINCLUDE|include $(PVMINCL)|'
# ---------- I/O API Build System directory definitions --------
VERSION = 3.2-${CPLMODE}
BASEDIR = ${PWD}
NCFLIBS = -lnetcdff -lnetcdf
IODIR = $(BASEDIR)/ioapi
FIXDIR = $(IODIR)/fixed_src
HTMLDIR = $(BASEDIR)/HTML
TOOLDIR = $(BASEDIR)/m3tools
OBJDIR = $(BASEDIR)/$(BIN)
# ---------------------- TOP-LEVEL TARGETS: ------------------
#
all: dirs fix configure
(cd $(IODIR) ; make BIN=${BIN} all)
(cd $(TOOLDIR) ; make BIN=${BIN} all)
test:
(cd $(BASEDIR)/tests; ioapitest.csh ${BASEDIR} ${BIN} )
configure: ${IODIR}/Makefile ${TOOLDIR}/Makefile
(cd $(IODIR) ; sed $(SEDCMD) < Makefile.$(CPLMODE).sed > Makefile )
(cd $(TOOLDIR) ; sed $(SEDCMD) < Makefile.$(CPLMODE).sed > Makefile )
bins: dirs
(cd $(IODIR) ; make bins)
(cd $(TOOLDIR) ; make bins)
clean:
(cd $(IODIR) ; make BIN=${BIN} -i clean)
(cd $(TOOLDIR) ; make BIN=${BIN} -i clean)
binclean: dirs
(cd $(IODIR) ; make binclean)
(cd $(TOOLDIR) ; make binclean)
relink:
(cd $(TOOLDIR) ; make BIN=${BIN} relink)
binrelink:
(cd $(TOOLDIR) ; make binrelink)
install: $(LIBINST) $(BININST)
echo "Installing I/O API and M3TOOLS in $(LIBINST) and $(BININST)"
(cd $(IODIR) ; make BIN=${BIN} INSTDIR=${LIBINST} install)
(cd $(TOOLDIR) ; make BIN=${BIN} INSTDIR=${BININST} install)
dirs: $(OBJDIR) $(FIXDIR)
fix:
(cd $(IODIR) ; make fixed_src)
gtar:
cd $(BASEDIR); date > VERSION.txt; \
gtar cvfz ioapi-$(VERSION).tar.gz --dereference -X exclude \
Makefile* *.txt exclude ioapi HTML m3tools tests
lib: dirs
(cd $(IODIR) ; make all)
nametest: lib $(OBJDIR)/libnetcdff.a
(cd $(IODIR) ; make nametest)
$(FIXDIR):
mkdir -p $(FIXDIR)
$(OBJDIR):
mkdir -p $(OBJDIR)
$(LIBINST): $(INSTALL)
cd $(INSTALL); mkdir -p $(LIBINST)
$(BININST): $(INSTALL)
cd $(INSTALL); mkdir -p $(BININST)