Skip to content
Snippets Groups Projects
Commit c8a47efe authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Merge branch 'mnt/c++standard' into 'master'

Clean up construction of compiler flags

See merge request fsl/base!4
parents de68f2e1 39d2b363
No related branches found
No related tags found
1 merge request!4Clean up construction of compiler flags
Pipeline #6737 failed
# This master make file is based on the "old" # This file defines architecture specific commands and compiler flags.
# systemvars.mk and externallibs.mk files from: # It is included before vars.mk, which uses the ARCH* compiler flags
# apple-darwin13-llvm6.0 # to construct the final compiler flag variables that are used in C/C++
# linux_64-gcc4.4 # compilation.
# linux_64-gcc4.8
# get system type (Darwin, Linux) # get system type (Darwin, Linux)
SYSTYPE := $(shell uname -s) SYSTYPE := $(shell uname -s)
...@@ -27,17 +26,26 @@ TCLSH ?= ${FSLDIR}/bin/fsltclsh ...@@ -27,17 +26,26 @@ TCLSH ?= ${FSLDIR}/bin/fsltclsh
# #
##################################################################### #####################################################################
# All platform specific compiler/linker options are added to # Platform specific compiler/linker options may be added to
# the following variables. They are populated in the platform- # the following ARCH* variables. These variables are *always*
# specific branches below. Final values for CFLAGS, CXXFLAGS, # added to compiler calls.
# and LDFLAGS (including include/library search paths) are #
# constructed in common/vars.mk # Final values for CFLAGS, CXXFLAGS, and LDFLAGS (including
# include/library search paths) are constructed in vars.mk.
#
# The ARCH* variables here are added to the end of the final
# FLAGS variables, which means that any options specified here
# will usually take precedence over options provided by the
# environment.
# Compiler flags for C projects # Compiler flags for C projects
ARCHCFLAGS = ARCHCFLAGS = -std=c99
# Compiler flags for C++ projects. # Compiler flags for C++ projects.
ARCHCXXFLAGS = -D_GLIBCXX_USE_CXX11_ABI=0 ARCHCXXFLAGS = -std=c++11
# Preprocesor flags for C/C++ projects.
ARCHCPPFLAGS =
# Linker flags for all projects # Linker flags for all projects
ARCHLDFLAGS = ARCHLDFLAGS =
...@@ -51,6 +59,13 @@ ARCHNVCCFLAGS = ...@@ -51,6 +59,13 @@ ARCHNVCCFLAGS =
# Linker flags for CUDA projects. # Linker flags for CUDA projects.
ARCHNVCCLDFLAGS = ARCHNVCCLDFLAGS =
# Allow flags to be provided by the environment.
# Default CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
# are set in the platform-specific sections below.
CPPFLAGS ?=
NVCCFLAGS ?=
NVCCLDFLAGS ?=
##################################################################### #####################################################################
# #
# Darwin specific sys vars and ext libs # Darwin specific sys vars and ext libs
...@@ -58,15 +73,14 @@ ARCHNVCCLDFLAGS = ...@@ -58,15 +73,14 @@ ARCHNVCCLDFLAGS =
##################################################################### #####################################################################
ifeq ($(SYSTYPE), Darwin) ifeq ($(SYSTYPE), Darwin)
# Commands # Compiler flags. CC, CXX, CFLAGS, CXXFLAGS, and
CC ?= cc # LDFLAGS may be overridden by the environment.
CXX ?= c++ CC ?= clang
CXX ?= clang++
# Compiler flags CFLAGS ?= -arch x86_64 -Wall -pedantic -fPIC
ARCHCXXFLAGS += -arch x86_64 -Wall -pedantic -fPIC CXXFLAGS ?= -arch x86_64 -Wall -pedantic -fPIC
ARCHCFLAGS += $(ARCHCXXFLAGS) -std=c99 LDFLAGS ?= -Wl,-search_paths_first
ARCHLDFLAGS += -Wl,-search_paths_first ARCHLIBS += -llapack -lblas -lz -lm
ARCHLIBS += -llapack -lblas -lz -lm
endif endif
##################################################################### #####################################################################
...@@ -76,16 +90,15 @@ endif ...@@ -76,16 +90,15 @@ endif
##################################################################### #####################################################################
ifeq ($(SYSTYPE), Linux) ifeq ($(SYSTYPE), Linux)
# Commands # Compiler flags. CC, CXX, CFLAGS, CXXFLAGS, and
CC ?= gcc # LDFLAGS may be overridden by the environment.
CXX ?= c++ CC ?= gcc
CXX ?= g++
# Compiler flags CFLAGS ?= -fexpensive-optimizations \
ARCHCFLAGS += -fexpensive-optimizations \
-Wall -pedantic -Wno-long-long -fPIC -Wall -pedantic -Wno-long-long -fPIC
ARCHCXXFLAGS += $(ARCHCFLAGS) CXXFLAGS ?= -fexpensive-optimizations \
ARCHLDFLAGS += -Wl,-rpath,'$$ORIGIN/../lib' LDFLAGS ?= -Wl,-rpath,'$$ORIGIN/../lib'
ARCHLIBS += -lopenblas -lz -lm ARCHLIBS += -lopenblas -lz -lm
endif # if Linux endif # if Linux
##################################################################### #####################################################################
......
include ${FSLCONFDIR}/common/buildSettings.mk # Platform specific settings and defaults,
include ${FSLCONFDIR}/common/vars.mk # which are used by vars.mk
include ${FSLCONFDIR}/common/rules.mk include ${FSLCONFDIR}/buildSettings.mk
# Definition of variables controlling
# compilation and installation
include ${FSLCONFDIR}/vars.mk
# Make rules
include ${FSLCONFDIR}/rules.mk
File moved
File moved
######################################################### #########################################################
# Variables used for FSL project compilation/installation # Variables used for FSL project compilation/installation
#
# Default compiler/platform specific variables are
# initialised in buildSettings.mk, which is included
# before this file. Project specific variables are
# initialised in the project Makefile.
######################################################### #########################################################
# All projects must specify a name # All projects must specify a name
...@@ -12,6 +17,7 @@ USRLDFLAGS = # Project-specific linker flags ...@@ -12,6 +17,7 @@ USRLDFLAGS = # Project-specific linker flags
USRINCFLAGS = # Project-specific include directories USRINCFLAGS = # Project-specific include directories
USRCFLAGS = # Project-specific compiler flags for C projects USRCFLAGS = # Project-specific compiler flags for C projects
USRCXXFLAGS = # Project-specific compiler flags for C++ projects USRCXXFLAGS = # Project-specific compiler flags for C++ projects
USRCPPFLAGS = # Project-specific preprocessor flags
LIBS = # Project-specific libraries to link against for C LIBS = # Project-specific libraries to link against for C
# and C++ projects - these are incorporated into the # and C++ projects - these are incorporated into the
# final LDFLAGS, below. # final LDFLAGS, below.
...@@ -66,29 +72,46 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} ...@@ -66,29 +72,46 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR}
# Final compiler/linker flags # Final compiler/linker flags
############################# #############################
# Ignore flags provided by the environment # Allow flags to be added by the environment
CFLAGS = CFLAGS ?=
CXXFLAGS = CXXFLAGS ?=
CPPFLAGS = CPPFLAGS ?=
NVCCFLAGS = NVCCFLAGS ?=
LDFLAGS = LDFLAGS ?=
NVCCLDFLAGS = NVCCLDFLAGS ?=
# All projects must use these flags for # All projects must use these flags for
# compilation/linking, using the form: # compilation/linking, using the form:
# #
# $(CC) $(CFLAGS) <project flags/files> $(LDFLAGS) # $(CC) $(CFLAGS) <input/output files> $(LDFLAGS)
# $(CXX) $(CXXFLAGS) <project flags/files> $(LDFLAGS) # $(CXX) $(CXXFLAGS) <input/output files> $(LDFLAGS)
# $(NVCC) $(NVCCFLAGS) <project flags/files> $(NVCCLDFLAGS) # $(NVCC) $(NVCCFLAGS) <input/output files> $(NVCCLDFLAGS)
# #
# LDFLAGS *must* come at the end, to ensure proper linking. # LDFLAGS *must* come at the end, to ensure proper linking.
LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \ # The order in which the final FLAGS variables are
-L. -L${DEVLIBDIR} -L${LIBDIR} \ # constructed here is important:
${LIBS} ${ARCHLIBS} #
NVCCLDFLAGS += ${ARCHNVCCLDFLAGS} ${USRNVCCLDFLAGS} \ # 1. Flags provided by the environment come first
-L. -L${DEVLIBDIR} -L${LIBDIR} \ # 2. ARCH* flags defined in buildSettings.mk come next
${CUDALIBS} # 3. USR* flags defined in the Project Makefile come
CFLAGS += ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS} # last.
CXXFLAGS += ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS} #
NVCCFLAGS += ${ARCHNVCCFLAGS} ${USRNVCCFLAGS} ${INCFLAGS} # Many compiler options, if specified multiple times,
# are interpreted such that only the last option takes
# effect. This essentiallyy means that, because of the
# construction order, a project Makefile can override
# the default options specified in buildSettings.mk,
# which in turn can override options provided by the
# environment.
CPPFLAGS += ${ARCHCPPFLAGS} ${USRCPPFLAGS}
CFLAGS += ${CPPFLAGS} ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS}
CXXFLAGS += ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS}
NVCCFLAGS += ${ARCHNVCCFLAGS} ${USRNVCCFLAGS} ${INCFLAGS}
LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \
-L. -L${DEVLIBDIR} -L${LIBDIR} \
${LIBS} ${ARCHLIBS}
NVCCLDFLAGS += ${ARCHNVCCLDFLAGS} ${USRNVCCLDFLAGS} \
-L. -L${DEVLIBDIR} -L${LIBDIR} \
${CUDALIBS}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment