Tweak science/libsvm version 3.18
[dports.git] / Mk / bsd.gcc.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # bsd.gcc.mk - Support for smarter USE_GCC usage.
5 #
6 # Created by: Edwin Groothuis <edwin@freebsd.org>
7 #
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 uses the canonical version of GCC defined in bsd.default-versions.mk.
11 #
12 # USE_GCC=any is similar, except that it also accepts the old GCC 4.2-
13 # based system compiler in older versions of FreeBSD.
14
15 # If your port needs a specific (minimum) version of GCC, you can easily
16 # specify that with a USE_GCC= statement.  Unless absolutely necessary
17 # do so by specifying USE_GCC=X.Y+ which requests at least GCC version
18 # X.Y.  To request a specific version omit the trailing + sign.
19 #
20 # Examples:
21 #   USE_GCC=    yes                     # port requires a current version of GCC
22 #                                                       # as defined in bsd.default-versions.mk.
23 #   USE_GCC=    any                     # port requires GCC 4.2 or later.
24 #   USE_GCC=    4.8+            # port requires GCC 4.8 or later.
25 #   USE_GCC=    4.8                     # port requires GCC 4.8.
26 #
27 # If you are wondering what your port exactly does, use "make test-gcc"
28 # to see some debugging.
29 #
30 # $FreeBSD$
31
32 GCC_Include_MAINTAINER=         gerald@FreeBSD.org
33
34 .include "${PORTSDIR}/Mk/bsd.default-versions.mk"
35
36 # All GCC versions supported by the ports framework.  Keep them in
37 # ascending order and in sync with the table below. 
38 GCCVERSIONS=    040200 040600 040700 040800 040900
39
40 # The first field if the OSVERSION in which it appeared in the base.
41 # The second field is the OSVERSION in which it disappeared from the base.
42 # The third field is the version as USE_GCC would use.
43 GCCVERSION_040200=           0       0 4.2
44 GCCVERSION_040600=           0       0 4.6
45 GCCVERSION_040700=      300400 9999999 4.7
46 GCCVERSION_040800=           0       0 4.8
47 GCCVERSION_040900=           0       0 4.9
48
49 # Version of lang/gcc
50 GCC_DEFAULT_V=  4.8
51 DFLY_DEFAULT_VERSION=   47
52
53 # No configurable parts below this. ####################################
54 #
55
56 .if defined(USE_GCC) && ${USE_GCC} == yes
57 USE_GCC=        ${GCC_DEFAULT}
58 .endif
59
60 # Extract the fields from GCCVERSION_...
61 .for v in ${GCCVERSIONS}
62 . for j in ${GCCVERSION_${v}}
63 .  if !defined(_GCCVERSION_${v}_L)
64 _GCCVERSION_${v}_L=     ${j}
65 .  elif !defined(_GCCVERSION_${v}_R)
66 _GCCVERSION_${v}_R=     ${j}
67 .  elif !defined(_GCCVERSION_${v}_V)
68 _GCCVERSION_${v}_V=     ${j}
69 .  endif
70 . endfor
71 .endfor
72
73 .if defined(USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
74
75 . if empty(USE_GCC) || ${USE_GCC} == any || ${USE_GCC:tl} == "yes"
76
77 # Enable the clang-is-cc workaround.  Default to the last GCC imported
78 # into base.
79 _USE_GCC:=      ${GCC_DEFAULT}
80 _GCC_ORLATER:=  false
81
82 . else # ${USE_GCC} == any
83
84 # See if we can use a later version or exclusively the one specified.
85 _USE_GCC:=      ${USE_GCC:S/+//}
86 .if ${USE_GCC} != ${_USE_GCC}
87 _GCC_ORLATER:=  true
88 .endif
89
90 . endif # ${USE_GCC} == any
91
92 # Initialize _GCC_FOUND${v}.  In parallel, check if USE_GCC points to a
93 # valid version to begin with.
94 # Set USE_GCC=3.4(4.2, 4.4, 4.6) all to base compiler (4.7)
95 .for v in ${GCCVERSIONS}
96 . if ${DFLYVERSION} >= ${_GCCVERSION_${v}_L} \
97   && ${DFLYVERSION} <  ${_GCCVERSION_${v}_R} \
98   && ${DFLY_DEFAULT_VERSION} <= ${_GCCVERSION_${v}_V:S/.//}
99 _GCC_FOUND${v}= base
100 . elif exists(${LOCALBASE}/bin/gcc${_GCCVERSION_${v}_V:S/.//})
101 _GCC_FOUND${v}= port
102 . endif
103 . if ${_USE_GCC}==${_GCCVERSION_${v}_V}
104 _GCCVERSION_OKAY=       true
105 . endif
106 .endfor
107
108 .if !defined(_GCCVERSION_OKAY)
109 IGNORE= Unknown version of GCC specified (USE_GCC=${USE_GCC})
110 .endif
111
112 # If the GCC package defined in USE_GCC does not exist, but a later
113 # version is allowed (for example 4.7+), see if there is a later.
114 # First check if the base installed version is good enough, otherwise
115 # get the first available version.
116 #
117 .if defined(_GCC_ORLATER)
118 . for v in ${GCCVERSIONS}
119 .  if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
120 _GCC_MIN1:=     true
121 .  endif
122 .  if defined(_GCC_MIN1) && defined(_GCC_FOUND${v}) && ${_GCC_FOUND${v}}=="base" && !defined(_GCC_FOUND)
123 _GCC_FOUND:=    ${_GCCVERSION_${v}_V}
124 .  endif
125 . endfor
126 . for v in ${GCCVERSIONS}
127 .  if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
128 _GCC_MIN2:=     true
129 .  endif
130 .  if defined(_GCC_MIN2) && defined(_GCC_FOUND${v}) && !defined(_GCC_FOUND)
131 _GCC_FOUND:=    ${_GCCVERSION_${v}_V}
132 .  endif
133 . endfor
134
135 . if defined(_GCC_FOUND)
136 _USE_GCC:=      ${_GCC_FOUND}
137 . elif ${_USE_GCC} < ${GCC_DEFAULT}
138 _USE_GCC:=      ${GCC_DEFAULT}
139 . endif
140 .endif # defined(_GCC_ORLATER)
141
142 .endif # defined(USE_GCC)
143
144
145 .if defined(_USE_GCC)
146 # A concrete version has been selected.  Determine if the installed OS 
147 # features this version in the base, and if not then set proper ports
148 # dependencies, CC, CXX, CPP, and flags.
149 .for v in ${GCCVERSIONS}
150 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
151 .  if ${DFLYVERSION} < ${_GCCVERSION_${v}_L} || ${DFLYVERSION} > ${_GCCVERSION_${v}_R}
152 V:=                     ${_GCCVERSION_${v}_V:S/.//}
153 _GCC_PORT_DEPENDS:=     gcc${V}
154 .   if ${_USE_GCC} == ${GCC_DEFAULT_V}
155 _GCC_PORT:=             gcc
156 .   else
157 _GCC_PORT:=             gcc${V}
158 .   endif
159 CC:=                    gcc${V}
160 CXX:=                   g++${V}
161 CPP:=                   cpp${V}
162 _GCC_RUNTIME:=          ${LOCALBASE}/lib/gcc${V}
163 CFLAGS+=                -Wl,-rpath=${_GCC_RUNTIME}
164 CXXFLAGS+=              -Wl,-rpath=${_GCC_RUNTIME}
165 LDFLAGS+=               -Wl,-rpath=${_GCC_RUNTIME} -L${_GCC_RUNTIME}
166 .  else # Use GCC in base.
167 CC:=                    gcc
168 CXX:=                   g++
169 CPP:=                   cpp
170 CONFIGURE_ENV+=         CCVER=gcc${DFLY_DEFAULT_VERSION}
171 MAKE_ENV+=              CCVER=gcc${DFLY_DEFAULT_VERSION}
172 .  endif # Use GCC in base.
173 . endif # ${_USE_GCC} == ${_GCCVERSION_${v}_V}
174 .endfor
175 .undef V
176
177 .if defined(_GCC_PORT_DEPENDS)
178 BUILD_DEPENDS+= ${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_PORT}
179 RUN_DEPENDS+=   ${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_PORT}
180 .  if ${_USE_GCC:S/.//} > ${GCC_DEFAULT}
181 # Later GCC ports already depend on binutils; make sure whatever we
182 # build leverages this as well.
183 USE_BINUTILS=   yes
184 .  endif
185 .endif
186 .endif # defined(_USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
187
188
189 test-gcc:
190         @echo USE_GCC=${USE_GCC}
191 .if defined(IGNORE)
192         @echo "IGNORE: ${IGNORE}"
193 .else
194 .if defined(USE_GCC)
195 .if defined(_GCC_ORLATER)
196         @echo Port can use later versions.
197 .else
198         @echo Port cannot use later versions.
199 .endif
200 .for v in ${GCCVERSIONS}
201         @echo -n "GCC version: ${_GCCVERSION_${v}_V} "
202 .if defined(_GCC_FOUND${v})
203         @echo -n "(${_GCC_FOUND${v}}) "
204 .endif
205         @echo "- OSVERSION from ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R}"
206 #       @echo ${v} - ${_GCC_FOUND${v}} - ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R} - ${_GCCVERSION_${v}_V}
207 .endfor
208         @echo Using GCC version ${_USE_GCC}
209 .endif
210         @echo CC=${CC} - CXX=${CXX} - CPP=${CPP} - CFLAGS=\"${CFLAGS}\"
211         @echo LDFLAGS=\"${LDFLAGS}\"
212         @echo CONFIGURE_ENV=${CONFIGURE_ENV}
213         @echo MAKE_ENV=${MAKE_ENV}
214         @echo "BUILD_DEPENDS=${BUILD_DEPENDS}"
215         @echo "RUN_DEPENDS=${RUN_DEPENDS}"
216 .endif