[BACK]Return to compiler.mk CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / mk

Annotation of pkgsrc/mk/compiler.mk, Revision 1.24

1.24    ! sketch      1: # $NetBSD: compiler.mk,v 1.23 2003/11/12 13:13:43 grant Exp $
1.1       grant       2:
                      3: # This Makefile fragment implements handling for supported
                      4: # C/C++/fortran compilers.
1.8       grant       5: #
                      6: # This file should NOT be included from pkg Makefiles, as it is
1.15      grant       7: # automatically included by bsd.prefs.mk.
1.1       grant       8: #
                      9: # The following variables are used:
                     10: #
1.7       grant      11: # GCC_REQD
                     12: #      Sets the minimum required version of gcc. Packages can set
                     13: #      this if they are known to require gcc>2.8.0, which is the
                     14: #      compiler shipped with NetBSD 1.5.
                     15: #
                     16: #      Note: Be conservative when setting GCC_REQD, as lang/gcc3 is
                     17: #      known not to build on some platforms, eg. Darwin. If gcc3 is
                     18: #      required, set GCC_REQD=3.0 so that we do not try to pull in
                     19: #      lang/gcc3 unnecessarily and have it fail.
                     20: #
                     21: # USE_GCC_SHLIB
                     22: #      Indicates that a package uses GCC shared libraries, so we
                     23: #      register a runtime dependency on the compiler package.
                     24: #
1.1       grant      25: # USE_GCC2
1.15      grant      26: #      Always use pkgsrc gcc2 from lang/gcc. This overrides any
                     27: #      GCC_REQD setting. Must NOT be set in package Makefiles.
1.1       grant      28: #
                     29: # USE_GCC3
1.15      grant      30: #      Always use pkgsrc gcc3 from lang/gcc3. This overrides any
                     31: #      GCC_REQD setting. Must NOT be set in package Makefiles.
1.1       grant      32: #
1.7       grant      33: # USE_PKGSRC_GCC
                     34: #      Use the appropriate version of GCC from pkgsrc based on
                     35: #      GCC_REQD.
1.1       grant      36: #
1.6       salo       37: # USE_SUNPRO
                     38: #      Use the Sun Microsystems Inc. WorkShop/Forte/Sun ONE Studio
                     39: #      compiler collection.
                     40: #
1.1       grant      41: # USE_MIPSPRO
                     42: #      Use the Silicon Graphics, Inc. MIPSpro compiler.
1.15      grant      43: #
                     44: # The following variables are defined, and available for testing in
                     45: # package Makefiles:
                     46: #
                     47: # CC_VERSION
                     48: #      The compiler and version being used. For gcc, this is
1.20      grant      49: #      'gcc-<version>' and the string reported by ${CC} -V | grep
                     50: #      '^cc' for others.
1.15      grant      51: #
                     52: #      e.g.
                     53: #              .include "../../mk/bsd.prefs.mk"
                     54: #
                     55: #              .if !empty(CC_VERSION:Mgcc-3*)
                     56: #              ...
                     57: #              .endif
1.1       grant      58: #
                     59:
                     60: .if !defined(COMPILER_MK)
                     61: COMPILER_MK=   # defined
1.13      grant      62:
                     63: # Defaults for SunPro, work around sys.mk setting CC by default to
                     64: # 'gcc'. These can be overriden by the user in /etc/mk.conf or on the
                     65: # command line.
                     66: .if defined(USE_SUNPRO) && defined(CC) && !empty(CC:Mgcc)
                     67: CC=    /opt/SUNWspro/bin/cc
1.24    ! sketch     68: CPP=   /opt/SUNWspro/bin/cc -E
1.13      grant      69: CXX=   /opt/SUNWspro/bin/CC
                     70: .endif
