1 # $NetBSD: compiler.mk,v 1.45 2005/02/15 07:43:43 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)
19 # mipspro Silicon Graphics, Inc. MIPSpro (n32/n64)
20 # mipspro-ucode Silicon Graphics, Inc. MIPSpro (o32)
21 # sunpro Sun Microsystems, Inc. WorkShip/Forte/Sun
23 # xlc IBM's XL C/C++ compiler suite (Darwin/MacOSX)
25 # The default is "gcc". You can use ccache and/or distcc with
26 # an appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc
27 # gcc". You can also use "f2c" to overlay the lang/f2c package
28 # over the C compiler instead of using the system Fortran
29 # compiler. The chain should always end in a real compiler.
30 # This should only be set in /etc/mk.conf.
33 # A list of version numbers used to determine the minimum
34 # version of GCC required by a package. This value should only
35 # be appended to by a package Makefile.
37 # NOTE: Be conservative when setting GCC_REQD, as lang/gcc3 is
38 # known not to build on some platforms, e.g. Darwin. If gcc3 is
39 # required, set GCC_REQD=3.0 so that we do not try to pull in
40 # lang/gcc3 unnecessarily and have it fail.
43 # Force using the appropriate version of GCC from pkgsrc based on
44 # GCC_REQD instead of the native compiler. Should only be set in
49 # Lists the languages used in the source code of the package,
50 # and is used to determine the correct compilers to install.
51 # Valid values are: c, c++, fortran, java, objc. The default
52 # is "c" ("c" is actually _always_ implicitly in this list).
54 # The following variables are defined, and available for testing in
58 # The compiler and version being used, e.g.,
60 # .include "../../mk/compiler.mk"
62 # .if !empty(CC_VERSION:Mgcc-3*)
67 .if !defined(BSD_COMPILER_MK)
68 BSD_COMPILER_MK= defined
70 .include "../../mk/bsd.prefs.mk"
72 # Always require a C compiler for proper compiler detection.
74 .if empty(USE_LANGUAGES:Mc)
75 USE_LANGUAGES:= c ${USE_LANGUAGES}
78 # For environments where there is an external gcc too, but pkgsrc
79 # should use the pkgsrc one for consistency.
81 .if defined(USE_PKGSRC_GCC)
85 _COMPILERS= ccc gcc icc mipspro mipspro-ucode sunpro xlc
86 _PSEUDO_COMPILERS= ccache distcc f2c
88 .if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER)
89 . for _compiler_ in ${_COMPILERS}
90 . if ${NOT_FOR_COMPILER:M${_compiler_}} == ""
91 _ACCEPTABLE_COMPILERS+= ${_compiler_}
94 .elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER)
95 . for _compiler_ in ${_COMPILERS}
96 . if ${ONLY_FOR_COMPILER:M${_compiler_}} != ""
97 _ACCEPTABLE_COMPILERS+= ${_compiler_}
101 _ACCEPTABLE_COMPILERS+= ${_COMPILERS}
104 .if defined(_ACCEPTABLE_COMPILERS)
105 . for _acceptable_ in ${_ACCEPTABLE_COMPILERS}
106 . for _compiler_ in ${PKGSRC_COMPILER}
107 . if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER)
108 _COMPILER= ${_compiler_}
114 .if !defined(_COMPILER)
115 PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}."
118 .for _compiler_ in ${PKGSRC_COMPILER}
119 . if !empty(_PSEUDO_COMPILERS:M${_compiler_})
120 _PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER}
123 _PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER}
125 _COMPILER_STRIP_VARS= # empty
127 .for _compiler_ in ${_PKGSRC_COMPILER}
128 . include "../../mk/compiler/${_compiler_}.mk"
132 # Strip the leading paths from the toolchain variables since we manipulate
133 # the PATH to use the correct executable.
135 .for _var_ in ${_COMPILER_STRIP_VARS}
136 . if empty(${_var_}:C/^/_asdf_/1:N_asdf_*)
137 ${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T}
139 ${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*}
143 .if defined(ABI) && !empty(ABI)
144 _WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}}
145 _WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}}
146 _WRAP_EXTRA_ARGS.LD+= ${_LINKER_ABI_FLAG.${ABI}}
149 .endif # BSD_COMPILER_MK