Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 2f6cc47cd7
Fetching contributors…

Cannot retrieve contributors at this time

266 lines (222 sloc) 8.17 kB
# -*- 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)
else
GLOBAL_CM_ROOT := $(GLOBAL_ROOT)
endif
ifndef OPENCMISSEXAMPLES_ROOT
OPENCMISSEXAMPLES_ROOT := $(GLOBAL_CM_ROOT)/../examples
endif
include $(GLOBAL_CM_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/$(LIB_ARCH_DIR)$(MT_SUFFIX)$(DEBUG_SUFFIX)$(PROF_SUFFIX)/$(MPI)/$(COMPILER)_$(COMPILER_VERSION)
EXE_DIR := $(EXAMPLE_ROOT)/bin/$(BIN_ARCH_DIR)/$(MPI)/$(COMPILER)_$(COMPILER_VERSION)
else
OBJECT_DIR := $(EXAMPLE_ROOT)/object/$(LIB_ARCH_DIR)$(MT_SUFFIX)$(DEBUG_SUFFIX)$(PROF_SUFFIX)/$(MPI)/$(COMPILER)
EXE_DIR := $(EXAMPLE_ROOT)/bin/$(BIN_ARCH_DIR)/$(MPI)/$(COMPILER)
endif
else
OBJECT_DIR := $(EXAMPLE_ROOT)/object/$(LIB_ARCH_DIR)$(MT_SUFFIX)$(DEBUG_SUFFIX)$(PROF_SUFFIX)/$(MPI)/$(COMPILER)
EXE_DIR := $(EXAMPLE_ROOT)/bin/$(BIN_ARCH_DIR)/$(MPI)/$(COMPILER)
endif
MAIN_SOURCE_DIR := $(GLOBAL_CM_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 $(GLOBAL_CM_ROOT); $(MAKE) )
# Place the list of dependencies for the objects here.
#
# ----------------------------------------------------------------------------
run : main
$(EXECUTABLE)
callgrindrun : main
valgrind --tool=callgrind $(EXECUTABLE)
massifrun : main
valgrind --tool=massif $(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 $(EXTERNAL_CM_ROOT)/packages/Makefile DEBUG=$(DEBUG) ABI=$(ABI)
debug opt debug64 opt64:
$(MAKE) --no-print-directory DEBUG=$(DEBUG) ABI=$(ABI)
debug debug64: DEBUG=true
opt opt64: DEBUG=false
ifneq (,$(filter $(MACHNAME),ia64 x86_64))# ia64 or x86_64
debug opt: ABI=64
else
debug opt: ABI=32
endif
debug64 opt64: ABI=64
all: debug opt
all64: debug64 opt64
# TODO only for linux 64bit for now.
test:
# Test for 2x2 mesh using bilinear lagrange basis
python $(CURDIR)/testscript.py $(CURDIR)/bin/$(LIB_ARCH_DIR)/$(BASE_EXAMPLE_NAME)$(DEBUG_SUFFIX)$(PROF_SUFFIX)/$(MPI)/$(COMPILER)
#-----------------------------------------------------------------------------
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 " massifrun"
@echo " Run the executable with valgrid massif."
@echo
@echo " callgrindrun"
@echo " Run the executable with valgrid callgrind."
@echo
@echo
@echo " test"
@echo " Run the executables for test. Linux 64 bit and AnalyticLaplaceExample only for now."
@echo
Jump to Line
Something went wrong with that request. Please try again.