1.1       grant      71:
1.7       grant      72: # Do a dance to determine which version of gcc is being used, if any,
                     73: # and whether it satisfies GCC_REQD.
                     74: #
                     75: # We only pull in lang/gcc or lang/gcc3 if necessary, or if
                     76: # USE_PKGSRC_GCC is defined.
                     77: #
                     78: .if !defined(USE_SUNPRO) && !defined(USE_MIPSPRO) && \
                     79:     !defined(USE_GCC2) && !defined(USE_GCC3)
                     80:
                     81: # Darwin's gcc reports "Apple Computer ... based on gcc version ...",
                     82: # so we can't just grep for ^gcc.
                     83: _CC_VERSION_STRING!=   if ${CC} -v 2>&1 | ${GREP} -q 'gcc version'; then \
                     84:                                echo `${CC} -v 2>&1 | ${GREP} 'gcc version'`; \
                     85:                        fi
                     86:
                     87: # egcs is considered to be gcc-2.8.1.
1.9       wiz        88: .  if !empty(_CC_VERSION_STRING:Megcs*)
                     89: _CC_VERSION=           2.8.1
                     90: _CC_IS_GCC=            YES
                     91: .  elif !empty(_CC_VERSION_STRING:Mgcc*)
1.7       grant      92: _CC_VERSION!=          ${CC} -dumpversion
                     93: _CC_IS_GCC=            YES
                     94: .  endif
                     95:
                     96: .  if defined(_CC_IS_GCC)
                     97: GCC_REQD?=             2.8.0
                     98: _GCC_VERSION_REQD=     gcc>=${GCC_REQD}
                     99:
                    100: # packages should define USE_PKGSRC_GCC to force install and use of
                    101: # pkgsrc gcc, which defaults to gcc2.
                    102: .    if defined(USE_PKGSRC_GCC)
                    103: GCC_REQD=              2.95.3
                    104: _NEED_PKGSRC_GCC=      YES
                    105: .    else
1.23      grant     106: _GCC_IN_USE=           gcc-${_CC_VERSION}
1.7       grant     107: _NEED_PKGSRC_GCC!=     \
                    108:        if ${PKG_ADMIN} pmatch '${_GCC_VERSION_REQD}' ${_GCC_IN_USE}; then \
                    109:                ${ECHO} "NO"; \
                    110:        else \
                    111:                ${ECHO} "YES"; \
                    112:        fi
                    113: .    endif # USE_PKGSRC_GCC
                    114:
                    115: .  endif # _CC_IS_GCC
                    116:
                    117: .endif # !USE_MIPSPRO && !USE_SUNPRO && !USE_GCC2 && !USE_GCC3
                    118:
                    119: # we default to gcc2 if all of the above determined that we need
                    120: # pkgsrc gcc.
                    121: .if defined(_NEED_PKGSRC_GCC) && ${_NEED_PKGSRC_GCC} == "YES"
                    122: .  if !empty(GCC_REQD:M3*)
                    123: USE_GCC3=              # defined
                    124: .  else
                    125: USE_GCC2=              # defined
                    126: .  endif
                    127: .endif
                    128:
1.17      grant     129: .if defined(USE_GCC2) && empty(_PKGSRC_DEPS:Mgcc-2*)
1.7       grant     130: GCC_REQD=              2.95.3
1.1       grant     131:
                    132: # we need to define these early, as they are used by gcc/buildlink2.mk.
1.11      grant     133: _GCC_SUBPREFIX=                gcc-2.95.3/
                    134: _GCC_ARCHDIR=          ${_GCC_PREFIX}${_GCC_ARCHSUBDIR}
1.10      gavan     135: _GCC_PREFIX=           ${LOCALBASE}/${_GCC_SUBPREFIX}
                    136: _GCC_LIBGCCDIR!=                                               \
                    137:   if [ -x ${_GCC_PREFIX}bin/gcc ]; then                                \
                    138:     dirname `${_GCC_PREFIX}bin/gcc --print-libgcc-file-name`;  \
                    139:   else                                                         \
                    140:     ${ECHO} not-defined;                                       \
                    141:   fi
                    142: _GCC_ARCHSUBDIR= \
                    143:   ${_GCC_LIBGCCDIR:S|^${BUILDLINK_PREFIX.gcc}/${_GCC_SUBPREFIX}||}
