vars.mk 8.04 KB
Newer Older
wangkx1's avatar
change  
wangkx1 committed
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
#########################################################
# 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}