1 # $NetBSD: compiler.mk,v 1.46 2005/02/16 08:41:20 grant Exp $
3 # This Makefile fragment implements handling for supported C/C++/Fortran
6 # The following variables are used by this file:
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 # distcc distributed C/C++ (chainable)
16 # f2c Fortran 77 to C compiler (chainable)
17 # icc Intel C++ Compiler (Linux)
18 # ido SGI IRIS Development Option cc (IRIX 5)
20 # mipspro Silicon Graphics, Inc. MIPSpro (n32/n64)
21 # mipspro-ucode Silicon Graphics, Inc. MIPSpro (o32)
22 # sunpro Sun Microsystems, Inc. WorkShip/Forte/Sun
24 # xlc IBM's XL C/C++ compiler suite (Darwin/MacOSX)
26 # The default is "gcc". You can use ccache and/or distcc with
27 # an appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc
28 # gcc". You can also use "f2c" to overlay the lang/f2c package
29 # over the C compiler instead of using the system Fortran
30 # compiler. The chain should always end in a real compiler.
31 # This should only be set in /etc/mk.conf.
34 # A list of version numbers used to determine the minimum
35 # version of GCC required by a package. This value should only
36 # be appended to by a package Makefile.
38 # NOTE: Be conservative when setting GCC_REQD, as lang/gcc3 is
39 # known not to build on some platforms, e.g. Darwin. If gcc3 is
40 # required, set GCC_REQD=3.0 so that we do not try to pull in
41 # lang/gcc3 unnecessarily and have it fail.
44 # Force using the appropriate version of GCC from pkgsrc based on
45 # GCC_REQD instead of the native compiler. Should only be set in
50 # Lists the languages used in the source code of the package,
51 # and is used to determine the correct compilers to install.
52 # Valid values are: c, c++, fortran, java, objc. The default
53 # is "c" ("c" is actually _always_ implicitly in this list).
55 # The following variables are defined, and available for testing in
59 # The compiler and version being used, e.g.,
61 # .include "../../mk/compiler.mk"
63 # .if !empty(CC_VERSION:Mgcc-3*)
68 .if !defined(BSD_COMPILER_MK)
69 BSD_COMPILER_MK= defined
71 .include "../../mk/bsd.prefs.mk"
73 # Always require a C compiler for proper compiler detection.
75 .if empty(USE_LANGUAGES:Mc)
76 USE_LANGUAGES:= c ${USE_LANGUAGES}
79 # For environments where there is an external gcc too, but pkgsrc
80 # should use the pkgsrc one for consistency.
82 .if defined(USE_PKGSRC_GCC)
86 _COMPILERS= ccc gcc icc ido mipspro mipspro-ucode sunpro xlc
87 _PSEUDO_COMPILERS= ccache distcc f2c
89 .if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER)
90 . for _compiler_ in ${_COMPILERS}
91 . if ${NOT_FOR_COMPILER:M${_compiler_}} == ""
92 _ACCEPTABLE_COMPILERS+= ${_compiler_}
95 .elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER)
96 . for _compiler_ in ${_COMPILERS}
97 . if ${ONLY_FOR_COMPILER:M${_compiler_}} != ""
98 _ACCEPTABLE_COMPILERS+= ${_compiler_}
102 _ACCEPTABLE_COMPILERS+= ${_COMPILERS}
105 .if defined(_ACCEPTABLE_COMPILERS)
106 . for _acceptable_ in ${_ACCEPTABLE_COMPILERS}
107 . for _compiler_ in ${PKGSRC_COMPILER}
108 . if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER)
109 _COMPILER= ${_compiler_}
115 .if !defined(_COMPILER)
116 PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}."
119 .for _compiler_ in ${PKGSRC_COMPILER}
120 . if !empty(_PSEUDO_COMPILERS:M${_compiler_})
121 _PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER}
124 _PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER}
126 _COMPILER_STRIP_VARS= # empty
128 .for _compiler_ in ${_PKGSRC_COMPILER}
129 . include "../../mk/compiler/${_compiler_}.mk"
133 # Strip the leading paths from the toolchain variables since we manipulate
134 # the PATH to use the correct executable.
136 .for _var_ in ${_COMPILER_STRIP_VARS}
137 . if empty(${_var_}:C/^/_asdf_/1:N_asdf_*)
138 ${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T}
140 ${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*}
144 .if defined(ABI) && !empty(ABI)
145 _WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}}
146 _WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}}
147 _WRAP_EXTRA_ARGS.LD+= ${_LINKER_ABI_FLAG.${ABI}}
150 .endif # BSD_COMPILER_MK