-
Notifications
You must be signed in to change notification settings - Fork 92
/
ExampleMakefile
executable file
·273 lines (226 loc) · 8.05 KB
/
ExampleMakefile
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
264
265
266
267
268
269
270
271
272
273
# -*- makefile -*-
#
# For use with GNU make.
#
#
#----------------------------------------------------------------------------------------------------------------------------------
# ExampleMakefile for compiling OpenCMISS examples
#
# Original by Chris Bradley adapted from the CMISS Makefile by Karl Tomlinson
# Changes:
#
#----------------------------------------------------------------------------------------------------------------------------------
#
# LICENSE
#
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#
# The Original Code is OpenCMISS
#
# The Initial Developer of the Original Code is University of Auckland,
# Auckland, New Zealand, the University of Oxford, Oxford, United
# Kingdom and King's College, London, United Kingdom. Portions created
# by the University of Auckland, the University of Oxford and King's
# College, London are Copyright (C) 2007-2010 by the University of
# Auckland, the University of Oxford and King's College, London.
# All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
#----------------------------------------------------------------------------------------------------------------------------------
ifndef GLOBAL_ROOT
$(error GLOBAL_ROOT is not setup)
endif
OC_CM_GLOBAL_ROOT = $(GLOBAL_ROOT)
ifndef OPENCMISSEXAMPLES_ROOT
OPENCMISSEXAMPLES_ROOT := $(OC_CM_GLOBAL_ROOT)/../examples
endif
include $(OC_CM_GLOBAL_ROOT)/utils/MakefileCommon.inc
#----------------------------------------------------------------------------------------------------------------------------------
BASE_EXAMPLE_NAME = $(EXAMPLE_NAME)Example
ifndef EXAMPLE_PATH
EXAMPLE_PATH :=
endif
ifndef EXAMPLE_ROOT
EXAMPLE_ROOT := $(OPENCMISSEXAMPLES_ROOT)/$(EXAMPLE_PATH)$(EXAMPLE_NAME)
endif
ifeq ($(OPERATING_SYSTEM),linux)# Linux
ifdef COMPILER_VERSION
OBJECT_DIR := $(EXAMPLE_ROOT)/object/$(ENVIRONMENT)$(BUILD_TYPE)$(MPI_TOOLCHAIN)
EXE_DIR := $(EXAMPLE_ROOT)/bin/$(BIN_ARCH_DIR)/$(MPI)/$(COMPILER)_$(COMPILER_VERSION)
else
OBJECT_DIR := $(EXAMPLE_ROOT)/object/$(ENVIRONMENT)$(BUILD_TYPE)$(MPI_TOOLCHAIN)
EXE_DIR := $(EXAMPLE_ROOT)/bin/$(BIN_ARCH_DIR)/$(MPI)/$(COMPILER)
endif
else
OBJECT_DIR := $(EXAMPLE_ROOT)/object/$(ENVIRONMENT)$(BUILD_TYPE)$(MPI_TOOLCHAIN)
EXE_DIR := $(EXAMPLE_ROOT)/bin/$(BIN_ARCH_DIR)/$(MPI)/$(COMPILER)
endif
MAIN_SOURCE_DIR := $(OC_CM_GLOBAL_ROOT)/src
BASE_EXE_NAME = $(BASE_EXAMPLE_NAME)
BASE_LIB_NAME = OpenCMISS
EXAMPLE_SOURCE_DIR = $(EXAMPLE_ROOT)/src
MODULE_DIR := $(OBJECT_DIR)
INC_NAME := opencmiss.mod
INCLUDE := $(INC_DIR)/$(INC_NAME)
LIB_NAME := lib$(BASE_LIB_NAME)$(EXE_ABI_SUFFIX)$(MT_SUFFIX)$(DEBUG_SUFFIX)$(PROF_SUFFIX).a
LIBRARY := $(LIB_DIR)/$(LIB_NAME)
EXE_NAME := $(BASE_EXE_NAME)$(EXE_ABI_SUFFIX)$(MT_SUFFIX)$(DEBUG_SUFFIX)$(PROF_SUFFIX)
EXECUTABLE := $(EXE_DIR)/$(EXE_NAME)
C_INCLUDE_DIRS := $(INC_DIR) \
$(EXAMPLE_SOURCE_DIR)
F_INCLUDE_DIRS := $(MODULE_DIR)
CPPFLAGS += $(addprefix -I, $(C_INCLUDE_DIRS) )
FPPFLAGS += $(addprefix -I, $(F_INCLUDE_DIRS) )
OPENCMISS_LIBRARY = $(LIBRARY)
OPENCMISS_INCLUDE_PATH = $(addprefix -I, $(INC_DIR) )
FPPFLAGS += $(OPENCMISS_INCLUDE_PATH) $(EXTERNAL_INCLUDE_PATH)
ELFLAGS += $(EXTERNAL_LIB_PATH)
.SUFFIXES: .f90 .c
$(OBJECT_DIR)/%.o : $(EXAMPLE_SOURCE_DIR)/%.f90
( cd $(OBJECT_DIR) ; $(FC) -o $@ $(FFLAGS) $(FPPFLAGS) -c $< )
$(OBJECT_DIR)/%.o : $(EXAMPLE_SOURCE_DIR)/../input/%.f90
( cd $(OBJECT_DIR) ; $(FC) -o $@ $(FFLAGS) $(FPPFLAGS) -c $< )
# end changed krittian
$(OBJECT_DIR)/%.o : $(EXAMPLE_SOURCE_DIR)/%.c
( cd $(OBJECT_DIR) ; $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< )
OBJECTS = $(OBJECT_DIR)/$(BASE_EXAMPLE_NAME).o
main: preliminaries \
$(EXECUTABLE)
preliminaries: $(OBJECT_DIR) \
$(EXE_DIR)
$(OBJECT_DIR) :
mkdir -p $@
$(EXE_DIR) :
mkdir -p $@;
$(EXECUTABLE) : $(OBJECTS) $(OPENCMISS_LIBRARY)
$(EXE_LINK) -o $@ $(OBJECTS) $(OPENCMISS_LIBRARY) $(ELFLAGS) $(EXTERNAL_LIBRARIES)
$(OPENCMISS_LIBRARY) :
( cd $(OC_CM_GLOBAL_ROOT); $(MAKE) )
# Place the list of dependencies for the objects here.
#
# ----------------------------------------------------------------------------
run : main
$(EXECUTABLE)
test: main
DIR=$(EXAMPLE_PATH)$(EXAMPLE_NAME) python $(OPENCMISSEXAMPLES_ROOT)/scripts/run_tests.py
callgrindrun : main
valgrind --tool=callgrind $(EXECUTABLE)
cachegrindrun : main
valgrind --tool=cachegrind $(EXECUTABLE)
hellgrindrun : main
valgrind --tool=hellgrind $(EXECUTABLE)
massifrun : main
valgrind --tool=massif $(EXECUTABLE)
memcheckrun : main
valgrind --tool=memcheck $(EXECUTABLE)
# ----------------------------------------------------------------------------
#
# clean and clobber for removing objects and executable.
clean:
@echo "Cleaning house ..."
rm -rf $(OBJECT_DIR) $(EXECUTABLE)
allclean:
@echo "Cleaning house ..."
rm -rf object/* bin/*
clobber: clean
rm -f $(EXECUTABLE)
externallibs:
$(MAKE) --no-print-directory -f $(UTILS_ROOT)/Makefile DEBUG=$(DEBUG) ABI=$(ABI)
all64: debug64 opt64
#-----------------------------------------------------------------------------
help:
@echo " Compile a version of OpenCMISS"
@echo " =============================="
@echo
@echo "Examples of usage: "
@echo
@echo " gmake"
@echo " gmake OPT= ABI=32"
@echo " gmake PROF="
@echo " gmake debug64"
@echo
@echo "Options: (The former is the default unless specified.)"
@echo
@echo " (DEBUG=|OPT=)"
@echo " MPI=(mpich2|intel|openmpi|mvapich2|cray)"
@echo " PROF=(true|)"
@echo " MPIPROF=(true|)"
@echo " ABI=(32|64)"
@echo " COMPILER=(intel|gnu|ibm|cray)"
@echo " USECELLML=(false|true)"
@echo " USEFIELDML=(false|true)"
@echo
@echo "Available targets: "
@echo
@echo " clean"
@echo " Remove generated files associated with a single"
@echo " version."
@echo
@echo " clobber"
@echo " Remove all files associated with a single version."
@echo
@echo " help"
@echo " Display this message."
@echo
@echo " debug opt debug64 opt64"
@echo " Compile the specified version with automatic setting"
@echo " of DEBUG, ABI, and MP."
@echo
@echo " all"
@echo " Compile all versions."
@echo
@echo " all64"
@echo " Compile all 64-bit versions."
@echo
@echo
@echo " externallibs"
@echo " Compile the external libraries."
@echo
@echo " run"
@echo " Run the executable."
@echo
@echo " cachegrindrun"
@echo " Run the executable with valgrid cachegrind."
@echo
@echo " callgrindrun"
@echo " Run the executable with valgrid callgrind."
@echo
@echo " hellgrindrun"
@echo " Run the executable with valgrid hellgrind."
@echo
@echo " massifrun"
@echo " Run the executable with valgrid massif."
@echo
@echo " memcheckrun"
@echo " Run the executable with valgrid memcheck."
@echo
@echo " test"
@echo " Run the executables and test."
@echo
#-----------------------------------------------------------------------------
# Aliases
#-----------------------------------------------------------------------------
include $(OCE_MAKEINC_ROOT)/Makefile_Aliases.inc