1.1       grant     144:
1.17      grant     145: # Only pull in the pkg dependency if we're not actually building it
                    146: .  if empty(PKGPATH:Mlang/gcc)
                    147:
                    148: .    if empty(USE_BUILDLINK2:M[nN][oO])
                    149: .      include "../lang/gcc/buildlink2.mk"
                    150: .    else
1.1       grant     151:
                    152: # Packages that link against gcc shared libraries need a full
                    153: # dependency.
1.17      grant     154: .      if defined(USE_GCC_SHLIB)
1.1       grant     155: DEPENDS+=              gcc>=${GCC_REQD}:../../lang/gcc
1.17      grant     156: .      else
1.1       grant     157: BUILD_DEPENDS+=                gcc>=${GCC_REQD}:../../lang/gcc
1.17      grant     158: .      endif
                    159: .    endif     # buildlink2
                    160: .  endif       # PKGPATH != lang/gcc
1.3       grant     161:
1.17      grant     162: .  if exists(${_GCC_PREFIX}bin/gcc)
1.12      grant     163: _CC_IS_GCC=            YES
1.1       grant     164: PATH:=                 ${_GCC_PREFIX}bin:${PATH}
                    165: CC=                    ${_GCC_PREFIX}bin/gcc
                    166: CPP=                   ${_GCC_PREFIX}bin/cpp
                    167: CXX=                   ${_GCC_PREFIX}bin/g++
                    168: F77=                   ${_GCC_PREFIX}bin/g77
1.16      grant     169: PKG_FC:=               ${F77}
1.17      grant     170: .  endif
1.1       grant     171:
1.17      grant     172: .elif defined(USE_GCC3) && empty(_PKGSRC_DEPS:Mgcc-3*)
1.7       grant     173: GCC_REQD=              3.3
1.1       grant     174:
                    175: # we need to define these early, as they are used by gcc3/buildlink2.mk.
                    176: _GCC_SUBPREFIX=                gcc-3.3/
                    177: _GCC_ARCHDIR=          ${_GCC_PREFIX}${_GCC_ARCHSUBDIR}
1.17      grant     178: _GCC_PREFIX=           ${LOCALBASE}/${_GCC_SUBPREFIX}
1.1       grant     179:
1.17      grant     180: # Only pull in the pkg dependency if we're not actually building it
                    181: .  if empty(PKGPATH:Mlang/gcc3)
                    182:
                    183: .    if empty(USE_BUILDLINK2:M[nN][oO])
                    184: .      include "../lang/gcc3/buildlink2.mk"
                    185: .    else
1.1       grant     186:
                    187: # Packages that link against gcc shared libraries need a full
                    188: # dependency.
1.17      grant     189: .      if defined(USE_GCC_SHLIB)
1.1       grant     190: DEPENDS+=              gcc3>=${GCC_REQD}:../../lang/gcc3
1.17      grant     191: .      else
1.1       grant     192: BUILD_DEPENDS+=                gcc3>=${GCC_REQD}:../../lang/gcc3
1.17      grant     193: .      endif
                    194: .    endif     # buildlink2
                    195: .  endif       # PKGPATH != lang/gcc3
                    196:
                    197: .  if exists(${_GCC_PREFIX}bin/gcc)
                    198: _GCC_LIBGCCDIR!= \
                    199:   dirname `${_GCC_PREFIX}bin/gcc --print-libgcc-file-name`
                    200: _GCC_ARCHSUBDIR= \
                    201:   ${_GCC_LIBGCCDIR:S|^${LOCALBASE}/${_GCC_SUBPREFIX}||}
1.3       grant     202:
1.12      grant     203: _CC_IS_GCC=            YES
1.1       grant     204: PATH:=                 ${_GCC_PREFIX}bin:${PATH}
                    205: CC=                    ${_GCC_PREFIX}bin/gcc
                    206: CPP=                   ${_GCC_PREFIX}bin/cpp
                    207: CXX=                   ${_GCC_PREFIX}bin/g++
                    208: F77=                   ${_GCC_PREFIX}bin/g77
