Update www/p5-HTML-Parser-Simple to version 2.02
[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.9+            # port requires GCC 4.9 or later.
25 #   USE_GCC=    4.9                     # port requires GCC 4.9.
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 050000
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 42
44 GCCVERSION_040600=           0       0 4.6 43
45 GCCVERSION_040800=           0       0 4.8 48
46 GCCVERSION_040900=           0       0 4.9 49
47
48 .if defined(NO_GCC50) || !defined(DPORTS_BUILDER)
49 GCCVERSION_040700=      300400 9999999 4.7 47
50 GCCVERSION_050000=           0       0 5   50
51 .else
52 GCCVERSION_040700=      300400  400102 4.7 47
53 GCCVERSION_050000=      400103 9999999 5   50
54 .endif
55
56 # No configurable parts below this. ####################################
57 #
58
59 # Extract the fields from GCCVERSION_...
60 .for v in ${GCCVERSIONS}
61 . for j in ${GCCVERSION_${v}}
62 .  if !defined(_GCCVERSION_${v}_L)
63 _GCCVERSION_${v}_L=     ${j}
64 .  elif !defined(_GCCVERSION_${v}_R)
65 _GCCVERSION_${v}_R=     ${j}
66 .  elif !defined(_GCCVERSION_${v}_V)
67 _GCCVERSION_${v}_V=     ${j}
68 .  elif !defined(_GCCVERSION_${v}_VV)
69 _GCCVERSION_${v}_VV=    ${j}
70 .  endif
71 . endfor
72 .endfor
73
74 .if defined(DPORTS_BUILDER) && !defined(NO_GCC50) && ${DFLYVERSION} >= ${_GCCVERSION_050000_L}
75 LASTBASE=               5
76 DFLY_DEFAULT_VERSION=   50
77 .else
78 LASTBASE=               4.7
79 DFLY_DEFAULT_VERSION=   47
80 .endif
81
82 .if ${USE_GCC:Myes}
83 USE_GCC=        ${LASTBASE}
84 .endif
85
86 .if defined(USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
87
88 . if ${USE_GCC} == any
89
90 # Enable the clang-is-cc workaround.  Default to the last GCC imported
91 # into base.
92 _USE_GCC:=      ${LASTBASE}
93 _GCC_ORLATER:=  true
94
95 . else # ${USE_GCC} == any
96
97 # See if we can use a later version or exclusively the one specified.
98 _USE_GCC:=      ${USE_GCC:S/+//}
99 .if ${USE_GCC} != ${_USE_GCC}
100 _GCC_ORLATER:=  true
101 .endif
102
103 . endif # ${USE_GCC} == any
104
105 # Initialize _GCC_FOUND${v}.  In parallel, check if USE_GCC points to a
106 # valid version to begin with.
107 .for v in ${GCCVERSIONS}
108 . if ${DFLY_DEFAULT_VERSION} >= ${_GCCVERSION_${v}_VV}
109 _GCC_FOUND${v}= base
110 . elif exists(${LOCALBASE}/bin/gcc${_GCCVERSION_${v}_V:S/.//})
111 _GCC_FOUND${v}= port
112 . endif
113 . if ${_USE_GCC}==${_GCCVERSION_${v}_V}
114 _GCCVERSION_OKAY=       true
115 . endif
116 .endfor
117
118 .if !defined(_GCCVERSION_OKAY)
119 IGNORE= Unknown version of GCC specified (USE_GCC=${USE_GCC})
120 .endif
121
122 # If the GCC package defined in USE_GCC does not exist, but a later
123 # version is allowed (for example 4.7+), see if there is a later.
124 # First check if the base installed version is good enough, otherwise
125 # get the first available version.
126 #
127 .if defined(_GCC_ORLATER)
128 . if ${_USE_GCC:M5} && ${DFLY_DEFAULT_VERSION:M50}
129 #  _USE_GCC is already correct
130 . elif ${_USE_GCC:N5} && (${_USE_GCC:S/.//} <= ${DFLY_DEFAULT_VERSION})
131 _USE_GCC= ${LASTBASE}
132 . else # HEAD ORIG - run on 4.0 and below
133 . for v in ${GCCVERSIONS}
134 .  if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
135 _GCC_MIN1:=     true
136 .  endif
137 .  if defined(_GCC_MIN1) && defined(_GCC_FOUND${v}) && ${_GCC_FOUND${v}}=="base" && !defined(_GCC_FOUND)
138 _GCC_FOUND:=    ${_GCCVERSION_${v}_V}
139 .  endif
140 . endfor
141 . for v in ${GCCVERSIONS}
142 .  if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
143 _GCC_MIN2:=     true
144 .  endif
145 .  if defined(_GCC_MIN2) && defined(_GCC_FOUND${v}) && !defined(_GCC_FOUND)
146 _GCC_FOUND:=    ${_GCCVERSION_${v}_V}
147 .  endif
148 . endfor
149
150 . if defined(_GCC_FOUND)
151 _USE_GCC:=      ${_GCC_FOUND}
152 . elif ${_USE_GCC} < ${GCC_DEFAULT}
153 _USE_GCC:=      ${GCC_DEFAULT}
154 . endif
155 . endif   # TAIL ORIG
156 .else  # defined(_GCC_ORLATER)
157 . if ${_USE_GCC:M4.[67]}
158 _USE_GCC=               4.7
159 DFLY_DEFAULT_VERSION=   47
160 . endif
161 .endif # defined(_GCC_ORLATER)
162
163 .endif # defined(USE_GCC)
164
165
166 .if defined(_USE_GCC)
167 # A concrete version has been selected.  Determine if the installed OS 
168 # features this version in the base, and if not then set proper ports
169 # dependencies, CC, CXX, CPP, and flags.
170 .for v in ${GCCVERSIONS}
171 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
172 .  if (${_GCCVERSION_${v}_L} == 0 && ${_GCCVERSION_${v}_R} == 0) || \
173       ${DFLYVERSION} < ${_GCCVERSION_${v}_L}
174 V:=                     ${_GCCVERSION_${v}_V:S/.//}
175 _GCC_PORT_DEPENDS:=     gcc${V}
176 .   if ${_USE_GCC} == ${LANG_GCC_IS}
177 _GCC_PORT:=             gcc
178 .   else
179 _GCC_PORT:=             gcc${V}
180 .   endif
181 CC:=                    gcc${V}
182 CXX:=                   g++${V}
183 CPP:=                   cpp${V}
184 _GCC_RUNTIME:=          ${LOCALBASE}/lib/gcc${V}
185 CFLAGS+=                -Wl,-rpath=${_GCC_RUNTIME}
186 CXXFLAGS+=              -Wl,-rpath=${_GCC_RUNTIME}
187 LDFLAGS+=               -Wl,-rpath=${_GCC_RUNTIME} -L${_GCC_RUNTIME}
188 .  else # Use GCC in base.
189 CC:=                    gcc
190 CXX:=                   g++
191 CPP:=                   cpp
192 CONFIGURE_ENV+=         CCVER=gcc${DFLY_DEFAULT_VERSION}
193 MAKE_ENV+=              CCVER=gcc${DFLY_DEFAULT_VERSION}
194 .  endif # Use GCC in base.
195 . endif # ${_USE_GCC} == ${_GCCVERSION_${v}_V}
196 .endfor
197 .undef V
198
199 .if defined(_GCC_PORT_DEPENDS)
200 BUILD_DEPENDS+= ${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_PORT}
201 RUN_DEPENDS+=   ${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_PORT}
202 # Later GCC ports already depend on binutils; make sure whatever we
203 # build leverages this as well.
204 USE_BINUTILS=   yes
205 .endif
206 .endif # defined(_USE_GCC) && !defined(FORCE_BASE_CC_FOR_TESTING)
207
208
209 test-gcc:
210         @echo USE_GCC=${USE_GCC}
211 .if defined(IGNORE)
212         @echo "IGNORE: ${IGNORE}"
213 .else
214 .if defined(USE_GCC)
215 .if defined(_GCC_ORLATER)
216         @echo Port can use later versions.
217 .else
218         @echo Port cannot use later versions.
219 .endif
220 .for v in ${GCCVERSIONS}
221         @echo -n "GCC version: ${_GCCVERSION_${v}_V} "
222 .if defined(_GCC_FOUND${v})
223         @echo -n "(${_GCC_FOUND${v}}) "
224 .endif
225         @echo "- OSVERSION from ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R}"
226 #       @echo ${v} - ${_GCC_FOUND${v}} - ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R} - ${_GCCVERSION_${v}_V}
227 .endfor
228         @echo Using GCC version ${_USE_GCC}
229 .endif
230         @echo CC=${CC} - CXX=${CXX} - CPP=${CPP} - CFLAGS=\"${CFLAGS}\"
231         @echo LDFLAGS=\"${LDFLAGS}\"
232         @echo CONFIGURE_ENV=${CONFIGURE_ENV}
233         @echo MAKE_ENV=${MAKE_ENV}
234         @echo "BUILD_DEPENDS=${BUILD_DEPENDS}"
235         @echo "RUN_DEPENDS=${RUN_DEPENDS}"
236 .endif