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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# $NetBSD: compiler.mk,v 1.12 2003/09/24 12:22:04 grant Exp $
# This Makefile fragment implements handling for supported
# C/C++/fortran compilers.
#
# This file should NOT be included from pkg Makefiles, as it is
# automatically included by bsd.pkg.mk.
#
# The following variables are used:
#
# GCC_REQD
# Sets the minimum required version of gcc. Packages can set
# this if they are known to require gcc>2.8.0, which is the
# compiler shipped with NetBSD 1.5.
#
# Note: Be conservative when setting GCC_REQD, as lang/gcc3 is
# known not to build on some platforms, eg. Darwin. If gcc3 is
# required, set GCC_REQD=3.0 so that we do not try to pull in
# lang/gcc3 unnecessarily and have it fail.
#
# USE_GCC_SHLIB
# Indicates that a package uses GCC shared libraries, so we
# register a runtime dependency on the compiler package.
#
# USE_GCC2
# Use pkgsrc gcc2 from lang/gcc. This overrides any GCC_REQD
# setting.
#
# USE_GCC3
# Use pkgsrc gcc3 from lang/gcc3. This overrides any GCC_REQD
# setting.
#
# USE_PKGSRC_GCC
# Use the appropriate version of GCC from pkgsrc based on
# GCC_REQD.
#
# USE_SUNPRO
# Use the Sun Microsystems Inc. WorkShop/Forte/Sun ONE Studio
# compiler collection.
#
# USE_MIPSPRO
# Use the Silicon Graphics, Inc. MIPSpro compiler.
#
.if !defined(COMPILER_MK)
COMPILER_MK= # defined
# Do a dance to determine which version of gcc is being used, if any,
# and whether it satisfies GCC_REQD.
#
# We only pull in lang/gcc or lang/gcc3 if necessary, or if
# USE_PKGSRC_GCC is defined.
#
.if !defined(USE_SUNPRO) && !defined(USE_MIPSPRO) && \
!defined(USE_GCC2) && !defined(USE_GCC3)
# Darwin's gcc reports "Apple Computer ... based on gcc version ...",
# so we can't just grep for ^gcc.
_CC_VERSION_STRING!= if ${CC} -v 2>&1 | ${GREP} -q 'gcc version'; then \
echo `${CC} -v 2>&1 | ${GREP} 'gcc version'`; \
fi
# egcs is considered to be gcc-2.8.1.
. if !empty(_CC_VERSION_STRING:Megcs*)
_CC_VERSION= 2.8.1
_CC_IS_GCC= YES
. elif !empty(_CC_VERSION_STRING:Mgcc*)
_CC_VERSION!= ${CC} -dumpversion
_CC_IS_GCC= YES
. endif
. if defined(_CC_IS_GCC)
GCC_REQD?= 2.8.0
_GCC_VERSION_REQD= gcc>=${GCC_REQD}
# packages should define USE_PKGSRC_GCC to force install and use of
# pkgsrc gcc, which defaults to gcc2.
. if defined(USE_PKGSRC_GCC)
GCC_REQD= 2.95.3
_NEED_PKGSRC_GCC= YES
. else
_GCC_IN_USE= gcc-${_CC_VERSION}
_NEED_PKGSRC_GCC!= \
if ${PKG_ADMIN} pmatch '${_GCC_VERSION_REQD}' ${_GCC_IN_USE}; then \
${ECHO} "NO"; \
else \
${ECHO} "YES"; \
fi
. endif # USE_PKGSRC_GCC
. endif # _CC_IS_GCC
.endif # !USE_MIPSPRO && !USE_SUNPRO && !USE_GCC2 && !USE_GCC3
# we default to gcc2 if all of the above determined that we need
# pkgsrc gcc.
.if defined(_NEED_PKGSRC_GCC) && ${_NEED_PKGSRC_GCC} == "YES"
. if !empty(GCC_REQD:M3*)
USE_GCC3= # defined
. else
USE_GCC2= # defined
. endif
.endif
.if defined(USE_GCC2) && empty(PKGPATH:Mlang/gcc) && empty(_PKGSRC_DEPS:Mgcc-2*)
GCC_REQD= 2.95.3
# we need to define these early, as they are used by gcc/buildlink2.mk.
_GCC_SUBPREFIX= gcc-2.95.3/
_GCC_ARCHDIR= ${_GCC_PREFIX}${_GCC_ARCHSUBDIR}
_GCC_PREFIX= ${LOCALBASE}/${_GCC_SUBPREFIX}
_GCC_LIBGCCDIR!= \
if [ -x ${_GCC_PREFIX}bin/gcc ]; then \
dirname `${_GCC_PREFIX}bin/gcc --print-libgcc-file-name`; \
else \
${ECHO} not-defined; \
fi
_GCC_ARCHSUBDIR= \
${_GCC_LIBGCCDIR:S|^${BUILDLINK_PREFIX.gcc}/${_GCC_SUBPREFIX}||}
. if empty(USE_BUILDLINK2:M[nN][oO])
. include "../lang/gcc/buildlink2.mk"
. else
# Packages that link against gcc shared libraries need a full
# dependency.
. if defined(USE_GCC_SHLIB)
DEPENDS+= gcc>=${GCC_REQD}:../../lang/gcc
. else
BUILD_DEPENDS+= gcc>=${GCC_REQD}:../../lang/gcc
. endif
. endif # buildlink2
_CC_IS_GCC= YES
PATH:= ${_GCC_PREFIX}bin:${PATH}
CC= ${_GCC_PREFIX}bin/gcc
CPP= ${_GCC_PREFIX}bin/cpp
CXX= ${_GCC_PREFIX}bin/g++
F77= ${_GCC_PREFIX}bin/g77
PKG_FC= ${F77}
.elif defined(USE_GCC3) && empty(PKGPATH:Mlang/gcc3) && empty(_PKGSRC_DEPS:Mgcc-3*)
GCC_REQD= 3.3
# we need to define these early, as they are used by gcc3/buildlink2.mk.
_GCC_SUBPREFIX= gcc-3.3/
_GCC_ARCHDIR= ${_GCC_PREFIX}${_GCC_ARCHSUBDIR}
. if empty(USE_BUILDLINK2:M[nN][oO])
. include "../lang/gcc3/buildlink2.mk"
. else
_GCC_PREFIX= ${LOCALBASE}/${_GCC_SUBPREFIX}
. if exists(${_GCC_PREFIX}bin/gcc)
_GCC_LIBGCCDIR!= \
dirname `${_GCC_PREFIX}bin/gcc --print-libgcc-file-name`
_GCC_ARCHSUBDIR= \
${_GCC_LIBGCCDIR:S|^${LOCALBASE}/${_GCC_SUBPREFIX}||}
. endif
# Packages that link against gcc shared libraries need a full
# dependency.
. if defined(USE_GCC_SHLIB)
DEPENDS+= gcc3>=${GCC_REQD}:../../lang/gcc3
. else
BUILD_DEPENDS+= gcc3>=${GCC_REQD}:../../lang/gcc3
. endif
. endif # buildlink2
_CC_IS_GCC= YES
PATH:= ${_GCC_PREFIX}bin:${PATH}
CC= ${_GCC_PREFIX}bin/gcc
CPP= ${_GCC_PREFIX}bin/cpp
CXX= ${_GCC_PREFIX}bin/g++
F77= ${_GCC_PREFIX}bin/g77
PKG_FC= ${F77}
.endif # USE_GCC3
# Ensure that the correct rpath is passed to the linker if we need to
# link against gcc shared libs.
.if (defined(USE_GCC2) || defined(USE_GCC3)) && defined(USE_GCC_SHLIB)
_GCC_LDFLAGS= -L${_GCC_ARCHDIR} -Wl,${RPATH_FLAG}${_GCC_ARCHDIR} -L${_GCC_PREFIX}lib -Wl,${RPATH_FLAG}${_GCC_PREFIX}lib
LDFLAGS+= ${_GCC_LDFLAGS}
.endif
# CC_VERSION can be tested by package Makefiles to tweak things based
# on the compiler being used. This is only functional for gcc right now.
#
CC_VERSION?= # empty
.if defined(_CC_IS_GCC)
. if !defined(_CC_VERSION)
_CC_VERSION!= if ${CC} -dumpversion > /dev/null 2>&1; then \
${ECHO} `${CC} -dumpversion`; \
else \
${ECHO} ""; \
fi
. endif
CC_VERSION= gcc-${_CC_VERSION}
.endif
# The SunPro C++ compiler doesn't support passing linker flags with
# -Wl to CC, so we make buildlink2 perform the required magic.
#
.if defined(USE_SUNPRO)
_COMPILER_LD_FLAG= # SunPro compiler
.else
_COMPILER_LD_FLAG= -Wl, # GCC and others
.endif
.endif # COMPILER_MK
|