1.16      grant     209: PKG_FC:=               ${F77}
1.17      grant     210: .  endif
1.1       grant     211: .endif # USE_GCC3
1.3       grant     212:
                    213: # Ensure that the correct rpath is passed to the linker if we need to
                    214: # link against gcc shared libs.
                    215: .if (defined(USE_GCC2) || defined(USE_GCC3)) && defined(USE_GCC_SHLIB)
                    216: _GCC_LDFLAGS=          -L${_GCC_ARCHDIR} -Wl,${RPATH_FLAG}${_GCC_ARCHDIR} -L${_GCC_PREFIX}lib -Wl,${RPATH_FLAG}${_GCC_PREFIX}lib
                    217: LDFLAGS+=              ${_GCC_LDFLAGS}
1.14      grant     218: .endif
                    219:
1.12      grant     220: # CC_VERSION can be tested by package Makefiles to tweak things based
1.20      grant     221: # on the compiler being used.
1.12      grant     222: #
                    223: CC_VERSION?=           # empty
1.20      grant     224: .if defined(_CC_IS_GCC)
                    225: .  if !defined(_CC_VERSION)
1.12      grant     226: _CC_VERSION!=          if ${CC} -dumpversion > /dev/null 2>&1; then \
                    227:                                ${ECHO} `${CC} -dumpversion`; \
                    228:                        else \
                    229:                                ${ECHO} ""; \
                    230:                        fi
1.20      grant     231: .  endif
1.19      grant     232: CC_VERSION=            gcc-${_CC_VERSION}
1.20      grant     233: .else
1.19      grant     234: CC_VERSION!=           ${CC} -V 2>&1 | ${GREP} '^cc'
1.4       grant     235: .endif
                    236:
                    237: # The SunPro C++ compiler doesn't support passing linker flags with
                    238: # -Wl to CC, so we make buildlink2 perform the required magic.
                    239: #
                    240: .if defined(USE_SUNPRO)
                    241: _COMPILER_LD_FLAG=             # SunPro compiler
                    242: .else
                    243: _COMPILER_LD_FLAG=     -Wl,    # GCC and others
1.18      grant     244: .endif
                    245:
                    246: # Pass the required flags to imake to tell it we're using gcc on
                    247: # Solaris.
                    248: #
                    249: .if ${OPSYS} == "SunOS" && defined(_CC_IS_GCC)
                    250: IMAKEOPTS+=    -DHasGcc2=YES -DHasGcc2ForCplusplus=YES
1.3       grant     251: .endif
1.1       grant     252:
                    253: .endif # COMPILER_MK
1.21      grant     254:
                    255: # XXX this test is outside if !defined(COMPILER_MK) because some
                    256: # XXX packages include bsd.prefs.mk before defining USE_BUILDLINK2.
                    257: #
                    258: # create a fake libstdc++.la if one exists in /usr/lib.
                    259: .if empty(USE_BUILDLINK2:M[nN][oO])
                    260: .  if defined(_CC_IS_GCC) && exists(/usr/lib/libstdc++.la)
                    261: .    if (!defined(BUILDLINK_TARGETS) || \
                    262:      defined(BUILDLINK_TARGETS) && empty(BUILDLINK_TARGETS:Mlibstdc++-buildlink-la))
                    263: BUILDLINK_TARGETS+=            libstdc++-buildlink-la
                    264:
                    265: libstdc++-buildlink-la:
                    266:        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
                    267:        lafile="${BUILDLINK_DIR}/lib/libstdc++.la";                     \
                    268:        libpattern="/usr/lib/libstdc++.*";                              \
                    269:        ${BUILDLINK_FAKE_LA}
                    270: .    endif
                    271: .  endif
                    272: .endif

CVSweb <webmaster@jp.NetBSD.org>