pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/compiler New compiler specification framework, base...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/642f5bb34521
branches:  trunk
changeset: 467449:642f5bb34521
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Sun Feb 01 00:31:00 2004 +0000

description:
New compiler specification framework, based on mk/compiler.mk.  The
changes from the old compiler.mk are:

  * Split apart the compiler-specific logic into separate files.  This
    should make supporting other compilers a bit easier.

  * Deprecate all of the USE_* compiler.mk variables, e.g. USE_GCC[23],
    USE_SUNPRO, etc.  It's all replaced with a new PKGSRC_COMPILER
    variable.

  * Clean up the GCC handling so that it's all controlled by a single
    variable GCC_REQD.  The following behaviour is expected:

    (a) If USE_PKGSRC_GCC is defined, then pretend there is no GCC on
        the system.
    (b) If there is no GCC, then the appropriate GCC corresponding to
        GCC_REQD is installed and used.
    (c) If there is a GCC, if it satisfies GCC_REQD, then use it;
        otherwise install and use the appropriate GCC package.
    (d) If lang/gcc is installed and GCC_REQD > 2.95.3, then lang/gcc3
        is installed and used.
    (e) If lang/gcc3 is installed and GCC_REQD = 2.95.3, then gcc3 is
        still used instead of installing lang/gcc.

New features include:

  * PKGSRC_COMPILER takes a list of values specifying the chain of
    compilers to call when building packages.  Valid values are:

        distcc          distributed C/C++ (chainable)
        ccache          compiler cache (chainable)
        gcc             GNU
        mipspro         Silicon Graphics, Inc. MIPSpro
        sunpro          Sun Microsystems, Inc. WorkShip/Forte/Sun
                        ONE Studio

    The default is "gcc".  You can use ccache and/or distcc with an
    appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc gcc".

  * Change GCC_REQD to hold a list of values that we scan through to
    find the highest version of GCC required by the build.  Package
    Makefiles should now do "GCC_REQD+=..." instead of "GCC_REQD=...".

diffstat:

 mk/compiler/bsd.compiler.mk |   93 ++++++++++++++++++
 mk/compiler/ccache.mk       |   45 ++++++++
 mk/compiler/distcc.mk       |   45 ++++++++
 mk/compiler/gcc.mk          |  224 ++++++++++++++++++++++++++++++++++++++++++++
 mk/compiler/mipspro.mk      |   15 ++
 mk/compiler/sunpro.mk       |   17 +++
 6 files changed, 439 insertions(+), 0 deletions(-)

diffs (truncated from 463 to 300 lines):

diff -r ba742f752f8a -r 642f5bb34521 mk/compiler/bsd.compiler.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/compiler/bsd.compiler.mk       Sun Feb 01 00:31:00 2004 +0000
@@ -0,0 +1,93 @@
+# $NetBSD: bsd.compiler.mk,v 1.1 2004/02/01 00:31:00 jlam Exp $
+#
+# This Makefile fragment implements handling for supported C/C++/Fortran
+# compilers.
+#
+# The following variables are used:
+#
+# PKGSRC_COMPILER
+#      A list of values specifying the chain of compilers to be used by
+#      pkgsrc to build packages.
+#
+#      Valid values are:
+#              distcc          distributed C/C++ (chainable)
+#              ccache          compiler cache (chainable)
+#              gcc             GNU
+#              mipspro         Silicon Graphics, Inc. MIPSpro
+#              sunpro          Sun Microsystems, Inc. WorkShip/Forte/Sun
+#                              ONE Studio
+#
+#      The default is "gcc".  You can use ccache and/or distcc with an
+#      appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc gcc".
+#
+# GCC_REQD
+#      A list of version numbers used to determine the minimum
+#      version of GCC required by a package.  This value should only
+#      be appended to by a package Makefile.
+#
+#      NOTE: Be conservative when setting GCC_REQD, as lang/gcc3 is
+#      known not to build on some platforms, e.g. 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_PKGSRC_GCC
+#      Force using the appropriate version of GCC from pkgsrc based on
+#      GCC_REQD instead of the native compiler.
+#
+# USE_GCC_SHLIB
+#      Indicates that a package uses GCC shared libraries, so we
+#      register a runtime dependency on the compiler package.
+#
+# The following variables are defined, and available for testing in
+# package Makefiles:
+#
+# CC_VERSION
+#      The compiler and version being used, e.g.,
+#
+#      .include "../../mk/bsd.prefs.mk"
+#
+#      .if !empty(CC_VERSION:Mgcc-3*)
+#      ...
+#      .endif
+#
+# The following variables are deprecated:
+#
+# USE_GCC2, USE_GCC3, USE_SUNPRO, USE_MIPSPRO
+
+.if !defined(BSD_COMPILER_MK)
+BSD_COMPILER_MK=       defined
+
+# Support some deprecated variables for a while.  They'll be removed
+# after the pkgsrc-2004Q1 branch is cut.
+#
+.if defined(USE_GCC2)
+GCC_REQD?=             2.8.0
+PKGSRC_COMPILER=       gcc
+.elif defined(USE_GCC3)
+GCC_REQD?=             3.0
+PKGSRC_COMPILER=       gcc
+.elif defined(USE_PKGSRC_GCC)
+_USE_PKGSRC_GCC=       yes
+PKGSRC_COMPILER=       gcc
+.elif defined(USE_SUNPRO)
+PKGSRC_COMPILER=       sunpro
+.elif defined(USE_MIPSPRO)
+PKGSRC_COMPILER=       mipspro
+.else
+PKGSRC_COMPILER?=      gcc
+.endif
+
+_PKGSRC_COMPILER=      # empty
+.for _compiler_ in ${PKGSRC_COMPILER}
+.  if empty(_PKGSRC_COMPILER:M${_compiler_})
+_PKGSRC_COMPILER:=     ${_compiler_} ${_PKGSRC_COMPILER}
+.  endif
+.endfor
+
+.for _compiler_ in ${_PKGSRC_COMPILER}
+.  if exists(../../mk/compiler/${_compiler_}.mk)
+.    include "../../mk/compiler/${_compiler_}.mk"
+.  endif
+.endfor
+
+.endif # BSD_COMPILER_MK
diff -r ba742f752f8a -r 642f5bb34521 mk/compiler/ccache.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/compiler/ccache.mk     Sun Feb 01 00:31:00 2004 +0000
@@ -0,0 +1,45 @@
+# $NetBSD: ccache.mk,v 1.1 2004/02/01 00:31:00 jlam Exp $
+
+.if !defined(COMPILER_CCACHE_MK)
+COMPILER_CCACHE_MK=    defined
+
+.if !empty(PKGPATH:Mdevel/ccache)
+IGNORE_CCACHE= yes
+MAKEFLAGS+=    IGNORE_CCACHE=yes
+.endif
+
+.if defined(IGNORE_CCACHE)
+_USE_CCACHE=   NO
+.endif
+
+.if !defined(_USE_CCACHE)
+_USE_CCACHE=   YES
+.endif
+
+.if !empty(_USE_CCACHE:M[yY][eE][sS])
+#
+# Add the dependency on ccache.
+BUILD_DEPENDS+=        ccache-[0-9]*:../../devel/ccache
+.endif
+
+EVAL_PREFIX+=  _CCACHEBASE=ccache
+_CCACHEBASE_DEFAULT=   ${LOCALBASE}
+_CCACHEBASE?=          ${LOCALBASE}
+
+.if exists(${_CCACHEBASE}/bin/ccache)
+_CCACHE_DIR=   ${WRKDIR}/.ccache
+PATH:=         ${_CCACHE_DIR}/bin:${PATH}
+
+CC=            ${_CCACHE_DIR}/bin/cc
+CXX=           ${_CCACHE_DIR}/bin/c++
+
+.  for _target_ in CC CXX
+override-tools: ${${_target_}}
+${${_target_}}:
+       ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
+       ${LN} -fs ${_CCACHEBASE}/bin/ccache ${.TARGET}
+.  endfor
+.endif
+
+.endif # COMPILER_CCACHE_MK
diff -r ba742f752f8a -r 642f5bb34521 mk/compiler/distcc.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/compiler/distcc.mk     Sun Feb 01 00:31:00 2004 +0000
@@ -0,0 +1,45 @@
+# $NetBSD: distcc.mk,v 1.1 2004/02/01 00:31:00 jlam Exp $
+
+.if !defined(COMPILER_DISTCC_MK)
+COMPILER_DISTCC_MK=    defined
+
+.if !empty(PKGPATH:Mdevel/distcc)
+IGNORE_DISTCC= yes
+MAKEFLAGS+=    IGNORE_DISTCC=yes
+.endif
+
+.if defined(IGNORE_DISTCC)
+_USE_DISTCC=   NO
+.endif
+
+.if !defined(_USE_DISTCC)
+_USE_DISTCC=   YES
+.endif
+
+.if !empty(_USE_DISTCC:M[yY][eE][sS])
+#
+# Add the dependency on distcc.
+BUILD_DEPENDS+=        distcc-[0-9]*:../../devel/distcc
+.endif
+
+EVAL_PREFIX+=  _DISTCCBASE=distcc
+_DISTCCBASE_DEFAULT=   ${LOCALBASE}
+_DISTCCBASE?=          ${LOCALBASE}
+
+.if exists(${_DISTCCBASE}/bin/distcc)
+_DISTCC_DIR=   ${WRKDIR}/.distcc
+PATH:=         ${_DISTCC_DIR}/bin:${PATH}
+
+CC=            ${_DISTCC_DIR}/bin/cc
+CXX=           ${_DISTCC_DIR}/bin/c++
+
+.  for _target_ in CC CXX
+override-tools: ${${_target_}}
+${${_target_}}:
+       ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
+       ${LN} -fs ${_DISTCCBASE}/bin/distcc ${.TARGET}
+.  endfor
+.endif
+
+.endif # COMPILER_DISTCC_MK
diff -r ba742f752f8a -r 642f5bb34521 mk/compiler/gcc.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/compiler/gcc.mk        Sun Feb 01 00:31:00 2004 +0000
@@ -0,0 +1,224 @@
+# $NetBSD: gcc.mk,v 1.1 2004/02/01 00:31:00 jlam Exp $
+
+.if !defined(COMPILER_GCC_MK)
+COMPILER_GCC_MK=       defined
+
+.include "../../mk/bsd.prefs.mk"
+
+GCC_REQD?=     2.8.0
+
+# _GCC_DIST_VERSION is the highest version of GCC installed by the pkgsrc
+# without the PKGREVISIONs.
+#
+_GCC_DIST_VERSION=     3.3
+
+# _GCC2_PATTERNS matches N s.t. N <= 2.95.3.
+_GCC2_PATTERNS=        2.8 2.8.* 2.9 2.9.* 2.[1-8][0-9] 2.[1-8][0-9].* \
+               2.9[0-4] 2.9[0-4].* 2.95 2.95.[0-3]
+
+# _GCC3_PATTERNS matches N s.t. 2.95.3 < N.
+_GCC3_PATTERNS=        2.95.[4-9]* 2.95.[1-9][0-9]* 2.9[6-9] 2.9[6-9].*        \
+               2.[1-9][0-9][0-9]* 3.* [4-9]*
+
+.if !defined(_IS_BUILTIN_GCC)
+#
+# GCC in older versions of Darwin report "Apple Computer ... based on gcc
+# version ...", so we can't just grep for "^gcc".
+#
+_IS_BUILTIN_GCC!=      \
+       gccpath="`${TYPE} ${CC} | ${AWK} '{ print $$NF }'`";            \
+       case $$gccpath in                                               \
+       ${LOCALBASE}/*)                                                 \
+               ${ECHO} "NO";                                           \
+               ;;                                                      \
+       *)                                                              \
+               if ${CC} -v 2>&1 | ${GREP} -q 'gcc version'; then       \
+                       ${ECHO} "YES";                                  \
+               else                                                    \
+                       ${ECHO} "NO";                                   \
+               fi;                                                     \
+               ;;                                                      \
+       esac
+.endif
+
+# Distill the GCC_REQD list into a single _GCC_REQD value that is the
+# highest version of GCC required.
+#
+_GCC_STRICTEST_REQD?=  none
+.for _version_ in ${GCC_REQD}
+.  for _pkg_ in gcc-${_version_}
+.    if ${_GCC_STRICTEST_REQD} == "none"
+_GCC_PKG_SATISFIES_DEP=                YES
+.      for _vers_ in ${GCC_REQD}
+.        if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
+_GCC_PKG_SATISFIES_DEP!=       \
+       if ${PKG_ADMIN} pmatch 'gcc>=${_vers_}' ${_pkg_}; then          \
+               ${ECHO} "YES";                                          \
+       else                                                            \
+               ${ECHO} "NO";                                           \
+       fi
+.        endif
+.      endfor
+.      if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
+_GCC_STRICTEST_REQD=   ${_version_}
+.      endif
+.    endif
+.  endfor
+.endfor
+_GCC_REQD=     ${_GCC_STRICTEST_REQD}
+
+# Determine whether we require GCC-2.x or GCC-3.x by examining _GCC_REQD.
+.for _pattern_ in ${_GCC2_PATTERNS}
+.  if !empty(_GCC_REQD:M${_pattern_})
+_GCC2_REQD:=   ${_GCC_REQD}
+.  endif
+.endfor
+.for _pattern_ in ${_GCC3_PATTERNS}
+.  if !empty(_GCC_REQD:M${_pattern_})
+_GCC3_REQD:=   ${_GCC_REQD}
+.  endif
+.endfor
+.if defined(_GCC2_REQD)
+_GCC_REQD:=            ${_GCC2_REQD}
+_GCC_PKGBASE=          gcc
+_GCC_PKGSRCDIR=                ../../lang/gcc
+.  if !empty(PKGPATH:Mlang/gcc)
+_IGNORE_GCC_REQD=      yes
+MAKEFLAGS+=            _IGNORE_GCC_REQD=yes
+.  endif
+.elif defined(_GCC3_REQD)
+_GCC_REQD:=            ${_GCC3_REQD}
+_GCC_PKGBASE=          gcc3
+_GCC_PKGSRCDIR=                ../../lang/gcc3
+.  if !empty(PKGPATH:Mlang/gcc3)
+_IGNORE_GCC_REQD=      yes
+MAKEFLAGS+=            _IGNORE_GCC_REQD=yes
+.  endif
+.endif
+_GCC_DEPENDS=          ${_GCC_PKGBASE}>=${_GCC_REQD}
+
+.if defined(_IGNORE_GCC_REQD)
+_USE_PKGSRC_GCC=       NO



Home | Main Index | Thread Index | Old Index