4 # bsd.gcc.mk - Support for smarter USE_GCC usage.
6 # Created by: Edwin Groothuis <edwin@freebsd.org>
8 # To request the use of a current version of GCC, specify USE_GCC=yes in
9 # your port/system configuration. This is the preferred use of USE_GCC.
10 # It defines a canonical, default version of GCC; the same version of
11 # GCC is also implied by USE_FORTRAN=yes.
13 # If your port needs a specific (minimum) version of GCC, you can easily
14 # specify that with a USE_GCC= statement. Unless absolutely necessary
15 # do so by specifying USE_GCC=X.Y+ which requests at least GCC version
16 # X.Y. To request a specific version omit the trailing + sign. Use of
17 # a Fortran compiler is declared by the USE_FORTRAN knob, not USE_GCC.
20 # USE_GCC= yes # port requires a current version of GCC
21 # # (4.6 as of today, subject to change).
22 # USE_GCC= 4.2+ # port requires GCC 4.2 or later.
23 # USE_GCC= 4.7 # port requires GCC 4.7.
25 # If your port needs a Fortran compiler, please specify that with the
26 # USE_FORTRAN= knob. Here is the list of options for that knob:
28 # USE_FORTRAN= yes # use gfortran47 (lang/gcc-aux)
29 # USE_FORTRAN= g77 # use g77-34 (lang/gcc34)
30 # USE_FORTRAN= ifort # use the Intel compiler (lang/ifc)
32 # Due to object file incompatiblity between Fortran compilers, we strongly
33 # recommend to use only one of them on any system.
35 # If you are wondering what your port exactly does, use "make test-gcc"
36 # to see some debugging.
38 # $FreeBSD: Mk/bsd.gcc.mk 315538 2013-03-29 11:26:14Z gerald $
41 GCC_Include_MAINTAINER= gerald@FreeBSD.org
43 # All GCC versions supported by the ports framework. Keep them in
44 # ascending order and in sync with the table below.
45 GCCVERSIONS= 030402 040200 040400 040600 040700 040800
47 # The first field if the DFLYVERSION in which it appeared in the base.
48 # The second field is the DFLYVERSION in which it disappeared from the base.
49 # The third field is the version as USE_GCC would use.
50 # This doesn't work so well with DragonFly due to dual compilers
51 # DPorts wasn't supported until DragonFly 3.3.
52 GCCVERSION_030402= 100000 200000 3.4
53 GCCVERSION_040100= 200000 300200 4.1
54 GCCVERSION_040200= 0 0 4.2
55 GCCVERSION_040400= 300200 300400 4.4
56 GCCVERSION_040600= 0 0 4.6
57 GCCVERSION_040700= 300400 9999999 4.7
58 GCCVERSION_040800= 0 0 4.8
60 GCC_DEFAULT_VERSION= 4.7
61 DFLY_DEFAULT_VERSION= 47
62 GCC_DEFAULT_V= ${GCC_DEFAULT_VERSION:S/.//}
64 # No configurable parts below this. ####################################
67 .if defined(USE_GCC) && ${USE_GCC} == yes
68 USE_GCC= ${GCC_DEFAULT_VERSION}
71 # Extract the fields from GCCVERSION_...
72 .for v in ${GCCVERSIONS}
73 . for j in ${GCCVERSION_${v}}
74 . if !defined(_GCCVERSION_${v}_L)
75 _GCCVERSION_${v}_L= ${j}
76 . elif !defined(_GCCVERSION_${v}_R)
77 _GCCVERSION_${v}_R= ${j}
78 . elif !defined(_GCCVERSION_${v}_V)
79 _GCCVERSION_${v}_V= ${j}
84 # bsd.gcc.mk can also be used for primarily requesting a Fortran compiler.
85 # If we are using GCC we still define whatever we'd usually do for C and
88 .if defined (USE_FORTRAN)
90 # The default case, with a current lang/gcc port.
91 . if ${USE_FORTRAN} == yes
92 BUILD_DEPENDS+= ${LOCALBASE}/gcc-aux/bin/gfortran:${PORTSDIR}/lang/gcc-aux
93 RUN_DEPENDS+= ${LOCALBASE}/gcc-aux/bin/gfortran:${PORTSDIR}/lang/gcc-aux
94 _USE_GCC:= ${GCC_DEFAULT_VERSION} # dummy to avoid further depends
95 _GCC_RUNTIME:= ${LOCALBASE}/gcc-aux/lib
96 FC:= ${LOCALBASE}/gcc-aux/bin/gfortran
97 F77:= ${LOCALBASE}/gcc-aux/bin/gfortran
98 CC:= ${LOCALBASE}/gcc-aux/bin/gcc
99 CXX:= ${LOCALBASE}/gcc-aux/bin/g++
100 CPP:= ${LOCALBASE}/gcc-aux/bin/cpp
101 LDFLAGS+= -L${LOCALBASE}/gcc-aux/lib -Wl,-rpath,${LOCALBASE}/gcc-aux/lib
103 # Intel Fortran compiler from lang/ifc.
104 . elif ${USE_FORTRAN} == ifort
105 BUILD_DEPENDS+= ${LOCALBASE}/intel_fc_80/bin/ifort:${PORTSDIR}/lang/ifc
106 RUN_DEPENDS+= ${LOCALBASE}/intel_fc_80/bin/ifort:${PORTSDIR}/lang/ifc
107 FC:= ${LOCALBASE}/intel_fc_80/bin/ifort
108 F77:= ${LOCALBASE}/intel_fc_80/bin/ifort
110 # g77 from lang/gcc34.
111 . elif ${USE_FORTRAN} == g77
116 IGNORE= specifies unknown value "${USE_FORTRAN}" for USE_FORTRAN
119 CONFIGURE_ENV+= F77="${F77}" FC="${FC}" FFLAGS="${FFLAGS}"
120 MAKE_ENV+= F77="${F77}" FC="${FC}" FFLAGS="${FFLAGS}"
124 .if defined(USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
126 . if empty(USE_GCC) || ${USE_GCC} == any || ${USE_GCC:tl} == "yes"
128 # Enable the clang-is-cc workaround. Default to the last GCC imported
130 _USE_GCC:= ${GCC_DEFAULT_VERSION}
133 . else # ${USE_GCC} == any
135 # See if we can use a later version or exclusively the one specified.
136 _USE_GCC:= ${USE_GCC:S/+//}
137 .if ${USE_GCC} != ${_USE_GCC}
141 . endif # ${USE_GCC} == any
143 # Initialize _GCC_FOUND${v}. In parallel, check if USE_GCC points to a
144 # valid version to begin with.
145 # Set USE_GCC=3.4(4.2, 4.4, 4.6) all to base compiler (4.7)
146 .for v in ${GCCVERSIONS}
147 . if ${DFLYVERSION} >= ${_GCCVERSION_${v}_L} \
148 && ${DFLYVERSION} < ${_GCCVERSION_${v}_R} \
149 && ${DFLY_DEFAULT_VERSION} <= ${_GCCVERSION_${v}_V:S/.//}
151 . elif exists(${LOCALBASE}/bin/gcc${_GCCVERSION_${v}_V:S/.//})
154 . if ${_USE_GCC}==${_GCCVERSION_${v}_V}
155 _GCCVERSION_OKAY= true
159 .if !defined(_GCCVERSION_OKAY)
160 IGNORE= Unknown version of GCC specified (USE_GCC=${USE_GCC})
163 # If the GCC package defined in USE_GCC does not exist, but a later
164 # version is allowed (for example 4.2+), see if there is a later.
165 # First check if the base installed version is good enough, otherwise
166 # get the first available version.
168 .if defined(_GCC_ORLATER)
169 . for v in ${GCCVERSIONS}
170 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
173 . if defined(_GCC_MIN1) && defined(_GCC_FOUND${v}) && ${_GCC_FOUND${v}}=="base" && !defined(_GCC_FOUND)
174 _GCC_FOUND:= ${_GCCVERSION_${v}_V}
177 . for v in ${GCCVERSIONS}
178 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
181 . if defined(_GCC_MIN2) && defined(_GCC_FOUND${v}) && !defined(_GCC_FOUND)
182 _GCC_FOUND:= ${_GCCVERSION_${v}_V}
186 . if defined(_GCC_FOUND)
187 _USE_GCC:= ${_GCC_FOUND}
188 . elif ${_USE_GCC} < ${GCC_DEFAULT_VERSION}
189 _USE_GCC:= ${GCC_DEFAULT_VERSION}
191 .endif # defined(_GCC_ORLATER)
193 .endif # defined(USE_GCC)
196 .if defined(_USE_GCC)
197 # A concrete version has been selected. Determine if the installed OS
198 # features this version in the base, and if not then set proper ports
199 # dependencies, CC, CXX, CPP, and flags.
200 .for v in ${GCCVERSIONS}
201 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
202 . if ${DFLYVERSION} < ${_GCCVERSION_${v}_L} || ${DFLYVERSION} > ${_GCCVERSION_${v}_R}
203 V:= ${_GCCVERSION_${v}_V:S/.//}
204 _GCC_PORT_DEPENDS:= gcc${V}
205 . if ${_USE_GCC} == ${GCC_DEFAULT_VERSION}
213 . if ${_USE_GCC} != 3.4
214 _GCC_RUNTIME:= ${LOCALBASE}/lib/gcc${V}
215 CFLAGS+= -Wl,-rpath=${_GCC_RUNTIME}
216 CXXFLAGS+= -Wl,-rpath=${_GCC_RUNTIME}
217 LDFLAGS+= -Wl,-rpath=${_GCC_RUNTIME}
218 . if defined (USE_FORTRAN)
219 . if ${USE_FORTRAN} == yes
220 FFLAGS+= -Wl,-rpath=${_GCC_RUNTIME}
223 # The following is for the sakes of some ports which use this without
224 # ever telling us; to be fixed.
225 _GCC_BUILD_DEPENDS:= ${_GCC_PORT_DEPENDS}
226 . endif # ${_USE_GCC} != 3.4
227 . else # Use GCC in base.
231 CONFIGURE_ENV+= CCVER=gcc${DFLY_DEFAULT_VERSION}
232 MAKE_ENV+= CCVER=gcc${DFLY_DEFAULT_VERSION}
233 . endif # Use GCC in base.
234 . endif # ${_USE_GCC} == ${_GCCVERSION_${v}_V}
238 .if defined(_GCC_PORT_DEPENDS)
239 BUILD_DEPENDS+= ${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_PORT}
240 . if ${_USE_GCC} != 3.4
241 RUN_DEPENDS+= ${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_PORT}
242 . if ${_USE_GCC:S/.//} > ${GCC_DEFAULT_VERSION}
243 # Later GCC ports already depend on binutils; make sure whatever we
244 # build leverages this as well.
249 .endif # defined(_USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
253 @echo USE_GCC=${USE_GCC}
254 @echo USE_FORTRAN=${USE_FORTRAN}
256 @echo "IGNORE: ${IGNORE}"
259 .if defined(_GCC_ORLATER)
260 @echo Port can use later versions.
262 @echo Port cannot use later versions.
264 .for v in ${GCCVERSIONS}
265 @echo -n "GCC version: ${_GCCVERSION_${v}_V} "
266 .if defined(_GCC_FOUND${v})
267 @echo -n "(${_GCC_FOUND${v}}) "
269 @echo "- OSVERSION from ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R}"
270 # @echo ${v} - ${_GCC_FOUND${v}} - ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R} - ${_GCCVERSION_${v}_V}
272 @echo Using GCC version ${_USE_GCC}
274 @echo CC=${CC} - CXX=${CXX} - CPP=${CPP} - CFLAGS=\"${CFLAGS}\"
275 @echo F77=${F77} - FC=${FC} - FFLAGS=\"${FFLAGS}\"
276 @echo LDFLAGS=\"${LDFLAGS}\"
277 @echo CONFIGURE_ENV=${CONFIGURE_ENV}
278 @echo MAKE_ENV=${MAKE_ENV}
279 @echo "BUILD_DEPENDS=${BUILD_DEPENDS}"
280 @echo "RUN_DEPENDS=${RUN_DEPENDS}"