Commit 476c62ac authored by wangkx1's avatar wangkx1
Browse files

change

parent 5e75fc76
# This file defines standard commands and compiler flags. It is included
# before vars.mk, which uses the variables defined here to construct the
# final compiler flag variables that are used in C/C++ compilation.
#
# Final values for CFLAGS, CPPFLAGS, CXXFLAGS, LDFLAGS, NVCCFLAGS, and
# NVCCLDFLAGS (including include/library search paths) are constructed in
# vars.mk,
# get system type (Darwin, Linux)
SYSTYPE ?= $(shell uname -s)
#####################################################################
#
# Standard commands
#
#####################################################################
SHELL ?= /bin/sh
RM ?= /bin/rm
CP ?= /bin/cp
MV ?= /bin/mv
CHMOD ?= /bin/chmod
MKDIR ?= /bin/mkdir
INSTALL ?= install -p
TCLSH ?= ${FSLDIR}/bin/fsltclsh
#####################################################################
#
# Architecture-independent compiler/linker flags
#
#####################################################################
# Platform independent compiler/linker options may be added to
# the following ARCH* variables. These variables are *always*
# added to compiler calls, for all platforms.
#
# The ARCH* variables here are added to the end of the final
# FLAGS variables, which means that any options specified here
# will typically take precedence over options provided by the
# environment.
# Compiler flags for C projects.
# - C99 as minimum source compatibility standard
# - Position independent code essential for
# compiling/using shared libraries
ARCHCFLAGS = -std=c99 -fPIC
# Compiler flags for C++ projects.
# - C++17 as minimum source compatibility standard
# - Position independent code essential for
# compiling/using shared libraries
ARCHCXXFLAGS = -std=c++17 -fPIC -g -O0
# Preprocesor flags for C/C++ projects.
ARCHCPPFLAGS = -g -O0
# Linker flags for all projects
ARCHLDFLAGS = -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# Libraries available for linking by all projects.
ARCHLIBS = -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# Compiler flags for CUDA projects.
# - Define ARMA_ALLOW_FAKE_GCC, otherwise nvcc-compiled
# armadillo structures may have different byte-alignment
# to equivalent g++-compiled structures (see
# include/armadillo_bits/compiler_setup.hpp)
#
# - Set -std=c++14. This is the newest C++ standard
# supported by nvcc for CUDA<11.0.
# ARCHNVCCFLAGS = -std=c++14 -fPIC
ARCHNVCCFLAGS = -DARMA_ALLOW_FAKE_GCC -std=c++17 -fPIC -g -O0
# Linker flags for CUDA projects.
ARCHNVCCLDFLAGS = -std=c++17 -fPIC -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
#####################################################################
#
# Default compiler commands, flags and basic external libraries for
# macOS.
#
#####################################################################
# Drop -rpath flags from LDFLAGS if it is set in
# the environment - we explicitly add them below
# such that executables will be able to find libs
# in $(pwd), $FSLDEVDIR/lib, and $FSLDIR/lib *in
# that order*. This is so that executables
# located in the project source dir can be
# executed in place with sensible behaviour (i.e.
# any shared libs located in the same dir will
# take precedence over libs of the same name in
# $FSLDIR/lib/).
#
# Fortunately -Wl,-rpath is used for both g++ and
# clang, so we can cover both with one substitution.
COMMA := ,
_LDFLAGS := $(patsubst -Wl${COMMA}-rpath%,,${LDFLAGS})
LDFLAGS = ${_LDFLAGS}
# Also drop -L options from LDFLAGS if set in the
# environment, as we want to set our own
# precedence rules as above ($FSLDEVDIR > $FSLDIR)
# - this is done in vars.mk
_LDFLAGS := $(patsubst -L%,,${_LDFLAGS})
LDFLAGS = ${_LDFLAGS}
# Construct all rpath options, and add them to
# LDFLAGS. We keep them in a separate variable
# so they can be added to NVCCLDFLAGS as well.
RPATHS =
ifeq ($(SYSTYPE), Darwin)
# CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
# may be overridden by the environment.
CC ?= clang
CXX ?= clang++
CFLAGS ?= -arch x86_64 -Wall -pedantic
CXXFLAGS ?= -arch x86_64 -Wall -pedantic
RPATHS += -Wl,-rpath,"@executable_path/"
# Only add FSLDEVDIR if different to FSLDIR
ifneq (${FSLDEVDIR}, ${FSLDIR})
# RPATHS += -Wl,-rpath,"${FSLDEVDIR}/lib"
endif
# RPATHS += -Wl,-rpath,"${FSLDIR}/lib"
ARCHLIBS += -llapack -lblas -lz -lm
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# Old versions of libxml++ (which is used by
# ciftilib) use std::auto_ptr, which has been
# removed from the llvm C++17 implementation.
# Adding this flag is a hack which allows us
# to continue to use std::auto_ptr.
ARCHCPPFLAGS += -D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
# Some standard C++ features may be hidden when
# being compiled on a macOS version which does
# not support those features. But we use the
# conda provided libc++.
# https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-skd
ARCHCPPFLAGS += -D_LIBCPP_DISABLE_AVAILABILITY
# On macOS, we need to change the install
# name of shared libs so that they can be
# looked up according to the rpath of
# executables that depend on them. Note
# that we give shared libs a suffix of
# .so (not .dylib) on both linux and
# macOS.
%.so : RPATHS += -Wl,-install_name,@rpath/$@
ARCHLDFLAGS += ${RPATHS}
endif
#####################################################################
#
# Default compiler commands, flags and basic external libraries for
# Linux.
#
#####################################################################
ifeq ($(SYSTYPE), Linux)
# CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
# may be overridden by the environment.
CC ?= gcc
CXX ?= g++
CFLAGS ?= -fexpensive-optimizations \
-Wall -pedantic -Wno-long-long
CXXFLAGS ?= -fexpensive-optimizations \
-Wall -pedantic -Wno-long-long
# RPATHS += -Wl,-rpath,'$$ORIGIN' \
# -Wl,-rpath-link,'$$ORIGIN'
# Only add FSLDEVDIR if different to FSLDIR
ifneq (${FSLDEVDIR}, ${FSLDIR})
# RPATHS += -Wl,-rpath,'${FSLDEVDIR}/lib' \
# -Wl,-rpath-link,'${FSLDEVDIR}/lib'
endif
# RPATHS += -Wl,-rpath,'${FSLDIR}/lib' \
# -Wl,-rpath-link,'${FSLDIR}/lib'
LDFLAGS += ${RPATHS}
# Libraries which are implicitly available
# to all projects for linking
ARCHCXXFLAGS += -pthread
ARCHLIBS += -llapack -lblas -lz -lm
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
endif
#####################################################################
#
# Default compiler commands, flags, and basic external libraries for
# CUDA projects. nvcc must be on the $PATH, or $NVCC must be set.
#
#####################################################################
NVCC ?= $(shell which nvcc 2> /dev/null)
ifneq (${NVCC}, )
# NVCC, GENCODEFLAGS, NVCCFLAGS, NVCCLDFLAGS,
# and CUDA_DYNAMIC may be specified/overridden
# by the environment.
CUDA_HOME = $(realpath $(dir ${NVCC})/../)
CUDA_VER = $(shell ${NVCC} --version | grep release | cut -d ' ' -f 5 | tr -d ',')
GENCODEFLAGS ?= $(shell ${FSLCONFDIR}/supportedGencodes.sh ${CUDA_VER})
# We use nvcc to compile .cu files, g++ to
# compile .cc/.cpp files, and nvcc to perform
# the final linking. So we need to manage
# compiler/linker flags carefully.
# NVCCFLAGS is used for compiling .cu files
# (and final linking) - it contains nvcc-
# specific options.
#
# See vars.mk for the final construction of
# these variables
# We specify the compiler to use with -ccbin, as
# nvcc might otherwise naively call "g++", rather
# than honouring $(CXX). We specifically use
# "-ccbin" rather than "--compiler-bindir" here,
# because the conda-forge nvcc wrapper checks for
# -ccbin, and adds its own if not present.
NVCCFLAGS ?= ${GENCODEFLAGS} \
-ccbin $(CXX)
NVCCLDFLAGS ?= -L${CUDA_HOME}/lib \
-L${CUDA_HOME}/lib64 \
-L${CUDA_HOME}/lib/stubs \
-L${CUDA_HOME}/lib64/stubs \
-L/usr/local/cuda/lib \
$(subst -Wl${COMMA},--linker-options ,${RPATHS})
# Link CUDA libraries dynamically, if compilation
# was invoked with "make CUDA_DYNAMIC=1". The
# default behaviour is to link statically.
# Compiler / linker options vary depending on the
# CUDA version
_CUDALIBS = -lcuda
ifndef CUDA_DYNAMIC
# The cuda/cudart/cudadevrt libs are handled by nvcc.
# Other components of the CUDA toolkit are provided
# as both dynamic and static libraries. "_CUDALIBS"
# is what is used to construct the final NVCCLDFLAGS
# (see vars.mk).
#
# --cudadevrt was added in CUDA/nvcc 10.*
#
# In CUDA 10.* and newer, cublas_static requires
# cublas_Lt_static, in addition to culibos
ifeq ($(patsubst 9.%,,${CUDA_VER}),)
# CUBLAS_STATIC = -lcublas -lculibos
CUBLAS_STATIC = -lcublas -lcublasLt -l cudart -l cudadevrt
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# NVCCLDFLAGS += --cudart=static
else
# CUBLAS_STATIC = -lcublas -lcublasLt -lculibos
CUBLAS_STATIC = -lcublas -lcublasLt -l cudart -l cudadevrt
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# NVCCLDFLAGS += --cudart=static --cudadevrt=static
endif
# Other CUDA toolkit components will
# be added here on an as-needed basis.
_CUDALIBS += $(subst -lcublas,${CUBLAS_STATIC}, \
$(subst -lcurand,-lcurand_static,${CUDALIBS}))
else
ifeq ($(patsubst 9.%,,${CUDA_VER}),)
NVCCLDFLAGS += --cudart=shared
else
NVCCLDFLAGS += --cudart=shared --cudadevrt=static
endif
_CUDALIBS += ${CUDALIBS}
endif
endif
# This file defines standard commands and compiler flags. It is included
# before vars.mk, which uses the variables defined here to construct the
# final compiler flag variables that are used in C/C++ compilation.
#
# Final values for CFLAGS, CPPFLAGS, CXXFLAGS, LDFLAGS, NVCCFLAGS, and
# NVCCLDFLAGS (including include/library search paths) are constructed in
# vars.mk,
# get system type (Darwin, Linux)
SYSTYPE ?= $(shell uname -s)
#####################################################################
#
# Standard commands
#
#####################################################################
SHELL ?= /bin/sh
RM ?= /bin/rm
CP ?= /bin/cp
MV ?= /bin/mv
CHMOD ?= /bin/chmod
MKDIR ?= /bin/mkdir
INSTALL ?= install -p
TCLSH ?= ${FSLDIR}/bin/fsltclsh
#####################################################################
#
# Architecture-independent compiler/linker flags
#
#####################################################################
# Platform independent compiler/linker options may be added to
# the following ARCH* variables. These variables are *always*
# added to compiler calls, for all platforms.
#
# The ARCH* variables here are added to the end of the final
# FLAGS variables, which means that any options specified here
# will typically take precedence over options provided by the
# environment.
# Compiler flags for C projects.
# - C99 as minimum source compatibility standard
# - Position independent code essential for
# compiling/using shared libraries
ARCHCFLAGS = -std=c99 -fPIC
# Compiler flags for C++ projects.
# - C++17 as minimum source compatibility standard
# - Position independent code essential for
# compiling/using shared libraries
ARCHCXXFLAGS = -std=c++17 -fPIC -g -O0
# Preprocesor flags for C/C++ projects.
ARCHCPPFLAGS = -g -O0
# Linker flags for all projects
ARCHLDFLAGS =
# Libraries available for linking by all projects.
ARCHLIBS =
# Compiler flags for CUDA projects.
# - Define ARMA_ALLOW_FAKE_GCC, otherwise nvcc-compiled
# armadillo structures may have different byte-alignment
# to equivalent g++-compiled structures (see
# include/armadillo_bits/compiler_setup.hpp)
#
# - Set -std=c++14. This is the newest C++ standard
# supported by nvcc for CUDA<11.0.
# ARCHNVCCFLAGS = -std=c++14 -fPIC
ARCHNVCCFLAGS = -DARMA_ALLOW_FAKE_GCC -std=c++17 -fPIC -g -O0
# Linker flags for CUDA projects.
ARCHNVCCLDFLAGS = -std=c++17 -fPIC
#####################################################################
#
# Default compiler commands, flags and basic external libraries for
# macOS.
#
#####################################################################
# Drop -rpath flags from LDFLAGS if it is set in
# the environment - we explicitly add them below
# such that executables will be able to find libs
# in $(pwd), $FSLDEVDIR/lib, and $FSLDIR/lib *in
# that order*. This is so that executables
# located in the project source dir can be
# executed in place with sensible behaviour (i.e.
# any shared libs located in the same dir will
# take precedence over libs of the same name in
# $FSLDIR/lib/).
#
# Fortunately -Wl,-rpath is used for both g++ and
# clang, so we can cover both with one substitution.
COMMA := ,
_LDFLAGS := $(patsubst -Wl${COMMA}-rpath%,,${LDFLAGS})
LDFLAGS = ${_LDFLAGS}
# Also drop -L options from LDFLAGS if set in the
# environment, as we want to set our own
# precedence rules as above ($FSLDEVDIR > $FSLDIR)
# - this is done in vars.mk
_LDFLAGS := $(patsubst -L%,,${_LDFLAGS})
LDFLAGS = ${_LDFLAGS}
# Construct all rpath options, and add them to
# LDFLAGS. We keep them in a separate variable
# so they can be added to NVCCLDFLAGS as well.
RPATHS =
ifeq ($(SYSTYPE), Darwin)
# CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
# may be overridden by the environment.
CC ?= clang
CXX ?= clang++
CFLAGS ?= -arch x86_64 -Wall -pedantic
CXXFLAGS ?= -arch x86_64 -Wall -pedantic
RPATHS += -Wl,-rpath,"@executable_path/"
# Only add FSLDEVDIR if different to FSLDIR
ifneq (${FSLDEVDIR}, ${FSLDIR})
# RPATHS += -Wl,-rpath,"${FSLDEVDIR}/lib"
endif
# RPATHS += -Wl,-rpath,"${FSLDIR}/lib"
ARCHLIBS += -llapack -lblas -lz -lm
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# Old versions of libxml++ (which is used by
# ciftilib) use std::auto_ptr, which has been
# removed from the llvm C++17 implementation.
# Adding this flag is a hack which allows us
# to continue to use std::auto_ptr.
ARCHCPPFLAGS += -D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
# Some standard C++ features may be hidden when
# being compiled on a macOS version which does
# not support those features. But we use the
# conda provided libc++.
# https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-skd
ARCHCPPFLAGS += -D_LIBCPP_DISABLE_AVAILABILITY
# On macOS, we need to change the install
# name of shared libs so that they can be
# looked up according to the rpath of
# executables that depend on them. Note
# that we give shared libs a suffix of
# .so (not .dylib) on both linux and
# macOS.
%.so : RPATHS += -Wl,-install_name,@rpath/$@
ARCHLDFLAGS += ${RPATHS}
endif
#####################################################################
#
# Default compiler commands, flags and basic external libraries for
# Linux.
#
#####################################################################
ifeq ($(SYSTYPE), Linux)
# CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
# may be overridden by the environment.
CC ?= gcc
CXX ?= g++
CFLAGS ?= -fexpensive-optimizations \
-Wall -pedantic -Wno-long-long
CXXFLAGS ?= -fexpensive-optimizations \
-Wall -pedantic -Wno-long-long
# RPATHS += -Wl,-rpath,'$$ORIGIN' \
# -Wl,-rpath-link,'$$ORIGIN'
# Only add FSLDEVDIR if different to FSLDIR
ifneq (${FSLDEVDIR}, ${FSLDIR})
# RPATHS += -Wl,-rpath,'${FSLDEVDIR}/lib' \
# -Wl,-rpath-link,'${FSLDEVDIR}/lib'
endif
# RPATHS += -Wl,-rpath,'${FSLDIR}/lib' \
# -Wl,-rpath-link,'${FSLDIR}/lib'
LDFLAGS += ${RPATHS}
# Libraries which are implicitly available
# to all projects for linking
ARCHCXXFLAGS += -pthread
ARCHLIBS += -llapack -lblas -lz -lm
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
endif
#####################################################################
#
# Default compiler commands, flags, and basic external libraries for
# CUDA projects. nvcc must be on the $PATH, or $NVCC must be set.
#
#####################################################################
NVCC ?= $(shell which nvcc 2> /dev/null)
ifneq (${NVCC}, )
# NVCC, GENCODEFLAGS, NVCCFLAGS, NVCCLDFLAGS,
# and CUDA_DYNAMIC may be specified/overridden
# by the environment.
CUDA_HOME = $(realpath $(dir ${NVCC})/../)
CUDA_VER = $(shell ${NVCC} --version | grep release | cut -d ' ' -f 5 | tr -d ',')
GENCODEFLAGS ?= $(shell ${FSLCONFDIR}/supportedGencodes.sh ${CUDA_VER})
# We use nvcc to compile .cu files, g++ to
# compile .cc/.cpp files, and nvcc to perform
# the final linking. So we need to manage
# compiler/linker flags carefully.
# NVCCFLAGS is used for compiling .cu files
# (and final linking) - it contains nvcc-
# specific options.
#
# See vars.mk for the final construction of
# these variables
# We specify the compiler to use with -ccbin, as
# nvcc might otherwise naively call "g++", rather
# than honouring $(CXX). We specifically use
# "-ccbin" rather than "--compiler-bindir" here,
# because the conda-forge nvcc wrapper checks for
# -ccbin, and adds its own if not present.
NVCCFLAGS ?= ${GENCODEFLAGS} \
-ccbin $(CXX)
NVCCLDFLAGS ?= -L${CUDA_HOME}/lib \
-L${CUDA_HOME}/lib64 \
-L${CUDA_HOME}/lib/stubs \
-L${CUDA_HOME}/lib64/stubs \
-L/usr/local/cuda/lib \
$(subst -Wl${COMMA},--linker-options ,${RPATHS})
# Link CUDA libraries dynamically, if compilation
# was invoked with "make CUDA_DYNAMIC=1". The
# default behaviour is to link statically.
# Compiler / linker options vary depending on the
# CUDA version
_CUDALIBS = -lcuda
ifndef CUDA_DYNAMIC
# The cuda/cudart/cudadevrt libs are handled by nvcc.
# Other components of the CUDA toolkit are provided
# as both dynamic and static libraries. "_CUDALIBS"
# is what is used to construct the final NVCCLDFLAGS
# (see vars.mk).
#
# --cudadevrt was added in CUDA/nvcc 10.*
#
# In CUDA 10.* and newer, cublas_static requires
# cublas_Lt_static, in addition to culibos
ifeq ($(patsubst 9.%,,${CUDA_VER}),)
# CUBLAS_STATIC = -lcublas -lculibos
CUBLAS_STATIC = -lcublas -lcublasLt -l cudart -l cudadevrt
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# NVCCLDFLAGS += --cudart=static
else
# CUBLAS_STATIC = -lcublas -lcublasLt -lculibos
CUBLAS_STATIC = -lcublas -lcublasLt -l cudart -l cudadevrt
# -L /usr/local/lib/python3.10/dist-packages/ray/core -ljemalloc
# NVCCLDFLAGS += --cudart=static --cudadevrt=static
endif
# Other CUDA toolkit components will
# be added here on an as-needed basis.
_CUDALIBS += $(subst -lcublas,${CUBLAS_STATIC}, \
$(subst -lcurand,-lcurand_static,${CUDALIBS}))
else
ifeq ($(patsubst 9.%,,${CUDA_VER}),)
NVCCLDFLAGS += --cudart=shared
else
NVCCLDFLAGS += --cudart=shared --cudadevrt=static
endif
_CUDALIBS += ${CUDALIBS}
endif
endif
# Platform specific settings and defaults,
# which are used by vars.mk
include ${FSLCONFDIR}/buildSettings.mk
# Definition of variables controlling
# compilation and installation
include ${FSLCONFDIR}/vars.mk
# Make rules
include ${FSLCONFDIR}/rules.mk
# Make rules for FSL projects
#
# Automatic GNU make rules are used for compiling C and C++ files.
all:
help:
@echo " make Rebuild project targets";
@echo " make clean Remove executables, libraries and object files";
@echo " make install Install into your local FSLDEVDIR";
clean:
${RM} -f *.o *.a *.so *.exe \
${XFILES} ${FXFILES} ${SOFILES} ${AFILES} ${TESTXFILES}
${RM} -rf ${DEPDIR}
insertcopyright:
${FSLDIR}/share/fsl/sbin/insertcopyright * */*
# Automatically generate Make rules and dependencies for
# all source files in the project. Based on the technique
# described at:
#
# https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
#
# This mechanism supports C (.c), C++ (.cc, .cxx, .cpp)
# and CUDA (.cu) source files.
#
# For each source file, a dependency file is created in a
# subdirectory .deps/, which defines a rule specifying the
# dependencies for that source file. The dependency file
# is created the first time that the source file is compiled
# (as part of a single compiler invocation).
DEPDIR = .deps
# The default directory for object files is the project
# directory (i.e. "."), but this can be overridden via
# the BUILDDIR and CUDABUILDDIR variables. Note that these
# variables must be set *before* this file is included.
#
# Make sure we have a single trailing slash to use in the
# compilation rules below.
ifdef SRCDIR
SRCDIR_ := ${SRCDIR:/=}/
endif
ifdef BUILDDIR
BUILDDIR_ := ${BUILDDIR:/=}/
endif
ifdef CUDABUILDDIR
CUDABUILDDIR_ := ${CUDABUILDDIR:/=}/
else
ifdef BUILDDIR_
CUDABUILDDIR_ := ${BUILDDIR_}
endif
endif
# The SRCFILES variable defaults to all source files within
# the project directory, however note that SRCFILES can be
# overridden in the project Makefile. Note that SRCFILES
# must be set *before* this file is included.
SRCFILES ?= $(shell find ${SRCDIR_}* -name "*.c" \
-or -name "*.cc" \
-or -name "*.cxx" \
-or -name "*.cpp" \
-or -name "*.cu")
# We need to define separate build rules for files in each
# source directory, so we pull out each source directory
# from the SRCFILES list. If $SRCDIR has been set, we
# exclude any directories not contained within it.
SRCDIRS := $(sort $(dir ${SRCFILES}))
SRCDIRS := $(filter ${SRCDIR_}%,${SRCDIRS})
# Now we get into the nitty gritty. We use a different
# naming convention for C/C++ and CUDA dependency
# files, to support projects which may have C++/CUDA
# source files with the same name, or which may compile
# the same file with different parameters for CPU / GPU
# execution.
#
# C/C++ dependency files end in .c.d, and CUDA dep files
# end in .cu.d.
#
# If a source file is contained within a sub-directory,
# the sub-directory is baked into the dependency file name
# (with slashes replaced by underscores).
#
# For example, a file "srcs/code.cpp" being compiled with
# g++ will have a dependency file named
# ".deps/srcs_code.cpp.c.d"
CDEPFILES := $(addsuffix .c.d, $(subst /,_,${SRCFILES}))
CUDEPFILES := $(addsuffix .cu.d, $(subst /,_,${SRCFILES}))
CDEPFILES := $(addprefix ${DEPDIR}/, ${CDEPFILES})
CUDEPFILES := $(addprefix ${DEPDIR}/, ${CUDEPFILES})
DEPFILES := ${CDEPFILES} ${CUDEPFILES}
# Rule to make deps directory
${DEPDIR}:
@mkdir -p ${DEPDIR}
# Define an empty rule for each dep file. In the compilation
# rules below, we list each dependency file as a prerequisite
# of the corresponding object file. But because the object
# and dependency files are created in a single step, Make would
# fail if the dependency file does not exist.
#
# However, by listing dependency files as targets with no
# prerequisites or commands causes Make to basically assume
# that they exist.
${DEPFILES}:
# This is where the auto dependency rules are actually applied -
# we include all dependency files that exist.
include $(wildcard ${DEPFILES})
# Rules for compilation. We define our own compilation rules
# which are equivalent to the implicit Make rules, but with
# some modifications to allow automatic dependency generation.
# Compiler flags for generating dependency files. These are
# added in the %.o compilation rules below.
CDEPFLAGS = -MMD -MT $$@ -MF ${DEPDIR}/$$(subst /,_,$$<).c.d
CUDEPFLAGS = -MMD -MT $$@ -MF ${DEPDIR}/$$(subst /,_,$$<).cu.d
# Override implicit rules
%: %.c
%: %.cc
%: %.cxx
%: %.cpp
%: %.c++
%.o: %.c
%.o: %.cc
%.o: %.cxx
%.o: %.cpp
%.o: %.c++
%.o: %.cu
# This canned recipe defines a rule for compiling a specific
# type of source file and saving the object file into a
# specific location. It has been carefully constructed to
# ensure that the compiler flags are not expanded until the
# rule is executed.
#
# The following arguments are passed:
# $1 source dir (or empty string)
# $2 full build dir (or empty string)
# $3 source suffix ("cpp", "cxx", etc)
# $4 dependency file suffix ("c" or "cu")
# $5 Name of compiler variable
# $6 Name of compiler flags variable
# $7 dependency flags
# This rule ensures the deps directory exists before anything
# is compiled, and lists the dependency file as a prerequisite
# of the object file so that if the dep file is missing, the
# object file will be re-built.
define gen_build_rule =
${2}%.o: ${1}%.${3} | ${DEPDIR}/$(subst /,_,${1})%.${3}.${4}.d ${DEPDIR} ${2}
$$(eval COMPILER := $$(value ${5}))
$$(eval COMPILER_FLAGS := $$(value ${6}))
$${COMPILER} $${COMPILER_FLAGS} ${7} -c -o $$@ $$<
endef
# This canned recipe defines rules for compiling source files
# located in a specific directory. Separate rules are required,
# because the build directory structure replicates the source
# directory structure. For example, the rule for files in the
# project root would be:
#
# build/%.o: %.cpp
#
# Whereas the rule for files in a sub-directory (let's say
# cuda/*.cu) would be:
#
# build/cuda/%.o: cuda/%.cu
#
# The following arguments are passed:
# $1 The source directory (or an empty string for pwd)
# $2 The source directory, with $SRCDIR stripped, for
# projects which store sources in a subdirectory
define gen_build_rules =
# Define rules to create build directories
# (unless objects are being saved to pwd)
ifneq (${BUILDDIR_}${2},)
${BUILDDIR_}${2}:
@mkdir -p $$@
endif
ifneq (${CUDABUILDDIR_},${BUILDDIR_})
ifneq (${CUDABUILDDIR_}${2},)
${CUDABUILDDIR_}${1}:
@mkdir -p $$@
endif
endif
# Define rules to compile different types of source file
# Eddy uses g++ to compile .cpp files that are linked into
# a CUDA executble, so we define an additional rule here.
ifneq ($(wildcard ${1}*.cpp),)
$$(eval $$(call gen_build_rule,${1},${BUILDDIR_}${2},cpp,c,CXX,CXXFLAGS,$${CDEPFLAGS}))
ifneq (${CUDABUILDDIR}, ${BUILDDIR})
$$(eval $$(call gen_build_rule,${1},${CUDABUILDDIR_}${2},cpp,cu,CXX,CUDACXXFLAGS,$${CUDEPFLAGS}))
endif
endif
ifneq ($(wildcard ${1}*.cc),)
$$(eval $$(call gen_build_rule,${1},${BUILDDIR_}${2},cc,c,CXX,CXXFLAGS,$${CDEPFLAGS}))
endif
ifneq ($(wildcard ${1}*.cxx),)
$$(eval $$(call gen_build_rule,${1},${BUILDDIR_}${2},cxx,c,CXX,CXXFLAGS,$${CDEPFLAGS}))
endif
ifneq ($(wildcard ${1}*.c++),)
$$(eval $$(call gen_build_rule,${1},${BUILDDIR_}${2},c++,c,CXX,CXXFLAGS,$${CDEPFLAGS}))
endif
ifneq ($(wildcard ${1}*.c),)
$$(eval $$(call gen_build_rule,${1},${BUILDDIR_}${2},c,c,CC,CFLAGS,$${CDEPFLAGS}))
endif
ifneq ($(wildcard ${1}*.cu),)
$$(eval $$(call gen_build_rule,${1},${CUDABUILDDIR_}${2},cu,cu,NVCC,NVCCFLAGS,$${CUDEPFLAGS}))
endif
endef
# Generate build rules for each source directory
$(foreach SD_,${SRCDIRS},$(eval $(call gen_build_rules,${SD_:./%=%},$(patsubst ./%,%,${SD_:${SRCDIR_}%=%}))))
# Make sure that environment compiler flags are passed through
# to sub-makes. The _ENV* variables are defined in vars.mk
install:
@mkdir -p ${FSLDEVDIR}
@CXXFLAGS="${_ENVCXXFLAGS}" \
CFLAGS="${_ENVCFLAGS}" \
CPPFLAGS="${_ENVCPPFLAGS}" \
LDFLAGS="${_ENVLDFLAGS}" \
${MAKE} \
"DESTDIR=${FSLDEVDIR}" \
master-install-script
# The custominstall rule can be optionally
# defined in project Makefiles.
.PHONY: custominstall
master-install-script:
@if [ "X${PROJNAME}X" = XX ] ; then \
echo " " ; \
echo "No PROJNAME defined in the Makefile" ; \
echo " ... aborting install" ; \
echo " " ; \
exit 4 ; \
fi;
@CXXFLAGS="${_ENVCXXFLAGS}" \
CFLAGS="${_ENVCFLAGS}" \
CPPFLAGS="${_ENVCPPFLAGS}" \
LDFLAGS="${_ENVLDFLAGS}" \
${MAKE} all
@${MAKE} exeinstall
@${MAKE} hdrinstall
@${MAKE} libinstall
@${MAKE} tclinstall
@${MAKE} pyinstall
@${MAKE} datainstall
@${MAKE} custominstall
# Generic routine used to install
# XFILES, PYFILES, SCRIPTS, etc etc
# Expects four arguments:
# - $1: Label, just used to print a descriptive message
# - $2: Destination directory for installation
# - $3: Permission mask to apply to all installed files (e.g. 0755)
# - $4: Space-separated list of target files/directories to install
define _x_install =
if ! echo $(wildcard $(4)) | grep -q -e "^ *$$"; then \
echo Installing $(1) ; \
${MKDIR} -p -m 0755 $(2) ; \
fi
for target in $(4) verylongdummyname ; do \
if [ -f $$target ] ; then \
echo ${INSTALL} -m $(3) $$target $(2)/ ; \
${INSTALL} -m $(3) $$target $(2)/ ; \
elif [ -d $$target ]; then \
echo ${CP} -r $$target $(2)/ ; \
${CP} -r $$target $(2)/ ; \
find $(2)/`basename $$target` -type d -exec chmod 0755 {} \; ; \
find $(2)/`basename $$target` -type f -exec chmod $(3) {} \; ; \
fi; \
done;
endef
# Installs PYFILES into $FSLDIR/etc/fsl/python/$PROJNAME/
pyinstall:
@${MKDIR} -p -m 0755 $(dest_PYDIR)
@$(call _x_install,"python scripts",${dest_PYDIR}/${PROJNAME}/,0644,${PYFILES})
# Installs AFILES and SOFILES into $FSLDIR/lib/
libinstall:
@${MKDIR} -p -m 0755 $(dest_LIBDIR)
@$(call _x_install,"library files",${dest_LIBDIR},0644,${AFILES} ${SOFILES})
# Installs:
# - HFILES into $FSLDIR/include/$PROJNAME/
# - GLOBALHFILES into $FSLDIR/include/
hdrinstall:
@${MKDIR} -p -m 0755 $(dest_INCDIR)
@$(call _x_install,"header files",${dest_INCDIR}/${PROJNAME}/,0644,${HFILES})
@$(call _x_install,"global header files",${dest_INCDIR}/,0644,${GLOBALHFILES})
# Installs DATAFILES into $FSLDIR/data/$PROJNAME/
datainstall:
@${MKDIR} -p -m 0755 $(dest_DATADIR)
@$(call _x_install,"data files",${dest_DATADIR}/${PROJNAME}/,0644,${DATAFILES})
# Installs:
# - XFILES into $FSLDIR/bin/
# - SCRIPTS into $FSLDIR/bin/
exeinstall:
@${MKDIR} -p -m 0755 $(dest_BINDIR)
@$(call _x_install,"binaries",${dest_BINDIR}/,0755,${XFILES})
@$(call _x_install,"scripts",${dest_BINDIR}/,0755,${SCRIPTS})
# Installs:
# - TCLFILES into $FSLDIR/tcl/
# - RUNTCLS into $FSLDIR/bin/
tclinstall:
@${MKDIR} -p -m 0755 $(dest_TCLDIR)
@${MKDIR} -p -m 0755 $(dest_BINDIR)
@$(call _x_install,"tcl scripts",${dest_TCLDIR}/,0755,${TCLFILES})
@# create RUNTCLS links
@for lntarget in ${RUNTCLS} verylongdummyname ; do \
if [ $${lntarget} != verylongdummyname ] ; then \
cd ${dest_BINDIR} ; \
if [ ${SYSTYPE} != Darwin ] ; then \
${RM} -f $${lntarget} ; \
echo ln -s Runtcl $${lntarget} ; \
ln -s Runtcl $${lntarget} ; \
fi ; \
${RM} -f $${lntarget}_gui ; \
echo ln -s Runtcl $${lntarget}_gui ; \
ln -s Runtcl $${lntarget}_gui ; \
fi \
done
#!/bin/sh
#
# Returns a string with allowed -gencode value pairs
# for the given CUDA version.
#
# Compute capabilities that are supported by each CUDA
# version are listed in the "Compute Capabilities"
# table of the Programming guide for each CUDA version,
# e.g.:
#
# https://docs.nvidia.com/cuda/archive/11.4.1/cuda-c-programming-guide/index.html#compute-capabilities
#
# The topic of binary and PTX compute capability
# compatibility is described in the CUDA programming
# guide:
#
# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#binary-compatibility
vn=$1
if [ "$vn" = 5.5 ]
then
echo "-gencode arch=compute_10,code=sm_10 \
-gencode arch=compute_11,code=sm_11 \
-gencode arch=compute_12,code=sm_12 \
-gencode arch=compute_13,code=sm_13 \
-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_35,code=compute_35"
elif [ "$vn" = 6.0 ]
then
echo "-gencode arch=compute_10,code=sm_10 \
-gencode arch=compute_11,code=sm_11 \
-gencode arch=compute_12,code=sm_12 \
-gencode arch=compute_13,code=sm_13 \
-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50"
elif [ "$vn" = 6.5 ]
then
echo "-gencode arch=compute_11,code=sm_11 \
-gencode arch=compute_12,code=sm_12 \
-gencode arch=compute_13,code=sm_13 \
-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50"
elif [ "$vn" = 7.0 ] ||
[ "$vn" = 7.5 ]
then
echo "-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_53,code=compute_53"
elif [ "$vn" = 8.0 ]
then
echo "-gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_62,code=compute_62"
elif [ "$vn" = 9.0 ] ||
[ "$vn" = 9.1 ]
then
echo "-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_70,code=compute_70"
elif [ "$vn" = 9.2 ]
then
echo "-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_72,code=compute_72"
elif [ "$vn" = 10.0 ] ||
[ "$vn" = 10.1 ] ||
[ "$vn" = 10.2 ]
then
echo "-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_32,code=sm_32 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_75,code=compute_75"
elif [ "$vn" = 11.0 ]
then
echo "-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_80,code=compute_80"
elif [ "$vn" = 11.1 ] ||
[ "$vn" = 11.2 ] ||
[ "$vn" = 11.3 ] ||
[ "$vn" = 11.4 ]
then
echo "-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_86,code=sm_86 \
-gencode arch=compute_86,code=compute_86"
elif [ "$vn" = 11.5 ] ||
[ "$vn" = 11.6 ] ||
[ "$vn" = 11.7 ]
then
echo "-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_86,code=sm_86 \
-gencode arch=compute_87,code=sm_87 \
-gencode arch=compute_87,code=compute_87"
elif [ "$vn" = 11.8 ]
then
echo "-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_37,code=sm_37 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_86,code=sm_86 \
-gencode arch=compute_87,code=sm_87 \
-gencode arch=compute_89,code=sm_89 \
-gencode arch=compute_90,code=sm_90 \
-gencode arch=compute_90,code=compute_90"
elif [ "$vn" = 12.0 ] ||
[ "$vn" = 12.1 ] ||
[ "$vn" = 12.2 ] ||
[ "$vn" = 12.3 ] ||
[ "$vn" = 12.4 ] ||
[ "$vn" = 12.5 ] ||
[ "$vn" = 12.6 ]
then
echo "-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_53,code=sm_53 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_62,code=sm_62 \
-gencode arch=compute_70,code=sm_70 \
-gencode arch=compute_72,code=sm_72 \
-gencode arch=compute_75,code=sm_75 \
-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_86,code=sm_86 \
-gencode arch=compute_87,code=sm_87 \
-gencode arch=compute_89,code=sm_89 \
-gencode arch=compute_90,code=sm_90 \
-gencode arch=compute_90,code=compute_90"
else
echo "Unrecognised CUDA version: $vn"
exit 1
fi
#########################################################
# 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.
#########################################################
# Boolean flag which defines this FSL installation
# as being from FSL 6.0.6 or newer ("GE" = greater
# than or equal to). This flag may be used by FSL
# Makefiles which need to preserve support for
# older versions of FSL.
FSL_GE_606 := true
# All projects must specify a name
PROJNAME ?=
# Project-specific compiler/linker flags - these
# can be overridden in the project Makefile, or
# by the environment.
USRLDFLAGS ?= # Linker flags
USRINCFLAGS ?= # Include directories
USRCFLAGS ?= # Compiler flags for C files
USRCXXFLAGS ?= # Compiler flags for C++ files
USRCPPFLAGS ?= # Preprocessor flags
USRNVCCFLAGS ?= # Compiler flags for CUDA files
USRNVCCLDFLAGS ?= # Linker flags for CUDA libraries/executables
# Libraries to link against for C and C++ projects -
# these are incorporated into the final LDFLAGS, below.
LIBS ?=
# CUDA libraries to link against (e.g. curand, cublas, etc) -
# these are incorporated into the final NVCCLDFLAGS, below.
# -lcuda and -lcudart are automatically added, so do not
# need to be explicitly listed. Dynamic library names should
# be used here - they will be transformed to their static
# versions if static compilation is selected is set (see
# buildSettings.mk).
CUDALIBS ?=
# Project outputs - these variables control
# what gets installed from a project. They
# may be customised/overridden in project
# Makefiles.
HFILES ?= *.h # installed into $FSLDIR/include/$PROJNAME/
GLOBALHFILES ?= # installed into $FSLDIR/include/ (should
# not be used in normal circumstances)
AFILES ?= *.a # installed into $FSLDIR/lib/
SOFILES ?= *.so # installed into $FSLDIR/lib/
XFILES ?= # installed into $FSLDIR/bin/
FXFILES ?= # installed into $FSLDIR/bin/, only for internal builds
SCRIPTS ?= # installed into $FSLDIR/bin/
FSCRIPTS ?= # installed into $FSLDIR/bin/, only for internal builds
RUNTCLS ?= # link to Runtcl created in $FSLDIR/bin/ which assumes
# that <file>.tcl has been installed into
# $FSLDIR/tcl/
PYFILES ?= *.py # installed into $FSLDIR/etc/fsl/python/$PROJNAME/
TCLFILES ?= *.tcl # installed into $FSLDIR/tcl/
DATAFILES ?= # installed into $FSLDIR/data/$PROJNAME/
TESTXILES ?= # not currently used
# Final install destinations
# for project outputs
DESTDIR = ${FSLDEVDIR}
dest_INCDIR = ${DESTDIR}/include
dest_LIBDIR = ${DESTDIR}/lib
dest_BINDIR = ${DESTDIR}/bin
dest_TCLDIR = ${DESTDIR}/tcl
dest_PYDIR = ${DESTDIR}/python
dest_DOCDIR = ${DESTDIR}/doc
dest_DATADIR = ${DESTDIR}/data
# Standard header/library locations for compiling/linking
FSL_INCDIR = ${FSLDIR}/include
FSL_LIBDIR = ${FSLDIR}/lib
FSL_DEVINCDIR = ${FSLDEVDIR}/include
FSL_DEVLIBDIR = ${FSLDEVDIR}/lib
# Final header include directories
INCFLAGS = -isystem ${FSL_DEVINCDIR} -isystem ${FSL_INCDIR} -I /workspace/FSL-install/include -I . ${USRINCFLAGS} -g
NVCCINCFLAGS = -isystem ${CUDA_HOME}/include \
-isystem ${CUDA_HOME}/targets/x86_64-linux/include
#############################
# Final compiler/linker flags
#############################
# All projects must use these flags for compilation/linking.
# Commands for compilation of intermediate object files
# should have the form:
# $(CC) $(CFLAGS) <input/output files> # for .c files
# $(CXX) $(CXXFLAGS) <input/output files> # for .cc files
# $(NVCC) $(NVCCFLAGS) <input/output files> # for .cu files
#
# And commands for compilation and linking of executables
# and libraries should have the form:
#
# $(CC) $(CFLAGS) <input/output files> ${LDFLAGS} # for c libs/exes
# $(CXX) $(CXXFLAGS) <input/output files> ${LDFLAGS} # for executables
# $(CXX) $(CXXFLAGS) -shared <input/output files> ${LDFLAGS} # for dynanmic libs
# $(NVCC) $(NVCCFLAGS) -shared <input/output files> ${NVCCLDFLAGS} # for CUDA libs
# $(NVCC) $(NVCCFLAGS) <input/output files> ${NVCCLDFLAGS} # for CUDA exes
#
# When creating shared libraries and linking executables,
# `LDFLAGS` *must* come at the end, to ensure proper linking.
#
# The order in which the final FLAGS variables are
# constructed here is important:
#
# 1. Include flags come first, so they aren't
# overridden by the environment.
# 2. Flags provided by the environment come next
# 3. ARCH* flags defined in buildSettings.mk come next
# 4. USR* flags defined in the Project Makefile come
# last.
#
# 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.
#
# We save copis of *FLAGS from the environment before
# constructing their final values, so we can prepend
# flags before them without running into issues w.r.t.
# recursively expanded variables.
_ENVCFLAGS := ${CFLAGS}
_ENVCPPFLAGS := ${CPPFLAGS}
_ENVCXXFLAGS := ${CXXFLAGS}
_ENVLDFLAGS := ${LDFLAGS}
# Final construction of compiler flags
CPPFLAGS = ${_ENVCPPFLAGS} ${ARCHCPPFLAGS} ${USRCPPFLAGS}
CFLAGS = ${INCFLAGS} ${_ENVCFLAGS} ${CPPFLAGS} ${ARCHCFLAGS} ${USRCFLAGS}
CXXFLAGS = ${INCFLAGS} ${_ENVCXXFLAGS} ${CPPFLAGS} ${ARCHCXXFLAGS} ${USRCXXFLAGS}
LDFLAGS = ${_ENVLDFLAGS} ${ARCHLDFLAGS} ${USRLDFLAGS} \
-L /workspace/FSL-install/lib -L${FSL_DEVLIBDIR} -L${FSL_LIBDIR} \
${LIBS} ${ARCHLIBS}
# TODO
# CUDACXXFLAGS is used for compiling .cpp files with
# g++ which include CUDA headers. This really shouldn't
# be neeed, but is used by eddy for the time being.
CUDACXXFLAGS = ${NVCCINCFLAGS} ${CXXFLAGS} ${USRNVCCFLAGS}
# Remove any -std=c++ options, as we are already setting
# -std in ARCHNVCCFLAGS (see buildSettings.mk), and
# passing another one via --compiler-options will confuse
# nvcc. We assume that project Makefile has not added
# -std to USRCXXFLAGGS/USRCPPFLAGS.
# NVCCFLAGS += ${NVCCINCFLAGS} \
# --compiler-options "${INCFLAGS}" \
# --compiler-options "$(patsubst -std=c++%,,${_ENVCXXFLAGS})" \
# --compiler-options "${CPPFLAGS}" \
# ${ARCHNVCCFLAGS} \
# --compiler-options "$(patsubst -std=c++%,,${ARCHCXXFLAGS})" \
# ${USRNVCCFLAGS} \
# --compiler-options "${USRCXXFLAGS}"
NVCCFLAGS += ${NVCCINCFLAGS} \
"${INCFLAGS}" \
"$(patsubst -std=c++%,,${_ENVCXXFLAGS})" \
"${CPPFLAGS}" \
${ARCHNVCCFLAGS} \
"$(patsubst -std=c++%,,${ARCHCXXFLAGS})" \
${USRNVCCFLAGS} \
"${USRCXXFLAGS}"
# NVCCLDFLAGS += ${ARCHNVCCLDFLAGS} \
# --compiler-options "${ARCHLDFLAGS}" \
# ${USRNVCCLDFLAGS} \
# --compiler-options "${USRLDFLAGS}" \
# -L. -L${FSL_DEVLIBDIR} -L${FSL_LIBDIR} \
# ${LIBS} ${_CUDALIBS} ${ARCHLIBS}
NVCCLDFLAGS += ${ARCHNVCCLDFLAGS} \
"${ARCHLDFLAGS}" \
${USRNVCCLDFLAGS} \
"${USRLDFLAGS}" \
-L. -L${FSL_DEVLIBDIR} -L${FSL_LIBDIR} \
${LIBS} ${_CUDALIBS} ${ARCHLIBS}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment