1 # $NetBSD: compiler.mk,v 1.79 2012/08/09 12:32:41 jperkin Exp $
3 # This Makefile fragment implements handling for supported C/C++/Fortran
6 # The following variables may be set by the pkgsrc user in mk.conf:
9 # A list of values specifying the chain of compilers to be used by
10 # pkgsrc to build packages.
13 # ccc Compaq C Compilers (Tru64)
14 # ccache compiler cache (chainable)
15 # clang Clang C and Objective-C compiler
16 # distcc distributed C/C++ (chainable)
17 # f2c Fortran 77 to C compiler (chainable)
18 # icc Intel C++ Compiler (Linux)
19 # ido SGI IRIS Development Option cc (IRIX 5)
21 # hp HP-UX C/aC++ compilers
22 # mipspro Silicon Graphics, Inc. MIPSpro (n32/n64)
23 # mipspro-ucode Silicon Graphics, Inc. MIPSpro (o32)
24 # pcc Portable C Compiler
25 # sunpro Sun Microsystems, Inc. WorkShip/Forte/Sun
27 # xlc IBM's XL C/C++ compiler suite (Darwin/MacOSX)
29 # The default is "gcc". You can use ccache and/or distcc with
30 # an appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc
31 # gcc". You can also use "f2c" to overlay the lang/f2c package
32 # over the C compiler instead of using the system Fortran
33 # compiler. The chain should always end in a real compiler.
34 # This should only be set in /etc/mk.conf.
36 # COMPILER_USE_SYMLINKS
37 # If set to yes, use symlinks for the compiler drivers, otherwise
38 # shell scripts are created. The default is yes.
40 # The following variables may be set by a package:
43 # Lists the languages used in the source code of the package,
44 # and is used to determine the correct compilers to install.
45 # Valid values are: c, c99, c++, fortran, fortran77, java, objc,
46 # obj-c++, and ada. The default is "c".
48 # The following variables are defined, and available for testing in
52 # The compiler and version being used, e.g.,
54 # .include "../../mk/compiler.mk"
56 # .if !empty(CC_VERSION:Mgcc-3*)
62 .if
!defined
(BSD_COMPILER_MK
)
63 BSD_COMPILER_MK
= defined
66 _USER_VARS.compiler
= PKGSRC_COMPILER USE_PKGSRC_GCC ABI COMPILER_USE_SYMLINKS
67 _PKG_VARS.compiler
= USE_LANGUAGES GCC_REQD NOT_FOR_COMPILER ONLY_FOR_COMPILER
68 _SYS_VARS.compiler
= CC_VERSION
70 .
include "bsd.fast.prefs.mk"
72 # Since most packages need a C compiler, this is the default value.
75 # Add c support if c99 is set
76 .if
!empty
(USE_LANGUAGES
:Mc99
)
80 COMPILER_USE_SYMLINKS?
= yes
82 _COMPILERS
= ccc gcc icc ido mipspro mipspro-ucode \
83 sunpro xlc hp pcc clang
84 _PSEUDO_COMPILERS
= ccache distcc f2c g95
86 .if defined
(NOT_FOR_COMPILER
) && !empty
(NOT_FOR_COMPILER
)
87 . for _compiler_ in
${_COMPILERS}
88 . if
${NOT_FOR_COMPILER
:M
${_compiler_}} == ""
89 _ACCEPTABLE_COMPILERS
+= ${_compiler_}
92 .elif defined
(ONLY_FOR_COMPILER
) && !empty
(ONLY_FOR_COMPILER
)
93 . for _compiler_ in
${_COMPILERS}
94 . if
${ONLY_FOR_COMPILER
:M
${_compiler_}} != ""
95 _ACCEPTABLE_COMPILERS
+= ${_compiler_}
99 _ACCEPTABLE_COMPILERS
+= ${_COMPILERS}
102 .if defined
(_ACCEPTABLE_COMPILERS
)
103 . for _acceptable_ in
${_ACCEPTABLE_COMPILERS}
104 . for _compiler_ in
${PKGSRC_COMPILER}
105 . if
!empty
(_ACCEPTABLE_COMPILERS
:M
${_compiler_}) && !defined
(_COMPILER
)
106 _COMPILER
= ${_compiler_}
112 .if
!defined
(_COMPILER
)
113 PKG_FAIL_REASON
+= "No acceptable compiler found for ${PKGNAME}."
116 .for _compiler_ in
${PKGSRC_COMPILER}
117 . if
!empty
(_PSEUDO_COMPILERS
:M
${_compiler_})
118 _PKGSRC_COMPILER
:= ${_compiler_} ${_PKGSRC_COMPILER}
121 _PKGSRC_COMPILER
:= ${_COMPILER} ${_PKGSRC_COMPILER}
123 _COMPILER_STRIP_VARS
= # empty
125 .for _compiler_ in
${_PKGSRC_COMPILER}
126 .
include "compiler/${_compiler_}.mk"
130 .if
!defined
(PKG_CPP
)
134 # Ensure the Solaris linker is used by default.
135 .if
${OPSYS} == "SunOS"
136 . if exists
(/usr
/ccs
/bin
/ld)
137 PKG_LD?
= /usr
/ccs
/bin
/ld
138 . elif exists
(/usr
/bin
/ld)
143 # Strip the leading paths from the toolchain variables since we manipulate
144 # the PATH to use the correct executable.
146 .for _var_ in
${_COMPILER_STRIP_VARS}
147 . if empty
(${_var_}:C
/^
/_asdf_
/1:N_asdf_
*)
148 ${_var_}:= ${${_var_}:C
/^
/_asdf_
/1:M_asdf_
*:S
/^_asdf_
//:T
}
150 ${_var_}:= ${${_var_}:C
/^
/_asdf_
/1:M_asdf_
*:S
/^_asdf_
//:T
} ${${_var_}:C
/^
/_asdf_
/1:N_asdf_
*}
154 .if defined
(ABI
) && !empty
(ABI
)
155 _WRAP_EXTRA_ARGS.CC
+= ${_COMPILER_ABI_FLAG.
${ABI}}
156 _WRAP_EXTRA_ARGS.CXX
+= ${_COMPILER_ABI_FLAG.
${ABI}}
157 _WRAP_EXTRA_ARGS.FC
+= ${_COMPILER_ABI_FLAG.
${ABI}}
160 # If the languages are not requested, force them not to be available
161 # in the generated wrappers.
163 _FAIL_WRAPPER.CC
= ${WRKDIR}/.compiler
/bin
/c-fail-wrapper
164 _FAIL_WRAPPER.CXX
= ${WRKDIR}/.compiler
/bin
/c
++-fail-wrapper
165 _FAIL_WRAPPER.FC
= ${WRKDIR}/.compiler
/bin
/fortran-fail-wrapper
166 _FAIL_WRAPPER.ADA
= ${WRKDIR}/.compiler
/bin
/ada-fail-wrapper
168 ${_FAIL_WRAPPER.CC
}: fail-wrapper
169 ${_FAIL_WRAPPER.CXX
}: fail-wrapper
170 ${_FAIL_WRAPPER.FC
}: fail-wrapper
171 ${_FAIL_WRAPPER.ADA
}: fail-wrapper
175 ${RUN}${MKDIR} ${.TARGET
:H
}
178 ${ECHO} '#!'${TOOLS_SHELL
:Q
}; \
179 ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG
:Q
}'}"'; \
180 ${ECHO} 'lang="${.TARGET:T:S/-fail-wrapper//}"'; \
181 ${ECHO} 'msg="*** Please consider adding $$lang to USE_LANGUAGES in the package Makefile."'; \
182 ${ECHO} '${ECHO} "$$msg" >> $$wrapperlog'; \
183 ${ECHO} '${ECHO} "$$msg" > ${WARNING_DIR}/${.TARGET:T}'; \
184 ${ECHO} '${ECHO} "PKGSRC-WARNING: Something is trying to run the $$lang compiler," 1>&2'; \
185 ${ECHO} '${ECHO} "PKGSRC-WARNING: but it is not added to USE_LANGUAGES in the package Makefile." 1>&2'; \
187 ${RUN}${CHMOD} +x
${.TARGET
}
189 .if empty
(USE_LANGUAGES
:Mc
) && empty
(USE_LANGUAGES
:Mobjc
) && empty
(USE_LANGUAGES
:Mobjc-c
++)
190 PKG_CC
:= ${_FAIL_WRAPPER.CC
}
191 ALL_ENV
+= CPP
=${CPP
:Q
}
192 override-tools
: ${_FAIL_WRAPPER.CC
}
194 .if empty
(USE_LANGUAGES
:Mc
++)
195 PKG_CXX
:= ${_FAIL_WRAPPER.CXX
}
196 ALL_ENV
+= CXXCPP
=${CPP
:Q
} # to make some Autoconf scripts happy
197 override-tools
: ${_FAIL_WRAPPER.CXX
}
199 .if empty
(USE_LANGUAGES
:Mfortran
) && empty
(USE_LANGUAGES
:Mfortran77
)
200 PKG_FC
:= ${_FAIL_WRAPPER.FC
}
201 override-tools
: ${_FAIL_WRAPPER.FC
}
203 .if empty
(USE_LANGUAGES
:Mada
)
204 PKG_ADA
:= ${_FAIL_WRAPPER.ADA
}
205 override-tools
: ${_FAIL_WRAPPER.ADA
}
208 .if
!empty
(DRAGONFLY_CCVER
) && ${OPSYS} == "DragonFly"
209 ALL_ENV
+= CCVER
=${DRAGONFLY_CCVER}
212 .
endif # BSD_COMPILER_MK