Import of pkgsrc-2013Q2

This commit is contained in:
2013-09-26 17:14:40 +02:00
commit 785076ae39
74991 changed files with 4380255 additions and 0 deletions

74
mk/alternatives.mk Normal file
View File

@@ -0,0 +1,74 @@
# $NetBSD: alternatives.mk,v 1.11 2009/06/14 22:58:05 joerg Exp $
#
# This Makefile fragment handles the alternatives system, registering a
# package in the database.
#
# User-settable variables:
#
# (none)
#
# Package-settable variables:
#
# ALTERNATIVES_SRC
# A _single_ file that contains the alternatives provided by the
# package.
#
# Default value: The name of the ALTERNATIVES file in the package
# directory, if it exists. Otherwise, nothing.
#
# Each line of the alternatives file contains two filenames, first
# the wrapper and then the alternative provided by the package.
# Both paths are relative to PREFIX.
#
# Variables defined by this file:
#
# PKG_ALTERNATIVES
# The path to the pkg_alternatives command.
#
.if !defined(ALTERNATIVES_MK)
ALTERNATIVES_MK= # defined
_VARGROUPS+= alternatives
_PKG_VARS.alternatives= ALTERNATIVES_SRC
_SYS_VARS.alternatives= PKG_ALTERNATIVES
.if exists(${.CURDIR}/ALTERNATIVES)
ALTERNATIVES_SRC?= ${.CURDIR}/ALTERNATIVES
.endif
ALTERNATIVES_SRC?= # none
.if !empty(ALTERNATIVES_SRC)
${WRKDIR}/.altinstall: ${ALTERNATIVES_SRC}
@{ ${ECHO} 'if ${TEST} $${STAGE} = "POST-INSTALL"; then'; \
${ECHO} '${CAT} >./+ALTERNATIVES <<EOF'; \
${SED} ${FILES_SUBST_SED} <${ALTERNATIVES_SRC}; \
${ECHO} 'EOF'; \
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
${ECHO} '${PKG_ALTERNATIVES} -gs register ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
${ECHO} 'fi'; \
} >${WRKDIR}/.altinstall
${WRKDIR}/.altdeinstall: ${ALTERNATIVES_SRC}
@{ ${ECHO} 'if ${TEST} $${STAGE} = "DEINSTALL"; then'; \
${ECHO} 'if ${TEST} -x ${PKG_ALTERNATIVES}; then'; \
${ECHO} '${PKG_ALTERNATIVES} -gs unregister ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
${ECHO} '${RM} -f ./+ALTERNATIVES'; \
${ECHO} 'fi'; \
} >${WRKDIR}/.altdeinstall
PRINT_PLIST_AWK+= /^libdata\/alternatives\// { next; }
EVAL_PREFIX+= PREFIX.pkg_alternatives=pkg_alternatives
PREFIX.alternatives_DEFAULT= ${LOCALBASE}
PKG_ALTERNATIVES= ${PREFIX.pkg_alternatives}/sbin/pkg_alternatives
INSTALL_TEMPLATES+= ${WRKDIR}/.altinstall
DEINSTALL_TEMPLATES+= ${WRKDIR}/.altdeinstall
.endif
.endif # ALTERNATIVES_MK

146
mk/apache.mk Normal file
View File

@@ -0,0 +1,146 @@
# $NetBSD: apache.mk,v 1.27 2012/04/14 12:58:19 adam Exp $
#
# This file is meant to be included by packages that require an apache
# web server.
#
# User-settable variables:
#
# PKG_APACHE_DEFAULT
# The default apache server to use and install. If there already
# is an apache installed, this will have no effect.
#
# Possible values: apache13 apache2 apache22 apache24
#
# Package-settable variables:
#
# PKG_APACHE_ACCEPTED
# The list of apache packages that can be used as a dependency for
# the package.
#
# Possible values: (see PKG_APACHE_DEFAULT)
#
# USE_APR
# If apache2 is chosen by this file and this variable is set to
# "yes", a full dependency to the Apache Portable Runtime library
# will be added.
#
# Variables defined by this file:
#
# PKG_APACHE
# The Apache version that is actually used.
#
# Possible values: (see PKG_APACHE_DEFAULT)
#
# APACHE_PKG_PREFIX
# The package name prefix for apache modules.
#
# Possible values: ap13 ap2 ap22 ap24
#
.if !defined(APACHE_MK)
APACHE_MK= # defined
_VARGROUPS+= apache
_USER_VARS.apache= PKG_APACHE_DEFAULT
_PKG_VARS.apache= PKG_APACHE_ACCEPTED USE_APR
_SYS_VARS.apache= PKG_APACHE APACHE_PKG_PREFIX
.include "bsd.fast.prefs.mk"
PKG_APACHE_DEFAULT?= apache22
BUILD_DEFS+= PKG_APACHE_DEFAULT
BUILD_DEFS_EFFECTS+= PKG_APACHE APACHE_PKG_PREFIX
# Package-settable variables
PKG_APACHE_ACCEPTED?= ${_PKG_APACHES}
USE_APR?= no
# The available apache packages:
_PKG_APACHES= apache13 apache2 apache22 apache24
_APACHE_PKGBASE.apache13= apache-1*
_APACHE_PKG_PREFIX.apache13= ap13
_APACHE_PKGSRCDIR.apache13= ../../www/apache
_APACHE_PKGBASE.apache2= apache-2.0*
_APACHE_PKG_PREFIX.apache2= ap2
_APACHE_PKGSRCDIR.apache2= ../../www/apache2
_APACHE_PKGBASE.apache22= apache-2.[23]*
_APACHE_PKG_PREFIX.apache22= ap22
_APACHE_PKGSRCDIR.apache22= ../../www/apache22
_APACHE_PKGBASE.apache24= apache-2.[456789]*
_APACHE_PKG_PREFIX.apache24= ap24
_APACHE_PKGSRCDIR.apache24= ../../www/apache24
#
# Sanity checks.
#
.if empty(_PKG_APACHES:M${PKG_APACHE_DEFAULT})
PKG_FAIL_REASON+= "[apache.mk] Invalid apache package \""${PKG_APACHE_DEFAULT:Q}"\" in PKG_APACHE_DEFAULT."
PKG_APACHE_DEFAULT= apache2
.endif
.for _ap_ in ${PKG_APACHE_ACCEPTED}
. if empty(_PKG_APACHES:M${_ap_})
PKG_FAIL_REASON+= "[apache.mk] Invalid apache package \""${_ap_:Q}"\" in PKG_APACHE_ACCEPTED."
PKG_APACHE_ACCEPTED= # none
. endif
.endfor
# Mark the acceptable apaches and check which apache packages are installed.
.for _ap_ in ${PKG_APACHE_ACCEPTED}
_APACHE_OK.${_ap_}= yes
_APACHE_INSTALLED.${_ap_}!= \
if ${PKG_INFO} -qe ${_APACHE_PKGBASE.${_ap_}:Q}; then \
${ECHO} yes; \
else \
${ECHO} no; \
fi
.endfor
.for ap in ${_PKG_APACHES}
_APACHE_OK.${ap}?= no
.endfor
.undef PKG_APACHE
# Use one of the installed apaches, ...
.for _ap_ in ${PKG_APACHE_ACCEPTED}
. if ${_APACHE_INSTALLED.${_ap_}} == "yes"
PKG_APACHE?= ${_ap_}
. endif
.endfor
# ... otherwise, prefer the default one if it's accepted, ...
.if ${_APACHE_OK.${PKG_APACHE_DEFAULT}} == "yes"
PKG_APACHE?= ${PKG_APACHE_DEFAULT}
.endif
# ... otherwise, just use the first accepted apache.
.for ap in ${PKG_APACHE_ACCEPTED}
PKG_APACHE?= ${ap}
.endfor
.if defined(PKG_APACHE)
. include "${_APACHE_PKGSRCDIR.${PKG_APACHE}}/buildlink3.mk"
.else
PKG_FAIL_REASON+= "[apache.mk] No acceptable apache package found."
PKG_APACHE= none
.endif
APACHE_PKG_PREFIX= ${_APACHE_PKG_PREFIX.${PKG_APACHE}}
.if (${PKG_APACHE} == "apache2") && !empty(USE_APR:M[yY][eE][sS])
. include "../../devel/apr0/buildlink3.mk"
.elif (${PKG_APACHE} != "apache13") && !empty(USE_APR:M[Yy][Ee][Ss])
. include "../../devel/apr/buildlink3.mk"
. include "../../devel/apr-util/buildlink3.mk"
.endif
#
# Variable assignment for multi-apache packages
MULTI+= PKG_APACHE=${PKG_APACHE}
.endif # APACHE_MK

141
mk/bdb.buildlink3.mk Normal file
View File

@@ -0,0 +1,141 @@
# $NetBSD: bdb.buildlink3.mk,v 1.24 2010/06/02 12:11:52 adam Exp $
#
# This Makefile fragment is meant to be included by packages that
# require a Berkeley DB (BDB) implementation and that are not restricted
# to a single one. The available BDB implementations are db1
# (if builtin) and db[234].
#
# FIXME: This Makefile cannot handle packages that can use only a
# subset of { db2 db3 db4 }.
#
# === User-settable variables ===
#
# BDB_DEFAULT
# This value represents the package we use when either a db-1.85
# interface isn't required, or a db-1.85 interface is required,
# but it's not built-in.
#
# FIXME: Improve the wording of the text above so that one can
# understand it.
#
# Possible: db1 db2 db3 db4 db5
# Default: db4
#
# BDB185_DEFAULT
# The package we use when a db-1.85 interface is required.
# It defaults to "db1" if it's built-in, or to ${BDB_DEFAULT}
# otherwise.
#
# === Package-settable variables ===
#
# BDB_ACCEPTED
# The list of Berkeley DB implementations that can be used by the
# package.
#
# FIXME: If the list does not include db1 and does not include
# BDB_DEFAULT, the package will not build at the moment.
#
# === Variables set by this file ===
#
# BDB_TYPE
# The name of the selected BDB implementation.
#
# BDBBASE
# The base directory of the selected BDB implementation. It has
# subdirectories include/ and lib/.
#
# BDB_LIBS
# Linker flags to link against the BDB library.
# Note for when databases/db1 is imported:
# (1) Remove the section that conditionally sets the default
# value for BDB185_DEFAULT and always set it to be "db1".
# (2) Remove the special case for ${BDB_TYPE} == "db1" at the end.
# (3) Move mk/db1.builtin.mk to databases/db1/builtin.mk.
BDB_BUILDLINK3_MK:= ${BDB_BUILDLINK3_MK}+
.include "bsd.fast.prefs.mk"
.if !empty(BDB_BUILDLINK3_MK:M+)
_VARGROUPS+= bdb
_USER_VARS.bdb= BDB_DEFAULT BDB185_DEFAULT
_PKG_VARS.bdb= BDB_ACCEPTED
_SYS_VARS.bdb= BDB_TYPE BDBBASE BDB_LIBS
# If the package specified a list of acceptable Berkeley DB packages,
# set USE_DB185 to yes if db1 is included, and otherwise no, thus
# preferring to use db1. Assume that the package's configure process
# should know how to probe for the libraries and headers on its own.
#
. if defined(BDB_ACCEPTED) && empty(BDB_ACCEPTED:Mdb1)
USE_DB185?= no
. else
USE_DB185?= yes
. endif
# _BDB_PKGS is an exhaustive list of all of the Berkeley DB
# implementations that may be used with bdb.buildlink3.mk.
#
_BDB_PKGS?= db1 db2 db3 db4 db5
BDB_DEFAULT?= db4
BDB_ACCEPTED?= ${_BDB_PKGS}
# Decide what to use when DB185 is required. If builtin db1 is
# present, use it, and if not use DBD_DEFAULT.
#
CHECK_BUILTIN.db1:= yes
. include "db1.builtin.mk"
CHECK_BUILTIN.db1:= no
. if defined(IS_BUILTIN.db1) && !empty(IS_BUILTIN.db1:M[yY][eE][sS])
BDB185_DEFAULT?= db1
. else
BDB185_DEFAULT?= ${BDB_DEFAULT}
. endif
_BDB_PKGSRCDIR.db2= ../../databases/db
. for _bdb_ in ${_BDB_PKGS}
_BDB_PKGSRCDIR.${_bdb_}?= ../../databases/${_bdb_}
. endfor
_BDB_DEFAULT= ${BDB_DEFAULT}
_BDB185_DEFAULT= ${BDB185_DEFAULT}
_BDB_ACCEPTED= ${BDB_ACCEPTED}
. if !defined(_BDB_TYPE)
. if !empty(USE_DB185:M[yY][eE][sS])
_BDB_TYPE= ${_BDB185_DEFAULT}
. else
_BDB_TYPE= ${_BDB_DEFAULT}
. endif
. endif
# Note that if BDB_ACCEPTED does not contain db1 or BDB_DEFAULT, this
# results in BDB_TYPE being none (rather than the most preferred value
# in BDB_ACCEPTED, which might or might not be better.)
. if !empty(_BDB_ACCEPTED:M${_BDB_TYPE})
BDB_TYPE= ${_BDB_TYPE}
. else
BDB_TYPE= none
. endif
# Define some public variables to refer to package-specific variables.
BDBBASE= ${BUILDLINK_PREFIX.${BDB_TYPE}}
BDB_LIBS= ${BUILDLINK_LDADD.${BDB_TYPE}}
BUILD_DEFS+= BDB_DEFAULT BDB185_DEFAULT
BUILD_DEFS_EFFECTS+= BDBBASE BDB_LIBS BDB_TYPE
.endif # BDB_BUILDLINK3_MK
.if ${BDB_TYPE} == "none"
PKG_FAIL_REASON= \
"[bdb.buildlink3.mk] ${_BDB_TYPE} is not an acceptable Berkeley DB type for ${PKGNAME}."
.elif ${BDB_TYPE} == "db1"
BUILDLINK_TREE+= db1 -db1
BUILDLINK_BUILTIN_MK.db1= ../../mk/db1.builtin.mk
.else
. include "${_BDB_PKGSRCDIR.${BDB_TYPE}}/buildlink3.mk"
.endif

8
mk/bsd.fast.prefs.mk Normal file
View File

@@ -0,0 +1,8 @@
# $NetBSD: bsd.fast.prefs.mk,v 1.1 2006/11/05 14:28:38 joerg Exp $
#
# Conditionally include mk/bsd.prefs.mk, if it wasn't processed already.
#
.if !defined(BSD_PKG_MK)
.include "../../mk/bsd.prefs.mk"
.endif

69
mk/bsd.hacks.mk Normal file
View File

@@ -0,0 +1,69 @@
# $NetBSD: bsd.hacks.mk,v 1.3 2006/07/15 23:58:52 rillig Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# This Makefile fragment automatically includes the necessary hacks to
# make the package build correctly by including the package's hacks.mk
# file if it exists.
#
# An example package hacks.mk:
#
# -------------8<-------------8<-------------8<-------------8<-------------
# .if !defined(FOO_HACKS_MK)
# FOO_HACKS_MK= defined
#
# ### [Sun Nov 14 02:08:31 EST 2004 : jlam]
# ### arm GCC 2.95.x optimisation bug tickled when compiling
# ### lib/funkyfile.c. Require a more recent version of GCC as a
# ### workaround and patch lib/funkyfile.c (patch-ae).
# ###
# .if !empty(MACHINE_ARCH:Marm*)
# PKG_HACKS+= optimisation
# GCC_REQD+= 3.0
# .endif
#
# .endif # FOO_HACKS_MK
# -------------8<-------------8<-------------8<-------------8<-------------
PKG_HACKS?= # empty
.if exists(${PKGDIR}/hacks.mk)
. include "${PKGDIR}/hacks.mk"
.endif
# Record any package hacks that we use in the installed package.
.if !empty(PKG_HACKS)
_BUILD_DEFS+= PKG_HACKS
.endif

40
mk/bsd.makevars.mk Normal file
View File

@@ -0,0 +1,40 @@
# $NetBSD: bsd.makevars.mk,v 1.5 2010/02/24 22:53:34 joerg Exp $
#
# This Makefile fragment is included by bsd.prefs.mk to set all of
# the variables saved through MAKEVARS. Typical usage is:
#
# .include "../../mk/bsd.prefs.mk"
#
# .if !defined(EXPENSIVE_VAR)
# EXPENSIVE_VAR!= ( ... an expensive computation ... )
# .endif
# MAKEVARS+= EXPENSIVE_VAR
#
# This causes EXPENSIVE_VAR to be computed, then subsequently stored in
# the variable cache file. The next time through, EXPENSIVE_VAR is
# set by bsd.makevars.mk, which avoids running the expensive computation
# again.
#
# The cache files are created as we pass through each phase of the build,
# and we only include the latest cache file that was created.
#
_ALL_PHASES= fetch tools extract patch \
wrapper configure build stage-install package
_REV_ALL_PHASES= package stage-install build configure wrapper \
patch extract tools fetch
# Try including the *.makevars.mk files in reverse order so that the
# latest file is included and no more. We check for _MAKEVARS_MK since
# all of the *.makevars.mk files define this symbol at the top of the
# file.
#
.for _phase_ in ${_REV_ALL_PHASES}
_MAKEVARS_MK.${_phase_}= ${WRKDIR}/.${_phase_}_makevars.mk
. if !target(${_phase_}-vars)
${_phase_}-vars: ${_MAKEVARS_MK.${_phase_}}
. endif
. if !defined(_MAKEVARS_MK)
. sinclude "${_MAKEVARS_MK.${_phase_}}"
. endif
.endfor

445
mk/bsd.options.mk Normal file
View File

@@ -0,0 +1,445 @@
# $NetBSD: bsd.options.mk,v 1.71 2013/06/07 00:41:39 obache Exp $
#
# This Makefile fragment provides boilerplate code for standard naming
# conventions for handling per-package build options.
#
# Before including this file, the following variables can be defined:
#
# PKG_SUPPORTED_OPTIONS
# This is a list of build options supported by the package.
# This variable should be set in a package Makefile. E.g.,
#
# PKG_SUPPORTED_OPTIONS= kerberos ldap ssl
#
# PKG_OPTIONS_VAR (must be defined)
# The variable the user can set to enable or disable
# options specifically for this package.
#
# PKG_OPTIONS_OPTIONAL_GROUPS
# This is a list of names of groups of mutually exclusive
# options. The options in each group are listed in
# PKG_OPTIONS_GROUP.<groupname>. The most specific
# setting of any option from the group takes precedence
# over all other options in the group. Options from
# the groups will be automatically added to
# PKG_SUPPORTED_OPTIONS.
#
# PKG_OPTIONS_REQUIRED_GROUPS
# Like PKG_OPTIONS_OPTIONAL_GROUPS, but building
# the packages will fail if no option from the group
# is selected.
#
# PKG_OPTIONS_NONEMPTY_SETS
# This is a list of names of sets of options. At
# least one option from each set must be selected.
# The options in each set are listed in
# PKG_OPTIONS_SET.<setname>. Options from the sets
# will be automatically added to PKG_SUPPORTED_OPTIONS.
#
# PKG_SUGGESTED_OPTIONS (defaults to empty)
# This is a list of build options which are enabled by default.
#
# PKG_OPTIONS_LEGACY_VARS
# This is a list of USE_VARIABLE:option pairs that
# map legacy /etc/mk.conf variables to their option
# counterparts.
#
# PKG_OPTIONS_LEGACY_OPTS
# This is a list of old-option:new-option pairs that
# map options that have been renamed to their new
# counterparts.
#
# PKG_LEGACY_OPTIONS
# A list of options implied by deprecated variables
# used. This can be used for cases that neither
# PKG_OPTIONS_LEGACY_VARS nor PKG_OPTIONS_LEGACY_OPTS
# can handle, e. g. when PKG_OPTIONS_VAR is renamed.
#
# PKG_OPTIONS_DEPRECATED_WARNINGS
# A list of warnings about deprecated variables or
# options used, and what to use instead.
#
# If none of PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS,
# PKG_OPTIONS_REQUIRED_GROUPS, and PKG_OPTIONS_NONEMPTY_SETS are
# defined, PKG_OPTIONS is set to the empty list and the package
# is otherwise treated as not using the options framework.
#
#
# Optionally, the user may define the following variables in /etc/mk.conf:
#
# PKG_DEFAULT_OPTIONS
# This variable can be used to override default
# options for every package. Options listed in this
# variable will be enabled in every package that
# supports them. If you prefix an option with `-',
# it will be disabled in every package.
#
# ${PKG_OPTIONS_VAR}
# This variable can be used to override default
# options and options listed in PKG_DEFAULT_OPTIONS.
# The syntax is the same as PKG_DEFAULT_OPTIONS.
#
# After including this file, the following variables are defined:
#
# PKG_OPTIONS
# This is the list of the selected build options, properly
# filtered to remove unsupported and duplicate options.
#
.if !defined(BSD_OPTIONS_MK)
BSD_OPTIONS_MK= # defined
# To add options support to a package, here is an example for an
# options.mk file. This file should be included by the package Makefile
# or Makefile.common.
#
# -------------8<-------------8<-------------8<-------------8<-------------
# PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
# PKG_SUPPORTED_OPTIONS= wibble-foo ldap sasl
# PKG_OPTIONS_OPTIONAL_GROUPS= database
# PKG_OPTIONS_GROUP.database= mysql pgsql
# PKG_SUGGESTED_OPTIONS= wibble-foo
# PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
# PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_SASL2:sasl
# PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
#
# .include "../../mk/bsd.prefs.mk"
#
# # this package was previously named wibble2
# .if defined(PKG_OPTIONS.wibble2)
# PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
# PKG_OPTIONS_DEPRECATED_WARNINGS+="Deprecated variable PKG_OPTIONS.wibble2 used, use "${PKG_OPTIONS_VAR:Q}" instead."
# .endif
#
# .include "../../mk/bsd.options.mk"
#
# # Package-specific option-handling
#
# ###
# ### FOO support
# ###
# .if !empty(PKG_OPTIONS:Mwibble-foo)
# CONFIGURE_ARGS+= --enable-foo
# .endif
# ###
# ### LDAP support
# ###
# .if !empty(PKG_OPTIONS:Mldap)
# . include "../../databases/openldap-client/buildlink3.mk"
# CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
# .endif
#
# ###
# ### SASL authentication
# ###
# .if !empty(PKG_OPTIONS:Msasl)
# . include "../../security/cyrus-sasl/buildlink3.mk"
# CONFIGURE_ARGS+= --enable-sasl=${BUILDLINK_PREFIX.sasl}
# .endif
#
# ###
# ### database support
# ###
# .if !empty(PKG_OPTIONS:Mmysql)
# . include "../../mk/mysql.buildlink3.mk"
# .endif
# .if !empty(PKG_OPTIONS:Mpgsql)
# . include "../../mk/pgsql.buildlink3.mk"
# .endif
# -------------8<-------------8<-------------8<-------------8<-------------
#
# Keywords: options.mk
_VARGROUPS+= options
_USER_VARS.options= PKG_DEFAULT_OPTIONS ${PKG_OPTIONS_VAR}
_PKG_VARS.options= PKG_SUPPORTED_OPTIONS PKG_OPTIONS_VAR \
PKG_OPTIONS_OPTIONAL_GROUPS PKG_OPTIONS_REQUIRED_GROUPS \
PKG_OPTIONS_NONEMPTY_SETS PKG_SUGGESTED_OPTIONS \
PKG_OPTIONS_LEGACY_VARS PKG_OPTIONS_LEGACY_OPTS \
PKG_LEGACY_OPTIONS PKG_OPTIONS_DEPRECATED_WARNINGS
_SYS_VARS.options= PKG_OPTIONS
.include "bsd.prefs.mk"
# Define PKG_OPTIONS, no matter if we have an error or not, to suppress
# further make(1) warnings.
PKG_OPTIONS= # empty
# Check for variable definitions required before including this file.
.if !defined(PKG_OPTIONS_VAR)
PKG_FAIL_REASON+= "[bsd.options.mk] PKG_OPTIONS_VAR is not defined."
.endif
.if !defined(PKG_SUPPORTED_OPTIONS) \
&& !defined(PKG_OPTIONS_OPTIONAL_GROUPS) \
&& !defined(PKG_OPTIONS_REQUIRED_GROUPS) \
&& !defined(PKG_OPTIONS_NONEMPTY_SETS)
PKG_SUPPORTED_OPTIONS?= # none
PKG_FAIL_REASON+= "[bsd.options.mk] The package has no options, but includes this file."
.endif
#
# create map of option to group and add group options to PKG_SUPPORTED_OPTIONS
#
.for _grp_ in ${PKG_OPTIONS_OPTIONAL_GROUPS} ${PKG_OPTIONS_REQUIRED_GROUPS}
_PKG_OPTIONS_GROUP_STACK.${_grp_}:=#empty
. if !defined(PKG_OPTIONS_GROUP.${_grp_}) || empty(PKG_OPTIONS_GROUP.${_grp_})
PKG_FAIL_REASON+= "[bsd.options.mk] PKG_OPTIONS_GROUP."${_grp_:Q}" must be non-empty."
. endif
. for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}}
PKG_SUPPORTED_OPTIONS+= ${_opt_}
_PKG_OPTIONS_GROUP_MAP.${_opt_}=${_grp_}
. endfor
.endfor
#
# add options from sets to PKG_SUPPORTED_OPTIONS
#
_PKG_OPTIONS_ALL_SETS:=#empty
.for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
. if !defined(PKG_OPTIONS_SET.${_set_}) || empty(PKG_OPTIONS_SET.${_set_})
PKG_FAIL_REASON+= "[bsd.options.mk] PKG_OPTIONS_SET."${_set_:Q}" must be non-empty."
. endif
. for _opt_ in ${PKG_OPTIONS_SET.${_set_}}
PKG_SUPPORTED_OPTIONS+= ${_opt_}
_PKG_OPTIONS_ALL_SETS+= ${_opt_}
. endfor
.endfor
#
# include deprecated variable to options mapping
#
.include "defaults/obsolete.mk"
#
# place options implied by legacy variables in PKG_LEGACY_OPTIONS
#
.for _m_ in ${PKG_OPTIONS_LEGACY_VARS}
_var_:= ${_m_:C/:.*//}
_opt_:= ${_m_:C/.*://}
_popt_:=${_opt_:C/^-//}
. if !empty(PKG_SUPPORTED_OPTIONS:M${_popt_})
. if defined(${_var_})
. if empty(${_var_}:M[nN][oO])
PKG_LEGACY_OPTIONS:=${PKG_LEGACY_OPTIONS} ${_opt_}
PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Deprecated variable "${_var_:Q}" set to "${${_var_}:Q}", use PKG_DEFAULT_OPTIONS+="${_opt_:Q}" instead."
. elif empty(_opt_:M-*)
PKG_LEGACY_OPTIONS:=${PKG_LEGACY_OPTIONS} -${_popt_}
PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Deprecated variable "${_var_:Q}" set to "${${_var_}:Q}", use PKG_DEFAULT_OPTIONS+=-"${_popt_:Q}" instead."
. else
PKG_LEGACY_OPTIONS:=${PKG_LEGACY_OPTIONS} ${_popt_}
PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Deprecated variable "${_var_:Q}" set to "${${_var_}:Q}", use PKG_DEFAULT_OPTIONS+="${_popt_:Q}" instead."
. endif
. endif
. endif
.endfor
.undef _var_
.undef _opt_
.undef _popt_
#
# create map of old option name to new option name for legacy options
#
.for _m_ in ${PKG_OPTIONS_LEGACY_OPTS}
_old_:= ${_m_:C/:.*//}
_new_:= ${_m_:C/.*://}
. if !empty(PKG_SUPPORTED_OPTIONS:M${_new_})
_PKG_LEGACY_OPTMAP.${_old_}:=${_new_}
. endif
.endfor
.undef _old_
.undef _new_
#
# filter unsupported options from PKG_DEFAULT_OPTIONS
#
_OPTIONS_DEFAULT_SUPPORTED:= #empty
.for _o_ in ${PKG_DEFAULT_OPTIONS}
_opt_:= ${_o_}
_popt_:= ${_opt_:C/^-//}
. if !empty(PKG_SUPPORTED_OPTIONS:M${_popt_}) \
|| defined(_PKG_LEGACY_OPTMAP.${_popt_})
_OPTIONS_DEFAULT_SUPPORTED:=${_OPTIONS_DEFAULT_SUPPORTED} ${_opt_}
. endif
.endfor
.undef _opt_
.undef _popt_
#
# process options from generic to specific
#
PKG_OPTIONS:= # empty
_OPTIONS_UNSUPPORTED:= #empty
.for _o_ in ${PKG_SUGGESTED_OPTIONS} ${PKG_LEGACY_OPTIONS} \
${_OPTIONS_DEFAULT_SUPPORTED} ${${PKG_OPTIONS_VAR}}
_opt_:= ${_o_}
_popt_:= ${_o_:C/^-//} # positive option
. if defined(_PKG_LEGACY_OPTMAP.${_popt_})
PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Deprecated option "${_popt_:Q}" used, use option "${_PKG_LEGACY_OPTMAP.${_popt_}:Q}" instead."
_popt_:= ${_PKG_LEGACY_OPTMAP.${_popt_}}
. if empty(_opt_:M-*)
_opt_:= ${_popt_}
. else
_opt_:= -${_popt_}
. endif
. endif
. if empty(PKG_SUPPORTED_OPTIONS:M${_popt_})
. if empty(_opt_:M-*)
_OPTIONS_UNSUPPORTED:=${_OPTIONS_UNSUPPORTED} ${_opt_}
. else
PKG_OPTIONS_DEPRECATED_WARNINGS:=${PKG_OPTIONS_DEPRECATED_WARNINGS} "Option "${_opt_:C/^-//:Q}" is unsupported, so disabling it has no effect."
. endif
. else
. if defined(_PKG_OPTIONS_GROUP_MAP.${_popt_})
_grp_:= ${_PKG_OPTIONS_GROUP_MAP.${_popt_}}
_stk_:= _PKG_OPTIONS_GROUP_STACK.${_grp_}
_cnt_:= ${${_stk_}}
. if !empty(_opt_:M-*)
${_stk_}:= ${_cnt_:N${_popt_}}
. else
${_stk_}:= ${_cnt_} ${_popt_}
. endif
. else
. if !empty(_opt_:M-*)
PKG_OPTIONS:= ${PKG_OPTIONS:N${_popt_}}
. else
PKG_OPTIONS:= ${PKG_OPTIONS} ${_popt_}
. endif
. endif
. endif
.endfor
.undef _opt_
.undef _popt_
.undef _stk_
.for _grp_ in ${PKG_OPTIONS_REQUIRED_GROUPS}
. if empty(_PKG_OPTIONS_GROUP_STACK.${_grp_})
PKG_FAIL_REASON+= "[bsd.options.mk] One of the following options must be selected: "${PKG_OPTIONS_GROUP.${_grp_}:O:u:Q}
. endif
.endfor
.for _grp_ in ${PKG_OPTIONS_REQUIRED_GROUPS} ${PKG_OPTIONS_OPTIONAL_GROUPS}
. undef _opt_
. for _o_ in ${_PKG_OPTIONS_GROUP_STACK.${_grp_}}
_opt_:= ${_o_}
. endfor
. if defined(_opt_)
PKG_OPTIONS:= ${PKG_OPTIONS} ${_opt_}
. endif
.endfor
.undef _opt_
.for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
_ISEMPTY:=true
. for _opt_ in ${PKG_OPTIONS_SET.${_set_}}
. if !empty(PKG_OPTIONS:M${_opt_})
_ISEMPTY:=false
. endif
. endfor
. if ${_ISEMPTY} == "true"
PKG_FAIL_REASON+= "[bsd.options.mk] At least one of the following options must be selected: "${PKG_OPTIONS_SET.${_set_}:O:u:Q}
. endif
.endfor
.undef _ISEMPTY
.if !empty(_OPTIONS_UNSUPPORTED)
PKG_FAIL_REASON+= "[bsd.options.mk] The following selected options are not supported: "${_OPTIONS_UNSUPPORTED:O:u:Q}"."
.endif
.undef _OPTIONS_DEFAULT_SUPPORTED
PKG_OPTIONS:= ${PKG_OPTIONS:O:u}
_PKG_OPTIONS_WORDWRAP_FILTER= \
${XARGS} -n 1 | \
${AWK} ' \
BEGIN { printwidth = 40; line = "" } \
{ \
if (length(line) > 0) \
line = line" "$$0; \
else \
line = $$0; \
if (length(line) > 40) { \
print " "line; \
line = ""; \
} \
} \
END { if (length(line) > 0) print " "line } \
'
.PHONY: show-options
show-options:
@${ECHO} Any of the following general options may be selected:
.for _opt_ in ${PKG_SUPPORTED_OPTIONS:O}
. if !defined(_PKG_OPTIONS_GROUP_MAP.${_opt_}) && empty(_PKG_OPTIONS_ALL_SETS:M${_opt_})
@${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
. endif
.endfor
.for _grp_ in ${PKG_OPTIONS_REQUIRED_GROUPS}
@${ECHO} "Exactly one of the following "${_grp_:Q}" options is required:"
. for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}:O}
@${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
. endfor
.endfor
.for _grp_ in ${PKG_OPTIONS_OPTIONAL_GROUPS}
@${ECHO} "At most one of the following "${_grp_:Q}" options may be selected:"
. for _opt_ in ${PKG_OPTIONS_GROUP.${_grp_}:O}
@${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
. endfor
.endfor
.for _set_ in ${PKG_OPTIONS_NONEMPTY_SETS}
@${ECHO} "At least one of the following "${_set_:Q}" options must be selected:"
. for _opt_ in ${PKG_OPTIONS_SET.${_set_}:O}
@${ECHO} " "${_opt_:Q}" "`${SED} -n "s/^"${_opt_:Q}" //p" ../../mk/defaults/options.description`
. endfor
.endfor
@${ECHO}
@${ECHO} "These options are enabled by default:"
@${ECHO} ${PKG_SUGGESTED_OPTIONS:O:Q} | ${_PKG_OPTIONS_WORDWRAP_FILTER}
@${ECHO} ""
@${ECHO} "These options are currently enabled:"
@${ECHO} ${PKG_OPTIONS:O:Q} | ${_PKG_OPTIONS_WORDWRAP_FILTER}
@${ECHO} ""
@${ECHO} "You can select which build options to use by setting PKG_DEFAULT_OPTIONS"
@${ECHO} "or "${PKG_OPTIONS_VAR:Q}"."
@set args ${PKG_OPTIONS_DEPRECATED_WARNINGS}; shift; \
[ $$# -eq 0 ] || ${ECHO}; \
for l in "$$@"; do \
${ECHO} "$$l"; \
done
.if defined(PKG_SUPPORTED_OPTIONS)
.PHONY: supported-options-message
pre-depends-hook: supported-options-message
supported-options-message:
. if !empty(PKG_SUPPORTED_OPTIONS)
@${ECHO} "=========================================================================="
@${ECHO} "The supported build options for ${PKGBASE} are:"
@${ECHO} ""
@${ECHO} ${PKG_SUPPORTED_OPTIONS:O:Q} | ${_PKG_OPTIONS_WORDWRAP_FILTER}
. if !empty(PKG_OPTIONS)
@${ECHO} ""
@${ECHO} "The currently selected options are:"
@${ECHO} ""
@${ECHO} ${PKG_OPTIONS:O:Q} | ${XARGS} -n 1 | ${_PKG_OPTIONS_WORDWRAP_FILTER}
. endif
@${ECHO} ""
@${ECHO} "You can select which build options to use by setting PKG_DEFAULT_OPTIONS"
@${ECHO} "or the following variable. Its current value is shown:"
@${ECHO} ""
. if !defined(${PKG_OPTIONS_VAR})
@${ECHO} " ${PKG_OPTIONS_VAR} (not defined)"
. else
@${ECHO} " ${PKG_OPTIONS_VAR} = "${${PKG_OPTIONS_VAR}:Q}
. endif
@set args ${PKG_OPTIONS_DEPRECATED_WARNINGS}; shift; \
[ $$# -eq 0 ] || ${ECHO}; \
for l in "$$@"; do \
${ECHO} "$$l"; \
done
@${ECHO} ""
@${ECHO} "=========================================================================="
. endif
.endif
.endif # BSD_OPTIONS_MK

93
mk/bsd.pkg.barrier.mk Normal file
View File

@@ -0,0 +1,93 @@
# $NetBSD: bsd.pkg.barrier.mk,v 1.19 2013/05/23 13:18:56 obache Exp $
_COOKIE.barrier= ${WRKDIR}/.barrier_cookie
# _BARRIER_PRE_TARGETS is a list of the targets that must be built before
# the "barrier" target invokes a new make.
#
_BARRIER_PRE_TARGETS= checksum-phase makedirs depends
# _BARRIER_POST_TARGETS is a list of the targets that must be built after
# the "barrier" target invokes a new make. This list is specially
# ordered so that if more than one is specified on the command-line,
# then pkgsrc will still do the right thing.
#
# FIXME: why is wrapper before extract?
_BARRIER_POST_TARGETS= tools
_BARRIER_POST_TARGETS+= wrapper
_BARRIER_POST_TARGETS+= extract
_BARRIER_POST_TARGETS+= patch
_BARRIER_POST_TARGETS+= configure
_BARRIER_POST_TARGETS+= build build-env
_BARRIER_POST_TARGETS+= test
_BARRIER_POST_TARGETS+= all
_BARRIER_POST_TARGETS+= stage-install
_BARRIER_POST_TARGETS+= stage-package-create
_BARRIER_POST_TARGETS+= reinstall
_BARRIER_POST_TARGETS+= replace
_BARRIER_POST_TARGETS+= package
_BARRIER_POST_TARGETS+= repackage
_BARRIER_POST_TARGETS+= package-install
_BARRIER_POST_TARGETS+= install
.for _target_ in ${_BARRIER_POST_TARGETS}
. if make(${_target_})
_BARRIER_CMDLINE_TARGETS+= ${_target_}
. endif
.endfor
######################################################################
### barrier (PRIVATE)
######################################################################
### barrier is a helper target that can be used to separate targets
### that should be built in a new make process from being built in
### the current one. The targets that must be built after the "barrier"
### target invokes a new make should be listed in _BARRIER_POST_TARGETS,
### and should be of the form:
###
### .if !defined(_PKGSRC_BARRIER)
### foo: barrier
### .else
### foo: foo's real source dependencies
### .endif
###
### Note that none of foo's real source dependencies should include
### targets that occur before the barrier.
###
.PHONY: barrier-error-check
barrier-error-check: error-check
.PHONY: barrier
barrier: ${_BARRIER_PRE_TARGETS} ${_COOKIE.barrier}
.if !defined(_PKGSRC_BARRIER)
. if defined(PKG_VERBOSE)
@${PHASE_MSG} "Invoking \`\`"${_BARRIER_CMDLINE_TARGETS:Q}"'' after barrier for ${PKGNAME}"
. endif
${RUN} \
if ${TEST} -n "${_PKGSRC_UPDATE_CHECK}" && \
${PKG_INFO} -qe ${PKGNAME}; then \
${PHASE_MSG} "Skipping installation of already handled package"; \
else \
cd ${.CURDIR} \
&& ${RECURSIVE_MAKE} ${MAKEFLAGS} _PKGSRC_BARRIER=yes ALLOW_VULNERABLE_PACKAGES= ${_BARRIER_CMDLINE_TARGETS} \
|| { \
exitcode="$$?"; \
${RECURSIVE_MAKE} ${MAKEFLAGS} _PKGSRC_BARRIER=yes barrier-error-check; \
exit "$$exitcode"; \
}; \
fi
. if defined(PKG_VERBOSE)
@${PHASE_MSG} "Leaving \`\`"${_BARRIER_CMDLINE_TARGETS:Q}"'' after barrier for ${PKGNAME}"
. endif
.endif
######################################################################
### barrier-cookie (PRIVATE)
######################################################################
### barrier-cookie creates the "barrier" cookie file.
###
${_COOKIE.barrier}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN}${ECHO} ${PKGNAME} > ${.TARGET}

96
mk/bsd.pkg.clean.mk Normal file
View File

@@ -0,0 +1,96 @@
# $NetBSD: bsd.pkg.clean.mk,v 1.14 2013/06/01 19:31:52 rillig Exp $
#
# This Makefile fragment is included to bsd.pkg.mk and defines the
# relevant variables and targets for the "clean" phase.
#
# The following variables may be set by the package Makefile and
# specify how cleaning happens:
#
# CLEANDEPENDS specifies the whether "cleaning" will also clean
# in all dependencies, implied and direct. CLEANDEPENDS
# defaults to "no".
#
# The following targets are defined by bsd.pkg.clean.mk:
#
# clean-depends:
# descends into dependencies' package directories and invokes the
# "clean" action.
#
# do-clean:
# does the actual cleaning, which involves removing the work
# directory and other temporary files used by the package.
#
# clean:
# is invoked by the user to perform the "clean" action.
#
# cleandir:
# an alias for "clean".
#
CLEANDEPENDS?= no
.if defined(PRIVILEGED_STAGES) && !empty(PRIVILEGED_STAGES:Mclean)
_MAKE_CLEAN_AS_ROOT=yes
.endif
.PHONY: clean-depends
clean-depends:
${RUN} \
${_DEPENDS_WALK_CMD} ${PKGPATH} | \
while read dir; do \
cd ${.CURDIR}/../../$$dir && \
${RECURSIVE_MAKE} ${MAKEFLAGS} CLEANDEPENDS=no clean; \
done
.PHONY: pre-clean
.if !target(pre-clean)
pre-clean:
@${DO_NADA}
.endif
.PHONY: post-clean
.if !target(post-clean)
post-clean:
@${DO_NADA}
.endif
.PHONY: do-clean
.if !target(do-clean)
. if !empty(_MAKE_CLEAN_AS_ROOT:M[Yy][Ee][Ss])
do-clean: su-target
. else
do-clean: su-do-clean
. endif
.endif
su-do-clean: .PHONY
@${PHASE_MSG} "Cleaning for ${PKGNAME}"
${RUN} \
if ${TEST} -d ${WRKDIR}; then \
if ${TEST} -w ${WRKDIR}; then \
${RM} -fr ${WRKDIR}; \
else \
${STEP_MSG} ${WRKDIR}" not writable, skipping"; \
fi; \
fi
.if defined(WRKOBJDIR)
${RUN} \
${RMDIR} ${BUILD_DIR} 2>/dev/null || ${TRUE}; \
${RMDIR} ${BUILD_DIR:H} 2>/dev/null || ${TRUE}; \
${RM} -f ${WRKDIR_BASENAME} 2>/dev/null || ${TRUE}
.endif
_CLEAN_TARGETS+= pre-clean
.if empty(CLEANDEPENDS:M[nN][oO])
_CLEAN_TARGETS+= clean-depends
.endif
_CLEAN_TARGETS+= do-clean
_CLEAN_TARGETS+= post-clean
.PHONY: clean
.if !target(clean)
clean: ${_CLEAN_TARGETS}
.endif
.PHONY: cleandir
cleandir: clean

147
mk/bsd.pkg.debug.mk Normal file
View File

@@ -0,0 +1,147 @@
# $NetBSD: bsd.pkg.debug.mk,v 1.21 2008/02/07 21:36:13 rillig Exp $
#
# Public targets:
#
# debug:
# outputs the values of some commonly used variables and the
# contents of some files which are useful for tracking bugs,
# especially for packages that use the GNU autotools.
#
PRINTF?= printf
# Note: In the many cases where ${x} is used, the quoting is left out
# intentionally, since x is an element of a list of shell words, and
# passing such a shell word to the shell should still result in one
# word. That way, no extra level of quoting is introduced.
#
# The only exception is the "<" character in CONFIGURE_ARGS, where it
# is often used to redirect the input coming from another source. That
# character has to be quoted.
.PHONY: \
debug \
_show-dbginfo-file-versions \
_show-dbginfo-tools \
_show-dbginfo-configure \
_show-dbginfo-config.status \
_show-dbginfo-config.h \
_show-dbginfo-build \
_show-dbginfo-install \
_show-dbginfo-plist-subst
debug: \
_show-dbginfo-file-versions \
_show-dbginfo-tools \
_show-dbginfo-configure \
_show-dbginfo-config.status \
_show-dbginfo-config.h \
_show-dbginfo-build \
_show-dbginfo-install \
_show-dbginfo-plist-subst
_show-dbginfo-file-versions:
@${PRINTF} "File versions:\\n"
${RUN} \
sedexpr='s,^.*\([$$]NetBSD:[^$$]*\$$\).*,\1,p'; \
${FIND} * -type f -print \
| while read fname; do \
ident=`${SED} -n \
-e 's,^.*\\([$$]NetBSD:[^$$]*\\$$\\).*,\\1,p' \
-e 's,^.*\\([$$]Id:[^$$]*\\$$\\).*,\\1,p' \
"$${fname}" | ${SED} 1q` || continue; \
case $${ident} in \
*?*) ${PRINTF} "\\t%s: %s\\n" "$${fname}" "$${ident}";; \
esac; \
done
@${PRINTF} "\\n"
_show-dbginfo-tools:
@${PRINTF} "TOOLS:\\n"
@${USE_TOOLS:C/:.*//:O:u:@t@${_TOOLS_VARNAME.${t}:D${PRINTF} "\\t%s=%s\\n" ${_TOOLS_VARNAME.${t}} ${${_TOOLS_VARNAME.${t}}:Q};}@}
@${PRINTF} "\\n"
_show-dbginfo-configure:
@${PRINTF} "CONFIGURE_DIRS:\\n"; ${CONFIGURE_DIRS:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "CONFIGURE_ENV (sorted alphabetically):\\n"; ${CONFIGURE_ENV:O:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "CONFIGURE_SCRIPT:\\n\\t%s\\n" ${CONFIGURE_SCRIPT}
@${PRINTF} "\\n"
@${PRINTF} "CONFIGURE_ARGS:\\n"; ${CONFIGURE_ARGS:@x@${PRINTF} "\\t%s\\n" ${x:S,<,\<,};@}
@${PRINTF} "\\n"
_show-dbginfo-config.status:
.if !empty(CONFIGURE_DIRS:M*)
${RUN} \
if ${TEST} -d ${WRKSRC:Q}; then cd ${WRKSRC:Q}; \
for cs in ${CONFIGURE_DIRS:=/config.status}; do \
if ${TEST} ! -f "$${cs}"; then continue; fi; \
${PRINTF} "%s:\\n" "$${cs}"; \
${SED} -n -e 's,|#_!!_#|,,g' \
-e '/s,^\\(\[ #\]\*\\)/d' \
-e 's:^s,@\([^@]*\)@,\(.*\),;t t$$: \1=\2:p' \
-e 's:^s&@\([^@]*\)@&\(.*\)&;t t$$: \1=\2:p' \
-e 's:^s,@\([^@]*\)@,\(.*\),g$$: \1=\2:p' \
-e 's:^s%@\([^@]*\)@%\(.*\)%g$$: \1=\2:p' \
-e 's:^s&@\([^@]*\)@&\(.*\)&g$$: \1=\2:p' \
-e 's:^\(s[^[:alnum:]].*\): &:p' \
-e '/:\[FHLC\]/q' \
"$${cs}" \
| ${SORT}; \
${PRINTF} "\\n"; \
done; fi
.else
@${DO_NADA}
.endif
_show-dbginfo-config.h:
.if !empty(CONFIGURE_DIRS:M*)
${RUN} \
[ -d ${WRKSRC} ] || exit 0; \
print_config_h() { \
printf "%s:\\n" "`pwd`/$$1"; \
awk '/^#define / { print "\t"$$0; } /^\/\* #undef / { print "\t" $$2 " " $$3; }' < "$$1"; \
printf "\\n"; \
}; \
for cdir in ${CONFIGURE_DIRS}; do \
cd ${WRKSRC}; [ -d "$$cdir" ] || continue; cd "$$cdir"; \
[ ! -f config.h ] || { print_config_h config.h; continue; }; \
[ ! -f config.status ] || { \
: "autoconf 2.59"; \
chs=`sed -n 's,^config_headers="\([^:]*\).*".*,\1,p' config.status || true`; \
: "autoconf 2.13"; \
[ "$$chs" ] || chs=`sed -n 's,^ CONFIG_HEADERS="\([^:"]*\).*,\1,p' config.status || true`; \
done=no; \
for ch in $$chs; do print_config_h "$$ch"; done=yes; done; \
[ $$done = no ] || continue; \
}; \
printf "WARNING: No config header found in `pwd`.\\n\\n"; \
done
.else
@${DO_NADA}
.endif
_show-dbginfo-build:
@${PRINTF} "PKGSRC_MAKE_ENV (sorted alphabetically):\\n"; ${PKGSRC_MAKE_ENV:O:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "BUILD_DIRS:\\n"; ${BUILD_DIRS:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "MAKE_ENV (sorted alphabetically):\\n"; ${MAKE_ENV:O:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "MAKE_PROGRAM:\\n\\t%s\\n" ${MAKE_PROGRAM:Q}
@${PRINTF} "\\n"
@${PRINTF} "MAKE_FLAGS:\\n"; ${MAKE_FLAGS:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "BUILD_MAKE_FLAGS:\\n"; ${BUILD_MAKE_FLAGS:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
_show-dbginfo-install:
@${PRINTF} "INSTALL_DIRS:\\n"; ${INSTALL_DIRS:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
@${PRINTF} "INSTALL_MAKE_FLAGS:\\n"; ${INSTALL_MAKE_FLAGS:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"
_show-dbginfo-plist-subst:
@${PRINTF} "PLIST_SUBST (sorted alphabetically):\\n"; ${PLIST_SUBST:O:@x@${PRINTF} "\\t%s\\n" ${x};@}
@${PRINTF} "\\n"

62
mk/bsd.pkg.error.mk Normal file
View File

@@ -0,0 +1,62 @@
# $NetBSD: bsd.pkg.error.mk,v 1.4 2008/02/07 21:36:13 rillig Exp $
ERROR_DIR= ${WRKDIR}/.error
WARNING_DIR= ${WRKDIR}/.warning
_ERROR_DONE_DIR= ${WRKDIR}/.error-done
_WARNING_DONE_DIR= ${WRKDIR}/.warning-done
# Macros for outputting delayed error and warning messages that are
# picked up by the error-check target and can be used in place of
# ${ECHO}. We output to files that are named without leading dots.
#
DELAYED_ERROR_MSG?= ${ECHO} >> ${ERROR_DIR}/${.TARGET:T:C/^[.]*//:Q}
DELAYED_WARNING_MSG?= ${ECHO} >> ${WARNING_DIR}/${.TARGET:T:C/^[.]*//:Q}
makedirs: ${ERROR_DIR} ${WARNING_DIR} ${_ERROR_DONE_DIR} ${_WARNING_DONE_DIR}
${ERROR_DIR} ${WARNING_DIR} ${_ERROR_DONE_DIR} ${_WARNING_DONE_DIR}:
${RUN}${MKDIR} ${.TARGET}
.PHONY: error-check
######################################################################
### error-check (PRIVATE)
######################################################################
### error-check is a macro target that will peek in the warning and
### error directories to check for the presence of any files. If they
### exist and are non-empty, then they are assumed to be message files
### and will be outputted then removed. If they are from the error
### directory, then the target will fail.
###
error-check: .USE
${RUN} \
${RM} -f ${WARNING_DIR}/*.tmp; \
${TEST} -d ${WARNING_DIR} || exit 0; \
cd ${WARNING_DIR}; \
for file in ./*; do \
${TEST} "$$file" != "./*" || exit 0; \
break; \
done; \
${CAT} ./* | ${WARNING_CAT}; \
${MV} -f ./* ${_WARNING_DONE_DIR}
${RUN} \
${RM} -f ${ERROR_DIR}/*.tmp; \
${TEST} -d ${ERROR_DIR} || exit 0; \
cd ${ERROR_DIR}; \
for file in ./*; do \
${TEST} "$$file" != "./*" || exit 0; \
break; \
done; \
${CAT} * | ${ERROR_CAT}; \
if ${_NONZERO_FILESIZE_P} ./*; then \
${MV} -f ./* ${_ERROR_DONE_DIR}; \
exit 1; \
fi
######################################################################
### error-clean (PRIVATE)
######################################################################
### error-clean removes the error and warning directory and files.
###
error-clean:
${RUN}${RM} -fr ${ERROR_DIR} ${WARNING_DIR}

818
mk/bsd.pkg.mk Normal file
View File

@@ -0,0 +1,818 @@
# $NetBSD: bsd.pkg.mk,v 1.1992 2013/06/05 08:19:57 tron Exp $
#
# This file is in the public domain.
#
# Please see the pkgsrc/doc/guide manual for details on the
# variables used in this make file template.
#
# Default sequence for "all" is:
#
# bootstrap-depends
# fetch
# checksum
# depends
# tools
# extract
# patch
# wrapper
# configure
# build
#
.include "misc/common.mk"
############################################################################
# Transform package Makefile variables and set defaults
# This is the early set used directly or indirectly in
# the phase variables.
############################################################################
##### PKGBASE, PKGNAME[_NOREV], PKGVERSION
PKGBASE?= ${PKGNAME:C/-[^-]*$//}
PKGVERSION?= ${PKGNAME:C/^.*-//}
.if defined(PKGREVISION) && !empty(PKGREVISION) && (${PKGREVISION} != "0")
. if defined(PKGNAME)
PKGNAME_NOREV:= ${PKGNAME}
PKGNAME:= ${PKGNAME}nb${PKGREVISION}
. else
PKGNAME?= ${DISTNAME}nb${PKGREVISION}
PKGNAME_NOREV= ${DISTNAME}
. endif
.else
PKGNAME?= ${DISTNAME}
PKGNAME_NOREV= ${PKGNAME}
.endif
PKGVERSION_NOREV= ${PKGNAME_NOREV:C/^.*-//}
# Fail-safe in the case of circular dependencies
.if defined(_PKGSRC_DEPS) && defined(PKGNAME) && !empty(_PKGSRC_DEPS:M${PKGNAME})
PKG_FAIL_REASON+= "Circular dependency detected"
.endif
####
############################################################################
# Allow various phases to define the default variables
############################################################################
.if defined(EMUL_PLATFORMS) && !empty(EMUL_PLATFORMS)
. include "emulator/emulator.mk"
.endif
.include "features/features.mk"
.include "pkgformat/bsd.pkgformat-vars.mk"
.include "check/bsd.check-vars.mk"
.include "depends/bsd.depends-vars.mk"
.include "fetch/bsd.fetch-vars.mk"
.include "checksum/bsd.checksum-vars.mk"
.include "extract/bsd.extract-vars.mk"
.include "patch/bsd.patch-vars.mk"
.include "configure/bsd.configure-vars.mk"
.include "build/bsd.build-vars.mk"
.include "install/bsd.install-vars.mk"
.include "bsd.pkg.error.mk"
.include "bsd.hacks.mk"
############################################################################
# Transform package Makefile variables and set defaults
############################################################################
MKCRYPTO?= YES # build crypto packages by default
##### Others
BUILD_DEPENDS?= # empty
COMMENT?= (no description)
DEPENDS?= # empty
DESCR_SRC?= ${PKGDIR}/DESCR
INTERACTIVE_STAGE?= none
.if defined(OWNER)
MAINTAINER=${OWNER}
.else
MAINTAINER?= pkgsrc-users@NetBSD.org
.endif
PKGWILDCARD?= ${PKGBASE}-[0-9]*
SVR4_PKGNAME?= ${PKGNAME}
TOOL_DEPENDS?= # empty
WRKSRC?= ${WRKDIR}/${DISTNAME}
# Override for SU_CMD user check
_IS_ROOT_CMD?= ${TEST} `${ID} -u` = `${ID} -u ${_SU_ROOT_USER}`
_SU_ROOT_USER?= ${ROOT_USER}
REAL_ROOT_USER?= ${ROOT_USER}
REAL_ROOT_GROUP?= ${ROOT_GROUP}
.if (defined(INSTALL_UNSTRIPPED) && !empty(INSTALL_UNSTRIPPED:M[yY][eE][sS])) || defined(DEBUG_FLAGS)
_INSTALL_UNSTRIPPED= # set (flag used by platform/*.mk)
.endif
##### Transform USE_* into dependencies
.include "bsd.pkg.use.mk"
############################################################################
# Sanity checks
############################################################################
.if defined(BUILDLINK_DEPTH) || defined(BUILDLINK_PACKAGES) || \
defined(BUILDLINK_DEPENDS) || defined(BUILDLINK_ORDER)
PKG_FAIL_REASON+= "Out-dated buildlink3.mk detected, please update"
.endif
# PKG_INSTALLATION_TYPE can only be one of two values: "pkgviews" or
# "overwrite".
.if (${PKG_INSTALLATION_TYPE} != "pkgviews") && \
(${PKG_INSTALLATION_TYPE} != "overwrite")
PKG_FAIL_REASON+= "PKG_INSTALLATION_TYPE must be \`\`pkgviews'' or \`\`overwrite''."
.endif
.if empty(PKG_INSTALLATION_TYPES:M${PKG_INSTALLATION_TYPE})
PKG_FAIL_REASON+= "This package doesn't support PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE}."
.endif
.if !defined(CATEGORIES) || !defined(DISTNAME)
PKG_FAIL_REASON+='CATEGORIES and DISTNAME are mandatory.'
.endif
.if defined(PKG_PATH)
PKG_FAIL_REASON+='Please unset PKG_PATH before doing pkgsrc work!'
.endif
# Allow variables to be set on a per-OS basis
OPSYSVARS+= CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS
.for _var_ in ${OPSYSVARS:O}
. if defined(${_var_}.${OPSYS})
${_var_}+= ${${_var_}.${OPSYS}}
. elif defined(${_var_}.*)
${_var_}+= ${${_var_}.*}
. endif
.endfor
CPPFLAGS+= ${CPP_PRECOMP_FLAGS}
# To sanitise environment set PKGSRC_SETENV=${SETENV} -i
# This will however cause build failures (e.g. "www/firefox"). Settings
# like "ALLOW_VULNERABLE_PACKAGES" will also not be correctly passed
# to dependence builds.
PKGSRC_SETENV?= ${SETENV}
ALL_ENV+= CC=${CC:Q}
ALL_ENV+= CFLAGS=${CFLAGS:M*:Q}
ALL_ENV+= CPPFLAGS=${CPPFLAGS:M*:Q}
ALL_ENV+= CXX=${CXX:Q}
ALL_ENV+= CXXFLAGS=${CXXFLAGS:M*:Q}
ALL_ENV+= COMPILER_RPATH_FLAG=${COMPILER_RPATH_FLAG:Q}
ALL_ENV+= F77=${FC:Q}
ALL_ENV+= FC=${FC:Q}
ALL_ENV+= FFLAGS=${FFLAGS:M*:Q}
ALL_ENV+= LANG=C
ALL_ENV+= LC_ALL=C
ALL_ENV+= LC_COLLATE=C
ALL_ENV+= LC_CTYPE=C
ALL_ENV+= LC_MESSAGES=C
ALL_ENV+= LC_MONETARY=C
ALL_ENV+= LC_NUMERIC=C
ALL_ENV+= LC_TIME=C
ALL_ENV+= LDFLAGS=${LDFLAGS:M*:Q}
ALL_ENV+= LINKER_RPATH_FLAG=${LINKER_RPATH_FLAG:Q}
ALL_ENV+= PATH=${PATH:Q}:${LOCALBASE}/bin:${X11BASE}/bin
ALL_ENV+= PREFIX=${PREFIX}
# This variable can be added to MAKE_ENV to ease installation of packages
# that use BSD-style Makefiles.
BSD_MAKE_ENV= BINOWN=${BINOWN} BINGRP=${BINGRP}
BSD_MAKE_ENV+= GAMEOWN=${GAMEOWN} GAMEGRP=${GAMEGRP}
BSD_MAKE_ENV+= MANOWN=${MANOWN} MANGRP=${MANGRP}
BSD_MAKE_ENV+= SHAREOWN=${SHAREOWN} SHAREGRP=${SHAREGRP}
BSD_MAKE_ENV+= DOCOWN=${DOCOWN} DOCGRP=${DOCGRP}
BSD_MAKE_ENV+= BINMODE=${BINMODE} NONBINMODE=${NONBINMODE}
BSD_MAKE_ENV+= BINDIR=${PREFIX}/bin
BSD_MAKE_ENV+= INCSDIR=${PREFIX}/include
BSD_MAKE_ENV+= LIBDIR=${PREFIX}/lib
BSD_MAKE_ENV+= MANDIR=${PREFIX}/${PKGMANDIR}
BSD_MAKE_ENV+= STRIPFLAG=${_STRIPFLAG_INSTALL:Q}
BSD_MAKE_ENV+= MANINSTALL=${MANINSTALL:Q}
BSD_MAKE_ENV+= MKCATPAGES=${MKCATPAGES:Q}
BSD_MAKE_ENV+= MKHTML=no
_BUILD_DEFS= ${BUILD_DEFS}
_BUILD_DEFS+= LOCALBASE
_BUILD_DEFS+= PKGGNUDIR
_BUILD_DEFS+= PKGINFODIR
_BUILD_DEFS+= PKGMANDIR
_BUILD_DEFS+= _USE_DESTDIR
# Store the result in the +BUILD_INFO file so we can query for the build
# options using "pkg_info -Q PKG_OPTIONS <pkg>".
#
.if defined(PKG_SUPPORTED_OPTIONS) && defined(PKG_OPTIONS)
_BUILD_DEFS+= PKG_OPTIONS
.endif
.if empty(DEPOT_SUBDIR)
PKG_FAIL_REASON+= "DEPOT_SUBDIR may not be empty."
.endif
# Store the build options for multi-packages, i.e. packages that can
# be built with multiple versions of Apache, Python, Ruby, PHP etc.
#
.if defined(MULTI)
_BUILD_DEFS+= MULTI
.endif
# ZERO_FILESIZE_P exits with a successful return code if the given file
# has zero length.
# NONZERO_FILESIZE_P exits with a successful return code if the given file
# has nonzero length.
#
_ZERO_FILESIZE_P= ${AWK} 'END { exit (NR > 0) ? 1 : 0; }'
_NONZERO_FILESIZE_P= ${AWK} 'END { exit (NR > 0) ? 0 : 1; }'
# Automatically increase process limit where necessary for building.
_ULIMIT_CMD= ${UNLIMIT_RESOURCES:@_lim_@${ULIMIT_CMD_${_lim_}};@}
_NULL_COOKIE= ${WRKDIR}/.null
# Miscellaneous overridable commands:
SHCOMMENT?= ${ECHO_MSG} >/dev/null '***'
LIBABISUFFIX?=
TOUCH_FLAGS?= -f
# A few aliases for *-install targets
INSTALL= ${TOOLS_INSTALL} # XXX override sys.mk
INSTALL_PROGRAM?= \
${INSTALL} ${COPY} ${_STRIPFLAG_INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
INSTALL_GAME?= \
${INSTALL} ${COPY} ${_STRIPFLAG_INSTALL} -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEMODE}
INSTALL_SCRIPT?= \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
INSTALL_LIB?= \
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
INSTALL_DATA?= \
${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
INSTALL_GAME_DATA?= \
${INSTALL} ${COPY} -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEDATAMODE}
INSTALL_MAN?= \
${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
INSTALL_PROGRAM_DIR?= \
${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m ${PKGDIRMODE}
INSTALL_GAME_DIR?= \
${INSTALL} -d -o ${GAMEOWN} -g ${GAMEGRP} -m ${GAMEDIRMODE}
INSTALL_SCRIPT_DIR?= \
${INSTALL_PROGRAM_DIR}
INSTALL_LIB_DIR?= \
${INSTALL_PROGRAM_DIR}
INSTALL_DATA_DIR?= \
${INSTALL} -d -o ${SHAREOWN} -g ${SHAREGRP} -m ${PKGDIRMODE}
INSTALL_MAN_DIR?= \
${INSTALL} -d -o ${MANOWN} -g ${MANGRP} -m ${PKGDIRMODE}
INSTALL_MACROS= BSD_INSTALL_PROGRAM=${INSTALL_PROGRAM:Q} \
BSD_INSTALL_SCRIPT=${INSTALL_SCRIPT:Q} \
BSD_INSTALL_LIB=${INSTALL_LIB:Q} \
BSD_INSTALL_DATA=${INSTALL_DATA:Q} \
BSD_INSTALL_MAN=${INSTALL_MAN:Q} \
BSD_INSTALL=${INSTALL:Q} \
BSD_INSTALL_PROGRAM_DIR=${INSTALL_PROGRAM_DIR:Q} \
BSD_INSTALL_SCRIPT_DIR=${INSTALL_SCRIPT_DIR:Q} \
BSD_INSTALL_LIB_DIR=${INSTALL_LIB_DIR:Q} \
BSD_INSTALL_DATA_DIR=${INSTALL_DATA_DIR:Q} \
BSD_INSTALL_MAN_DIR=${INSTALL_MAN_DIR:Q} \
BSD_INSTALL_GAME=${INSTALL_GAME:Q} \
BSD_INSTALL_GAME_DATA=${INSTALL_GAME_DATA:Q} \
BSD_INSTALL_GAME_DIR=${INSTALL_GAME_DIR:Q}
MAKE_ENV+= ${INSTALL_MACROS:M*}
SCRIPTS_ENV+= ${INSTALL_MACROS:M*}
# If pkgsrc is supposed to ensure that tests are run before installation
# of the package, then the build targets should be "build test", otherwise
# just "build" suffices.
#
.if !empty(PKGSRC_RUN_TEST:M[yY][eE][sS])
_PKGSRC_BUILD_TARGETS= build test
.else
_PKGSRC_BUILD_TARGETS= build
.endif
# OVERRIDE_DIRDEPTH represents the common directory depth under
# ${WRKSRC} up to which we find the files that need to be
# overridden. By default, we search two levels down, i.e.,
# */*/file.
#
OVERRIDE_DIRDEPTH?= 2
# Handle alternatives
#
.include "alternatives.mk"
# Define SMART_MESSAGES in /etc/mk.conf for messages giving the tree
# of dependencies for building, and the current target.
_PKGSRC_IN?= ===${SMART_MESSAGES:D> ${.TARGET} [${PKGNAME}${_PKGSRC_DEPS}] ===}
# Used to print all the '===>' style prompts - override this to turn them off.
ECHO_MSG?= ${ECHO}
PHASE_MSG?= ${ECHO_MSG} ${_PKGSRC_IN:Q}\>
STEP_MSG?= ${ECHO_MSG} "=>"
INFO_MSG?= ${ECHO_MSG} "INFO:"
WARNING_MSG?= ${ECHO_MSG} 1>&2 "WARNING:"
ERROR_MSG?= ${ECHO_MSG} 1>&2 "ERROR:"
FAIL_MSG?= ${FAIL} ${ERROR_MSG}
WARNING_CAT?= ${SED} -e "s|^|WARNING: |" 1>&2
ERROR_CAT?= ${SED} -e "s|^|ERROR: |" 1>&2
# How to do nothing. Override if you, for some strange reason, would rather
# do something.
DO_NADA?= ${TRUE}
# the FAIL command executes its arguments and then exits with a non-zero
# status.
FAIL?= ${SH} ${PKGSRCDIR}/mk/scripts/fail
#
# Config file related settings - see doc/pkgsrc.txt
#
PKG_SYSCONFVAR?= ${PKGBASE}
PKG_SYSCONFSUBDIR?= # empty
.if ${PKG_INSTALLATION_TYPE} == "overwrite"
PKG_SYSCONFDEPOTBASE= # empty
PKG_SYSCONFBASEDIR= ${PKG_SYSCONFBASE}
.else
. if !empty(PKG_SYSCONFBASE:M${PREFIX}) || \
!empty(PKG_SYSCONFBASE:M${PREFIX}/*)
PKG_SYSCONFDEPOTBASE= # empty
PKG_SYSCONFBASEDIR= ${PKG_SYSCONFBASE}
. else
PKG_SYSCONFDEPOTBASE= ${PKG_SYSCONFBASE}/${DEPOT_SUBDIR}
PKG_SYSCONFBASEDIR= ${PKG_SYSCONFDEPOTBASE}/${PKGNAME}
. endif
.endif
.if empty(PKG_SYSCONFSUBDIR)
DFLT_PKG_SYSCONFDIR:= ${PKG_SYSCONFBASEDIR}
.else
DFLT_PKG_SYSCONFDIR:= ${PKG_SYSCONFBASEDIR}/${PKG_SYSCONFSUBDIR}
.endif
PKG_SYSCONFDIR= ${DFLT_PKG_SYSCONFDIR}
.if defined(PKG_SYSCONFDIR.${PKG_SYSCONFVAR})
PKG_SYSCONFDIR= ${PKG_SYSCONFDIR.${PKG_SYSCONFVAR}}
PKG_SYSCONFBASEDIR= ${PKG_SYSCONFDIR.${PKG_SYSCONFVAR}}
PKG_SYSCONFDEPOTBASE= # empty
.endif
PKG_SYSCONFDIR_PERMS?= ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 755
ALL_ENV+= PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
_BUILD_DEFS+= PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
# These are all of the tools use by pkgsrc Makefiles. This should
# eventually be split up into lists of tools required by different
# phases of a pkgsrc build.
#
USE_TOOLS+= \
[ awk basename cat chgrp chmod chown cmp cp cut dirname echo \
egrep env false find grep head hostname id install ln ls \
mkdir mv printf pwd rm rmdir sed sh sort \
tail test touch tr true wc xargs
# bsd.wrapper.mk
USE_TOOLS+= expr
# bsd.bulk-pkg.mk uses certain tools
.if defined(BATCH)
USE_TOOLS+= tee tsort
.endif
# scripts/shlib-type
.if ${_OPSYS_SHLIB_TYPE} == "ELF/a.out"
USE_TOOLS+= file
.endif
# INSTALL/DEINSTALL script framework
.include "pkginstall/bsd.pkginstall.mk"
# Locking
.include "internal/locking.mk"
# Tools
.include "tools/bsd.tools.mk"
# Barrier
.include "bsd.pkg.barrier.mk"
# Unprivileged builds
.include "unprivileged.mk"
# If NO_BUILD is defined, default to not needing a compiler.
.if defined(NO_BUILD)
USE_LANGUAGES?= # empty
.endif
# Get the proper dependencies and set the PATH to use the compiler
# named in PKGSRC_COMPILER.
#
.include "compiler.mk"
#Fake up a home directory
WRAPPER_TARGETS+= fake-home
FAKEHOMEDIR= ${WRKDIR}/.home
ALL_ENV+= HOME=${FAKEHOMEDIR}
.PHONY: fake-home
fake-home: ${FAKEHOMEDIR}
${FAKEHOMEDIR}:
${RUN} ${MKDIR} ${.TARGET}
.include "wrapper/bsd.wrapper.mk"
.if defined(ABI_DEPENDS) || defined(BUILD_ABI_DEPENDS)
. if !empty(USE_ABI_DEPENDS:M[yY][eE][sS])
DEPENDS+= ${ABI_DEPENDS}
BUILD_DEPENDS+= ${BUILD_ABI_DEPENDS}
. else
_BUILD_DEFS+= USE_ABI_DEPENDS
. endif
.endif
# Find out the PREFIX of dependencies where the PREFIX is needed at build time.
.if defined(EVAL_PREFIX)
FIND_PREFIX:= ${EVAL_PREFIX}
. include "find-prefix.mk"
.endif
.if !defined(_PATH_ORIG)
_PATH_ORIG:= ${PATH}
MAKEFLAGS+= _PATH_ORIG=${_PATH_ORIG:Q}
.endif
.if !empty(PREPEND_PATH:M*)
# This is very Special. Because PREPEND_PATH is set with += in reverse order,
# this command reverses the order again (since bootstrap bmake doesn't
# yet support the :[-1..1] construct).
_PATH_CMD= \
path=${_PATH_ORIG:Q}; \
for i in ${PREPEND_PATH}; do path="$$i:$$path"; done; \
${ECHO} "$$path"
PATH= ${_PATH_CMD:sh} # DOES NOT use :=, to defer evaluation
.endif
################################################################
# Many ways to disable a package.
#
# Ignore packages that can't be resold if building for a CDROM.
#
# Don't build a package if it's restricted and we don't want to
# get into that.
#
# Don't build any package that utilizes strong cryptography, for
# when the law of the land forbids it.
#
# Don't attempt to build packages against X if we don't have X.
#
# Don't build a package if it's broken.
################################################################
.if ${X11_TYPE} == "xorg"
PKG_FAIL_REASON+= "Support for X11_TYPE=xorg was removed."
PKG_FAIL_REASON+= "Please switch to X11_TYPE=modular."
X11_TYPE:= native
X11BASE:= /usr
.endif
.if !defined(NO_SKIP)
. if (defined(NO_BIN_ON_CDROM) && defined(FOR_CDROM))
PKG_FAIL_REASON+= "${PKGNAME} may not be placed in binary form on a CDROM:" \
" "${NO_BIN_ON_CDROM:Q}
. endif
. if (defined(NO_SRC_ON_CDROM) && defined(FOR_CDROM))
PKG_FAIL_REASON+= "${PKGNAME} may not be placed in source form on a CDROM:" \
" "${NO_SRC_ON_CDROM:Q}
. endif
. if (defined(RESTRICTED) && defined(NO_RESTRICTED))
PKG_FAIL_REASON+= "${PKGNAME} is restricted:" \
" "${RESTRICTED:Q}
. endif
. if !(${MKCRYPTO} == "YES" || ${MKCRYPTO} == yes)
. if defined(CRYPTO)
PKG_FAIL_REASON+= "${PKGNAME} may not be built, because it utilizes strong cryptography"
. endif
. endif
. if defined(USE_X11) && (${X11_TYPE} == "native") && !exists(${X11BASE})
PKG_FAIL_REASON+= "${PKGNAME} uses X11, but ${X11BASE} not found"
. endif
. if defined(BROKEN)
PKG_FAIL_REASON+= "${PKGNAME} is marked as broken:" ${BROKEN:Q}
. endif
.include "license.mk"
# Define __PLATFORM_OK only if the OS matches the pkg's allowed list.
. if defined(ONLY_FOR_PLATFORM) && !empty(ONLY_FOR_PLATFORM)
. for __tmp__ in ${ONLY_FOR_PLATFORM}
. if ${MACHINE_PLATFORM:M${__tmp__}} != ""
__PLATFORM_OK?= yes
. endif # MACHINE_PLATFORM
. endfor # __tmp__
. else # !ONLY_FOR_PLATFORM
__PLATFORM_OK?= yes
. endif # ONLY_FOR_PLATFORM
. for __tmp__ in ${NOT_FOR_PLATFORM}
. if ${MACHINE_PLATFORM:M${__tmp__}} != ""
. undef __PLATFORM_OK
. endif # MACHINE_PLATFORM
. endfor # __tmp__
. if !defined(__PLATFORM_OK)
PKG_FAIL_REASON+= "${PKGNAME} is not available for ${MACHINE_PLATFORM}"
. endif # !__PLATFORM_OK
.endif
# Add these defs to the ones dumped into +BUILD_DEFS
_BUILD_DEFS+= PKGPATH
_BUILD_DEFS+= OPSYS OS_VERSION MACHINE_ARCH MACHINE_GNU_ARCH
_BUILD_DEFS+= ABI
_BUILD_DEFS+= CPPFLAGS CFLAGS FFLAGS LDFLAGS
_BUILD_DEFS+= OBJECT_FMT LICENSE RESTRICTED
_BUILD_DEFS+= NO_SRC_ON_FTP NO_SRC_ON_CDROM
_BUILD_DEFS+= NO_BIN_ON_FTP NO_BIN_ON_CDROM
.if defined(OSVERSION_SPECIFIC)
_BUILD_DEFS+= OSVERSION_SPECIFIC
DEPENDS+= osabi-${OPSYS}-${OS_VERSION}:../../pkgtools/osabi
.endif # OSVERSION_SPECIFIC
.for _pkg_ in ${_BUILTIN_PKGS}
. if defined(USE_BUILTIN.${_pkg_}) && \
!empty(USE_BUILTIN.${_pkg_}:M[yY][eE][sS]) && \
defined(BUILTIN_PKG.${_pkg_}) && !empty(BUILTIN_PKG.${_pkg_})
BUILTIN_PKGS+= ${BUILTIN_PKG.${_pkg_}}
. endif
.endfor
.if defined(BUILTIN_PKGS)
_BUILD_DEFS+= BUILTIN_PKGS
.endif
.if defined(GLIBC_VERSION)
_BUILD_DEFS+= GLIBC_VERSION
.endif # GLIBC_VERSION
.PHONY: all
.if !target(all)
all: ${_PKGSRC_BUILD_TARGETS}
.endif
.PHONY: makedirs
makedirs: ${WRKDIR}
${WRKDIR}:
.if !defined(KEEP_WRKDIR)
. if ${WRKDIR_LOCKTYPE} != "none"
${RUN} ${TEST} -f ${_WRKDIR_LOCKFILE} || ${RM} -fr ${WRKDIR}
. endif
.endif
${RUN} umask 077 && ${MKDIR} ${WRKDIR}
# Create a symlink from ${WRKDIR} to the package directory if
# CREATE_WRKDIR_SYMLINK is "yes".
#
CREATE_WRKDIR_SYMLINK?= no
.if defined(WRKOBJDIR) && !empty(CREATE_WRKDIR_SYMLINK:M[Yy][Ee][Ss])
makedirs: ${.CURDIR}/${WRKDIR_BASENAME}
${.CURDIR}/${WRKDIR_BASENAME}:
. if ${WRKDIR_LOCKTYPE} != "none"
${RUN} ${TEST} -f ${_WRKDIR_LOCKFILE} || ${RM} -f ${.TARGET}
. endif
${RUN} \
if ${LN} -s ${WRKDIR} ${.TARGET} 2>/dev/null; then \
${ECHO_MSG} "${.TARGET:T} -> ${WRKDIR}"; \
fi
.endif
.include "pkgformat/bsd.pkgformat.mk"
.include "depends/bsd.depends.mk"
.include "check/bsd.check.mk"
.include "fetch/bsd.fetch.mk"
.include "checksum/bsd.checksum.mk"
.include "extract/bsd.extract.mk"
.include "patch/bsd.patch.mk"
.include "configure/bsd.configure.mk"
.include "build/bsd.build.mk"
.include "install/bsd.install.mk"
.include "package/bsd.package.mk"
.include "bsd.pkg.clean.mk"
.include "bsd.pkg.update.mk"
# su-target is a macro target that does just-in-time su-to-root before
# reinvoking the make process as root. It acquires root privileges and
# invokes a new make process with the target named "su-${.TARGET}".
#
# MAKEFLAGS.su-${.TARGET}
# The additional flags that are passed to the make process.
#
_ROOT_CMD= cd ${.CURDIR} && \
${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} \
PATH=${_PATH_ORIG:Q}:${SU_CMD_PATH_APPEND:Q} \
${MAKE} ${MAKEFLAGS} _PKGSRC_BARRIER=yes \
PKG_DEBUG_LEVEL=${PKG_DEBUG_LEVEL:Q} \
su-${.TARGET} ${MAKEFLAGS.su-${.TARGET}}
.PHONY: su-target
su-target: .USE
${RUN} \
case ${PRE_CMD.su-${.TARGET}:Q}"" in \
"") ;; \
*) ${PRE_CMD.su-${.TARGET}} ;; \
esac; \
if ${_IS_ROOT_CMD}; then \
${_ROOT_CMD}; \
else \
case ${PRE_ROOT_CMD:Q}"" in \
${TRUE:Q}"") ;; \
*) ${WARNING_MSG} "Running: "${PRE_ROOT_CMD:Q} ;; \
esac; \
${PRE_ROOT_CMD}; \
${STEP_MSG} "Becoming \`\`${_SU_ROOT_USER}'' to make su-${.TARGET} (`${ECHO} ${SU_CMD} | ${AWK} '{ print $$1 }'`)"; \
${SU_CMD} ${_ROOT_CMD:Q}; \
${STEP_MSG} "Dropping \`\`${_SU_ROOT_USER}'' privileges."; \
fi
################################################################
# Some more targets supplied for users' convenience
################################################################
# Run pkglint:
.PHONY: lint
lint:
${RUN} ${LOCALBASE}/bin/pkglint
# List of flags to pass to pkg_add(1) for bin-install:
BIN_INSTALL_FLAGS?= # -v
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
PKG_ARGS_ADD= -W ${LOCALBASE} -w ${DEFAULT_VIEW}
.endif
_BIN_INSTALL_FLAGS= ${BIN_INSTALL_FLAGS}
.if defined(_AUTOMATIC) && !empty(_AUTOMATIC:M[Yy][Ee][Ss])
_BIN_INSTALL_FLAGS+= -A
.endif
_BIN_INSTALL_FLAGS+= ${PKG_ARGS_ADD}
_SHORT_UNAME_R= ${:!${UNAME} -r!:C@\.([0-9]*)[_.-].*@.\1@} # n.n[_.]anything => n.n
.include "install/bin-install.mk"
.PHONY: show-pkgtools-version
.if !target(show-pkgtools-version)
show-pkgtools-version:
@${ECHO} ${PKGTOOLS_VERSION}
.endif
# convenience target, to display make variables from command line
# i.e. "make show-var VARNAME=var", will print var's value
#
# See also:
# show-vars, show-subdir-var
#
.PHONY: show-var
show-var:
@${ECHO} ${${VARNAME}:Q}
# enhanced version of target above, to display multiple variables
.PHONY: show-vars
show-vars:
.for VARNAME in ${VARNAMES}
@${ECHO} ${${VARNAME}:Q}
.endfor
# displays multiple variables as shell expressions
# VARS is space separated list of VARNAME:shellvarname
.PHONY: show-vars-eval
show-vars-eval:
.for var in ${VARS}
@${ECHO} ${var:C/^.*://}="${${var:C/:.*$//}:Q}"
.endfor
LICENSE_FILE?= ${PKGSRCDIR}/licenses/${LICENSE}
.if !target(show-license)
show-license show-licence: .PHONY
@license=${LICENSE:Q}; \
license_file=${LICENSE_FILE:Q}; \
pager=${PAGER:Q}; \
case "$$pager" in "") pager=${CAT:Q};; esac; \
case "$$license" in "") exit 0;; esac; \
if ${TEST} -f "$$license_file"; then \
$$pager "$$license_file"; \
else \
${ECHO} "Generic $$license information not available"; \
${ECHO} "See the package description (pkg_info -d ${PKGNAME}) for more information."; \
fi
.endif
# This target is defined in bsd.options.mk for packages that use
# the options framework.
.if !target(show-options)
.PHONY: show-options
show-options:
@${ECHO} This package does not use the options framework.
.endif
# Depend is generally meaningless for arbitrary packages, but if someone wants
# one they can override this. This is just to catch people who've gotten into
# the habit of typing `${MAKE} depend all install' as a matter of course.
#
.PHONY: depend
.if !target(depend)
depend:
.endif
# Same goes for tags
.PHONY: tags
.if !target(tags)
tags:
.endif
.include "plist/bsd.plist.mk"
.include "bsd.utils.mk"
.include "subst.mk"
#
# For bulk build targets (bulk-install, bulk-package), the
# BATCH variable must be set in /etc/mk.conf:
#
.if defined(BATCH)
. include "bulk/bsd.bulk-pkg.mk"
.endif
# README generation code.
.include "bsd.pkg.readme.mk"
# Create a PKG_ERROR_HANDLER shell command for each class listed in
# PKG_ERROR_CLASSES. The error handler is meant to be invoked within
# a make target.
#
.for _class_ in ${PKG_ERROR_CLASSES}
PKG_ERROR_HANDLER.${_class_}?= { \
ec=$$?; \
for str in ${PKG_ERROR_MSG.${_class_}}; do \
${PHASE_MSG} "$$str"; \
done; \
exit $$ec; \
}
.endfor
# Cache variables listed in MAKEVARS in a phase-specific "makevars.mk"
# file. These variables are effectively passed to sub-make processes
# that are invoked on the same Makefile.
#
.for _phase_ in ${_ALL_PHASES}
${_MAKEVARS_MK.${_phase_}}: ${WRKDIR}
${RUN}${RM} -f ${.TARGET}.tmp
. for _var_ in ${MAKEVARS:O:u}
. if defined(${_var_})
${RUN} \
${ECHO} ${_var_}"= "${${_var_}:Q} >> ${.TARGET}.tmp
. endif
. endfor
${RUN} \
if ${TEST} -f ${.TARGET}.tmp; then \
( ${ECHO} ".if !defined(_MAKEVARS_MK)"; \
${ECHO} "_MAKEVARS_MK= defined"; \
${ECHO} ""; \
${CAT} ${.TARGET}.tmp; \
${ECHO} ""; \
${ECHO} ".endif # _MAKEVARS_MK"; \
) > ${.TARGET}; \
${RM} -f ${.TARGET}.tmp; \
fi
${RUN}${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
.endfor
.if make(pbulk-index) || make(pbulk-index-item) || make(pbulk-save-wrkdir)
.include "pbulk/pbulk-index.mk"
.endif
.if defined(_OPSYS_REQUIRE_UAC_MANIFEST) && !empty(_OPSYS_REQUIRE_UAC_MANIFEST:M[Yy][Ee][Ss])
. if defined(UAC_REQD_EXECS) && !empty(UAC_REQD_EXECS)
.include "misc/uac-manifest.mk"
. endif
.endif
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
. include "misc/developer.mk"
.endif
.include "misc/show.mk"
.if make(debug)
. include "bsd.pkg.debug.mk"
.endif
.include "misc/warnings.mk"
.if make(import)
.include "misc/import.mk"
.endif
.include "misc/can-be-built-here.mk"

344
mk/bsd.pkg.readme.mk Normal file
View File

@@ -0,0 +1,344 @@
# $NetBSD: bsd.pkg.readme.mk,v 1.26 2013/05/09 23:37:25 riastradh Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and encapsulates the
# code to produce README.html files in each package directory.
#
# The following are the "public" targets provided by this module.
#
# readme This target generates a README.html file suitable
# for being served via FTP.
#
# cdrom-readme This target generates a README.html file suitable
# for being served from a mounted CD-ROM.
#
# The following are the user-settable variables that may be defined in
# /etc/mk.conf.
#
# FTP_PKG_URL_HOST is the host portion of the URL to embed in each
# README.html file to be served via FTP, and defaults to
# "ftp://ftp.NetBSD.org".
#
# FTP_PKG_URL_DIR is the directory portion of the URL to embed in each
# README.html file to be served via FTP, and defaults to
# "/pub/pkgsrc/packages".
#
# CDROM_PKG_URL_HOST is the host portion of the URL to embed in each
# README.html file to be served from a mounted CD-ROM, and defaults
# to "file://localhost".
#
# CDROM_PKG_URL_DIR is the directory portion of the URL to embed in each
# README.html file to be served from a mounted CD-ROM, and defaults
# to "/usr/pkgsrc/packages".
#
# Set to "html" by the README.html target to generate HTML code,
# or to "svr4" to print SVR4 (Solaris, ...) short package names, from
# SVR4_PKGNAME variable.
# This variable is passed down via build-depends-list and run-depends-list
PACKAGE_NAME_TYPE?= name
_HTML_PKGLINK= <a href="../../${PKGPATH}/README.html">${PKGNAME}</a>
.PHONY: package-name
.if !target(package-name)
package-name:
. if (${PACKAGE_NAME_TYPE} == "html")
@${ECHO} ${_HTML_PKGLINK:Q}
. elif (${PACKAGE_NAME_TYPE} == "svr4")
@${ECHO} ${SVR4_PKGNAME}
. else
@${ECHO} ${PKGNAME}
. endif # PACKAGE_NAME_TYPE
.endif # !target(package-name)
.PHONY: make-readme-html-help
.if !target(make-readme-html-help)
make-readme-html-help:
@${ECHO} '${PKGNAME}</a>: <TD>'${COMMENT:Q}
.endif # !target(make-readme-html-help)
# Show (non-recursively) all the packages this package depends on.
# If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible)
PACKAGE_DEPENDS_WITH_PATTERNS?=true
.PHONY: run-depends-list
.if !target(run-depends-list)
run-depends-list:
. for dep in ${DEPENDS}
@pkg="${dep:C/:.*//}"; \
dir="${dep:C/[^:]*://}"; \
cd ${.CURDIR}; \
if ${PACKAGE_DEPENDS_WITH_PATTERNS}; then \
${ECHO} "$$pkg"; \
else \
if cd $$dir 2>/dev/null; then \
${RECURSIVE_MAKE} ${MAKEFLAGS} package-name PACKAGE_NAME_TYPE=${PACKAGE_NAME_TYPE}; \
else \
${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \
fi; \
fi
. endfor
.endif # target(run-depends-list)
.PHONY: build-depends-list
.if !target(build-depends-list)
build-depends-list:
@${_DEPENDS_WALK_CMD} ${PKGPATH} | \
while read dir; do \
( cd ../../$$dir && ${RECURSIVE_MAKE} ${MAKEFLAGS} package-name) \
done
.endif
# If PACKAGES is set to the default (../../pkgsrc/packages), the current
# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
# The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
# the target used to generate the README.html file.
.PHONY: binpkg-list
.if !target(binpkg-list)
binpkg-list:
@if ${TEST} -d ${PACKAGES}; then \
cd ${PACKAGES}; \
case ${.CURDIR} in \
*/pkgsrc/packages) \
for pkg in ${PKGREPOSITORYSUBDIR}/${PKGWILDCARD}${PKG_SUFX} ; \
do \
if [ -f "$$pkg" ] ; then \
pkgname=`${ECHO} $$pkg | ${SED} 's@.*/@@'`; \
${ECHO} "<TR><TD>${MACHINE_ARCH}:<TD><a href=\"${PKG_URL}/$$pkg\">$$pkgname</a><TD>(${OPSYS} ${OS_VERSION})"; \
fi ; \
done ; \
;; \
*) \
cd ${PACKAGES}/../..; \
for i in [1-9].*/*; do \
if cd ${PACKAGES}/../../$$i/${PKGREPOSITORYSUBDIR} 2>/dev/null; then \
for j in ${PKGWILDCARD}${PKG_SUFX}; \
do \
if [ -f "$$j" ]; then \
${ECHO} $$i/$$j;\
fi; \
done; \
fi; \
done | ${AWK} -F/ ' \
{ \
release = $$1; \
arch = $$2; \
pkg = $$3; \
gsub("\\.tgz","", pkg); \
if (arch != "m68k" && arch != "mipsel") { \
if (arch in urls) \
urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a>, " urls[arch]; \
else \
urls[arch "/" pkg "/" release] = "<a href=\"${PKG_URL}/" release "/" arch "/${PKGREPOSITORYSUBDIR}/" pkg "${PKG_SUFX}\">" pkg "</a> "; \
} \
} \
END { \
for (av in urls) { \
split(av, ava, "/"); \
arch=ava[1]; \
pkg=ava[2]; \
release=ava[3]; \
print "<TR><TD>" arch ":<TD>" urls[av] "<TD>(${OPSYS} " release ")"; \
} \
}' | ${SORT} \
;; \
esac; \
fi
.endif
# This target generates an index entry suitable for aggregation into
# a large index. Format is:
#
# distribution-name|package-path|installation-prefix|comment| \
# description-file|maintainer|categories|build deps|run deps|for arch| \
# not for opsys
#
# XXX Need to handle BUILD_DEPENDS/TOOL_DEPENDS split.
#
.PHONY: describe
.if !target(describe)
describe:
@${ECHO_N} "${PKGNAME}|${.CURDIR}|"; \
${ECHO_N} "${PREFIX}|"; \
${ECHO_N} ${COMMENT:Q}; \
if [ -f "${DESCR_SRC}" ]; then \
${ECHO_N} "|${DESCR_SRC}"; \
else \
${ECHO_N} "|/dev/null"; \
fi; \
${ECHO_N} "|${MAINTAINER}|${CATEGORIES}|"; \
case "A${BUILD_DEPENDS}B${DEPENDS}C" in \
ABC) ;; \
*) cd ${.CURDIR} && ${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} build-depends-list | ${SORT} -u`;; \
esac; \
${ECHO_N} "|"; \
if [ "${DEPENDS}" != "" ]; then \
cd ${.CURDIR} && ${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`; \
fi; \
${ECHO_N} "|"; \
if [ "${ONLY_FOR_PLATFORM}" = "" ]; then \
${ECHO_N} "any"; \
else \
${ECHO_N} "${ONLY_FOR_PLATFORM}"; \
fi; \
${ECHO_N} "|"; \
if [ "${NOT_FOR_PLATFORM}" = "" ]; then \
${ECHO_N} "any"; \
else \
${ECHO_N} "not ${NOT_FOR_PLATFORM}"; \
fi; \
${ECHO} ""
.endif
.PHONY: readmes
.if !target(readmes)
readmes: readme
.endif
# This target is used to generate README.html files
.PHONY: readme
.if !target(readme)
FTP_PKG_URL_HOST?= ftp://ftp.NetBSD.org
FTP_PKG_URL_DIR?= /pub/pkgsrc/packages
readme:
@cd ${.CURDIR} && ${RECURSIVE_MAKE} ${MAKEFLAGS} README.html PKG_URL=${FTP_PKG_URL_HOST}${FTP_PKG_URL_DIR}
.endif
# This target is used to generate README.html files, very like "readme"
# However, a different target was used for ease of use.
.PHONY: cdrom-readme
.if !target(cdrom-readme)
CDROM_PKG_URL_HOST?= file://localhost
CDROM_PKG_URL_DIR?= /usr/pkgsrc/packages
cdrom-readme:
@cd ${.CURDIR} && ${RECURSIVE_MAKE} ${MAKEFLAGS} README.html PKG_URL=${CDROM_PKG_URL_HOST}${CDROM_PKG_URL_DIR}
.endif
README_NAME= ${TEMPLATES}/README.pkg
# set up the correct license information as a sed expression
.if defined(LICENSE)
SED_LICENSE_EXPR= -e 's|%%LICENSE%%|<p>Please note that this package has a ${LICENSE} license.</p>|'
.else
SED_LICENSE_EXPR= -e 's|%%LICENSE%%||'
.endif
# set up the "more info URL" information as a sed expression
.if defined(HOMEPAGE)
SED_HOMEPAGE_EXPR= -e 's|%%HOMEPAGE%%|<p>This package has a home page at <a HREF="${HOMEPAGE}">${HOMEPAGE}</a>.</p>|'
.else
SED_HOMEPAGE_EXPR= -e 's|%%HOMEPAGE%%||'
.endif
# If PACKAGES is set to the default (../../packages), the current
# ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
# structure of ...pkgsrc/packages/`uname -r`/${MACHINE_ARCH} is assumed.
# The PKG_URL is set from FTP_PKG_URL_* or CDROM_PKG_URL_*, depending on
# the target used to generate the README.html file.
.PHONY: README.html
README.html: .PRECIOUS
@${PKGSRC_SETENV} BMAKE=${MAKE:Q} ${SH} ../../mk/scripts/mkdatabase -f $@.tmp1
@if ${TEST} -d ${PACKAGES}; then \
cd ${PACKAGES}; \
case `${PWD_CMD}` in \
${PKGSRCDIR}/packages) \
MULTIARCH=no; \
;; \
*) \
MULTIARCH=yes; \
;; \
esac; \
cd ${.CURDIR} ; \
fi; \
if [ `${PKG_ADMIN} -V` -lt 20080415 ]; then \
SCAN_VULNERABILITIES=0; \
else \
_PVDIR=`${PKG_ADMIN} config-var PKGVULNDIR`; \
if [ -e "$${_PVDIR}"/pkg-vulnerabilities ]; then \
SCAN_VULNERABILITIES=2; \
else \
SCAN_VULNERABILITIES=1; \
fi; \
fi; \
${AWK} -f ../../mk/scripts/genreadme.awk \
builddependsfile=/dev/null \
dependsfile=/dev/null \
AWK=${AWK:Q} \
CMP=${CMP:Q} \
DISTDIR=${DISTDIR:Q} \
GREP=${GREP:Q} \
PACKAGES=${PACKAGES:Q} \
PKG_ADMIN=${PKG_ADMIN:Q} \
PKG_INFO=${PKG_INFO:Q} \
PKG_SUFX=${PKG_SUFX:Q} \
PKG_URL=${PKG_URL:Q} \
PKGSRCDIR=${.CURDIR:C|/[^/]*/[^/]*$||:Q} \
PKGTOOLS_VERSION=${PKGTOOLS_VERSION} \
SCAN_VULNERABILITIES=$${SCAN_VULNERABILITIES} \
SED=${SED:Q} \
SETENV=${SETENV:Q} \
SORT=${SORT:Q} \
TMPDIR=${TMPDIR:U/tmp:Q} \
SINGLEPKG=${PKGPATH:Q} \
$@.tmp1
@${RM} $@.tmp1
.PHONY: print-build-depends-list
.if !target(print-build-depends-list)
print-build-depends-list:
. if !empty(BUILD_DEPENDS) || !empty(DEPENDS)
@${ECHO_N} 'This package requires package(s) "'
@${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} build-depends-list | ${SORT} -u`
@${ECHO} '" to build.'
. endif
.endif
.PHONY: print-run-depends-list
.if !target(print-run-depends-list)
print-run-depends-list:
. if !empty(DEPENDS)
@${ECHO_N} 'This package requires package(s) "'
@${ECHO_N} `${RECURSIVE_MAKE} ${MAKEFLAGS} run-depends-list | ${SORT} -u`
@${ECHO} '" to run.'
. endif
.endif
# This target is used by the mk/scripts/mkreadme script to generate
# README.html files
.PHONY: print-summary-data
.if !target(print-summary-data)
print-summary-data:
@${ECHO} depends ${PKGPATH} ${DEPENDS:Q}
@${ECHO} build_depends ${PKGPATH} ${BUILD_DEPENDS:Q}
@${ECHO} conflicts ${PKGPATH} ${CONFLICTS:Q}
@${ECHO} index ${PKGPATH} ${PKGNAME:Q}
@${ECHO} htmlname ${PKGPATH} ${_HTML_PKGLINK:Q}
@${ECHO} homepage ${PKGPATH} ${HOMEPAGE:Q}
@${ECHO} wildcard ${PKGPATH} ${PKGWILDCARD:Q}
@${ECHO} comment ${PKGPATH} ${COMMENT:Q}
@${ECHO} license ${PKGPATH} ${LICENSE:Q}
@if [ "${ONLY_FOR_PLATFORM}" = "" ]; then \
${ECHO} "onlyfor ${PKGPATH} any"; \
else \
${ECHO} "onlyfor ${PKGPATH} ${ONLY_FOR_PLATFORM}"; \
fi
@if [ "${NOT_FOR_PLATFORM}" = "" ]; then \
${ECHO} "notfor ${PKGPATH} any"; \
else \
${ECHO} "notfor ${PKGPATH} not ${NOT_FOR_PLATFORM}"; \
fi;
@if [ -n "${OWNER}" ]; then \
${ECHO} "owner ${PKGPATH} ${OWNER}"; \
else \
${ECHO} "maintainer ${PKGPATH} ${MAINTAINER}"; \
fi
@${ECHO} "categories ${PKGPATH} ${CATEGORIES}"
@if [ -f "${DESCR_SRC}" ]; then \
${ECHO} "descr ${PKGPATH} ${DESCR_SRC:S;${PKGSRCDIR}/;;g}"; \
else \
${ECHO} "descr ${PKGPATH} /dev/null"; \
fi
@${ECHO} "prefix ${PKGPATH} ${PREFIX}"
.endif

185
mk/bsd.pkg.subdir.mk Normal file
View File

@@ -0,0 +1,185 @@
# $NetBSD: bsd.pkg.subdir.mk,v 1.70 2008/10/14 22:35:19 joerg Exp $
# Derived from: FreeBSD Id: bsd.port.subdir.mk,v 1.19 1997/03/09 23:10:56 wosch Exp
# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
#
# The include file <bsd.pkg.subdir.mk> contains the default targets
# for building ports subdirectories.
#
#
# +++ variables +++
#
# OPSYS Get the operating system type [`uname -s`]
#
# SUBDIR A list of subdirectories that should be built as well.
# Each of the targets will execute the same target in the
# subdirectories.
#
#
# +++ targets +++
#
# README.html:
# Creating README.html for package.
#
# afterinstall, all, beforeinstall, build, checksum, clean,
# configure, deinstall, depend, describe, extract, fetch, fetch-list,
# install, package, readmes, realinstall, reinstall, tags,
# mirror-distfiles, bulk-install, bulk-package, ${PKG_MISC_TARGETS}
#
.include "misc/common.mk"
AWK?= /usr/bin/awk
CAT?= /bin/cat
BASENAME?= /usr/bin/basename
ECHO?= echo
ECHO_MSG?= ${ECHO}
MV?= /bin/mv
RM?= /bin/rm
SED?= /usr/bin/sed
SORT?= /usr/bin/sort
_SUBDIRUSE: .USE
@for entry in "" ${SUBDIR}; do \
if [ "X$$entry" = "X" ]; then continue; fi; \
OK=""; \
for dud in "" ${DUDS}; do \
if [ "X$$dud" = "X" ]; then continue; fi; \
if [ $${dud} = $${entry} ]; then \
OK="false"; \
${ECHO_MSG} "===> ${_THISDIR_}$${entry} skipped"; \
fi; \
done; \
if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
edir=$${entry}.${MACHINE}; \
elif [ -d ${.CURDIR}/$${entry} ]; then \
edir=$${entry}; \
else \
OK="false"; \
${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
fi; \
if [ "$$OK" = "" ]; then \
cd ${.CURDIR}/$${edir}; \
${ECHO_MSG} "===> ${_THISDIR_}$${edir}"; \
${RECURSIVE_MAKE} ${MAKEFLAGS} "_THISDIR_=${_THISDIR_}$${edir}/" \
${.TARGET:realinstall=install} || true; \
fi; \
done
.for __target in all fetch package extract configure build clean \
cleandir distclean depend describe reinstall tags checksum \
makedistinfo makepatchsum makesum mirror-distfiles deinstall \
show-downlevel show-pkgsrc-dir show-var show-vars \
bulk-install bulk-package fetch-list-one-pkg \
fetch-list-recursive update clean-update lint \
check-vulnerable pbulk-index \
${PKG_MISC_TARGETS}
.if !target(__target)
.PHONY: ${__target}
${__target}: _SUBDIRUSE
.endif
.endfor
.if !target(install)
.if !target(beforeinstall)
beforeinstall:
.endif
.if !target(afterinstall)
afterinstall:
.endif
install: afterinstall
afterinstall: realinstall
realinstall: beforeinstall _SUBDIRUSE
.endif
.if !target(readmes)
readmes: readme _SUBDIRUSE
.endif
.if !target(readme)
readme:
@${RECURSIVE_MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--ftp _README_TYPE=$@
.endif
.if !target(cdrom-readme)
cdrom-readme:
@${RECURSIVE_MAKE} ${MAKEFLAGS} README.html _README_TYPE_FLAG=--cdrom README_TYPE=$@
.endif
.if defined(PKGSRCTOP)
README= templates/README.top
.else
README= ../templates/README.category
.endif
HTMLIFY= ${SED} -e 's/&/\&amp;/g' -e 's/>/\&gt;/g' -e 's/</\&lt;/g'
show-comment:
@if [ ${COMMENT:Q}"" ]; then \
${ECHO} ${COMMENT:Q}; \
elif [ -f COMMENT ] ; then \
${CAT} COMMENT; \
else \
${ECHO} '(no description)'; \
fi
.if !target(show-distfiles)
show-distfiles:
@for entry in ${SUBDIR}; do \
if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
edir=$${entry}.${MACHINE}; \
elif [ -d ${.CURDIR}/$${entry} ]; then \
edir=$${entry}; \
else \
OK="false"; \
${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
fi; \
if [ "$$OK" = "" ]; then \
cd ${.CURDIR}/$${edir} && ${RECURSIVE_MAKE} ${MAKEFLAGS} show-distfiles; \
fi; \
done
.endif
.PHONY: show-subdir-var
show-subdir-var:
@${ECHO} ${${VARNAME}:Q}
# Print out a script to fetch all needed files (no checksumming).
#
# When invoked at the top or category level, this target needs to be
# handled specially, to elide the "===>" messages that would otherwise
# ruin the script.
#
.if !target(fetch-list)
.PHONY: fetch-list
fetch-list:
@${ECHO} '#!/bin/sh'
@${ECHO} '#'
@${ECHO} '# This is an auto-generated script, the result of running'
@${ECHO} '# `make fetch-list'"'"' in directory "'"`${PWD_CMD}`"'"'
@${ECHO} '# on host "'"`${UNAME} -n`"'" on "'"`date`"'".'
@${ECHO} '#'
.if defined(PKGSRCTOP) && !defined(SPECIFIC_PKGS)
# Recursing over dependencies would be pointless, in this case.
@${RECURSIVE_MAKE} ${MAKEFLAGS} fetch-list-one-pkg \
| ${AWK} ' \
function do_block () { \
if (FoundSomething) { \
for (line = 0; line < c; line++) \
print block[line]; \
FoundSomething = 0 \
} \
c = 0 \
} \
/^[^#=]/ { FoundSomething = 1 } \
/^unsorted/ { gsub(/[[:space:]]+/, " \\\n\t") } \
/^echo/ { gsub(/;[[:space:]]+/, "\n") } \
!/^=/ { block[c++] = $$0 } \
/^=/ { do_block() } \
END { do_block() } \
'
.else
@${RECURSIVE_MAKE} ${MAKEFLAGS} fetch-list-recursive \
| ${SED} '/^=/d'
.endif
.endif # !target(fetch-list)

134
mk/bsd.pkg.update.mk Normal file
View File

@@ -0,0 +1,134 @@
# $NetBSD: bsd.pkg.update.mk,v 1.23 2011/05/04 09:49:34 obache Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and contains the targets
# and variables for "make update".
#
# There is no documentation on what "update" actually does. This is merely
# an attempt to separate the magic into a separate module that can be
# reimplemented later.
#
NOCLEAN?= NO # don't clean up after update
REINSTALL?= NO # reinstall upon update
# UPDATE_TARGET is the target that is invoked when updating packages during
# a "make update". This variable is user-settable within /etc/mk.conf.
#
.if !defined(UPDATE_TARGET)
. if defined(DEPENDS_TARGET) && (${DEPENDS_TARGET} == "update")
. if ${_USE_DESTDIR} != "no" || make(package) || make(package-install)
UPDATE_TARGET= package-install
. else
UPDATE_TARGET= install
. endif
. else
UPDATE_TARGET= ${DEPENDS_TARGET}
. endif
.endif
# The 'update' target can be used to update a package and all
# currently installed packages that depend upon this package.
_DDIR= ${WRKDIR}/.DDIR
_DLIST= ${WRKDIR}/.DLIST
.PHONY: update-create-ddir
update-create-ddir: ${_DDIR}
.PHONY: update
.if !target(update)
.if exists(${_DDIR})
RESUMEUPDATE?= YES
CLEAR_DIRLIST?= NO
update:
@${PHASE_MSG} "Resuming update for ${PKGNAME}"
. if ${REINSTALL} != "NO" && ${UPDATE_TARGET} != "replace"
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL
. endif
.else
RESUMEUPDATE?= NO
CLEAR_DIRLIST?= YES
update:
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} check-vulnerable
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
. if ${UPDATE_TARGET} != "replace"
${RUN} if ${PKG_INFO} -qe ${PKGBASE}; then \
${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES DEINSTALLDEPENDS=ALL \
|| (${RM} ${_DDIR} && ${FALSE}); \
fi
. endif
.endif
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} KEEP_WRKDIR=YES DEPENDS_TARGET=${DEPENDS_TARGET:Q}
${RUN} \
[ ! -s ${_DDIR} ] || for dep in `${CAT} ${_DDIR}` ; do \
(if cd ../.. && cd "$${dep}" ; then \
${PHASE_MSG} "Installing in $${dep}" && \
if [ "(" "${RESUMEUPDATE}" = "NO" -o \
"${REINSTALL}" != "NO" ")" -a \
"${UPDATE_TARGET}" != "replace" ] ; then \
${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall _UPDATE_RUNNING=YES; \
fi && \
${RECURSIVE_MAKE} ${MAKEFLAGS} ${UPDATE_TARGET} \
_PKGSRC_UPDATE_CHECK=yes \
DEPENDS_TARGET=${DEPENDS_TARGET:Q} ; \
else \
${PHASE_MSG} "Skipping removed directory $${dep}"; \
fi) ; \
done
.if ${NOCLEAN} == "NO"
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean-update CLEAR_DIRLIST=YES
.endif
.PHONY: clean-update
clean-update:
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} update-create-ddir
${RUN} \
if [ -s ${_DDIR} ] ; then \
for dep in `${CAT} ${_DDIR}` ; do \
(if cd ../.. && cd "$${dep}" ; then \
${RECURSIVE_MAKE} ${MAKEFLAGS} clean ; \
else \
${PHASE_MSG} "Skipping removed directory $${dep}";\
fi) ; \
done ; \
fi
.if ${CLEAR_DIRLIST} != "NO"
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean
.else
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean update-dirlist DIRLIST="`${CAT} ${_DDIR}`" PKGLIST="`${CAT} ${_DLIST}`"
@${WARNING_MSG} "preserved leftover directory list. Your next"
@${WARNING_MSG} "\`\`${MAKE} update'' may fail. It is advised to use"
@${WARNING_MSG} "\`\`${MAKE} update REINSTALL=YES'' instead!"
.endif
.endif # !target(update)
.PHONY: update-dirlist
update-dirlist:
${RUN} ${MKDIR} ${WRKDIR}
.if defined(PKGLIST)
. for __tmp__ in ${PKGLIST}
${RUN} ${ECHO} >>${_DLIST} "${__tmp__}"
. endfor
.endif
.if defined(DIRLIST)
. for __tmp__ in ${DIRLIST}
${RUN} ${ECHO} >>${_DDIR} "${__tmp__}"
. endfor
.endif
${_DDIR}: ${_DLIST}
${RUN} pkgs=`${CAT} ${_DLIST}`; \
if [ "$$pkgs" ]; then ${PKG_INFO} -Q PKGPATH $$pkgs; fi > ${_DDIR}
${_DLIST}: ${WRKDIR}
if ${PKG_INFO} -qe "${PKGWILDCARD}"; then \
${PKG_INFO} -qr "${PKGWILDCARD}" > ${_DLIST}; \
else \
${TOUCH} ${_DLIST}; \
fi

127
mk/bsd.pkg.use.mk Normal file
View File

@@ -0,0 +1,127 @@
# $NetBSD: bsd.pkg.use.mk,v 1.54 2013/05/10 09:07:37 obache Exp $
#
# Turn USE_* macros into proper depedency logic. Included near the top of
# bsd.pkg.mk, after bsd.prefs.mk.
#
# Package-settable variables:
#
# USE_BSD_MAKEFILE
# Should be set to "yes" whenever a package uses a BSD-style
# Makefile. These Makefiles typically end with a line including
# <bsd.prog.mk>.
# USE_IMAKE
# When set to "yes", means that the package uses imake as the
# primary (and often only) build system. This is different from
# USE_TOOLS+=imake, which only states that the package uses imake
# among other tools.
#
# Keywords: imake
#
.if defined(USE_BSD_MAKEFILE)
MAKE_ENV+= ${BSD_MAKE_ENV} INSTALL=${TOOLS_INSTALL:Q}
.endif
.if defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake)
PLIST_SUBST+= IMAKE_MAN_SOURCE_PATH=${IMAKE_MAN_SOURCE_PATH:Q}
PLIST_SUBST+= IMAKE_MAN_DIR=${IMAKE_MAN_DIR:Q}
PLIST_SUBST+= IMAKE_LIBMAN_DIR=${IMAKE_LIBMAN_DIR:Q}
PLIST_SUBST+= IMAKE_KERNMAN_DIR=${IMAKE_KERNMAN_DIR:Q}
PLIST_SUBST+= IMAKE_FILEMAN_DIR=${IMAKE_FILEMAN_DIR:Q}
PLIST_SUBST+= IMAKE_GAMEMAN_DIR=${IMAKE_GAMEMAN_DIR:Q}
PLIST_SUBST+= IMAKE_MISCMAN_DIR=${IMAKE_MISCMAN_DIR:Q}
PLIST_SUBST+= IMAKE_MAN_SUFFIX=${IMAKE_MAN_SUFFIX:Q}
PLIST_SUBST+= IMAKE_LIBMAN_SUFFIX=${IMAKE_LIBMAN_SUFFIX:Q}
PLIST_SUBST+= IMAKE_KERNMAN_SUFFIX=${IMAKE_KERNMAN_SUFFIX:Q}
PLIST_SUBST+= IMAKE_FILEMAN_SUFFIX=${IMAKE_FILEMAN_SUFFIX:Q}
PLIST_SUBST+= IMAKE_GAMEMAN_SUFFIX=${IMAKE_GAMEMAN_SUFFIX:Q}
PLIST_SUBST+= IMAKE_MISCMAN_SUFFIX=${IMAKE_MISCMAN_SUFFIX:Q}
PLIST_SUBST+= IMAKE_MANNEWSUFFIX=${IMAKE_MANNEWSUFFIX:Q}
.endif
.if defined(USE_IMAKE) && empty(USE_TOOLS:Mitools)
USE_X11BASE?= implied
.endif
.if defined(USE_IMAKE)
MAKE_FLAGS+= CC=${CC:Q} CXX=${CXX:Q}
.endif
.if defined(USE_X11BASE) && ${X11_TYPE} != "modular"
. include "x11.buildlink3.mk"
.endif
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
PREFIX= ${DEPOTBASE}/${PKGNAME}
.elif ${PKG_INSTALLATION_TYPE} == "overwrite"
. if defined(INSTALLATION_PREFIX)
PREFIX= ${INSTALLATION_PREFIX}
. elif defined(USE_X11BASE)
PREFIX= ${X11PREFIX}
. elif defined(USE_CROSSBASE)
PREFIX= ${CROSSBASE}
. else
PREFIX= ${LOCALBASE}
. endif
.endif
.if (${PKG_INSTALLATION_TYPE} == "pkgviews") && defined(INSTALLATION_PREFIX)
PKG_FAIL_REASON= "INSTALLATION_PREFIX can't be used in a pkgviews package"
.endif
############################################################################
# General settings
############################################################################
### PKG_USE_KERBEROS
.if defined(PKG_USE_KERBEROS)
CRYPTO?= uses Kerberos encryption code
BUILD_DEFS+= KERBEROS
.endif
### USE_LIBTOOL, PKG_[SH]LIBTOOL
#
# PKG_LIBTOOL is the path to the libtool script installed by libtool-base.
# _LIBTOOL is the path the libtool used by the build, which could be the
# path to a libtool wrapper script.
# LIBTOOL is the publicly-readable variable that should be used by
# Makefiles to invoke the proper libtool.
#
.if defined(USE_LANGUAGES) && !empty(USE_LANGUAGES:Mfortran) || \
defined(USE_LANGUAGES) && !empty(USE_LANGUAGES:Mfortran77)
. if !empty(USE_CROSS_COMPILE:M[yY][eE][sS]) # XXX
PKG_FAIL_REASON+= "Cross-compiling Fortran with libtool NYI."
. endif
PKG_LIBTOOL?= ${LOCALBASE}/bin/libtool-fortran
PKG_SHLIBTOOL?= ${LOCALBASE}/bin/shlibtool-fortran
. if defined(USE_LIBTOOL)
BUILD_DEPENDS+= libtool-fortran>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../devel/libtool-fortran
. endif
.else
. if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
PKG_LIBTOOL?= ${CROSSBASE}/bin/libtool
PKG_SHLIBTOOL?= ${CROSSBASE}/bin/shlibtool
. else
PKG_LIBTOOL?= ${LOCALBASE}/bin/libtool
PKG_SHLIBTOOL?= ${LOCALBASE}/bin/shlibtool
. endif
.endif
_LIBTOOL?= ${PKG_LIBTOOL}
_SHLIBTOOL?= ${PKG_SHLIBTOOL}
LIBTOOL?= ${PKG_LIBTOOL}
SHLIBTOOL?= ${PKG_SHLIBTOOL}
.if defined(USE_LIBTOOL)
LIBTOOL_REQD?= 2.2.6bnb3
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
TOOL_DEPENDS+= cross-libtool-base-${MACHINE_ARCH}>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../cross/libtool-base
.else
TOOL_DEPENDS+= libtool-base>=${_OPSYS_LIBTOOL_REQD:U${LIBTOOL_REQD}}:../../devel/libtool-base
.endif
CONFIGURE_ENV+= LIBTOOL="${LIBTOOL} ${LIBTOOL_FLAGS}"
MAKE_ENV+= LIBTOOL="${LIBTOOL} ${LIBTOOL_FLAGS}"
.endif

764
mk/bsd.prefs.mk Normal file
View File

@@ -0,0 +1,764 @@
# $NetBSD: bsd.prefs.mk,v 1.336 2013/04/28 13:21:47 obache Exp $
#
# This file includes the mk.conf file, which contains the user settings.
#
# Packages should include this file before any of the .if directives, as
# well as before modifying variables like CFLAGS, LDFLAGS, and so on.
# Otherwise the behavior may be unexpected.
#
# When mk.conf is included by this file, the following variables are
# defined:
#
# ACCEPTABLE_LICENSES
# This variable is set to the list of Open Source licenses. See
# mk/license.mk for details.
#
# MACHINE_PLATFORM
# The platform for which the packages are built. It has the form
# ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH}.
#
# NATIVE_MACHINE_PLATFORM
# The platform on which the packages are built. This is usually
# the same as ${MACHINE_PLATFORM}, but can be different when
# cross-building packages.
#
# PKGPATH
# The path of the package, relative to the pkgsrc top-level
# directory. Typical values look like editors/emacs or
# misc/openoffice-bin.
#
# Keywords: mk.conf user
#
.if !defined(BSD_PKG_MK)
# Let mk.conf know that this is pkgsrc.
BSD_PKG_MK=1
__PREFIX_SET__:=${PREFIX}
# Set PATH if not already set
.if !defined(PATH)
PATH=/bin:/usr/bin:/sbin:/usr/sbin
.endif
# Expand MAKE to a full path.
.if !defined(_MAKE)
_MAKE:= ${MAKE}
# allow for MAKE=./make and similar.
. if empty(_MAKE:M/*) && !empty(_MAKE:M*/*) && defined(PWD) && exists(${PWD}/${MAKE})
_MAKE:= ${PWD}/${MAKE}
. endif
. for _dir_ in ${PATH:C/\:/ /g}
. if empty(_MAKE:M/*)
. if exists(${_dir_}/${MAKE})
_MAKE:= ${_dir_}/${MAKE}
. endif
. endif
. endfor
. if !empty(_MAKE:M/*)
MAKEFLAGS+= _MAKE=${_MAKE:Q}
. endif
.endif
MAKE:= ${_MAKE}
.if exists(/usr/bin/uname)
UNAME=/usr/bin/uname
.elif exists(/bin/uname)
UNAME=/bin/uname
.else
UNAME=echo Unknown
.endif
.if !defined(OPSYS)
OPSYS:= ${:!${UNAME} -s!:S/-//g:S/\///g:C/^CYGWIN_.*$/Cygwin/}
MAKEFLAGS+= OPSYS=${OPSYS:Q}
.endif
# OS_VARIANT is used to differentiate operating systems which have a common
# basis but offer contrasting environments, for example Linux distributions
# or illumos forks.
OS_VARIANT?= # empty
# The _CMD indirection allows code below to modify these values
# without executing the commands at all. Later, recursed make
# invocations will skip these blocks entirely thanks to MAKEFLAGS.
.if !defined(OS_VERSION)
_OS_VERSION_CMD= ${UNAME} -r
OS_VERSION= ${_OS_VERSION_CMD:sh}
MAKEFLAGS+= OS_VERSION=${OS_VERSION:Q}
.endif
# Preload these for architectures not in all variations of bsd.own.mk,
# which do not match their GNU names exactly.
GNU_ARCH.arm26?= arm
GNU_ARCH.arm32?= arm
GNU_ARCH.i486?= i386
GNU_ARCH.i586?= i386
GNU_ARCH.i686?= i386
GNU_ARCH.m68000?= m68010
GNU_ARCH.mips?= mipsel
GNU_ARCH.sh3eb?= sh
GNU_ARCH.sh3el?= shle
NATIVE_MACHINE_GNU_ARCH?= ${GNU_ARCH.${NATIVE_MACHINE_ARCH}:U${NATIVE_MACHINE_ARCH}}
MACHINE_GNU_ARCH?= ${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}}
## If changes are made to how OS_VERSION is set below please keep
## "pkgsrc/pkgtools/osabi/INSTALL" in-sync.
.if ${OPSYS} == "NetBSD"
LOWER_OPSYS?= netbsd
.elif ${OPSYS} == "AIX"
LOWER_ARCH!= _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $$1 }'`; \
if /usr/sbin/lsattr -El $$_cpuid | grep ' POWER' >/dev/null 2>&1; then \
echo rs6000; \
else \
echo powerpc; \
fi
MACHINE_ARCH?= ${LOWER_ARCH}
. if exists(/usr/bin/oslevel)
_OS_VERSION!= /usr/bin/oslevel
. else
_OS_VERSION!= echo `${UNAME} -v`.`${UNAME} -r`
. endif
OS_VERSION= ${_OS_VERSION:C/([0-9]*\.[0-9]*).*/\1/}
LOWER_OPSYS_VERSUFFIX= ${_OS_VERSION}
LOWER_OPSYS?= aix
LOWER_VENDOR?= ibm
.elif ${OPSYS} == "BSDOS"
LOWER_OPSYS?= bsdi
.elif ${OPSYS} == "Cygwin"
LOWER_OPSYS?= cygwin
LOWER_VENDOR?= pc
. if !defined(LOWER_ARCH)
LOWER_ARCH!= ${UNAME} -m | sed -e 's/i.86/i386/'
. endif # !defined(LOWER_ARCH)
_OS_VERSION!= ${UNAME} -r
OS_VERSION= ${_OS_VERSION:C/\(.*\)//}
OS_VARIANT!= ${UNAME} -s
.elif ${OPSYS} == "Darwin"
LOWER_OPSYS?= darwin
.if empty(OS_VERSION:M[1-9].*.*)
# Automatically select the ABI under Mac OS X Snow Leopard. We don't
# use this at the moment because too many third party programs don't
# work with it.
#
# _SYSCTL_HW_OPTIONAL_X86_64!= /usr/sbin/sysctl -n hw.optional.x86_64
# . if ${_SYSCTL_HW_OPTIONAL_X86_64} == "1"
# ABI= 64
# .else
# ABI= 32
#. endif
ABI= 32
LOWER_ARCH.32= i386
LOWER_ARCH.64= x86_64
LOWER_ARCH= ${LOWER_ARCH.${ABI}}
.else
LOWER_ARCH!= ${UNAME} -p
.endif
MACHINE_ARCH= ${LOWER_ARCH}
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
LOWER_OPSYS_VERSUFFIX= ${LOWER_OS_VERSION:C/([0-9]*).*/\1/}
LOWER_VENDOR?= apple
.elif ${OPSYS} == "DragonFly"
OS_VERSION:= ${OS_VERSION:C/-.*$//}
LOWER_OPSYS?= dragonfly
LOWER_ARCH!= ${UNAME} -p
. if ${LOWER_ARCH} == "amd64"
MACHINE_ARCH= x86_64
. else
MACHINE_ARCH= ${LOWER_ARCH}
. endif
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
LOWER_VENDOR?= pc
.elif ${OPSYS} == "FreeBSD"
OS_VERSION:= ${OS_VERSION:C/-.*$//}
LOWER_OPSYS?= freebsd
LOWER_ARCH!= ${UNAME} -p
. if ${LOWER_ARCH} == "amd64"
MACHINE_ARCH= x86_64
. else
MACHINE_ARCH= ${LOWER_ARCH}
. endif
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
LOWER_OPSYS_VERSUFFIX= ${LOWER_OS_VERSION:C/([0-9]*).*/\1/}
. if ${LOWER_ARCH} == "i386"
LOWER_VENDOR?= pc
. endif
LOWER_VENDOR?= unknown
.elif ${OPSYS} == "Haiku"
LOWER_OPSYS?= haiku
. if ${MACHINE_ARCH} == "i386"
LOWER_VENDOR?= pc
. endif
.elif ${OPSYS} == "Interix"
LOWER_OPSYS?= interix
LOWER_VENDOR?= pc
. if exists(/usr/lib/libc.so.5.2) || exists(/usr/lib/x86/libc.so.5.2)
LOWER_OPSYS_VERSUFFIX= ${LOWER_OS_VERSION:C/([0-9]*).*/\1/}
. else
LOWER_OPSYS_VERSUFFIX?= 3
. if exists(/usr/lib/libc.so.3.5)
OS_VERSION= 3.5
. elif exists(/usr/lib/libc.so.3.1)
OS_VERSION= 3.1
. else
OS_VERSION= 3.0
. endif
. endif
.elif ${OPSYS} == "MirBSD"
LOWER_OPSYS?= mirbsd
LOWER_OS_VERSION= ${OS_VERSION}
LOWER_OPSYS_VERSUFFIX= ${OS_VERSION}
LOWER_ARCH!= arch -s
LOWER_VENDOR?= unknown
MACHINE_ARCH= ${LOWER_ARCH}
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
.elif !empty(OPSYS:MIRIX*)
LOWER_ARCH!= ${UNAME} -p
LOWER_OPSYS?= irix
LOWER_OPSYS_VERSUFFIX?= ${OS_VERSION}
LOWER_VENDOR?= sgi
.elif ${OPSYS} == "Linux"
OS_VERSION:= ${OS_VERSION:C/-.*$//}
LOWER_OPSYS?= linux
. if !defined(LOWER_ARCH)
LOWER_ARCH!= ${UNAME} -m | sed -e 's/i.86/i386/' -e 's/ppc/powerpc/'
. endif # !defined(LOWER_ARCH)
MACHINE_ARCH= ${LOWER_ARCH}
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
. if exists(/etc/debian_version)
LOWER_VENDOR?= debian
. elif exists(/etc/mandrake-release)
LOWER_VENDOR?= mandrake
. elif exists(/etc/redhat-version)
LOWER_VENDOR?= redhat
. elif exists(/etc/slackware-version)
LOWER_VENDOR?= slackware
. elif exists(/etc/ssdlinux_version)
LOWER_VENDOR?= ssd
. elif ${LOWER_ARCH} == "i386"
LOWER_VENDOR?= pc
. endif
LOWER_VENDOR?= unknown
.elif ${OPSYS} == "OSF1"
LOWER_ARCH!= ${UNAME} -p
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
MACHINE_ARCH?= ${LOWER_ARCH}
OS_VERSION:= ${OS_VERSION:C/^V//}
LOWER_OPSYS?= osf1
LOWER_OPSYS_VERSUFFIX?= ${OS_VERSION}
LOWER_VENDOR?= dec
.elif ${OPSYS} == "HPUX"
OS_VERSION:= ${OS_VERSION:C/^B.//}
.if ${MACHINE_ARCH} == "9000"
MACHINE_ARCH= hppa
.endif
LOWER_OPSYS?= hpux
LOWER_OPSYS_VERSUFFIX?= ${OS_VERSION}
LOWER_VENDOR?= hp
.elif ${OPSYS} == "SunOS"
ABI?= 32
. if ${MACHINE_ARCH} == "sparc"
SPARC_TARGET_ARCH?= sparcv7
. elif ${MACHINE_ARCH} == "sun4"
MACHINE_ARCH= sparc
SPARC_TARGET_ARCH?= sparcv7
. elif ${MACHINE_ARCH} == "i86pc" || ${MACHINE_ARCH} == "i86xpv" || ${MACHINE_ARCH} == "i386"
LOWER_ARCH.32= i386
LOWER_ARCH.64= x86_64
LOWER_ARCH= ${LOWER_ARCH.${ABI}}
MACHINE_ARCH= ${LOWER_ARCH}
. elif ${MACHINE_ARCH} == "unknown"
. if !defined(LOWER_ARCH)
LOWER_ARCH!= ${UNAME} -p
. endif # !defined(LOWER_ARCH)
MAKEFLAGS+= LOWER_ARCH=${LOWER_ARCH:Q}
. endif
LOWER_VENDOR?= sun
LOWER_OPSYS?= solaris
LOWER_OPSYS_VERSUFFIX= 2.${OS_VERSION:C/5.//}
_UNAME_V!= ${UNAME} -v
. if !empty(_UNAME_V:Mjoyent_*)
OS_VARIANT= SmartOS
. endif
.elif ${OPSYS} == "Minix"
LOWER_VENDOR?= pc
LOWER_OPSYS:= ${OPSYS:tl}
LDFLAGS+= -lcompat_minix -lminlib
.elif !defined(LOWER_OPSYS)
LOWER_OPSYS:= ${OPSYS:tl}
.endif
# Now commit the [LOWER_]OS_VERSION values computed above, eliding the :sh
OS_VERSION:= ${OS_VERSION}
LOWER_OS_VERSION:= ${OS_VERSION:tl}
MAKEFLAGS+= LOWER_OPSYS=${LOWER_OPSYS:Q}
LOWER_VENDOR?= # empty ("arch--opsys")
LOWER_ARCH?= ${MACHINE_GNU_ARCH}
# Expand now as MACHINE_ARCH can be overriden in mk.conf and
# LOWER_ARCH is typically derived from it.
NATIVE_LOWER_ARCH:= ${LOWER_ARCH}
NATIVE_MACHINE_ARCH:= ${MACHINE_ARCH}
NATIVE_MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${NATIVE_MACHINE_ARCH}
MACHINE_PLATFORM?= ${OPSYS}-${OS_VERSION}-${MACHINE_ARCH}
NATIVE_MACHINE_GNU_PLATFORM?= ${NATIVE_MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}
MACHINE_GNU_PLATFORM?= ${MACHINE_GNU_ARCH}-${LOWER_VENDOR}-${LOWER_OPSYS:C/[0-9]//g}${APPEND_ELF}${LOWER_OPSYS_VERSUFFIX}
# Needed to prevent an "install:" target from being created in bsd.own.mk.
NEED_OWN_INSTALL_TARGET=no
# This prevents default use of the cross-tool harness in the "src" tree,
# in the odd possible case of someone extracting "pkgsrc" underneath "src".
USETOOLS= no
MAKE_ENV+= USETOOLS=no
# Set this before <bsd.own.mk> does, since it doesn't know about Darwin
.if ${OPSYS} == "Darwin"
OBJECT_FMT?= Mach-O
.endif
ACCEPTABLE_LICENSES?= ${DEFAULT_ACCEPTABLE_LICENSES}
# Provide PKGPATH early on so that mk.conf can use it.
PKGPATH?= ${.CURDIR:C|.*/([^/]*/[^/]*)$|\1|}
# Load the settings from MAKECONF, which is /etc/mk.conf by default.
.include <bsd.own.mk>
# /usr/share/mk/bsd.own.mk on NetBSD 1.3 does not define OBJECT_FMT
.if !empty(MACHINE_PLATFORM:MNetBSD-1.3*)
. if ${MACHINE_ARCH} == "alpha" || \
${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64"
OBJECT_FMT?= ELF
. else
OBJECT_FMT?= a.out
. endif
# override what bootstrap-pkgsrc sets, which isn't right for NetBSD
# 1.4.
# XXX other ELF platforms in 1.4 need to be added to here.
.elif !empty(MACHINE_PLATFORM:MNetBSD-1.4*)
. if ${MACHINE_ARCH} == "alpha" || \
${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64"
OBJECT_FMT= ELF
. else
OBJECT_FMT= a.out
. endif
.endif
.if ${OPSYS} == "OpenBSD"
. if defined(ELF_TOOLCHAIN) && ${ELF_TOOLCHAIN} == "yes"
OBJECT_FMT?= ELF
. else
OBJECT_FMT?= a.out
. endif
.elif ${OPSYS} == "DragonFly"
OBJECT_FMT= ELF
.elif ${OPSYS} == "MirBSD"
OBJECT_FMT= ELF
MKPROFILE= no
.elif ${OPSYS} == "AIX"
OBJECT_FMT= XCOFF
.elif ${OPSYS} == "OSF1"
OBJECT_FMT= ECOFF
.elif ${OPSYS} == "HPUX"
. if ${MACHINE_ARCH} == "ia64" || (defined(ABI) && ${ABI} == "64")
OBJECT_FMT= ELF
. else
OBJECT_FMT= SOM
. endif
.elif ${OPSYS} == "Cygwin"
OBJECT_FMT= PE
.endif
# Calculate depth
.if exists(${.CURDIR}/mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}
.elif exists(${.CURDIR}/../mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}/..
.elif exists(${.CURDIR}/../../mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}/../..
.endif
# include the defaults file
.include "${_PKGSRC_TOPDIR}/mk/defaults/mk.conf"
SHAREOWN?= ${DOCOWN}
SHAREGRP?= ${DOCGRP}
SHAREMODE?= ${DOCMODE}
.if defined(PREFIX) && (${PREFIX} != ${__PREFIX_SET__})
.BEGIN:
@${ECHO_MSG} "You CANNOT set PREFIX manually or in mk.conf. Set LOCALBASE or X11BASE"
@${ECHO_MSG} "depending on your needs. See the pkg system documentation for more info."
@${FALSE}
.endif
# Load the OS-specific definitions for program variables. Default to loading
# the NetBSD ones if an OS-specific file doesn't exist.
.if exists(${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk)
. include "${_PKGSRC_TOPDIR}/mk/platform/${OPSYS}.mk"
.else
. include "${_PKGSRC_TOPDIR}/mk/platform/NetBSD.mk"
PKG_FAIL_REASON+= "missing mk/platform/${OPSYS}.mk"
.endif
PKGDIRMODE?= 755
# A meta-package is a package that does not have any files and whose
# only purpose is to depend on other packages, giving that collection
# a simple name.
#
# This variable must be set before including bsd.prefs.mk directly or
# indirectly.
#
# Keywords: meta meta-package META_PACKAGE
#
.if defined(META_PACKAGE)
PKG_DESTDIR_SUPPORT= user-destdir
NO_CONFIGURE= yes
NO_BUILD= yes
DISTFILES= # none
PLIST_SRC= # none
CHECK_PERMS= no
USE_LANGUAGES= # empty
do-patch:
@${DO_NADA}
do-install:
@${DO_NADA}
.endif
# After 2011Q1, the default is to use DESTDIR.
USE_DESTDIR?= yes
# PKG_DESTDIR_SUPPORT can only be one of "none", "destdir", or "user-destdir".
PKG_DESTDIR_SUPPORT?= user-destdir
.if ${PKG_DESTDIR_SUPPORT} == "none" || empty(USE_DESTDIR:M[Yy][Ee][Ss])
. if empty(USE_DESTDIR:M[Yy][Ee][Ss]) && empty(USE_DESTDIR:M[Nn][Oo])
PKG_FAIL_REASON+= "USE_DESTDIR must be either \`\`yes'' or \`\`no''"
. endif
_USE_DESTDIR= no
.elif ${PKG_DESTDIR_SUPPORT} == "user-destdir"
_USE_DESTDIR= user-destdir
.elif ${PKG_DESTDIR_SUPPORT} == "destdir"
_USE_DESTDIR= destdir
.else
PKG_FAIL_REASON+= "PKG_DESTDIR_SUPPORT must be \`\`none'', \`\`destdir'', or \`\`user-destdir''."
.endif
# This stanza serves to warn the user; deciding to not build
# non-DESTDIR-capable packages when not in DESTDIR mode is above.
.if ${PKG_DESTDIR_SUPPORT} == "none"
WARNINGS+= "[bsd.prefs.mk] The package ${PKGNAME} is missing DESTDIR support."
.endif
# When using staged installation, everything gets installed into
# ${DESTDIR}${PREFIX} instead of ${PREFIX} directly.
#
.if ${_USE_DESTDIR} != "no"
DESTDIR= ${WRKDIR}/.destdir
. if ${_USE_DESTDIR} == "destdir"
_MAKE_PACKAGE_AS_ROOT= yes
_MAKE_CLEAN_AS_ROOT= yes
_MAKE_INSTALL_AS_ROOT= yes
. elif ${_USE_DESTDIR} == "user-destdir"
_MAKE_PACKAGE_AS_ROOT= no
_MAKE_CLEAN_AS_ROOT= no
_MAKE_INSTALL_AS_ROOT= no
. endif
.else
DESTDIR=
.endif
_MAKE_CLEAN_AS_ROOT?= no
# Whether to run the clean target as root.
_MAKE_INSTALL_AS_ROOT?= yes
# Whether to run the install target as root.
_MAKE_PACKAGE_AS_ROOT?= yes
# Whether to run the package target as root.
# When cross-compilation support is requested, the following options
# must be specified as well or guessable:
# - MACHINE_ARCH is set to TARGET_ARCH if set.
# - CROSS_DESTDIR is guessed from MAKEOBJDIR and MACHINE_ARCH.
# - PKG_DBDIR is expanded and prefixed with CROSS_DESTDIR
# - DESTDIR support is required
#
# _CROSS_DESTDIR is set for internal use to avoid conditionalising
# the use.
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
. if defined(TARGET_ARCH)
MACHINE_ARCH= ${TARGET_ARCH}
. endif
CROSS_DESTDIR?= ${MAKEOBJDIR}/destdir.${MACHINE_ARCH}
. if !exists(${CROSS_DESTDIR}/usr/include/stddef.h)
PKG_FAIL_REASON+= "The cross-compiling root ${CROSS_DESTDIR:Q} is incomplete"
. else
_CROSS_DESTDIR= ${CROSS_DESTDIR}
. endif
.endif
# Depends on MACHINE_ARCH override above
.if ${OPSYS} == "NetBSD"
. if ${OBJECT_FMT} == "ELF" && \
(${MACHINE_GNU_ARCH} == "arm" || \
${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "m68k" || \
${MACHINE_ARCH} == "m68000" || \
${MACHINE_GNU_ARCH} == "sh" || \
${MACHINE_GNU_ARCH} == "shle" || \
${MACHINE_ARCH} == "sparc" || \
${MACHINE_ARCH} == "vax")
APPEND_ELF= elf
. endif
.endif
PKG_INSTALLATION_TYPES?= overwrite
# This is a whitespace-separated list of installation types supported
# by the package.
#
# *NOTE*: This variable *must* be set in the package Makefile *before*
# the inclusion of bsd.prefs.mk.
#
# Possible: any of: overwrite, pkgviews
# Default: overwrite
# Set the style of installation to be performed for the package. The
# funky make variable modifiers just select the first word of the value
# stored in the referenced variable.
#
.for _pref_ in ${PKG_INSTALLATION_PREFS}
. if !empty(PKG_INSTALLATION_TYPES:M${_pref_})
PKG_INSTALLATION_TYPE?= ${PKG_INSTALLATION_TYPES:M${_pref_}:S/^/_pkginsttype_/1:M_pkginsttype_*:S/^_pkginsttype_//}
. endif
.endfor
PKG_INSTALLATION_TYPE?= none
# if the system is IPv6-ready, compile with IPv6 support turned on.
.if empty(_OPSYS_HAS_INET6:M[nN][oO])
IPV6_READY= YES
.else
IPV6_READY= NO
.endif
LOCALBASE?= /usr/pkg
X11_TYPE?= modular
.if !empty(X11_TYPE:Mnative)
. if ${OPSYS} == "SunOS"
# On Solaris, we default to using OpenWindows for X11.
X11BASE?= /usr/openwin
. elif ${OPSYS} == "Cygwin" || ${OPSYS} == "IRIX" || ${OPSYS} == "OSF1" || ${OPSYS} == "HPUX"
X11BASE?= /usr
. elif !empty(MACHINE_PLATFORM:MDarwin-9.*-*) || \
!empty(MACHINE_PLATFORM:MDarwin-10.*-*) || \
!empty(MACHINE_PLATFORM:MDarwin-11.*-*)
X11BASE?= /usr/X11
. elif !empty(MACHINE_PLATFORM:MDarwin-??.*-*)
X11BASE?= /opt/X11
. elif ${OPSYS} == "NetBSD" && ${X11FLAVOUR:U} == "Xorg"
X11BASE?= /usr/X11R7
. elif exists(/usr/X11R7/lib/libX11.so)
X11BASE?= /usr/X11R7
. else
X11BASE?= /usr/X11R6
. endif
.endif
CROSSBASE?= ${LOCALBASE}/cross
.if defined(FIX_SYSTEM_HEADERS) && ${FIX_SYSTEM_HEADERS} == "yes" && \
!defined(BOOTSTRAP_PKG) && \
exists(../../pkgtools/compat_headers/buildlink3.mk)
. include "../../pkgtools/compat_headers/buildlink3.mk"
.endif
.if ${X11_TYPE} == "modular"
X11BASE= ${LOCALBASE}
.endif
X11PREFIX= ${LOCALBASE}
# Default directory for font encodings
.if ${X11_TYPE} == "modular"
X11_ENCODINGSDIR?= ${X11BASE}/share/fonts/X11/encodings
.else
X11_ENCODINGSDIR?= ${X11BASE}/lib/X11/fonts/encodings
.endif
IMAKE_MAN_SOURCE_PATH= man/man
IMAKE_MAN_SUFFIX= 1
IMAKE_LIBMAN_SUFFIX= 3
IMAKE_KERNMAN_SUFFIX= 4
IMAKE_FILEMAN_SUFFIX= 5
IMAKE_GAMEMAN_SUFFIX= 6
IMAKE_MISCMAN_SUFFIX= 7
IMAKE_MAN_DIR= ${IMAKE_MAN_SOURCE_PATH}1
IMAKE_LIBMAN_DIR= ${IMAKE_MAN_SOURCE_PATH}3
IMAKE_KERNMAN_DIR= ${IMAKE_MAN_SOURCE_PATH}4
IMAKE_FILEMAN_DIR= ${IMAKE_MAN_SOURCE_PATH}5
IMAKE_GAMEMAN_DIR= ${IMAKE_MAN_SOURCE_PATH}6
IMAKE_MISCMAN_DIR= ${IMAKE_MAN_SOURCE_PATH}7
IMAKE_MANNEWSUFFIX= ${IMAKE_MAN_SUFFIX}
IMAKE_MANINSTALL?= maninstall
DEPOT_SUBDIR?= packages
DEPOTBASE= ${LOCALBASE}/${DEPOT_SUBDIR}
# LINK_RPATH_FLAG publicly exports the linker flag used to set the
# run-time library search path.
#
.if defined(_OPSYS_LINKER_RPATH_FLAG)
LINKER_RPATH_FLAG= ${_OPSYS_LINKER_RPATH_FLAG}
.else
LINKER_RPATH_FLAG?= ${_LINKER_RPATH_FLAG}
.endif
# COMPILER_RPATH_FLAG publicly exports the compiler flag used to pass
# run-time library search path directives to the linker.
#
.if defined(_OPSYS_COMPILER_RPATH_FLAG)
COMPILER_RPATH_FLAG= ${_OPSYS_COMPILER_RPATH_FLAG}
.else
COMPILER_RPATH_FLAG?= ${_COMPILER_RPATH_FLAG}
.endif
COMPILER_INCLUDE_DIRS?= ${_OPSYS_INCLUDE_DIRS:U/usr/include}
COMPILER_LIB_DIRS?= ${_OPSYS_LIB_DIRS:U/usr/lib${LIBABISUFFIX} /lib${LIBABISUFFIX}}
SYSTEM_DEFAULT_RPATH?= ${_OPSYS_SYSTEM_RPATH:U/usr/lib}
# WHOLE_ARCHIVE_FLAG and NO_WHOLE_ARCHIVE_FLAG publically export the
# linker flags to extract all symbols from a static archive.
#
WHOLE_ARCHIVE_FLAG?= ${_OPSYS_WHOLE_ARCHIVE_FLAG}
NO_WHOLE_ARCHIVE_FLAG?= ${_OPSYS_NO_WHOLE_ARCHIVE_FLAG}
USE_TOOLS?= # empty
# Provide default values for TOOLs used by the top-level make.
USE_TOOLS+= [ awk dirname echo grep pwd sed test true
# These tools are used by the top-level make only in certain packages and
# should eventually be moved into those particular package Makefiles.
#
USE_TOOLS+= date tr
# These are tools used directly by bsd.prefs.mk and files included by
# bsd.prefs.mk.
#
USE_TOOLS+= awk:pkgsrc cut:pkgsrc echo:pkgsrc pwd:pkgsrc \
sed:pkgsrc tr:pkgsrc uname:pkgsrc
.include "${_PKGSRC_TOPDIR}/mk/tools/defaults.mk"
.if !defined(_PKGSRCDIR)
_PKGSRCDIR!= cd ${_PKGSRC_TOPDIR} && ${PWD_CMD}
MAKEFLAGS+= _PKGSRCDIR=${_PKGSRCDIR:Q}
.endif
PKGSRCDIR= ${_PKGSRCDIR}
DISTDIR?= ${PKGSRCDIR}/distfiles
PACKAGES?= ${PKGSRCDIR}/packages
TEMPLATES?= ${PKGSRCDIR}/templates
PATCHDIR?= ${.CURDIR}/patches
FILESDIR?= ${.CURDIR}/files
PKGDIR?= ${.CURDIR}
_PKGSRC_DEPS?= # empty
_BUILTIN_PKGS?= # empty
# If WRKOBJDIR is set, use that tree to build
.if defined(WRKOBJDIR)
BUILD_DIR?= ${WRKOBJDIR}/${PKGPATH}
.else
BUILD_DIR!= cd ${.CURDIR} && ${PWD_CMD}
.endif
# If OBJHOSTNAME is set, use first component of hostname in directory name.
# If OBJMACHINE is set, use ${MACHINE_ARCH} in the working directory name.
#
.if defined(OBJHOSTNAME)
. if !defined(_HOSTNAME)
_HOSTNAME!= ${UNAME} -n
MAKEFLAGS+= _HOSTNAME=${_HOSTNAME:Q}
. endif
WRKDIR_BASENAME?= work.${_HOSTNAME:C|\..*||}
MAKEFLAGS+= OBJHOSTNAME=${OBJHOSTNAME:Q}
.elif defined(OBJMACHINE)
WRKDIR_BASENAME?= work.${MACHINE_ARCH}
MAKEFLAGS+= OBJMACHINE=${OBJMACHINE:Q}
.else
WRKDIR_BASENAME?= work
.endif
WRKDIR?= ${BUILD_DIR}/${WRKDIR_BASENAME}
# There are many uses for a common log file, so define one that may be
# picked up and used by tools.mk, bsd.buildlink3.mk, etc.
#
WRKLOG?= ${WRKDIR}/.work.log
PKG_DEFAULT_OPTIONS?= # empty
PKG_OPTIONS?= # empty
# we want this *before* compiler.mk, so that compiler.mk paths override them
.if ${X11_TYPE} != "modular" && defined(USE_X11)
PREPEND_PATH+= ${X11BASE}/bin
.endif
PREPEND_PATH+= ${LOCALBASE}/bin
# Wrapper framework definitions
.include "wrapper/wrapper-defs.mk"
# Binary emulator framework definitions
.if defined(EMUL_PLATFORMS) && !empty(EMUL_PLATFORMS)
. include "emulator/emulator-vars.mk"
.endif
# System features framework
.include "features/features-vars.mk"
# Package system format definitions
.include "pkgformat/bsd.pkgformat-vars.mk"
# Make variable definitions cache
.include "bsd.makevars.mk"
# If MAKECONF is defined, then pass it down to all recursive make
# processes invoked by pkgsrc.
#
PKGSRC_MAKE_ENV+= ${MAKECONF:DMAKECONF=${MAKECONF:Q}}
RECURSIVE_MAKE= ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} ${MAKE}
_VARGROUPS+= dirs
_USER_VARS.dirs= DISTDIR LOCALBASE PACKAGES PKG_SYSCONFDIR WRKOBJDIR
_PKG_VARS.dirs= WRKSRC PATCHDIR FILESDIR PKGDIR
_SYS_VARS.dirs= WRKDIR DESTDIR PKG_SYSCONFBASEDIR
# List of 64bit operating systems with sizeof(int) != sizeof(void *).
# This can be used for software that is not 64bit clean.
#
# Keywords: ONLY_FOR_PLATFORM NOT_FOR_PLATFORM 64bit
#
LP64PLATFORMS= *-*-alpha *-*-sparc64 *-*-x86_64
.endif # BSD_PKG_MK

42
mk/bsd.utils.mk Normal file
View File

@@ -0,0 +1,42 @@
# $NetBSD: bsd.utils.mk,v 1.10 2013/05/09 23:37:25 riastradh Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and defines utility
# and otherwise miscellaneous variables and targets.
#
# DEPENDS_TYPE is used by the "show-depends-pkgpaths" target and specifies
# which class of dependencies to output. The special value "all" means
# to output every dependency.
#
DEPENDS_TYPE?= all
.if !empty(DEPENDS_TYPE:Mbuild) || !empty(DEPENDS_TYPE:Mall)
_ALL_DEPENDS+= ${BOOTSTRAP_DEPENDS} ${BUILD_DEPENDS} ${TOOL_DEPENDS}
.endif
.if !empty(DEPENDS_TYPE:Minstall) || !empty(DEPENDS_TYPE:Mpackage) || \
!empty(DEPENDS_TYPE:Mall)
_ALL_DEPENDS+= ${DEPENDS}
.endif
# _PKG_PATHS_CMD canonicalizes package paths so that they're relative to
# ${PKGSRCDIR} and also verifies that they exist within pkgsrc.
#
_PKG_PATHS_CMD= \
${PKGSRC_SETENV} ECHO=${TOOLS_ECHO:Q} PKGSRCDIR=${PKGSRCDIR:Q} \
PWD_CMD=${TOOLS_PWD_CMD:Q} TEST=${TOOLS_TEST:Q} \
${SH} ${.CURDIR}/../../mk/scripts/pkg_path
.PHONY: show-depends-dirs show-depends-pkgpaths
show-depends-dirs show-depends-pkgpaths:
@${_PKG_PATHS_CMD} ${_ALL_DEPENDS:C/^[^:]*://:O:u}
# _DEPENDS_WALK_CMD holds the command (sans arguments) to walk the
# dependency graph for a package.
#
# XXX Need to handle TOOL_DEPENDS/BUILD_DEPENDS split and cross-compilation.
#
_DEPENDS_WALK_MAKEFLAGS?= ${MAKEFLAGS}
_DEPENDS_WALK_CMD= \
${PKGSRC_SETENV} ECHO=${TOOLS_ECHO:Q} MAKE=${MAKE:Q} \
MAKEFLAGS=${_DEPENDS_WALK_MAKEFLAGS:Q} \
PKGSRCDIR=${PKGSRCDIR:Q} TEST=${TOOLS_TEST:Q} \
${AWK} -f ${.CURDIR}/../../mk/scripts/depends-depth-first.awk --

View File

@@ -0,0 +1,56 @@
# $NetBSD: bsd.build-vars.mk,v 1.8 2012/12/06 11:36:31 jperkin Exp $
#
# Package-settable variables:
#
# BUILD_DIRS is the list of directories in which to perform the build
# process. If the directories are relative paths, then they
# are assumed to be relative to ${WRKSRC}.
#
# MAKE_ENV is the shell environment that is exported to the make
# process.
#
# MAKE_FLAGS is a list of arguments that is pass to the make process.
#
# MAKE_FILE is the path to the makefile that is processed by the make
# executable. If the path is relative, then it is assumed to
# be relative to each directory listed in BUILD_DIRS.
#
# System-provided variables:
#
# MAKE_PROGRAM is the path to the make executable that is run to
# process the source makefiles. See mk/tools/make.mk.
#
_VARGROUPS+= build-vars
_USER_VARS.build-vars= # none
_PKG_VARS.build-vars= BUILD_DIRS MAKE_ENV MAKE_PROGRAM MAKE_FLAGS MAKE_FILE NO_BUILD
BUILD_DIRS?= ${CONFIGURE_DIRS}
MAKE_ENV?= # empty
MAKE_FLAGS?= # empty
MAKE_FILE?= Makefile
MAKE_ENV+= ${ALL_ENV}
MAKE_ENV+= ${NO_EXPORT_CPP:D:UCPP=${CPP:Q}}
MAKE_ENV+= LINK_ALL_LIBGCC_HACK=${LINK_ALL_LIBGCC_HACK:Q}
MAKE_ENV+= LOCALBASE=${LOCALBASE:Q}
MAKE_ENV+= NO_WHOLE_ARCHIVE_FLAG=${NO_WHOLE_ARCHIVE_FLAG:Q}
MAKE_ENV+= WHOLE_ARCHIVE_FLAG=${WHOLE_ARCHIVE_FLAG:Q}
MAKE_ENV+= X11BASE=${X11BASE:Q}
MAKE_ENV+= X11PREFIX=${X11PREFIX:Q}
MAKE_ENV+= PKGMANDIR=${PKGMANDIR:Q}
MAKE_ENV+= PKGINFODIR=${PKGINFODIR:Q}
MAKE_ENV+= PKGGNUDIR=${PKGGNUDIR:Q}
# Provide a consistent environment for packages using (Net)BSD-style
# Makefiles.
#
MAKE_ENV+= MAKECONF=${PKGMAKECONF:U/dev/null}
MAKE_ENV+= OBJECT_FMT=${OBJECT_FMT:Q}
MAKE_ENV+= ${USETOOLS:DUSETOOLS=${USETOOLS:Q}}
# Add these bits to the environment used when invoking the recursive make
# processes for build-related phases.
#
PKGSRC_MAKE_ENV+= PATH=${PATH:Q}
PKGSRC_MAKE_ENV+= USE_DESTDIR=${USE_DESTDIR:Q}

56
mk/build/bsd.build.mk Normal file
View File

@@ -0,0 +1,56 @@
# $NetBSD: bsd.build.mk,v 1.11 2008/02/07 21:36:13 rillig Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and provides all
# variables and targets related to building sources for a package.
#
# The following are the "public" targets provided by this module:
#
# build, test
#
# The following targets may be overridden in a package Makefile:
#
# pre-build, do-build, post-build
# pre-test, do-test, post-test
#
# Package-settable variables:
#
# NO_BUILD
# When defined, the whole build phase is skipped. That includes
# any substitutions that have one of {pre,do,post}-build as their
# SUBST_STAGE.
#
_COOKIE.build= ${WRKDIR}/.build_done
_COOKIE.test= ${WRKDIR}/.test_done
######################################################################
### build (PUBLIC)
######################################################################
### build is a public target to build the sources for the package.
###
.PHONY: build
.if !defined(NO_BUILD)
. include "build.mk"
.elif !target(build)
. if exists(${_COOKIE.build})
build:
@${DO_NADA}
. elif defined(_PKGSRC_BARRIER)
build: configure build-cookie pkginstall
. else
build: barrier
. endif
.endif
.include "test.mk"
######################################################################
### build-cookie (PRIVATE)
######################################################################
### build-cookie creates the "build" cookie file.
###
.PHONY: build-cookie
build-cookie:
${RUN}${TEST} ! -f ${_COOKIE.build} || ${FALSE}
${RUN}${MKDIR} ${_COOKIE.build:H}
${RUN}${ECHO} ${PKGNAME} > ${_COOKIE.build}

189
mk/build/build.mk Normal file
View File

@@ -0,0 +1,189 @@
# $NetBSD: build.mk,v 1.21 2012/05/27 14:32:29 cheusov Exp $
#
# This file defines what happens in the build phase, excluding the
# self-test, which is defined in test.mk.
#
# Public targets for developers:
#
# build-env:
# Runs an interactive shell (BUILD_ENV_SHELL) in the environment
# that is used for building the package.
#
# Package-settable variables:
#
# BUILD_MAKE_FLAGS is the list of arguments that is passed to the make
# process, in addition to the usual MAKE_FLAGS.
#
# BUILD_TARGET is the target from ${MAKE_FILE} that should be invoked
# to build the sources.
#
# MAKE_JOBS_SAFE
# Whether the package supports parallel builds. If set to yes,
# at most MAKE_JOBS jobs are carried out in parallel. The default
# value is "yes", and packages that don't support it must
# explicitly set it to "no".
#
# Keywords: parallel
#
# Variables defined in this file:
#
# BUILD_MAKE_CMD
# This command sets the proper environment for the build phase
# and runs make(1) on it. It takes a list of make targets and
# flags as argument.
#
# See also:
# mk/build/test.mk
#
# Keywords: build make
_VARGROUPS+= build
_USER_VARS.build= MAKE_JOBS BUILD_ENV_SHELL
_PKG_VARS.build= MAKE_ENV MAKE_FLAGS BUILD_MAKE_FLAGS BUILD_TARGET MAKE_JOBS_SAFE
_SYS_VARS.build= BUILD_MAKE_CMD
BUILD_MAKE_FLAGS?= # none
BUILD_TARGET?= all
BUILD_MAKE_CMD= \
${PKGSRC_SETENV} ${MAKE_ENV} \
${MAKE_PROGRAM} ${_MAKE_JOBS} \
${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
-f ${MAKE_FILE}
.if defined(MAKE_JOBS_SAFE) && !empty(MAKE_JOBS_SAFE:M[nN][oO])
_MAKE_JOBS= # nothing
.elif defined(MAKE_JOBS)
_MAKE_JOBS= -j${MAKE_JOBS}
.endif
######################################################################
### build (PUBLIC)
######################################################################
### build is a public target to build the sources from the package.
###
_BUILD_TARGETS+= check-vulnerable
_BUILD_TARGETS+= configure
_BUILD_TARGETS+= acquire-build-lock
_BUILD_TARGETS+= ${_COOKIE.build}
_BUILD_TARGETS+= release-build-lock
_BUILD_TARGETS+= pkginstall
.PHONY: build
.if !target(build)
. if exists(${_COOKIE.build})
build:
@${DO_NADA}
. elif defined(_PKGSRC_BARRIER)
build: ${_BUILD_TARGETS}
. else
build: barrier
. endif
.endif
.PHONY: acquire-build-lock release-build-lock
acquire-build-lock: acquire-lock
release-build-lock: release-lock
.if exists(${_COOKIE.build})
${_COOKIE.build}:
@${DO_NADA}
.else
${_COOKIE.build}: real-build
.endif
######################################################################
### rebuild (PUBLIC)
######################################################################
### rebuild is a special target to re-run the build target.
###
.PHONY: rebuild
rebuild: build-clean
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} build
######################################################################
### build-clean (PRIVATE)
######################################################################
### build-clean removes the state files for the "build" and
### later phases so that the "build" target may be re-invoked.
###
.PHONY: build-clean
build-clean: install-clean _package-clean
${RUN} ${RM} -f ${_COOKIE.build}
######################################################################
### real-build (PRIVATE)
######################################################################
### real-build is a helper target onto which one can hook all of the
### targets that do the actual building of the sources.
###
_REAL_BUILD_TARGETS+= build-check-interactive
_REAL_BUILD_TARGETS+= build-message
_REAL_BUILD_TARGETS+= build-vars
_REAL_BUILD_TARGETS+= pre-build-checks-hook
_REAL_BUILD_TARGETS+= pre-build
_REAL_BUILD_TARGETS+= do-build
_REAL_BUILD_TARGETS+= post-build
_REAL_BUILD_TARGETS+= build-cookie
_REAL_BUILD_TARGETS+= error-check
.PHONY: real-build
real-build: ${_REAL_BUILD_TARGETS}
.PHONY: build-message
build-message:
@${PHASE_MSG} "Building for ${PKGNAME}"
######################################################################
### build-check-interactive (PRIVATE)
######################################################################
### build-check-interactive checks whether we must do an interactive
### build or not.
###
build-check-interactive:
.if !empty(INTERACTIVE_STAGE:Mbuild) && defined(BATCH)
@${ERROR_MSG} "The build stage of this package requires user interaction"
@${ERROR_MSG} "Please build manually with:"
@${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} build\""
${RUN} ${FALSE}
.else
@${DO_NADA}
.endif
######################################################################
### pre-build, do-build, post-build (PUBLIC, override)
######################################################################
### {pre,do,post}-build are the heart of the package-customizable
### build targets, and may be overridden within a package Makefile.
###
.PHONY: pre-build do-build post-build
.if !target(do-build)
do-build:
. for _dir_ in ${BUILD_DIRS}
${RUN}${_ULIMIT_CMD} \
cd ${WRKSRC} && cd ${_dir_} && \
${BUILD_MAKE_CMD} ${BUILD_TARGET}
. endfor
.endif
.if !target(pre-build)
pre-build:
@${DO_NADA}
.endif
.if !target(post-build)
post-build:
@${DO_NADA}
.endif
BUILD_ENV_SHELL?= ${SH}
.if defined(_PKGSRC_BARRIER)
build-env: .PHONY configure
@${STEP_MSG} "Entering the build environment for ${PKGNAME}"
${RUN}${_ULIMIT_CMD} \
cd ${WRKSRC} && ${PKGSRC_SETENV} ${MAKE_ENV} ${BUILD_ENV_SHELL}
.else
build-env: barrier
.endif

185
mk/build/test.mk Normal file
View File

@@ -0,0 +1,185 @@
# $NetBSD: test.mk,v 1.18 2012/05/27 14:32:29 cheusov Exp $
#
# After the "build" phase, many packages provide some sort of self-test
# that can be run on the not-yet installed package. To enable these
# tests, the package must define TEST_TARGET or override the do-test
# target. Additionally, the pkgsrc user must define PKGSRC_RUN_TEST.
#
# User-settable variables:
#
# PKGSRC_RUN_TEST
# (See defaults/mk.conf)
#
# Package-settable variables:
#
# TEST_TARGET is the name of the ${MAKE} target, provided by the
# package, which enables the tests to be executed
#
# TEST_DIRS is the list of directories in which to run the tests.
# If the directories are relative paths, then they are
# assumed to be relative to ${WRKSRC}.
#
# TEST_ENV is the shell environment that is exported to the make
# process.
#
# TEST_MAKE_FLAGS is the list of arguments that is passed to the make
# process, in addition to the usual MAKE_FLAGS.
#
# Variables defined by this file:
#
# TEST_MAKE_CMD
# This command sets the proper environment for the test phase
# and runs make(1) on it. It takes a list of make targets and
# flags as argument.
#
# See also:
# mk/build/build.mk
#
# Keywords: test check
#
_VARGROUPS+= test
_USER_VARS.test= PKGSRC_RUN_TEST
_PKG_VARS.test= TEST_DIRS TEST_ENV TEST_MAKE_FLAGS MAKE_FILE TEST_TARGET
TEST_DIRS?= ${BUILD_DIRS}
TEST_ENV+= ${MAKE_ENV}
TEST_MAKE_FLAGS?= # none
TEST_MAKE_CMD= \
${PKGSRC_SETENV} ${TEST_ENV} \
${MAKE_PROGRAM} ${MAKE_FLAGS} ${TEST_MAKE_FLAGS} \
-f ${MAKE_FILE}
######################################################################
### test (PUBLIC)
######################################################################
### build is a public target to build the sources from the package.
###
_TEST_TARGETS+= check-vulnerable
_TEST_TARGETS+= build
_TEST_TARGETS+= acquire-test-lock
_TEST_TARGETS+= ${_COOKIE.test}
_TEST_TARGETS+= release-test-lock
.PHONY: test
.if !target(test)
. if exists(${_COOKIE.test})
test:
@${DO_NADA}
. elif defined(_PKGSRC_BARRIER)
test: ${_TEST_TARGETS}
. else
test: barrier
. endif
.endif
.PHONY: acquire-test-lock release-test-lock
acquire-test-lock: acquire-lock
release-test-lock: release-lock
.if exists(${_COOKIE.test})
${_COOKIE.test}:
@${DO_NADA}
.else
${_COOKIE.test}: real-test
.endif
######################################################################
### retest (PUBLIC)
######################################################################
### retest is a special target to re-run the test target.
###
.PHONY: retest
retest: test-clean
${RUN} ${RECURSIVE_MAKE} ${MAKEFLAGS} test
######################################################################
### real-test (PRIVATE)
######################################################################
### real-test is a helper target onto which one can hook all of the
### targets that do the actual test of the built objects.
###
_REAL_TEST_TARGETS+= test-check-interactive
_REAL_TEST_TARGETS+= test-message
_REAL_TEST_TARGETS+= pre-test
_REAL_TEST_TARGETS+= do-test
_REAL_TEST_TARGETS+= post-test
_REAL_TEST_TARGETS+= test-cookie
_REAL_TEST_TARGETS+= error-check
.PHONY: real-test
real-test: ${_REAL_TEST_TARGETS}
.PHONY: test-message
test-message:
@${PHASE_MSG} "Testing for ${PKGNAME}"
######################################################################
### test-check-interactive (PRIVATE)
######################################################################
### test-check-interactive checks whether we must do an interactive
### test or not.
###
test-check-interactive:
.if !empty(INTERACTIVE_STAGE:Mtest) && defined(BATCH)
@${ERROR_MSG} "The test stage of this package requires user interaction"
@${ERROR_MSG} "Please test manually with:"
@${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} test\""
${RUN} ${FALSE}
.else
@${DO_NADA}
.endif
######################################################################
### pre-test, do-test, post-test (PUBLIC, override)
######################################################################
### {pre,do,post}-test are the heart of the package-customizable
### test targets, and may be overridden within a package Makefile.
###
.PHONY: pre-test do-test post-test
.if !target(do-test)
. if defined(TEST_TARGET) && !empty(TEST_TARGET)
do-test:
. for _dir_ in ${TEST_DIRS}
${RUN}${_ULIMIT_CMD} \
cd ${WRKSRC} && cd ${_dir_} && \
${TEST_MAKE_CMD} ${TEST_TARGET}
. endfor
. else
do-test:
@${DO_NADA}
. endif
.endif
.if !target(pre-test)
pre-test:
@${DO_NADA}
.endif
.if !target(post-test)
post-test:
@${DO_NADA}
.endif
######################################################################
### test-cookie (PRIVATE)
######################################################################
### test-cookie creates the "test" cookie file.
###
.PHONY: test-cookie
test-cookie:
${RUN}${TEST} ! -f ${_COOKIE.test} || ${FALSE}
${RUN}${MKDIR} ${_COOKIE.test:H}
${RUN}${ECHO} ${PKGNAME} > ${_COOKIE.test}
######################################################################
### test-clean (PRIVATE)
######################################################################
### test-clean removes the state files for the "test" and
### later phases so that the "test" target may be re-invoked.
###
.PHONY: test-clean
test-clean:
${RUN} ${RM} -f ${_COOKIE.test}

View File

@@ -0,0 +1,77 @@
$NetBSD: BUILDLINK3_DG,v 1.7 2005/03/24 17:46:01 tv Exp $
0 Developer's guide to buildlink3
=================================
This is a tutorial for pkgsrc developers to understand and to use the
buildlink3 framework in pkgsrc.
1 Changes between buildlink2 and buildlink3
===========================================
The buildlink3 framework is a evolutionary descendant of the
buildlink2 framework that does a better job of adhering to the
fundamental buildlink principle: only allow the software build
process to see what we choose to allow it to see.
1.1 Better behavior with libtool
================================
One of the biggest problems in buildlink2 is handling packages that
install libtool archive files for libraries that are also present in
the base system. buildlink3 is significantly better at this as it
more tightly controls where libtool can find libtool archives. One
side effect of this is that we no longer need to create fake libtool
archives to work around cases where the pkgsrc libraries were being
used instead of the system libraries if they shared the same name.
1.2 New buildlink3.mk file structure
====================================
buildlink3.mk files have two major differences over buildlink2.mk
files. The first, most noticeable difference is that buildlink3.mk
generally don't contain a BUILDLINK_FILES definition. This is
because buildlink3 automatically determines which files to symlink
into ${BUILDLINK_DIR} by examining the PLIST of the installed package.
The second difference is that buildlink3.mk files keep track of how
"deep" we are in including buildlink3.mk files, and only creates
dependencies on packages encountered at depth 1. This means that
packages that want to add a dependency must directly include the
buildlink3.mk file for that dependency.
1.3 Support for pkgviews
========================
When building pkgviews packages, buildlink3 doesn't symlink files
into ${BUILDLINK_DIR} since it can safely refer to only a specific
package's files by passing the appropriate -I<dir> and -L<dir> flags
to the compiler, where <dir> points to a location in the package's
depot directory. When building "overwrite" packages, buildlink3 will
act and feel very much like buildlink2 but with more advanced wrapper
scripts, and there are provisions for allowing an "overwrite" package
to build against the viewed instance of a depoted package.
2 Troubleshooting
=================
Q1: Where can I see the actual command executed by the wrapper
scripts?
A1: You should examine the contents of the ${WRKDIR}/.work.log file.
The lines preceded with [*] are the commands that are intercepted
by the wrapper scripts, and the lines preceded with <.> are the
commands that are executed by the wrapper scripts.
Q2: Why can't I check the values of variables set by the buildlink3
framework using 'make show-var VARNAME=...'?
A2: Some variables are only defined for a subset of the package build
phases. Try instead:
make show-var PKG_PHASE=wrapper VARNAME=...

222
mk/buildlink3/PKGVIEWS_UG Normal file
View File

@@ -0,0 +1,222 @@
$NetBSD: PKGVIEWS_UG,v 1.4 2007/10/07 12:59:13 kano Exp $
0 User's Guide to pkgviews
==========================
This is a tutorial for pkgsrc users who wish to experiment with the
new "pkgviews" implementation in pkgsrc. More information about
pkgviews may be found in pkgsrc/mk/buildlink3/README. That document
also explains why you might want to use pkgviews. Some reasons
include:
* fully dynamic PLISTs
* multiple version of the same package can co-exist
* no or non-fatal conflicting packages
0.1 CAVEAT (USE AT YOUR OWN RISK!)
==================================
Pkgviews is *completely experimental* at this point in time. Bug
reports on pkgviews will be treated with a fairly low priority by the
general pkgsrc developers, though I may personally be more responsive.
However, the major thrust of the next several weeks of pkgsrc
development for me will revolve around testing and integrating the
buildlink3 framework into pkgsrc and deprecating buildlink2. Any
work on pkgviews during that time is strictly happenstance.
0.1 Preparing your system to use pkgviews
=========================================
You will need to start with a clean system to use pkgviews. Depoted
packages, a.k.a "pkgviews" packages (packages that are built using
pkgviews) cannot depend on non-depoted packages, a.k.a. "overwrite"
packages, although the reverse is possible. If you have _any_
packages installed, you will need to pkg_delete them before you can
start building depoted packages. In fact, it's best to completely
nuke /usr/pkg (or wherever you choose for your ${LOCALBASE}) as
pkgviews manages all of its own directories.
Next you will need to add the following line to /etc/mk.conf:
PKG_INSTALLATION_PREFS= pkgviews overwrite
This creates pkgviews packages instead of overwrite packages for any
packages that support it. The packages that do support pkgviews
can be identified by searching the package Makefile for the
following line:
PKG_INSTALLATION_TYPES= overwrite pkgviews
0.2 Installing your first pkgviews package
==========================================
The first package you will need to install is pkgsrc/pkgtools/digest.
===> Checking for vulnerabilities in digest-20021220
===> Extracting for digest-20021220
===> Checking for vulnerabilities in digest-20021220
===> Patching for digest-20021220
===> Overriding tools for digest-20021220
===> Buildlinking for digest-20021220
===> Configuring for digest-20021220
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... i386-unknown-netbsdelf1.6.2.
checking host system type... i386--netbsdelf
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
===> Building for digest-20021220
cc -DHAVE_CONFIG_H -I. -I. -DHOST=\"i386--netbsdelf\" -DVERSION=\"20021220\" -O2 -mcpu=pentiumpro -c bits.c -o bits.o
...
cc -O2 -mcpu=pentiumpro -o digest digest.o md5c.o rmd160.o rmd160hl.o sha2.o sha2hl.o md5hl.o sha1.o sha1hl.o
=> Fixing buildlink references in files-to-be-installed.
===> Installing for digest-20021220
===> Becoming root@blossom.hq.williamlam.com to install digest.
sudo /bin/sh ./mkinstalldirs /usr/pkg/packages/digest-20021220/bin
mkdir /usr/pkg/packages/digest-20021220/bin
install -c -s -o root -g wheel -m 555 digest /usr/pkg/packages/digest-20021220/bin/digest
/bin/sh ./mkinstalldirs /usr/pkg/packages/digest-20021220/man/man1
mkdir /usr/pkg/packages/digest-20021220/man
mkdir /usr/pkg/packages/digest-20021220/man/man1
install -c -o root -g wheel -m 444 digest.1 /usr/pkg/packages/digest-20021220/man/man1/digest.1
===> Registering installation for digest-20021220
===> Building views for digest-20021220
=> Performing package view clash check for digest-20021220 in standard view
=> Performing package view overwrite check for digest-20021220 in standard view
=> Linking package into standard view
Notice in the transcript that the digest package has been installed
into /usr/pkg/packages/digest-20021220 and then subsequently linked
into the "standard view". The standard view is simply /usr/pkg, which
means that the digest executable is accessible as /usr/pkg/bin/digest.
0.3 The contents of /usr/pkg (${LOCALBASE})
===========================================
There is a directory /usr/pkg/packages that contains all of the
depoted packages. The contents of /usr/pkg/packages after installing
digest are:
/usr/pkg/packages/digest-20021220/+BUILD_INFO
/usr/pkg/packages/digest-20021220/+BUILD_VERSION
/usr/pkg/packages/digest-20021220/+COMMENT
/usr/pkg/packages/digest-20021220/+CONTENTS
/usr/pkg/packages/digest-20021220/+DESC
/usr/pkg/packages/digest-20021220/+SIZE_ALL
/usr/pkg/packages/digest-20021220/+SIZE_PKG
/usr/pkg/packages/digest-20021220/+VIEWS
/usr/pkg/packages/digest-20021220/bin/digest
/usr/pkg/packages/digest-20021220/man/man1/digest.1
Note that all of the files related to the package, including the
package metadata files used by the pkg_* tools, are stored in the
"depot directory" for digest (/usr/pkg/packages/digest-20021220).
The digest package was also linked into the standard view. Looking
inside /usr/pkg shows us the following symlinks:
/usr/pkg/bin/digest -> /usr/pkg/packages/digest-20021220/bin/digest
/usr/pkg/man/man1/digest.1 -> /usr/pkg/packages/digest-20021220/man/man1/digest.1
Since digest is present in /usr/pkg/bin, it can be used as always
without any changes needed by the typical user with /usr/pkg/bin in
his PATH, and "man digest" will continue to work as expected.
0.4 Creating new views
======================
The following commands will install both pkgsrc/www/lynx and
pkgsrc/www/lynx-current onto the same system using pkgviews:
cd /usr/pkgsrc/www/lynx; make install
cd /usr/pkgsrc/www/lynx-current; make install PKGVIEWS=devel
The stable version of lynx (2.8.4.1nb2) is linked into the standard
view, while the -current version of lynx (2.8.5.0.7nb3) is linked into
the "devel" view. The lynx-related files in /usr/pkg are:
/usr/pkg/bin/lynx -> /usr/pkg/packages/lynx-2.8.4.1nb2/bin/lynx
/usr/pkg/man/man1/lynx.1 -> /usr/pkg/packages/lynx-2.8.4.1nb2/man/man1/lynx.1
/usr/pkg/share/locale/cs/LC_MESSAGES/lynx.mo -> ...
...
/usr/pkg/devel/bin/lynx -> /usr/pkg/packages/lynx-2.8.5.0.7nb3/bin/lynx
/usr/pkg/devel/man/man1/lynx.1 -> /usr/pkg/packages/lynx-2.8.5.0.7nb3/man/man1/lynx.1
/usr/pkg/devel/share/locale/cs/LC_MESSAGES/lynx.mo -> ...
...
Note that the files for pkgsrc/www/lynx have been symlinked into
/usr/pkg as usual, but the files for pkgsrc/www/lynx-current have been
symlinked into the "devel" subdirectory of /usr/pkg. The files in
in the "devel" view can be accessed by adding /usr/pkg/devel/bin to
the PATH and adding /usr/pkg/devel/man to MANPATH in the appropriate
place.
0.5 Managing views using pkg_* tools
====================================
Adding and removing package instances to and from views is always a
safe operation as the true package files are left untouched. All that
happens is that linkfarms are being added or removed, thus changes are
always easy to reverse.
Adding a depoted package into a view may be accomplished with:
pkg_view -w devel add gmake-3.80nb2
This adds the gmake-3.80nb2 package (already present on the system) to
the "devel" view. The "devel" view is created if it doesn't already
exist.
Removing a package from a view may be accomplished with either of the
following commands:
pkg_view -w devel delete gmake-3.80nb2
pkg_delete -K /usr/pkg/devel/.pkgdb gmake
Either of these will remove the gmake-3.80nb2 package from the "devel"
view if the package exists in the view.
Removing a package from the standard view may be accomplished with
either of the following commands
pkg_view delete gmake-3.80nb2
pkg_delete gmake
The latter one is recommended for speed.
0.6 Completely removing a package
=================================
Removing a depoted package from the system (removing it from all views
and removing the depot directory) is done with:
pkg_delete -K /usr/pkg/packages gmake-3.80nb2
If you know that only a single gmake is present on your system, then
you can specify "gmake" instead of the full package name to
pkg_delete(1). However, I recommend being explicit about the package
you are removing to avoid any surprises.
0.6 Where to learn more about pkgviews
======================================
There are several shell environment variables that may be set to
affect the default behaviour of the pkg_* tools. Please read the
pkg_view(1) man page for more information.
For a more complete understanding of the motivations and principles
behind pkgviews, the following paper by Alistair Crooks is highly
recommended:
http://www.NetBSD.org/docs/software/pkgviews.pdf

140
mk/buildlink3/README Normal file
View File

@@ -0,0 +1,140 @@
$NetBSD: README,v 1.7 2007/10/07 12:59:13 kano Exp $
0 Package Views
===============
Package views is a pkgsrc technology that supports building and
installing multiple versions of the same software such that they
co-exist on a single system. Individual packages are installed into
their own directory tree and their files are symlinked into "views".
Users can choose amongst different software collections provided by
different views by appropriately setting shell environment variables,
e.g., PATH, MANPATH, etc.
Package views is similar in spirit to the Encap Package Management
System, the GNU Stow Project, and the Carnegie Mellon University Depot
Configuration Management system:
http://www.encap.org/
http://www.gnu.org/software/stow/stow.html
http://asg.web.cmu.edu/andrew2/depot/
However, these projects have a philosophy of "install anywhere, use in
one place", whereas package views departs from that model with a
philosophy that can roughly be summarized as "install in one place,
use anywhere".
0.1 A short history of package views
====================================
Package views was proposed as a solution to the problem of not being
able to install multiple versions of the same software simultaneously
via pkgsrc. Alistair Crooks presented a paper on package views at
EuroBSDCon in November 2002 that described the work he did on the
"pkgviews" branch of pkgsrc where he implemented his ideas. The paper
is highly-recommended reading for a more complete understanding of
package views principles and is available at:
http://www.NetBSD.org/docs/software/pkgviews.pdf
Unfortunately, Alistair ran out of time to devote to integrating his
work into the main pkgsrc branch. The code he developed languished on
the "pkgviews" branch for over a year, and in the meantime much code
was added to pkgsrc that increased the complexity and the capabilities
of pkgsrc, including buildlink2, which conflicted with Alistair's
implementation of package views. In September 2003, Johnny Lam
integrated the functionality on the pkgviews branch into modern
pkgsrc. As part of the integration, a new buildlink3 framework was
created so that the ability to isolate builds from differences in
the environment wouldn't be lost.
0.2 Package views terminology
=============================
The terminology for packages in the package views world is as
follows: a "pkgviews" package is a package that has been converted to
build and install using package views. An "overwrite" package is one
that hasn't. A "depoted" package describes a pkgviews package
installed into /usr/pkg/packages in its "depot" directory. A package
"instance" in a view describes a depoted package symlinked into a
view.
0.3 What's been done
====================
The pkg_install tools have been enhanced to handle both binary depoted
packages and binary "overwrite" packages. The pkgsrc internals have
been modified to allow building and installing depoted packages and to
automatically add a depoted package in the default view.
"Overwrite" packages shouldn't be affected by the changes, and can be
freely mixed with pkgviews packages.
Packages that have been converted to use "pkgviews" should add the
following line to their Makefiles:
PKG_INSTALLATION_TYPES= overwrite pkgviews
PKG_INSTALLATION_TYPES can also just be one value or the other to
explicitly note that the package only supports that one type of
installation style. Users may add the following line to /etc/mk.conf:
PKG_INSTALLATION_PREFS= pkgviews overwrite
to note that they prefer building using pkgviews if the package
supports it, otherwise to build using the "overwrite" installation
style. However, users should not change PKG_INSTALLATION_PREFS from
the default value unless they're sure that they want to start
migrating their package system over to using pkgviews. The default,
"overwrite pkgviews", will cause all packages to build using the
"overwrite" installation style.
Some highlight of pkgviews packages include:
* fully dynamic PLISTs
* multiple versions of the same package can co-exist
0.4 buildlink3 pkgsrc build framework
=====================================
A new buildlink3 framework that takes advantage of depoted packages
has been added to pkgsrc as part of the package views changes.
Buildlink3 uses wrapper scripts much like buildlink2. However, when
building pkgviews packages, it doesn't symlink files into
${BUILDLINK_DIR} since it can safely refer to only a specific
package's files by passing the appropriate -I<dir> and -L<dir> flags
to the compiler, where <dir> points to a location in the package's
depot directory. When building "overwrite" packages, buildlink3 will
act and feel very much like buildlink2 but with more advanced wrapper
scripts, and there are provisions for allowing an "overwrite" package
to build against the viewed instance of a depoted package. The
implementation currently allows "overwrite" to depend on either
"overwrite" or pkgviews packages, but pkgviews packages are restricted
to only being able to depend on other pkgviews packages.
0.5 Future Work
===============
There may be some way around the problem of pkgviews packages not
being able to depend on "overwrite" packages. That's the only thing
standing in the way between allowing an arbitrary package to be built
using either installation style and working seamlessly with any other
package. The problem has to do with proper handling of metadata in
the +REQUIRED_BY and +CONTENTS files that are split in two separate
places. One possible route to a solution is that for each overwrite
package, we can symlink /usr/pkg/packages/<pkg> -> /var/db/pkg/<pkg>.
This allows depoted packages to record themselves directly in the
+REQUIRED_BY files of "overwrite" packages. If a user happens to run
pkg_delete -K /usr/pkg/packages <overwrite_pkg>
then it still uses the correct +CONTENTS, +INSTALL, and +DEINSTALL
scripts, so the package will still remove itself properly from
/usr/pkg. However, there are some remaining issues with properly
removing both the /var/db/pkg/<pkg> directory and the
/usr/pkg/packages/<pkg> symlink, so the deletion won't be completely
clean until this issue can be resolved.

51
mk/buildlink3/TODO Normal file
View File

@@ -0,0 +1,51 @@
$NetBSD: TODO,v 1.5 2004/02/17 08:59:44 jlam Exp $
TODO items
==========
* Make the error where pkgviews packages depend on overwrite packages
less obfuscated.
* Teach linkfarm to do tree-folding a la GNU stow.
* Correct handling of pkgconfig *.pc files.
Package views integration plan:
==============================
(1) Modify pkgsrc internals (bsd.pkg.mk & friends) to build and
install depoted packages if PKG_INSTALLATION_TYPE is set to
"pkgviews" in the package Makefile, and to add the depoted
package to the default view. The depoted package will include
all of its metadata files in the depot directory, and we rely
on pkg_view to copy the metadata files into /var/db/pkg as
part of adding the package to the default view. We only
support the default view. Depoted packages will install into
${LOCALBASE}/packages and the default view will be through
${LOCALBASE} for all packages.
Using this infrastructure, depoted packages that have been added to
the default view should look and feel like a non-depoted package in
all respects, down to what you find in /var/db/pkg/${PKGNAME}, so
non-depoted packages can depend on depoted packages without change.
(2) Migrate non-USE_X11BASE and non-USE_IMAKE packages to set
PKG_INSTALLATION_TYPE to "pkgviews". Depoted packages can only
depend on other depoted packages. A depoted package will have
<deppkg_dir>/lib and ${LOCALBASE}/lib in the run-time library
search path (-Wl,-R*) so that wildcard dependencies on library
packages will still work (so long as the major number of the shlib
hasn't increased).
At this point, all packages in pkgsrc except for those that define
USE_X11BASE or USE_IMAKE will be depoted.
(3) Make xpkgwedge the default for pkgsrc. It would be nice to
enhance xpkgwedge in some way so that a package could be compiled
with the correct defaults for finding app-defaults files without
having the user fiddle with environment variables.
This is a flag day change and will require bumping the PKGREVISIONs
for every single USE_X11BASE and USE_IMAKE package and all packages
that depend on them.
(4) Migrate the USE_X11BASE and USE_IMAKE packages to set
PKG_INSTALLATION_TYPE to "pkgviews".

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,156 @@
# $NetBSD: bsd.builtin.mk,v 1.11 2010/05/19 09:12:15 sbd Exp $
#
# Copyright (c) 2004-2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Include this file to set the value of USE_BUILTIN.<pkg> for each
# package listed in BUILDLINK_TREE. Note that this file may
# indirectly add additional values to BUILDLINK_TREE.
#
# For each package which may duplicate built-in software on the system,
# a builtin.mk file should be created. The only requirements of a
# builtin.mk file are:
#
# (1) It should set USE_BUILTIN.<pkg> to either "yes" or "no" after it
# is included.
# (2) It should *not* override any USE_BUILTIN.<pkg> which is already
# set before the builtin.mk file is included.
# (3) It should be written to allow multiple inclusion.
#
# An example package builtin.mk file is:
#
# -------------8<-------------8<-------------8<-------------8<-------------
# BUILTIN_PKG:= wibble
# .include "../../mk/buildlink3/bsd.builtin.mk"
#
# ###
# ### Determine if there is a built-in implementation of the package and
# ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
# ###
# .if !defined(IS_BUILTIN.wibble)
# IS_BUILTIN.wibble= no
# .endif
# MAKEVARS+= IS_BUILTIN.wibble
#
# ###
# ### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
# ### a package name to represent the built-in package.
# ###
# .if !defined(BUILTIN_PKG.wibble) && \
# !empty(IS_BUILTIN.wibble:M[yY][eE][sS])
# BUILTIN_PKG.wibble= wibble-1.0
# .endif
# MAKEVARS+= BUILTIN_PKG.wibble
#
# ###
# ### Determine whether we should use the built-in implementation if it
# ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
# ###
# .if !defined(USE_BUILTIN.wibble)
# . if ${PREFER.wibble} == "pkgsrc"
# USE_BUILTIN.wibble= no
# . else
# USE_BUILTIN.wibble= ${IS_BUILTIN.wibble}
# . if defined(BUILTIN_PKG.wibble) && \
# !empty(IS_BUILTIN.wibble:M[yY][eE][sS])
# USE_BUILTIN.wibble= yes
# . for _dep_ in ${BUILDLINK_API_DEPENDS.wibble}
# . if !empty(USE_BUILTIN.wibble:M[yY][eE][sS])
# USE_BUILTIN.wibble!= \
# if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.wibble:Q}; then \
# ${ECHO} "yes"; \
# else \
# ${ECHO} "no"; \
# fi
# . endif
# . endfor
# . endif
# . endif
# .endif
# MAKEVARS+= USE_BUILTIN.wibble
#
# ###
# ### The section below only applies if we are not including this file
# ### solely to determine whether a built-in implementation exists.
# ###
# CHECK_BUILTIN.wibble?= no
# .if !empty(CHECK_BUILTIN.wibble:M[nN][oO])
# #
# # Here we place code that depends on whether USE_BUILTIN.wibble is
# # set to "yes" or "no".
# #
# .endif # CHECK_BUILTIN.wibble
# -------------8<-------------8<-------------8<-------------8<-------------
#
# Note the structure of the builtin.mk file: first we set IS_BUILTIN.<pkg>,
# then USE_BUILTIN.<pkg>, then we isolate code that depends on the whether
# USE_BUILTIN.<pkg> is "yes" or "no" in a region that is guarded by
# CHECK_BUILTIN.<pkg>. Package builtin.mk files aren't protected against
# multiple inclusion.
#
.include "../../mk/bsd.fast.prefs.mk"
.for _pkg_ in ${BUILTIN_PKG}
#
# Define PREFER.<pkg> to be either "pkgsrc" or "native" depending on
# whether to prefer the pkgsrc or native versions of software that's
# also part of the base system. Its value is determined from the
# user-settable values PREFER_PKGSRC and PREFER_NATIVE. Preferences are
# determined by the most specific instance of the package in either
# PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in neither
# or in both variables, then PREFER_PKGSRC has precedence over
# PREFER_NATIVE.
#
_BLTN_PREFER.${_pkg_}= pkgsrc
. if !empty(PREFER_NATIVE:M[yY][eE][sS])
_BLTN_PREFER.${_pkg_}= native
. endif
. if !empty(PREFER_PKGSRC:M[yY][eE][sS])
_BLTN_PREFER.${_pkg_}= pkgsrc
. endif
. if !empty(PREFER_NATIVE:M${_pkg_})
_BLTN_PREFER.${_pkg_}= native
. endif
. if !empty(PREFER_PKGSRC:M${_pkg_})
_BLTN_PREFER.${_pkg_}= pkgsrc
. endif
PREFER.${_pkg_}?= ${_BLTN_PREFER.${_pkg_}}
. if empty(_BUILTIN_PKGS:M${_pkg_})
_BUILTIN_PKGS+= ${_pkg_}
. endif
.endfor
.include "../../mk/buildlink3/find-libs.mk"
.include "../../mk/buildlink3/find-files.mk"

View File

@@ -0,0 +1,74 @@
# $NetBSD: buildcmd-libtool,v 1.1 2004/09/21 15:01:40 jlam Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
case $arg in
######################################################################
# Don't append empty arguments to the command line.
######################################################################
"")
;;
######################################################################
# Reduce command length by not appending options that we've already
# seen. Also, suppress consecutive repeated libraries.
######################################################################
-[DILR]*|-Wl,-R*|-Wl,-*,/*)
case $cmd in
*" "$arg|*" "$arg" "*)
;;
*)
shquote "$arg"; arg="$shquoted"
cmd="$cmd $arg"
;;
esac
;;
-l*)
case $libs in
*" "$arg)
;;
*)
shquote "$arg"; arg="$shquoted"
cmd="$cmd $arg"
;;
esac
;;
######################################################################
# Append $arg to $cmd to build up the command line to be executed.
######################################################################
*)
shquote "$arg"; arg="$shquoted"
cmd="$cmd $arg"
;;
esac

View File

@@ -0,0 +1,41 @@
# $NetBSD: cleanup-libtool,v 1.1 2004/09/21 15:01:40 jlam Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
libtool_fix_la="@_BLNK_LIBTOOL_FIX_LA@"
if $test -n "$lafile" && $test -f "$lafile"; then
. $libtool_fix_la
fi

View File

@@ -0,0 +1,60 @@
# $NetBSD: cmd-sink-libtool,v 1.4 2007/04/09 22:33:26 tron Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Empty out the command buffer and build up the command line in $cmd.
while ! queue_is_empty cmdbuf; do
pop_queue cmdbuf arg
$debug_log $wrapperlog " (cmd-sink-libtool) pop: $arg"
case $arg in
##############################################################
# If we're in "compile" mode, then don't add any linker options
# to the command line.
##############################################################
-L*|-l*|-Wl,*)
case $lt_mode in
link)
. $buildcmd
;;
*)
$debug_log $wrapperlog " (cmd-sink-libtool) drop: $arg"
;;
esac
;;
*)
. $buildcmd
;;
esac
done

101
mk/buildlink3/find-files.mk Normal file
View File

@@ -0,0 +1,101 @@
# $NetBSD: find-files.mk,v 1.8 2010/05/03 06:58:27 obache Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# This is a "subroutine" that can be included to detect the presence of
# files in the base system.
#
# The following variables must be defined before including this file:
#
# BUILTIN_FIND_FILES_VAR is a list of variables to define. These
# variables take the value of the path to the file that is
# "found".
#
# BUILTIN_FIND_FILES.<var> is the list of paths to files to find, in
# order, on the filesystem. The variable <var> is set to the
# first path "found" on the filesystem.
#
# Optionally, the following variables may also be defined:
#
# BUILTIN_FIND_GREP.<var> is a regular expression that must be
# matched within a file in order for the file to be considered
# "found". If it isn't defined, then we simply check for the
# existence of the file.
#
# After including this file, the following variables are defined:
#
# <var> is the first of the files listed in ${BUILTIN_FIND_FILES.<var>}
# that is "found", or else it is "__nonexistent__".
#
# An example use is:
#
# BUILTIN_FIND_FILES_VAR:= FOO BAR
#
# BUILTIN_FIND_FILES.FOO= /path1 /path2
# BUILTIN_FIND_GREP.FOO= \#define.*FOO
#
# BUILTIN_FIND_FILES.BAR= /path3 /path4
# .include "../../mk/buildlink3/builtin-files.mk"
#
.if empty(USE_TOOLS:Mecho)
USE_TOOLS+= echo
.endif
.if empty(USE_TOOLS:Mgrep)
USE_TOOLS+= grep
.endif
.for _var_ in ${BUILTIN_FIND_FILES_VAR}
. if !defined(${_var_})
${_var_}= __nonexistent__
. for _file_ in ${BUILTIN_FIND_FILES.${_var_}}
. if !empty(${_var_}:M__nonexistent__) && exists(${_file_})
. if !defined(BUILTIN_FIND_GREP.${_var_})
${_var_}= ${_file_}
. else
${_var_}!= \
if ${GREP} -q ${BUILTIN_FIND_GREP.${_var_}:Q} ${_file_:Q}; then \
${ECHO} ${_file_:Q}; \
else \
${ECHO} __nonexistent__; \
fi
. endif
. endif
. endfor
. endif
MAKEVARS+= ${_var_}
.endfor

View File

@@ -0,0 +1,77 @@
# $NetBSD: find-libs.mk,v 1.11 2013/04/28 13:39:09 obache Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# This is a "subroutine" that can be included to detect the presence of
# libraries in the base system.
#
# The input variable is BUILDLINK_FIND_LIBS, which is a list of library
# names, e.g. ncurses, iconv, etc., that will be sought in the base
# system. BUILTIN_LIB_FOUND.<lib> is set to "yes" or "no" depending
# on the result of the search.
#
# An example use is:
#
# BUILDLINK_FIND_LIBS:= intl iconv
# .include "../../mk/buildlink3/find-libs.mk"
# # ${BUILTIN_LIB_FOUND.intl} and ${BUILTIN_LIB_FOUND.iconv} are now
# # either "yes" or "no".
#
.if empty(USE_TOOLS:Mecho)
USE_TOOLS+= echo
.endif
.if empty(USE_TOOLS:Mtest)
USE_TOOLS+= test
.endif
.for _lib_ in ${BUILTIN_FIND_LIBS}
. if !defined(BUILTIN_LIB_FOUND.${_lib_})
BUILTIN_LIB_FOUND.${_lib_}= no
. for _path_ in ${COMPILER_LIB_DIRS}
. if ${BUILTIN_LIB_FOUND.${_lib_}} == "no"
BUILTIN_LIB_FOUND.${_lib_}!= \
if ${TEST} "`${ECHO} ${_path_}/lib${_lib_}.*`" != "${_path_}/lib${_lib_}.*"; then \
${ECHO} yes; \
else \
${ECHO} no; \
fi
. endif
. endfor
. endif
MAKEVARS+= BUILTIN_LIB_FOUND.${_lib_}
.endfor

View File

@@ -0,0 +1,355 @@
# $NetBSD: libtool-fix-la,v 1.8 2006/11/09 02:07:59 rillig Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# For *.la files, in the "relink_command" line, we make the following
# replacements:
#
# "libfoo.la" -> "-L./.libs libfoo.la"
# "dirpath/libfoo.la" -> "-Ldirpath/.libs libfoo.la"
#
# This allows the libraries to be found within ${WRKSRC} during
# relinking. We rely on the proper rpath settings to be set by libtool.
#
# For the *.lai files, in the "dependency_libs" line, we remove
# redundant -Ldir and -llib options. We also make sure that we don't
# ever reference other .la files, only referring to other libraries
# via the usual "-L/path -llib" and making sure that /path is always
# somewhere under the default view. This makes wildcard dependencies
# work for "overwrite" packages by letting libtool find libraries in
# the default view.
BUILDLINK_DIR="@BUILDLINK_DIR@"
DEPOTBASE="@DEPOTBASE@"
LOCALBASE="@LOCALBASE@"
WRKSRC="@WRKSRC@"
basename="@BASENAME@"
dirname="@DIRNAME@"
egrep="@EGREP@"
mv="@MV@"
pwd="@PWD@"
rm="@RM@"
wrksrc_physical=`cd ${WRKSRC}; $pwd`
labase=`$basename $lafile .la`
ladir=`$dirname $lafile`
latimestamp=${ladir}/.${labase}.la.timestamp
laifile=${ladir}/.libs/${labase}.lai
if $test -f $lafile; then
. ${ladir}/${labase}.la
deps=
for i in ${dependency_libs}; do
case $i in
####################################################
# Skip all -R* options... rpath info shouldn't go into
# the dependency_libs line.
####################################################
-R*)
;;
####################################################
# Catch -L<dir> and remove redundant ones.
####################################################
-L*)
case $deps in
*"$i "*) ;;
*"$i") ;;
*) deps="$deps $i" ;;
esac
;;
####################################################
# Convert "dirpath/libfoo.la" into "-Ldirpath/.libs
# libfoo.la" if it's an uninstalled libtool archive.
# This allows proper relinking by libtool during the
# install stage by allowing it to find the uninstalled
# shared library in the .libs directory.
####################################################
*.la)
fixla=0
ltlibsdir=`$dirname $i`/.libs
case $ltlibsdir in
/*)
# fix if an absolute path in ${WRKSRC}
case $ltlibsdir in
${WRKSRC}/*) fixla=1 ;;
esac
;;
*)
# fix all relative paths
fixla=1
;;
esac
if $test $fixla -gt 0; then
case $deps in
*"-L$ltlibsdir "*) ;;
*"-L$ltlibsdir") ;;
*) deps="$deps -L$ltlibsdir" ;;
esac
fi
deps="$deps $i"
;;
####################################################
# Everything else Just Belongs in the dependency_libs
# line.
####################################################
*)
deps="$deps $i"
;;
esac
done
: ${relink_command=""}
relink=
for i in ${relink_command}; do
case $i in
####################################################
# -I* and -D* are useless for linking.
####################################################
-I*|-D*)
;;
####################################################
# Catch -L<dir> and remove redundant ones.
####################################################
-L*)
case $relink in
*"$i "*) ;;
*"$i") ;;
*) relink="$relink $i" ;;
esac
;;
# This is the .la file we're relinking... don't touch it!
$lafile)
relink="$relink $i"
;;
####################################################
# Convert "dirpath/libfoo.la" into "-Ldirpath/.libs
# libfoo.la" if it's an uninstalled libtool archive.
# This allows proper relinking by libtool during the
# install stage by allowing it to find the uninstalled
# shared library in the .libs directory.
####################################################
*.la)
fixla=0
ltlibsdir=`$dirname $i`/.libs
case $ltlibsdir in
/*)
# fix if an absolute path in ${WRKSRC}
case $ltlibsdir in
${WRKSRC}/*) fixla=1 ;;
esac
;;
*)
# fix all relative paths
fixla=1
;;
esac
if $test $fixla -gt 0; then
case $relink in
*"-L$ltlibsdir "*) ;;
*"-L$ltlibsdir") ;;
*) relink="$relink -L$ltlibsdir" ;;
esac
fi
relink="$relink $i"
;;
####################################################
# Everything else Just Belongs in the relink_command
# line.
####################################################
*)
relink="$relink $i"
;;
esac
done
##############################################################
# Save the orignal .la file produced by libtool as .la.blsav,
# and create the new one with a signature.
##############################################################
$mv -f $lafile ${lafile}.blsav
if $test -n "$deps"; then
(
$cat ${lafile}.blsav | $sed -e '/^dependency_libs=/,$d'
$echo "dependency_libs='$deps'"
$cat ${lafile}.blsav | $sed -e '1,/^dependency_libs=/d'
) > ${lafile}.tmp
else
$cat ${lafile}.blsav > ${lafile}.tmp
fi
if $test -n "$relink"; then
(
$cat ${lafile}.tmp | $sed -e '/^relink_command=/,$d'
$echo "relink_command='$relink'"
$cat ${lafile}.tmp | $sed -e '1,/^relink_command=/d'
) > $lafile
else
$cat ${lafile}.tmp > $lafile
fi
$echo >> $lafile
$echo "# Directory that this library was built in:" >> $lafile
$echo "buildlibdir='"`cd $ladir; $pwd | $sed -e "s,^${wrksrc_physical},${WRKSRC},"`"'" >> $lafile
$echo >> $lafile
$echo "# This file has been modified by buildlink3." >> $lafile
$rm ${lafile}.tmp
msg_log $wrapperlog "==> Fixed $lafile"
##############################################################
# Fix up any .lai files (libtool archives that will be
# installed).
##############################################################
if $test -z "$laifile" || $test ! -f "$laifile" || \
$egrep "^#.*modified by buildlink3" $laifile >/dev/null 2>&1; then
:
else
$sed @_BLNK_WRAP_LT_UNTRANSFORM_SED@ \
$laifile > ${laifile}.tmp
. ${laifile}.tmp
deps_ok=no
deps="${dependency_libs}"
while $test "$deps_ok" = "no"; do
deps_ok=yes
L=; l=; lexist=; prev=
for i in $deps; do
case $i in
######################################
# Don't allowed repeated arguments, so
# "-lm -lm" becomes just "-lm".
######################################
$prev)
;;
######################################
# Skip all -R* options... rpath info
# shouldn't go into the dependency_libs
# line.
######################################
-R*)
;;
######################################
# Skip directories that should never
# appear in the -L<dir> flags. Also
# modify directories in ${DEPOTBASE} to
# point to somewhere in the default view
# ${LOCALBASE}, since we want "overwrite"
# packages to think the libraries really
# do just exist through the default view.
######################################
-L*)
case $i in
-L${BUILDLINK_DIR}/*)
;;
-L${WRKSRC}|-L${WRKSRC}/*)
;;
-L${DEPOTBASE}/*)
i=`$echo "$i" | $sed -e "s,-L${DEPOTBASE}/[^/]*/,-L${LOCALBASE}/,"`
case $L in
*"$i "*) ;;
*"$i") ;;
*) L="$L $i" ;;
esac
;;
*)
case $L in
*"$i "*) ;;
*"$i") ;;
*) L="$L $i" ;;
esac
;;
esac
;;
######################################
# Libraries really do exist, so we want
# to keep any -L<dir> flags we've seen
# in the generated dependency_libs line.
######################################
-l*)
lexist=1
l="$l $i"
;;
######################################
# Libtool archives should be changed from
# "/path/libfoo.la" to "-L/path -lfoo",
# where /path is appropriately modified
# so that the depot directory is changed
# to the views directory. This allows
# the .la files to be used by either
# "overwrite" or "pkgviews" packages and
# works correctly with wildcard
# dependencies.
######################################
*.la)
dirbase=`$dirname $i`
dir=`$echo "X$dirbase" | $Xsed -e "s,^${DEPOTBASE}/[^/]*/,${LOCALBASE}/,"`
case $L in
*"-L$dir "*) ;;
*"-L$dir") ;;
*) L="$L -L$dir" ;;
esac
libbase=`$basename $i .la`
lib="${libbase#lib}"
lexist=1
l="$l -l$lib"
deps_ok=no
;;
######################################
# Everything else Just Belongs.
######################################
*)
l="$l $i"
;;
esac
prev="$i"
done
if $test -z "$lexist"; then
L=
fi
deps="$L$l"
deps=`$echo "X$deps" | $Xsed -e "s/^[ ]*//"`
done
$mv -f $laifile ${laifile}.blsav
(
$cat ${laifile}.tmp | $sed -e '/^dependency_libs=/,$d'
$echo "dependency_libs='$deps'"
$cat ${laifile}.tmp | $sed -e '1,/^dependency_libs=/d'
$echo
$echo "# This file has been modified by buildlink3."
) > ${laifile}
$rm -f ${laifile}.tmp
msg_log $wrapperlog "==> Fixed $laifile"
if $egrep "${BUILDLINK_DIR}" $laifile >/dev/null 2>&1; then
msg_log $wrapperlog "==> [buildlink3] Error: buildlink3 leakage into $laifile"
$echo "==> [buildlink3] Error: buildlink3 leakage into $laifile" 1>&2
wrapper_result=1
fi
fi
fi

View File

@@ -0,0 +1,81 @@
# $NetBSD: pkgconfig-builtin.mk,v 1.5 2009/07/11 07:56:25 rillig Exp $
# This file is used to factor out a common pattern in builtin.mk files
# backed up by the existence of a pkgconfig file.
#
# Parameters:
#
# BUILTIN_PKG
# The name of the package that is tested.
#
# PKGCONFIG_FILE.<BUILTIN_PKG>
# The absolute path where the pkgconfig file of the native
# implementation of the package is stored.
#
# Example: ${X11BASE}/lib/pkgconfig/fontcacheproto.pc
#
# PKGCONFIG_BASE.<BUILTIN_PKG> (optional)
# The base location for a native implementation of the package.
#
# Default: ${X11BASE}
#
# BUILTIN_VERSION_SCRIPT.<BUILTIN_PKG> (optional)
# The program that is used to extract the version number from the
# PKGCONFIG_FILE.<BUILTIN_PKG>. The expected output is the plain
# version number on a single line.
#
# By defining a custom script this file can be called by a lot
# more generic builtin.mk files.
#
# Default: (something suitable for pkgconfig files)
#
BUILTIN_FIND_FILES_VAR:= FIND_FILES_${BUILTIN_PKG}
BUILTIN_FIND_FILES.FIND_FILES_${BUILTIN_PKG}= ${PKGCONFIG_FILE.${BUILTIN_PKG}}
.include "../../mk/buildlink3/bsd.builtin.mk"
.if ${PKGCONFIG_BASE.${BUILTIN_PKG}:U${X11BASE}} == ${LOCALBASE}
IS_BUILTIN.${BUILTIN_PKG}= no
.elif !defined(IS_BUILTIN.${BUILTIN_PKG})
IS_BUILTIN.${BUILTIN_PKG}= no
. if empty(FIND_FILES_${BUILTIN_PKG}:M__nonexistent__)
IS_BUILTIN.${BUILTIN_PKG}= yes
. endif
.endif
MAKEVARS:= ${MAKEVARS} IS_BUILTIN.${BUILTIN_PKG}
.if !defined(BUILTIN_PKG.${BUILTIN_PKG}) && \
!empty(IS_BUILTIN.${BUILTIN_PKG}:M[yY][eE][sS]) && \
(!empty(FIND_FILES_${BUILTIN_PKG}:M*.pc) || \
(empty(FIND_FILES_${BUILTIN_PKG}:M__nonexistent__) && \
defined(BUILTIN_VERSION_SCRIPT.${BUILTIN_PKG})))
BUILTIN_VERSION_SCRIPT.${BUILTIN_PKG}?= ${SED} -n -e 's/Version: //p'
BUILTIN_VERSION.${BUILTIN_PKG}!= ${BUILTIN_VERSION_SCRIPT.${BUILTIN_PKG}} \
${FIND_FILES_${BUILTIN_PKG}}
BUILTIN_PKG.${BUILTIN_PKG}:= ${BUILTIN_PKG}-${BUILTIN_VERSION.${BUILTIN_PKG}}
.endif
MAKEVARS:= ${MAKEVARS} BUILTIN_PKG.${BUILTIN_PKG}
.if !defined(USE_BUILTIN.${BUILTIN_PKG})
. if ${PREFER.${BUILTIN_PKG}} == "pkgsrc"
USE_BUILTIN.${BUILTIN_PKG}= no
. else
USE_BUILTIN.${BUILTIN_PKG}:= ${IS_BUILTIN.${BUILTIN_PKG}}
. if defined(BUILTIN_PKG.${BUILTIN_PKG}) && \
!empty(IS_BUILTIN.${BUILTIN_PKG}:M[Yy][Ee][Ss])
USE_BUILTIN.${BUILTIN_PKG}= yes
. for _dep_ in ${BUILDLINK_API_DEPENDS.${BUILTIN_PKG}}
. if !empty(USE_BUILTIN.${BUILTIN_PKG}:M[Yy][Ee][Ss])
USE_BUILTIN.${BUILTIN_PKG}!= \
if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.${BUILTIN_PKG}}; then \
${ECHO} yes; \
else \
${ECHO} no; \
fi
. endif
. endfor
. endif
. endif
.endif
MAKEVARS:= ${MAKEVARS} USE_BUILTIN.${BUILTIN_PKG}

135
mk/buildlink3/scan-libtool Normal file
View File

@@ -0,0 +1,135 @@
# $NetBSD: scan-libtool,v 1.5 2010/01/20 14:29:46 joerg Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Discover the libtool mode by scanning the argument list.
lt_mode=
prevopt=
nonopt=
lafile=
for arg do
case $arg in
-*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
if $test -n "$prevopt"; then
case $prevopt in
--mode)
lt_mode="$arg"
;;
-o)
case $arg in
*.la) lafile="$arg" ;;
esac
;;
esac
prevopt=
continue
fi
case $arg in
--finish)
lt_mode="finish"
;;
--mode|-o)
prevopt="$arg"
;;
--mode=*)
lt_mode="$optarg"
;;
-*)
if $test -n "$nonopt" -a -z "$lt_mode"; then
case $arg in
-c) lt_mode=compile ;;
esac
fi
;;
*)
if $test -z "$nonopt" -a -z "$lt_mode"; then
nonopt="$arg"
case $nonopt in
*cc|*++|gcc*|*-gcc*|xlc*|*CC)
lt_mode=link
for arg do
case $arg in
-c) lt_mode=compile; break ;;
esac
done
;;
*install*|cp|mv)
lt_mode=install
;;
*rm)
lt_mode=uninstall
;;
esac
fi
;;
esac
done
if $test -z "$lt_mode"; then
lt_mode=link
fi
$debug_log $wrapperlog " (scan-libtool) mode: $lt_mode"
case $lt_mode in
######################################################################
# We're just being invoked to unwrap a libtool archive, so just
# invoke the cleanup script.
######################################################################
unwrap)
. $cleanup
exit 0
;;
######################################################################
# In case we're in "link" mode, we should add the extra LDFLAGS to the
# argument list so that libtool finds all of our libraries and libtool
# archives.
######################################################################
link)
append_extra_args=yes
;;
######################################################################
# We're doing libtool clean, execute, finish, install, or uninstall, so
# just invoke the real libtool with all of the given arguments.
######################################################################
execute|finish|install|uninstall)
msg_log $wrapperlog "<.> $cmd $@"
exec $cmd "$@"
;;
*)
append_extra_args=no
;;
esac

View File

@@ -0,0 +1,21 @@
#!/bin/sh
#
# $NetBSD: show-buildlink3.sh,v 1.3 2009/10/05 02:40:06 obache Exp $
#
# This script is a helper for the show-buildlink3 target and outputs
# the arguments as tree.
#
while test $# -gt 0; do
pkg="$1"
case $pkg in
-*)
indentation=${indentation# }
;;
*)
echo "${indentation}${pkg}"
indentation="${indentation} "
;;
esac
shift
done

View File

@@ -0,0 +1,119 @@
# $NetBSD: transform-libtool,v 1.3 2006/11/09 02:07:59 rillig Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
BUILDLINK_DIR="@BUILDLINK_DIR@"
WRKSRC="@WRKSRC@"
basename="@BASENAME@"
dirname="@DIRNAME@"
pwd="@PWD@"
case $arg in
######################################################################
# Workaround software authors that don't follow the libtool
# documentation and link against uninstalled libtool archives with:
#
# -L../package/source/dir -lfoo
#
# instead of the correct (according to the libtool documentation)
#
# ../package/source/dir/libfoo.la
#
# We convert the former into the latter by remembering all "local"
# directories that are mentioned in -L* arguments to to libtool
# wrapper, and checking to see if <dir>/libfoo.la exists when we see
# "-lfoo" on the libtool command line. Avoid matching the buildlink
# directory here for the WRKSRC == WRKDIR case.
######################################################################
-L${BUILDLINK_DIR}/*)
;;
-L.|-L./*|-L..*|-L[!/]*|-L${WRKSRC}*)
case $arg in
*/.libs)
# ignore -L.../.libs
;;
*)
msg_log $wrapperlog "*** [buildlink3] Warning: libtool detected $arg"
lpath="${arg#-L}"
case $rellpath in
*"$lpath "*) ;;
*"$lpath"*) ;;
*) rellpath="$rellpath $lpath" ;;
esac
addtocache=no
;;
esac
;;
-l*)
lib="${arg#-l}"
for dir in $rellpath; do
la="$dir/lib$lib.la"
if $test -f "$la"; then
ldir=`cd $dir; $pwd`
buildlibdir=`. $la; $echo ${buildlibdir-}`
if $test -n "$buildlibdir" -a \
"$ldir" != "$buildlibdir"; then
la="$buildlibdir/lib$lib.la"
fi
$debug_log $wrapperlog " (transform-libtool) to: $la"
msg_log $wrapperlog "*** [buildlink3] Warning: libtool replaced $arg with $la"
$echo "*** [buildlink3] Warning: libtool replaced $arg with $la" 1>&2
arg="$la"
addtocache=no
break
fi
done
;;
######################################################################
# Replace all references to locally-linked libtool archives with the
# full paths to the archives in $buildlibdir if $buildlibdir differs
# from the referenced directory. This makes linking against a symlinked
# local libtool archive possible.
######################################################################
./*.la|../*.la|[!-/]*.la|${WRKSRC}/*.la)
labase=`$basename $arg`
ladir=`$dirname $arg`
ldir=`cd $ladir; $pwd`
buildlibdir=`. $ladir/$labase; $echo ${buildlibdir-}`
if $test -n "$buildlibdir" -a "$ldir" != "$buildlibdir" -a \
-e "$buildlibdir/$labase"; then
arg="$buildlibdir/$labase"
$debug_log $wrapperlog " (transform-libtool) to: $arg"
msg_log $wrapperlog "*** [buildlink3] Warning: libtool replaced $ladir/$labase with $arg"
addtocache=yes
fi
;;
esac

3
mk/bulk/TODO Normal file
View File

@@ -0,0 +1,3 @@
* integrate pkgtools/libkver
* Generate list of packages that were "Successfully packaged"
* allow parallel builds (see parallel.txt)

583
mk/bulk/bsd.bulk-pkg.mk Normal file
View File

@@ -0,0 +1,583 @@
# $NetBSD: bsd.bulk-pkg.mk,v 1.152 2011/09/08 20:17:15 abs Exp $
#
# Copyright (c) 1999, 2000 Hubert Feyrer <hubertf@NetBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Hubert Feyrer for
# the NetBSD Project.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##
## For this to work, put
## DEPENDS_TARGET= bulk-install
## BATCH= yes
## into your /etc/mk.conf, then cd /usr/pkgsrc; make bulk-package
##
## bulk-install will only compile pkgs if necessary, and install binary
## pkgs if possible/available.
## bulk-package will build binary packages, and remove them (together with
## any depending packages) immediately after that, leaving only the
## binary package back. Broken packages are marked (``.broken'').
##
LS?= ls
TEE?= tee
WC?= wc
TO_HTML?= ${SED} -e 's,&,\&amp;,g' -e 's,<,\&lt;,g' -e 's,>,\&gt;,g'
# This variable is set to 'yes' by the pkgsrc/mk/bulk/build script. It enables
# the use of several cache files (DEPENDSTREEFILE, DEPENDSFILE, SUPPORTSFILE,
# and INDEXFILE) for speeding up the processing of dependencies. If we're not
# actively in the middle of a bulk build, however, we don't know that these files
# exist or are up to date and they take quite a while to rebuild. So unless
# they're known to exist and be up to date, don't use them.
USE_BULK_CACHE?= no
# If set to 'yes', avoids inflating the 'breaks' column of the final report
# by not counting dependent packages that are broken all by themselves.
# If set to 'no', may speed up building on some platforms where fork() is slow.
# (Only takes effect if USE_BULK_CACHE=yes.)
USE_BULK_BROKEN_CHECK?= yes
# This variable may be set to 'no' to avoid automatic rebuilding of dependent
# packages based solely on timestamps of the package's pkgsrc files and/or
# its dependency binary packages. This will cause rebuilding only when the
# full version number of the package changes (e.g., via PKGREVISION bump).
USE_BULK_TIMESTAMPS?= yes
# Shall we remove any packages which are installed, but not required
# to build this package
PRECLEAN?= yes
# Sometimes it's useful to not only keep the build logs from broken
# packages, but also the ones from packages that worked.
# This feature is still experimental.
KEEP_BUILDLOGS?= no
# If OBJHOSTNAME is set, use first component of hostname in cache and log files
# If OBJMACHINE is set, use ${MACHINE_ARCH} in the cache and log files
.if defined(OBJHOSTNAME)
. if !defined(_HOSTNAME)
_HOSTNAME!= ${UNAME} -n
. endif
BULK_ID?= .${_HOSTNAME:C|\..*||}
.elif defined(OBJMACHINE)
BULK_ID?= .${MACHINE_ARCH}
.else
BULK_ID?=
.endif
.if ${_USE_DESTDIR} != "no"
_PACKAGE_TARGET= package package-install
.else
_PACKAGE_TARGET= package
.endif
#
# Package-specific files
#
# If the package has been built successfully, and if KEEP_BUILDLOGS is
# set to "yes", the build log is saved in this file.
BUILD_SUCCEEDED_FILE?= .build_succeeded${BULK_ID}
# This file exists to mark a package as broken
BROKENFILE?= .broken${BULK_ID}.html
# When this file exists for a package, it has been marked as not to be
# available on this platform.
NOT_AVAILABLE_FILE?= .bulk-not_available
# This file is the work log for a broken package
BROKENWRKLOG?= .broken${BULK_ID}.work.txt
# This file is human-created to force a package to show up as broken
# (it is never cleaned by the bulk build, and contains the broken reason)
FORCEBROKENFILE?= .forcebroken
# This file is where the log of the build goes
BUILDLOG?= .make${BULK_ID}
#
# Top level databases and log files
#
# This is the directory in which all temporary files and log files from the
# bulk build are kept.
# It defaults to ${PKGSRCDIR}, but may be better suited to another directory
# if pkgsrc is on a remote (e.g., nfs) filesystem.
BULKFILESDIR?= ${PKGSRCDIR}
# This is a top level file which lists the entire pkgsrc depends tree in the
# format:
# foo/bar devel/libfoo
# meaning 'foo/bar' is requied to build 'devel/libfoo'
# this is in the format needed by tsort(1)
DEPENDSTREEFILE?= ${BULKFILESDIR}/.dependstree${BULK_ID}
# This is a top level file which lists the entire pkgsrc depends tree in the
# format:
# foo/bar depends on: devel/libfoo devel/libbar devel/baz .....
# ie, to build foo/bar we need devel/libfoo devel/libbar devel/baz ... installed
DEPENDSFILE?= ${BULKFILESDIR}/.depends${BULK_ID}
# This is a top level file which lists the entire pkgsrc depends tree in the
# format:
# devel/libfoo is depended upon by: foo/bar graphics/gtkfoo ...
# ie, to build foo/bar we need devel/libfoo to be installed.
# to build graphics/gtkfoo we need devel/libfoo to be installed
SUPPORTSFILE?= ${BULKFILESDIR}/.supports${BULK_ID}
# This is a top level file which cross-references each package name and pkg
# directory in the format:
# devel/libfoo libfoo-1.3
INDEXFILE?= ${BULKFILESDIR}/.index${BULK_ID}
# File containing a list of all the packages in the correct order for a bulk
# build. The correct order is one where packages that are required by others
# are built before the packages which require them.
ORDERFILE?= ${BULKFILESDIR}/.order${BULK_ID}
# File which is used as a timestamp for when the build started. This is used
# eventually for looking for leftover files (files not properly deinstalled)
STARTFILE?= ${BULKFILESDIR}/.start${BULK_ID}
# This top level file saves the bulk build ID. As it most often has a time
# stamp, it is only generated once and later retrieved from this file.
BULK_BUILD_ID_FILE?= ${BULKFILESDIR}/.bulk_build_id${BULK_ID}
# File created and used by lintpkgsrc(8) to cache package metadata for
# pruning and bulk-upload exclusions.
LINTPKGSRC_DB?= ${BULKFILESDIR}/.lintpkgsrc.db${BULK_ID}
# File which is used as a database for bulk builds in which SPECIFIC_PKGS is
# defined. This database is used to hold all the dependency and index
# information for the specific packages as well as their dependencies. In a
# SPECIFIC_PKGS bulk build, this file is created and then used to create the
# INDEXFILE and DEPENDSTREEFILE.
BULK_DBFILE?= ${BULKFILESDIR}/.bulk_db${BULK_ID}
# A list of pkgs which we should _never_ delete during a build. The primary
# use is for digest and also for xpkgwedge. Add pkgtools/xpkgwedge in
# /etc/mk.conf to do an xpkgwedged bulk build.
BULK_PREREQ+= pkgtools/digest
# Commands for printing informational messages from the bulk build.
# BULK_MSG_CONT is used for continuing a message started with BULK_MSG
BULK_MSG?= ${ECHO_MSG} "BULK>"
BULK_MSG_CONT?= ${ECHO_MSG} " "
#
# Private variables
#
# If this is "yes", the working directory will not be cleaned after building
# the package. It can also be set to "pack-if-failed" to save a .tar.gz
# file of the working directory in BULKFILESDIR instead of keeping the files,
# but only if the package failed to build.
_PRESERVE_WRKDIR?= no
# create an escaped version of PKGPATH. We do this because
# in several places we want to be able to use something like
# foo/bar.baz++ in a regular expression but have it be interpreted
# literally. So, turn it into foo\/bar\.baz\+\+
_ESCPKGPATH= ${PKGPATH:C@\/@\\/@g:C@\+@\\+@g:C@\.@\\.@g:Q}
# The directory where package-specific log files are saved.
_BULK_PKGLOGDIR= ${BULKFILESDIR}/${PKGPATH}
# Package-specific log files.
_BROKENFILE= ${_BULK_PKGLOGDIR}/${BROKENFILE}
_BROKENWRKLOG= ${_BULK_PKGLOGDIR}/${BROKENWRKLOG}
_BUILDLOG= ${_BULK_PKGLOGDIR}/${BUILDLOG}
_FORCEBROKENFILE= ${_BULK_PKGLOGDIR}/${FORCEBROKENFILE}
_BUILD_SUCCEEDED_FILE= ${_BULK_PKGLOGDIR}/${BUILD_SUCCEEDED_FILE}
# Only create directories if ${PKGSRCDIR} != ${BULKFILESDIR}
.if ${PKGSRCDIR} != ${BULKFILESDIR}
_BULK_MKDIR= ${MKDIR}
.else
_BULK_MKDIR= ${DO_NADA}
.endif
#
# Sanity checks
#
# Allow FORCEBROKENFILE files to be created in either PKGSRCDIR or BULKFILESDIR.
.if exists(${FORCEBROKENFILE})
PKG_FAIL_REASON+= "${PKGNAME} is marked as broken by the bulk build administrator: `cat ${FORCEBROKENFILE:Q:Q}`"
.elif exists(${_FORCEBROKENFILE})
PKG_FAIL_REASON+= "${PKGNAME} is marked as broken by the bulk build administrator: `cat ${_FORCEBROKENFILE:Q:Q}`"
.endif
#
# Make targets
#
# build the cache files used as part of a full bulk build
# Note: we have to install the BULK_PREREQ packages _before_
# extracting the depends tree because some packages like
# xpkgwedge only become DEPENDS if it is installed
.PHONY: bulk-cache
bulk-cache:
@${BULK_MSG} "Installing BULK_PREREQ packages"
.for __prereq in ${BULK_PREREQ} lang/perl5
cd ${PKGSRCDIR}/${__prereq} && ${RECURSIVE_MAKE} ${MAKEFLAGS} bulk-install
.endfor
${RM} -f ${BULK_DBFILE}
${TOUCH} ${BULK_DBFILE}
.if !defined(SPECIFIC_PKGS)
@${ECHO} "This file is unused for a full pkgsrc bulk build" >> ${BULK_DBFILE}
@${ECHO} "It is only used for a SPECIFIC_PKGS bulk build" >> ${BULK_DBFILE}
@${BULK_MSG} "Building complete pkgsrc dependency tree (this may take a while)."
cd ${PKGSRCDIR} && ${PKGSRC_SETENV} BMAKE=${MAKE:Q} ${SH} mk/bulk/printdepends ${BROKENFILE:Q} ${BULKFILESDIR:Q} > ${DEPENDSTREEFILE:Q}
@${BULK_MSG} "Generating package name <=> package directory cross reference file"
@${BULK_MSG_CONT} "(this may take a while)."
cd ${PKGSRCDIR} && ${PKGSRC_SETENV} BMAKE=${MAKE:Q} ${SH} mk/bulk/printindex ${NOT_AVAILABLE_FILE} ${BULKFILESDIR:Q} > ${INDEXFILE:Q}
.else
@${BULK_MSG} "Extracting database for SPECIFIC_PKGS subset of pkgsrc"
@${BULK_MSG_CONT} "along with their dependencies"
. for __tmp__ in ${SUBDIR} ${BULK_PREREQ} lang/perl5 pkgtools/lintpkgsrc
@if [ ! -d ${PKGSRCDIR}/${__tmp__} ]; then \
${BULK_MSG} "WARN: Skipping nonexisting directory ${__tmp__}"; \
${ECHO} " 0 ${__tmp__} 0" >> ${BULKFILESDIR:Q}/${BROKENFILE:Q}; \
else \
cd ${PKGSRCDIR}/${__tmp__} && ${PKGSRC_SETENV} BMAKE=${MAKE:Q} AWK=${AWK:Q} EXPR=${EXPR:Q} ${SH} ../../mk/scripts/mkdatabase -a -f ${BULK_DBFILE:Q}; \
fi
. endfor
@${BULK_MSG} "Extracting dependency tree file"
${AWK} '/^(build_)?depends/ {pkgs[$$2] = 1; cat=$$2; sub(/\/.*/, "", cat); \
for(i=3; i<=NF; i=i+1){ \
listed[$$2] = 1; \
sub(/[^:]*:\.\.\/\.\.\//, "", $$i); \
sub(/[^:]*:\.\./, cat , $$i); \
print $$i " " $$2; \
}} END{ \
for(pkg in pkgs) {if( pkg in listed ) {} else{ print pkg " " pkg;}} \
}' \
${BULK_DBFILE} | ${SORT} -u > ${DEPENDSTREEFILE}
@${BULK_MSG} "Extracting package name <=> package directory cross reference file"
${AWK} '/^index/ {print $$2 " " $$3 " "}' ${BULK_DBFILE} > ${INDEXFILE}
.endif
@${BULK_MSG} "Sorting build order."
cd ${BULKFILESDIR} && ${TSORT} ${DEPENDSTREEFILE} > ${ORDERFILE}
@${BULK_MSG} "Generating up and down dependency files."
${LOCALBASE}/bin/perl ${PKGSRCDIR}/mk/bulk/tflat ${SUPPORTSFILE} ${DEPENDSFILE} < ${DEPENDSTREEFILE}
# note explicit pathname on "perl" above, so that we do NOT auto-set
# USE_TOOLS=perl (which may be undesirable for package building)
# remove the bulk cache files
.PHONY: clean-bulk-cache
clean-bulk-cache:
${RM} -f ${BULK_DBFILE} \
${DEPENDSTREEFILE} \
${DEPENDSFILE} \
${SUPPORTSFILE} \
${INDEXFILE} \
${ORDERFILE}
# check if the $REF file is up to date, i.e. is newer than any of
# the pkg files; prints "1" if up to date, "0" if not.
.PHONY: bulk-check-uptodate
bulk-check-uptodate:
@uptodate=1; \
if [ -f "${REF}" ]; then \
if [ "${REF:T}" != "${PKGFILE:T}" ]; then \
${BULK_MSG} 1>&2 "${REF} is out of date (new version ${PKGNAME}); rebuilding..."; \
uptodate=0; \
elif [ "${USE_BULK_TIMESTAMPS}" = "yes" ]; then \
${SHCOMMENT} "Check files of this package"; \
newfiles="`${FIND} . \( \( -name CVS -o -name ${WRKDIR_BASENAME} \) -prune \) -o \( -type f -newer "${REF}" ! \( -name README.html -o -name DESCR -o -name COMMENT -o -name '.*' \) \) -print || ${TRUE}`"; \
nnewfiles="`echo $$newfiles | ${WC} -w`"; \
if [ "$$nnewfiles" -gt 0 ]; then \
${BULK_MSG} 1>&2 "Package ${PKGNAME} ($$newfiles) modified since last 'make package' re-packaging..."; \
uptodate=0; \
else \
${BULK_MSG} 1>&2 "${REF} is up to date."; \
fi; \
else \
${BULK_MSG} 1>&2 "${REF} is up to date."; \
fi; \
else \
${BULK_MSG} 1>&2 "Package ${PKGNAME} not built yet, packaging..."; \
uptodate=0; \
fi; \
if [ "$$uptodate" = "1" ]; then \
${SHCOMMENT} "Check required binary packages"; \
(${DEPENDS:C/:.*$//:@d@${ECHO} ${d:Q};@} ${TRUE}) | \
(while read dep; do \
${SHCOMMENT} "check against the binary pkg that pkg_add would pick, too:"; \
${SHCOMMENT} "(Only one should be returned here, really...)"; \
pkg=`${PKG_ADMIN} lsbest "${PACKAGES}/All/$$dep"`; \
if [ -z "$$pkg" ]; then \
${BULK_MSG} 1>&2 "Required binary package $$dep does not exist, rebuilding..."; \
exit 1; \
elif [ "${USE_BULK_TIMESTAMPS}" = "yes" ] && [ -n "`${FIND} $$pkg -prune -newer ${REF} -print`" ]; then \
${BULK_MSG} 1>&2 "Required binary package $$dep (`basename $$pkg`) is newer, rebuilding..."; \
exit 1; \
else \
${BULK_MSG} 1>&2 "Required binary package $$dep (`basename $$pkg`) is usable."; \
fi; \
done) || uptodate=0; \
fi; \
${ECHO} $$uptodate
# rebuild binpkg if any of the pkg files is newer than the binary archive
# set DO to ":" to not actually do anything (debugging, ...)
.PHONY: bulk-package
bulk-package:
@${_BULK_MKDIR} ${_BULK_PKGLOGDIR:Q}
@if [ -f ${_BROKENFILE:Q} ]; then \
${BULK_MSG} "Package ${PKGNAME} is already marked as broken."; \
exit 1; \
fi
${RUN} \
{ ${ECHO} "###"; \
${ECHO} "### `${DATE}`"; \
${ECHO} "### pkgsrc build log for ${PKGNAME}"; \
${ECHO} "###"; \
${ECHO} ""; \
} >> ${_BUILDLOG}
${RUN} set +e; \
uptodate=`${RECURSIVE_MAKE} ${MAKEFLAGS} bulk-check-uptodate REF=${PKGFILE}` ; \
if [ $$uptodate = 1 ]; then \
{ ${BULK_MSG} "Nothing to be done for ${PKGNAME}." ; \
} 2>&1 | ${TEE} -a ${_BUILDLOG:Q}; \
else \
( if ${PKG_INFO} -qe ${PKGWILDCARD:Q}; then \
oldpkg=`${PKG_INFO} -e ${PKGWILDCARD}`; \
${BULK_MSG} "Removing outdated (installed) package $$oldpkg first." ; \
${DO} ${PKG_DELETE} -r ${PKGWILDCARD:Q} ;\
fi ; \
if [ -f ${PKGFILE} ]; then \
${BULK_MSG} "Removing old binary package ${PKGFILE}." ; \
${DO} ${RM} -f ${PKGFILE} ; \
for cat in ${CATEGORIES}; do \
${DO} ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX}; \
done ;\
fi; \
${BULK_MSG} "Bulk building ${PKGNAME}" ; \
${DO} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean;\
if [ "${PRECLEAN}" = "yes" ]; then \
${BULK_MSG} "Currently installed packages:"; \
${PKG_INFO} -e "*" | ${SED} -e "s,^,* ,"; \
${PHASE_MSG} "Removing installed packages which are not needed to build ${PKGNAME}" ; \
if [ "${USE_BULK_CACHE}" = "yes" ]; then \
for pkgname in `${PKG_INFO} -e \\*`; do \
: "The package may have been deinstalled in between."; \
${PKG_INFO} -qe "$$pkgname" || continue; \
pkgdir=`${PKG_INFO} -Q PKGPATH "$$pkgname"`; \
[ "$$pkgdir" ] || { ${FAIL_MSG} "Empty PKGPATH for $$pkgname"; continue; }; \
required=`${AWK} '$$1 == "${PKGPATH}" { for (i = 4; i <= NF; i++) { if ($$i == "'"$$pkgdir"'") { print $$i; } } }' ${DEPENDSFILE}`; \
if true; then \
if [ "$$required" ]; then \
${STEP_MSG} "Keeping dependency $$pkgname." ;\
else \
case "${BULK_PREREQ}" in \
*$$pkgdir* ) \
${STEP_MSG} "Keeping BULK_PREREQ $$pkgname ($$pkgdir)" ;\
;; \
* ) \
${STEP_MSG} "Deinstalling $$pkgname"; \
${DO} ${PKG_DELETE} -r $$pkgname || ${TRUE}; \
;; \
esac ; \
fi ;\
fi ;\
done; \
else \
${STEP_MSG} "Deinstalling all packages"; \
${DO} ${PKG_DELETE} -r "*" || ${TRUE}; \
fi ;\
fi ;\
if [ "${USE_BULK_CACHE}" = "yes" ]; then \
${SHCOMMENT} "Install required depends via binarypkgs XXX" ; \
${BULK_MSG} "Installing dependencies for ${PKGNAME}." ;\
for pkgdir in `${SED} -n -e "/^${_ESCPKGPATH} / s;^[^:]*:;;p" ${DEPENDSFILE}` ${BULK_PREREQ} ; do \
pkgname=`${AWK} '$$1 == "'"$$pkgdir"'" { print $$2; }' ${INDEXFILE}`; \
if [ -z "$$pkgname" ]; then ${BULK_MSG} "WARNING: could not find package name for directory $$pkgdir"; continue ; fi ;\
if [ -f "${BULKFILESDIR}/$$pkgdir/${NOT_AVAILABLE_FILE}" ]; then \
${ECHO} "The dependency $$pkgname ($$pkgdir) is not available." >> ${BULKFILESDIR}/${PKGPATH}/${NOT_AVAILABLE_FILE}; \
exit 1; \
fi; \
pkgfile=${PACKAGES}/All/$${pkgname}${PKG_SUFX} ;\
if ${PKG_INFO} -qe $$pkgname ; then \
${BULK_MSG} "Dependency $$pkgname is already installed" ; \
else \
if [ -f $$pkgfile ]; then \
${BULK_MSG} "Installing $$pkgfile"; \
${DO} ${PKG_ADD} ${PKG_ARGS_ADD} $$pkgfile || ${WARNING_MSG} "could not add $$pkgfile." ; \
else \
${BULK_MSG} "warning: $$pkgfile does not exist. It will be rebuilt." ;\
fi ;\
fi ;\
done ;\
fi ;\
${ECHO_MSG} ${MAKE} package '(${PKGNAME})' 2>&1 ; \
${DO} ${RECURSIVE_MAKE} ${MAKEFLAGS} ${_PACKAGE_TARGET};\
${ECHO} ""; \
${ECHO} "===> Warnings from the wrapper log (sorted):"; \
${GREP} "^WARNING" ${WRKLOG} | ${SORT} -u | ${TO_HTML}; \
${ECHO} ""; \
) 2>&1 | ${TEE} -a ${_BUILDLOG:Q} ; \
if [ -f ${PKGFILE} ]; then \
case ${KEEP_BUILDLOGS} in \
yes) ${MV} ${_BUILDLOG:Q} ${_BUILD_SUCCEEDED_FILE:Q}; \
;; \
no) ${RM} ${_BUILDLOG:Q}; \
;; \
esac; \
else \
{ ${ECHO} "<html>"; \
${ECHO} "<head><title>pkgsrc build log for ${PKGNAME}</title></head>"; \
${ECHO} ""; \
${ECHO} "<body>"; \
${ECHO} "<pre>"; \
${TO_HTML} < ${_BUILDLOG:Q}; \
${MAKE} debug 2>&1 | ${TO_HTML}; \
${ECHO} "</pre>"; \
} > ${_BROKENFILE:Q}; \
${RM} -f ${_BUILDLOG:Q}; \
if [ -f "${WRKLOG}" ]; then \
${CP} ${WRKLOG:Q} ${_BROKENWRKLOG:Q}; \
fi; \
( \
if [ -f ${_BROKENWRKLOG:Q} ]; then \
${ECHO} "<p>"; \
${ECHO} "Please view the <a href=\"../../${PKGPATH}/${BROKENWRKLOG}\">work log for ${PKGNAME}</a>"; \
${ECHO} "</p>"; \
fi >> ${_BROKENFILE:Q}; \
${ECHO} "<pre>" >> ${_BROKENFILE:Q}; \
${BULK_MSG} "${PKGNAME} was marked as broken:" ; \
${LS} -la ${_BROKENFILE:Q} ; \
${ECHO_MSG} ${MAKE} deinstall ; \
${DO} ${RECURSIVE_MAKE} ${MAKEFLAGS} deinstall ; \
${ECHO} "</pre>" >> ${_BROKENFILE:Q}; \
nbrokenby=0;\
if [ "${USE_BULK_CACHE}" = "yes" ]; then \
${BULK_MSG} "Marking all packages which depend upon ${PKGNAME} as broken:"; \
tmp=`${SED} -n -e "/^${_ESCPKGPATH} / s;^[^:]*:[ ]*;;p" ${SUPPORTSFILE}` ; \
if test -n "$$tmp" ; then \
${ECHO} "<ul>"; \
for pkgdir in $$tmp ; do \
pkg_brokendir=${BULKFILESDIR:Q}/"$$pkgdir"; \
pkg_brokenfile="$$pkg_brokendir"/${BROKENFILE:Q}; \
pkgname=`${AWK} '$$1 == "'"$$pkgdir"'" { print $$2; }' ${INDEXFILE}`; \
case $$pkgname in \
"") pkgname="unknown"; \
${BULK_MSG} "WARNING: unknown pkgname in $$pkgdir.";; \
esac; \
${ECHO} "<li>$$pkgname ($$pkgdir)</li>";\
pkgerr='-1'; pkgignore=''; pkgskip=''; \
if [ "${USE_BULK_BROKEN_CHECK}" = 'yes' ]; then \
pkgignore=`(cd ${PKGSRCDIR}/$$pkgdir && ${RECURSIVE_MAKE} ${MAKEFLAGS} show-var VARNAME=PKG_FAIL_REASON)`; \
pkgskip=`(cd ${PKGSRCDIR}/$$pkgdir && ${RECURSIVE_MAKE} ${MAKEFLAGS} show-var VARNAME=PKG_SKIP_REASON)`; \
fi; \
if [ ! -z "$${pkgignore}$${pkgskip}" -a ! -f "$${pkg_brokenfile}" ]; then \
{ ${BULK_MSG} "$$pkgname ($$pkgdir) may not be packaged because:"; \
${BULK_MSG} "$$pkgignore"; \
${BULK_MSG} "$$pkgskip"; \
} >> "$${pkg_brokenfile}"; \
if [ "${USE_BULK_BROKEN_CHECK}" != 'yes' ] || [ -z "`(cd ${PKGSRCDIR}/$$pkgdir && ${RECURSIVE_MAKE} ${MAKEFLAGS} show-var VARNAME=BROKEN)`" ]; then \
pkgerr="0"; \
else \
pkgerr="1"; \
fi; \
fi; \
${_BULK_MKDIR} "$${pkg_brokendir}"; \
{ ${ECHO} "$$pkgname ($$pkgdir) is broken because it depends upon ${PKGNAME} (${PKGPATH}) which is broken."; \
${ECHO} "Please view the <a href=\"../../${PKGPATH}/${BROKENFILE}\">build log for ${PKGNAME}</a>.<br />"; \
} >> "$${pkg_brokenfile}"; \
nbrokenby=`expr $$nbrokenby + 1`;\
if ${GREP} -q " $$pkgdir/${BROKENFILE}" ${BULKFILESDIR:Q}/${BROKENFILE:Q} ; then :; \
else \
${ECHO} " $$pkgerr $$pkgdir/${BROKENFILE} 0 " >> ${BULKFILESDIR:Q}/${BROKENFILE:Q} ;\
fi ;\
done ;\
${ECHO} "</ul>"; \
fi ;\
fi ;\
nerrors=`${GREP} -c '^\*\*\* Error code' ${_BROKENFILE:Q} || true`; \
${ECHO} " $$nerrors ${PKGPATH}/${BROKENFILE} $$nbrokenby " >> ${BULKFILESDIR:Q}/${BROKENFILE:Q} \
) 2>&1 | ${TEE} -a ${_BROKENFILE:Q}; \
fi ; \
if [ ${_PRESERVE_WRKDIR} = "pack-if-failed" ] && [ ! -f ${PKGFILE} ]; then \
${BULK_MSG} "Making an archive from the working directory."; \
(cd ${WRKDIR} \
&& ${PAX} -wz -f ${_BULK_PKGLOGDIR}/wrkdir.tar.gz . \
) || ${TRUE}; \
fi; \
case ${_PRESERVE_WRKDIR} in \
yes|YES) ;; \
*) ${DO} ${RECURSIVE_MAKE} ${MAKEFLAGS} clean;; \
esac; \
fi
@if [ ! -f ${PKGFILE} ]; then \
${BULK_MSG} "Build for ${PKGNAME} was not successful, aborting." | ${TEE} -a ${_BROKENFILE:Q} ; \
${ECHO} "<pre>" >> ${_BROKENFILE:Q}; \
{ ${ECHO} "</pre>"; \
${ECHO} "</body>"; \
${ECHO} "</html>"; \
} >> ${_BROKENFILE:Q}; \
exitcode=1; \
else \
case ${KEEP_BUILDLOGS} in \
yes) ${TEST} ! -f ${_BUILDLOG:Q} \
|| ${MV} ${_BUILDLOG:Q} ${_BUILD_SUCCEEDED_FILE:Q}; \
;; \
no) ${RM} -f ${_BUILDLOG:Q}; \
;; \
esac; \
exitcode=0; \
fi; \
exit $$exitcode
.if ${BULKFILESDIR} != ${PKGSRCDIR}
${RUN} \
${RMDIR} ${_BULK_PKGLOGDIR:Q} 2>/dev/null 1>&2 || ${TRUE}
.endif
# Install pkg - if possible from binary pkg (i.e. available & up-to-date)
# else revert to the old recompiling.
# Don't rely upon pkg_add to snarf in depending pkgs as they may have
# been modified and need rebuilding.
.PHONY: bulk-install
bulk-install:
${RUN} if ${PKG_INFO} -qe ${PKGNAME} ; then exit 0; fi; \
if [ `${RECURSIVE_MAKE} ${MAKEFLAGS} bulk-check-uptodate REF=${PKGFILE}` = 1 ]; then \
if ${PKG_INFO} -qe ${PKGNAME} ; then :; \
else \
${DO} ${RECURSIVE_MAKE} ${MAKEFLAGS} install-depends ; \
${BULK_MSG} ${PKG_ADD} ${PKG_ARGS_ADD} ${PKGFILE} ; \
${DO} ${PKG_ADD} ${PKG_ARGS_ADD} ${PKGFILE} ; \
fi ; \
else \
${ECHO_MSG} ${MAKE} bulk-package PRECLEAN=no; \
${DO} ${RECURSIVE_MAKE} ${MAKEFLAGS} bulk-package PRECLEAN=no; \
fi
bulk-info: .PHONY
@${ECHO} pkgname ${PKGPATH} ${PKGNAME}
@:; ${DEPENDS:@d@${ECHO} ${PKGPATH} ${d:Q}@; }

505
mk/bulk/build Normal file
View File

@@ -0,0 +1,505 @@
#!/bin/sh
# $NetBSD: build,v 1.106 2009/07/09 12:46:49 he Exp $
#
# Copyright (c) 1999, 2000 Hubert Feyrer <hubertf@NetBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Hubert Feyrer for
# the NetBSD Project.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##
## Globals
##
scriptdir=`dirname "$0"`
scriptdir=`cd "${scriptdir}" && pwd`
#
# Default values for command line options.
#
resume=no
mirror_only=no
target=bulk-package
makeargs=""
noemail=no
post_only=no
prepare_only=no
##
## Functions
##
usage () {
cat <<EOF
usage: $0 [options]
$0 -h | --help
Runs a bulk pkgsrc build.
The following options are supported:
-c | --config <file>
Load the following configuration file instead of the default
one.
-e | --no-email
Don't send email when the bulk build is finished.
-h | --help
Displays this message.
-m | --mirror_only
Downloads all distfiles needed for the build but does not run
the build. IMPORTANT: Note that this will still run all the
pre-build stuff which involves removing all of your installed
packages.
The only difference between this option and a regular bulk build
is that the packages are not actually built.
-p | --post-build
Run the post-build processing and generate the report only.
--prepare
Only generate the package database that will be used when bulk
building the packages.
-r | --resume
Resume a previously interrupted bulk build.
The --resume option may be combined with the --mirror_only
option.
-s | --specific-pkgs
Sets SPECIFIC_PKGS=1 when building packages. This option is
used for building a subset of pkgsrc.
EOF
}
# print out error message and exit 1
die () {
echo "$0: error:" 1>&2
for i in "$@"; do
echo " $i" 1>&2
done
exit 1
}
# This function can be overridden in the build.conf file to change the
# output format of the bulk build. It is used in a pipe, so if you want
# the original output, just define post_filter_cmd() { cat; }.
#
# For more sophisticated output, you may use all the variables that this
# example function uses.
post_filter_cmd() {
${SED} "s;^;`date '+%Y/%m/%d %H:%M:%S'` ${percent} ${pkgdir} @ ${MACHINE_ARCH}> ;g"
}
# perform post-processing of the bulk-build results
do_post_build () {
echo "build> Post processing bulk build results..."
# Re-install BULK_PREREQ as we may need functionality (e.g. SMTP) provided by
# them for post-build to run.
echo "build> Re-installing prerequisite packages specified with BULK_PREREQ..."
for pkgdir in $BULK_PREREQ lang/perl5; do
echo "build> Installing prerequisite package $pkgdir"
( cd "${pkgsrc_dir}/${pkgdir}" \
&& ${BMAKE} bulk-install
) || die "Failed to install prerequisite packages."
done
#
# Generate the post-build report.
#
echo "build> Generating the bulk build report..."
bulk_build_id=`cat "${BULK_BUILD_ID_FILE}"` \
|| die "Could not read the bulk build ID from ${BULK_BUILD_ID_FILE}."
report_dir="${REPORTS_DIR}/${bulk_build_id}"
${MKDIR} "${report_dir}"
( cd "${pkgsrc_dir}" \
&& ${PERL5} mk/bulk/post-build \
> "${report_dir}/${REPORT_TXT_FILE}"
) || die "Could not write the results file."
}
# Notify the ADMIN of the finished build.
do_email () {
case $noemail in
no) cat "${report_dir}/${REPORT_TXT_FILE}" \
| ${MAIL_CMD} -s "pkgsrc ${OPSYS} ${OS_VERSION}/${MACHINE_ARCH} bulk build results ${bulk_build_id}" "$ADMIN"
esac
}
# output final note that we're done
do_done () {
echo ""
echo "build> Bulk build ended: `date`"
}
# set all commonly used variables, prepare files etc.
do_common_setup () {
#
# Choose an appropriate value for BMAKE depending on the operating
# system.
#
opsys=`uname -s`
case "$opsys" in
NetBSD) BMAKE=make ;;
*) BMAKE=bmake ;;
esac
export BMAKE
#
# Set resource limits as high as possible
#
ulimit -S -s `ulimit -H -s` # XXX: why do we need unlimited stack?
ulimit -S -d `ulimit -H -d` # some processes grow rather large
ulimit -S -t `ulimit -H -t` # pkgsrc bulk builds need _much_ time
#
# Find the configuration file.
#
BULK_BUILD_CONF="${BULK_BUILD_CONF-${scriptdir}/build.conf}"
case $BULK_BUILD_CONF in
/*) ;;
*) BULK_BUILD_CONF="${PWD}/${BULK_BUILD_CONF}"
esac
#
# Load the variables from the configuration file.
#
{ test -f "${BULK_BUILD_CONF}" \
&& . "${BULK_BUILD_CONF}" \
&& . "${scriptdir}/post-build-conf" \
&& check_config_vars \
&& export_config_vars
} || die "Cannot load config file ${BULK_BUILD_CONF}, aborting."
#
# Set the paths to commonly used directories.
#
pkgsrc_dir="${USR_PKGSRC}"
lintpkgsrc_dir="${USR_PKGSRC}/pkgtools/lintpkgsrc"
#
# Set up variables specific for the bulk build.
#
BATCH="1"
DEPENDS_TARGET="bulk-install"
export BATCH DEPENDS_TARGET
#
# Unset some environment variables that could disturbe the build.
#
unset CDPATH || true # ensure cd does not print new cwd to stdout, which
# confuses the printindex script.
unset DISPLAY || true # allow sane failure for gimp, xlispstat
}
# Check that the package tools are up to date.
check_tools () {
echo "build> Checking if the pkgtools are up-to-date"
( cd "${lintpkgsrc_dir}" \
&& ${BMAKE} fetch >/dev/null 2>&1
) || {
echo "build> Updating pkgtools"
( cd "${pkgsrc_dir}/pkgtools/pkg_install" \
&& ${BMAKE} clean \
&& ${BMAKE} update
) || die "Could not update the package tools."
}
}
# Run the pre-build script if necessary.
run_pre_build () {
case $resume in
yes) echo "build> Resuming -- skipping pre-build script";;
*) # make veryveryclean :)
( cd "${pkgsrc_dir}" \
&& /bin/sh mk/bulk/pre-build
) || die "Error during bulk-build preparations, aborting.";;
esac
}
# Load pkgsrc variables that affect the build process.
load_vars () {
echo "+----------------------------------------+"
echo "| Some variables used in the bulk build: |"
echo "+----------------------------------------+"
vars=" OPSYS OS_VERSION MACHINE_ARCH
BULK_PREREQ
BULKFILESDIR
BULK_DBFILE DEPENDSFILE INDEXFILE ORDERFILE STARTFILE
SUPPORTSFILE BULK_BUILD_ID_FILE BUILDLOG BROKENFILE
BROKENWRKLOG
PREFIX
AWK GREP MAIL_CMD MKDIR PAX PERL5 SED
PKG_DELETE PKG_INFO PKGBASE"
values=`cd "$lintpkgsrc_dir" && $BMAKE show-vars VARNAMES="$vars" USE_TOOLS="awk grep mail mkdir pax perl sed"`
for v in $vars; do
eval "read $v" || die "Could not read value for $v"
eval "value=\$$v"
if [ "$v" != "BULK_PREREQ" ] && [ ! "$value" ]; then
die "$v must not be empty."
fi
printf "%-15s = %s\\n" "$v" "$value"
done <<EOF
$values
EOF
echo "------------------------------------------"
[ "$PKGBASE" = "lintpkgsrc" ] \
|| die "Error reading the variables." \
"Try running $0 with another shell."
# Get the location of commonly used files
main_buildlog="${BULKFILESDIR}/${BUILDLOG}"
}
# Install prerequisite packages.
#
# Note: we do this _before_ the depends tree because some packages like
# xpkgwedge only become DEPENDS if they are installed.
install_prereqs () {
echo "build> Installing prerequisite packages specified with BULK_PREREQ..."
for pkgdir in $BULK_PREREQ; do
echo "build> Installing prerequisite package $pkgdir"
( cd "${pkgsrc_dir}/${pkgdir}" \
&& ${BMAKE} bulk-install
) || die "Could not install prerequisite packages."
done
}
# Everything is prepared. We can start building the real packages now.
#
# Loop over every package in the correct order. Before building
# each one, check to see if we've already processed this package
# before. This could happen if the build got interrupted and we
# started it again with the '-resume' option. This prevents us
# from having to do a potentially very large number of make's to
# get back to where we let off. After we build each package, add
# it to the top level buildlog
# (usually '.make' or '.make.${MACHINE}'). As a side benefit, this
# can make a progress-meter very simple to add!
do_real_bulk_build () {
cd "${pkgsrc_dir}" || die "The pkgsrc directory does not exist."
echo "build> Starting actual build using the order specified in $ORDERFILE..."
# make sure we have something to grep in in the build loop
touch "${main_buildlog}" || die "Cannot write to ${main_buildlog}."
tot=`${AWK} 'END { print NR }' "${ORDERFILE}"`
for pkgdir in `cat "${ORDERFILE}"`
do
if ${GREP} -q "^${pkgdir}\$" "${main_buildlog}"; then
: "skip this package"
else
percent=`${AWK} -v tot="${tot}" '
END {
printf("%d/%d=%4.1f%%", NR, tot, NR*100/tot);
}' "${main_buildlog}"`
( cd "${pkgsrc_dir}/${pkgdir}" \
&& ${NICE_LEVEL} ${BMAKE} USE_BULK_CACHE=yes "${target}" \
$makeargs </dev/null | post_filter_cmd
) || true
echo "$pkgdir" >> "${main_buildlog}"
check_pkg_dirs
fi
done
echo "build> Build finished."
}
check_pkg_dirs () {
for d in bin etc include info lib libexec man sbin share; do
if [ -f $PREFIX/$d ]; then
echo "Removing file, should be dir: $PREFIX/$d" >&2
rm -f $PREFIX/$d
fi
done
}
# clean up installed packages left over
do_bulk_cleanup () {
echo "build> Removing all installed packages left over from build..."
for pkgname in `${PKG_INFO} -e \*`
do
if ${PKG_INFO} -qe "${pkgname}"; then
pkgdir=`${AWK} '$2 == "'"$pkgname"'" { print $1; }' "$INDEXFILE"`
case "${BULK_PREREQ}" in
*"${pkgdir}"* )
echo "build> Keeping BULK_PREREQ: $pkgname ($pkgdir)" ;
;;
* )
echo "build> ${PKG_DELETE} -r ${pkgname}"
${PKG_DELETE} -r "${pkgname}"
if ${PKG_INFO} -qe "${pkgname}"; then
echo "build> $pkgname ($pkgdir) did not deinstall nicely. Forcing the deinstall"
${PKG_DELETE} -f "${pkgname}" || true
fi
;;
esac
fi
done
}
# start the full bulk-build
do_bulk_build () {
echo "build> Bulk build started: `date`"
echo ""
# this function from post-build-conf
show_config_vars
check_tools
run_pre_build
load_vars
#
# Create the directory for the log files if necessary
#
if [ "${BULKFILESDIR}" != "${pkgsrc_dir}" ]; then
${MKDIR} "${BULKFILESDIR}"
fi
#
# Save the bulk build ID in a file, as it most often contains a time
# stamp.
#
case $resume in
no) echo "${REPORT_BASEDIR}" > "${BULK_BUILD_ID_FILE}" \
|| die "Could not save the bulk build ID in ${BULK_BUILD_ID_FILE}.";;
esac
install_prereqs
#
# Create the bulk cache files.
#
if [ "x$resume" != "xyes" ]; then
( cd "${pkgsrc_dir}" \
&& env PKGLIST="${PKGLIST-}" ${BMAKE} bulk-cache $makeargs
) || die "Could not create the bulk build cache."
else
if [ ! -f "${ORDERFILE}" ]; then
die "The ${ORDERFILE} does not exist." \
"(You cannot resume a bulk build that has not yet started.)"
fi
fi
# XXX: This looks like a hack, and indeed, the functions in this file
# should be reorganized to better reflect the phases of the bulk build.
if [ $prepare_only = yes ]; then
exit 0
fi
do_real_bulk_build
do_bulk_cleanup
}
##
## main
##
#
# Parse the command line.
#
while test $# -gt 0; do
case $1 in
-c|--config)
shift
BULK_BUILD_CONF=$1; shift
;;
-e|--no-email)
noemail=yes
shift
;;
-h|--help)
usage
exit 0
;;
-m|--mirror_only)
mirror_only=yes
target=mirror-distfiles
shift
;;
-p|--post-build)
post_only=yes
shift
;;
--prepare)
prepare_only=yes
shift
;;
-r|--resume|--restart|restart)
resume=yes
shift
;;
-s|--specific-pkgs)
makeargs="$makeargs SPECIFIC_PKGS=1"
shift
;;
*)
echo "unknown option: $1" 1>&2
usage 1>&2
exit 1
;;
esac
done
do_common_setup
if [ "x$post_only" = "xyes" ]; then
load_vars
do_post_build
exit 0
fi
do_bulk_build
# for now, just quit if we were only mirroring distfiles. At somepoint we
# should teach the post-build script to generate a nice report about how many
# distfiles were downloaded, how many had bad checksums, failed master sites,
# network speed, etc.
if [ "x$mirror_only" = "xyes" ]; then
echo "build> Bulk mirror of distfiles completed: `date`"
exit 0
fi
do_post_build
do_email
do_done

106
mk/bulk/build.conf-example Normal file
View File

@@ -0,0 +1,106 @@
# $NetBSD: build.conf-example,v 1.39 2011/04/22 09:03:52 spz Exp $
#
# This is an example configuration file for pkgsrc bulk builds.
# Actually it's a shell script that is sourced in by the pre-build,
# build and post-build programs.
#
#
# System information
#
# The OS release this bulk build is happening on.
osrev=`uname -r`
# Where our pkgsrc is located.
USR_PKGSRC="/usr/pkgsrc"
# An absolute pathname to your mk.conf file.
# The file must be outside ${PREFIX}, or it will be overwritten.
#MAKECONF="$HOME/etc/mk.conf"
#
# Getting distfiles
#
# Prune distfiles to remove those which are out of date.
# Can be set to 'yes' or 'no'.
PRUNEDISTFILES=no
# Proxies (optional):
#ftp_proxy=http://proxy.machi.ne:3128/
#http_proxy=http://proxy.machi.ne:3128/
#
# Building the packages
#
# List of package directories to build.
# Defaults to all packages if PKGLIST is empty or undefined.
#PKGLIST="www/mozilla meta-pkgs/kde3"
# Nice level for builds
NICE_LEVEL="nice -n 20"
# Whether to cache the lintpkgsrc database for PRUNE* or uploading.
# Can be set to 'yes' or 'no'.
LINTPKGSRC_CACHE=no
#
# Generating the report
#
# Where build will mail the report.
ADMIN="you@some.whe.re"
# Who the report is signed by.
ADMINSIG="-Your Name"
# The directory where the final reports are collected.
#REPORTS_DIR="$HOME/bulk-logs"
REPORTS_DIR="/home/ftp/pub/NetBSD/pkgstat"
# The URL where the final reports will be available.
REPORTS_URL="ftp://localhost/pub/NetBSD/pkgstat"
# The basename of the directory of the current bulk build. This
# directory will be created under ${REPORTS_DIR}. After uploading the
# report, it will also be available under ${REPORTS_URL}.
REPORT_BASEDIR=`date +%Y%m%d.%H%M`
# The basenames of the the two report files, which will both be created
# in ${REPORTS_DIR}/${REPORT_BASEDIR}.
REPORT_HTML_FILE="report.html"
REPORT_TXT_FILE="report.txt"
#
# Uploading binary packages
#
# Optional flags, however these variables must be left defined (even if empty) to
# satisfy 'set -eu' in bulk scripts.
AUDIT_PACKAGES_FLAGS=
DOWNLOAD_VULNERABILITY_LIST_FLAGS=
# Update vulnerability database before uploading.
# Can be set to 'yes' or 'no'.
UPDATE_VULNERABILITY_LIST=yes
# Prune binary packages to remove those which are out of date.
# Can be set to 'yes' or 'no'.
PRUNEPACKAGES=yes
# Whether or not to create checksum files.
MKSUMS=yes
# Whether or not to create the summary file.
MKSUMMARY=no
# If you want to PGP sign the checksum files, set and correct.
#SIGN_AS=username@NetBSD.org
# Destination for packages and rsync options.
RSYNC_DST=ftp.NetBSD.org:/pub/pkgsrc/packages/NetBSD/SomeArch/${osrev}-201xQy/
RSYNC_OPTS='-e ssh'

14
mk/bulk/do-sandbox-build Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
# $NetBSD: do-sandbox-build,v 1.12 2005/07/13 22:07:46 rillig Exp $
#
# Script to start a sandbox build
#
# See pkgsrc/doc/pkgsrc.txt for documentation!
#
sh="/bin/sh"
build="mk/bulk/build"
chroot /usr/sandbox \
$sh -c "cd /usr/pkgsrc && exec $sh $build \"\$@\"" $build "$@"

14
mk/bulk/do-sandbox-upload Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
# $NetBSD: do-sandbox-upload,v 1.5 2005/07/13 22:07:46 rillig Exp $
#
# Script to start a sandbox build
#
# See pkgsrc/doc/pkgsrc.txt for documentation!
#
sh="/bin/sh"
upload="mk/bulk/upload"
chroot /usr/sandbox \
$sh -c "cd /usr/pkgsrc && exec $sh $upload \"\$@\"" $upload "$@"

105
mk/bulk/environment.txt Normal file
View File

@@ -0,0 +1,105 @@
# $NetBSD: environment.txt,v 1.5 2006/12/15 13:15:06 martti Exp $
#
===> Environment variables used by the bulk build scripts
This file lists all(?) the environment and pkgsrc variables that
directly influence the bulk build process, grouped by the script in
which they are used.
===> mk/bulk/build
=> Settable by the user
BULK_BUILD_CONF: Pathname
The configuration file for the bulk build.
http_proxy: URL
The HTTP proxy used for fetching distfiles.
ftp_proxy: URL
The FTP proxy used for fetching distfiles.
USR_PKGSRC: Pathname
The location of the pkgsrc root directory.
=> User-defined in mk.conf
BULK_DBFILE
DEPENDSTREEFILE
DEPENDSFILE
SUPPORTSFILE
INDEXFILE
ORDERFILE
BROKENFILE
BROKENWRKLOG
FORCEBROKENFILE
BUILDLOG
STARTFILE
BULK_PREREQ
=> Set by the script
BATCH=1
Used by pkgsrc.
BMAKE={make,bmake}
The make(1) program used for building the packages.
DEPENDS_TARGET=bulk-install
Used by pkgsrc.
### to be continued in line 191
===> mk/bulk/pre-build
=> User-definable
BULK_BUILD_CONF: Pathname
PRUNEDISTFILES: Boolean := no
PRUNEPACKAGES: Boolean := yes
PRUNELINKS: Boolean := yes
UPDATE_VULNERABILITY_LIST: Boolean := yes
USR_PKGSRC: Pathname
=> User-defined in mk.conf
BROKENFILE
BROKENWRKLOG
BUILDLOG
LINTPKGSRC_DB
STARTFILE
LOCALBASE
X11BASE
DISTDIR
PKG_DBDIR
DEPOTBASE
PKG_TOOLS_BIN
PACKAGES
=> Set by the script
BROKENF: Filename
Filename where the build log is saved when the build fails.
BRKWRKLOG: Filename
Filename where the work log is saved when the build fails.
BLDLOG: Filename
Filename where ? is saved when the build fails.
LINTPKGSRC_DB: Filename
Filename of the lintpkgsrc database.
STARTFILE: Filename
Cookie file to determine whether the build has started.
LOCALBASE: Pathname
Like in pkgsrc.
X11BASE: Pathname
Like in pkgsrc.
DISTDIR: Pathname
Like in pkgsrc.
PKG_DBDIR: Pathname
Like in pkgsrc.
DEPOTBASE: Pathname
Like in pkgsrc.
PKG_TOOLS_BIN: Pathname
Like in pkgsrc.
PACKAGES: Pathname
Like in pkgsrc.
=> Files used by the script
mk/bulk/pre-build.local: Shellscript

207
mk/bulk/parallel.txt Normal file
View File

@@ -0,0 +1,207 @@
# $Id: parallel.txt,v 1.7 2006/12/15 12:46:24 martti Exp $
#
These are my (<dmcmahill>) thoughts on how one would want a parallel
bulk build to work.
====================================================================
Single Machine Build Process
====================================================================
The current (as of 2003-03-16) bulk build system works in the
following manner:
1) All installed packages are removed.
2) Packages listed in the BULK_PREREQ variable are installed. This
must be done before step 3 as some packages (like xpkgwedge) can
affect the dependencies of other packages when installed.
3) Each package directory is visited and its explicitly listed
dependencies are extracted and put in a 'dependstree' file. The
mk/bulk/tflat script is used to generate flattened dependencies
for all packages from this dependstree file in both the up and
down directions. The result is a file 'dependsfile' which has one
line per package that lists all build dependencies. Additionally,
a 'supportsfile' is created which has one line for each package
and lists all packages which depend upon the listed pacakge.
Finally, tsort(1) is applied to the 'dependstree' file to
determine the correct build order for the bulk build. The build
order is stored in a 'buildorder' file. This is all achieved via
the 'bulk-cache' top level target. By extracting dependencies in
this fashion, we avoid highly redundant recursive make calls. For
example, we no longer need to use a recursive make to find the
dependencies for libtool literally thousands and thousands of
times throughout the build.
4) During the build, the 'buildorder' file is consulted to figure out
which package should be built next. Then to build the package,
the following steps are taken:
a) Check for the existance of a '.broken' file in the package
directory. If this file exists, then the package is already
broken for some reason so move on to the next package.
b) Remove all packages which are not needed to build the current
package. This dependency list is obtained from the 'dependsfile'
created in step 3 and the BULK_PREREQ variable.
c) Install via pkg_add all packages which are needed to build the
current package. We are able to do this because we have been
building our packages in a bottom up order so all dependencies
should have been built.
d) Build and package the package.
e) If the package build fails, then we copy over the build log to
a .broken file and in addition, we consult the 'supportsfile' and
mark all packages which depend upon this one as broken by adding a
line to their .broken files (creating them if needed). By going
ahead and marking these packages as broken, we avoid wasting time
on them later.
f) Append the package directory name to the top level pkgsrc
'.make' file to indicate that we have processed this package.
5) Run the mk/bulk/post-build script to collect the summary and
generate html pages and the email we've all seen.
====================================================================
Single Machine Build Comments
====================================================================
There are several features of this approach that are worth mentioning
explicitly.
1) Packages are built in the correct order. We don't want to rebuild
the gnome meta-pkg and then rebuild gnome-libs for example.
2) Restarting the build is a cheap operation. Remember that this
build can take weeks or more. In fact the 1.6 build took nearly 6
weeks on a sparc 20! If for some reason, the build needs to be
interrupted, it can be easily restarted because in step 4f we keep
track of what has been built in a file. The lines in the build
script which control this are:
for pkgdir in `cat $ORDERFILE` ; do
if ! grep -q "^${pkgdir}\$" $BUILDLOG ; then
(cd $pkgdir && \
nice -n 20 ${BMAKE} USE_BULK_CACHE=yes bulk-package)
fi
done
In addition to storing the progress to disk, the bulk cache files
(the 'dependstreefile', 'dependsfile', 'supportsfile', and
'orderfile') are stored on disk so they do not need to be
recreated if a build is stopped and then restarted.
3) By leaving packages installed and only deleting the ones which are
not needed before each build, we reduce the amount of installing
and deinstalling needed during the build. For example, it is
quite common to build several packages in a row which all need GNU
make or perl.
4) Using the 'supportsfile' to mark all packages which depend upon a
package which has just failed to build can greatly reduce the time
wasted on trying to build packages which known broken dependencies.
====================================================================
Parallel Build Thoughts
====================================================================
To exploit multiple machines in an attempt to reduce the build time,
many of the same ideas used in the single machine build can still be
used. My view of how a parallel build should work is detailed here.
master == master machine. This machine is in charge of directing
the build and may or may not actively participate in it.
In addition, this machine might not be of the same
architecture or operating system as the slaves (unless it
is to be used as a slave as well).
slave#x == slave machine #x. All slave machines are of the same
MACHINE_ARCH and have the same operating system and access
the same pkgsrc tree via NFS and access the same binary
packages directory.
If the master machine is also to be used as a build
machine, then it is also considered a slave.
Prior to starting the build, the master directs one of the slaves to
extract the dependency information per steps 1-3 in the single machine
case.
The actually build should progress as follows:
1) For each slave which needs a job, the master assigns a package to
build based on the rule that only packages that have had all their
dependencies built will be sent to slaves for compilation.
2) When a slave finishes, the master either notes that the binary
package is now available for use as a depends _or_ notes failure
and marks all packages which depend upon it as broken as in step
4e of the single machine build.
Each slave builds a package in the same way as it would in a single
machine build (steps 4a-d).
====================================================================
Important Parallel Build Considerations
====================================================================
1) Security. Packages are installed as root prior to packaging.
2) All state kept by the master should be stored to disk to
facilitate restarting a build. Remember this could take weeks so
we don't want to have to start over.
3) The master needs to be able to monitor all slaves for signs of
life. I.e., if a slave machine is simply shut off, the master
should detect that it's no longer there and re-assign that slaves
current job.
3a) The master must be able to distinguish between a slave failing to
compile a package due to the package failing vs a
network/power/disk/etc. failure. The former causes the package to
be marked as broken, the latter causes the slave to be marked as
broken.
4) Ability to add and remove slaves from the cluster during a build.
Again, a build may take a long time so we want to add/remove
slaves while the build is in progress.
====================================================================
Additional Thoughts
====================================================================
This is mostly related to using slaves which are not on a local
network.
- maybe a hook could be put in place which rsync's the binary package
tree between the binary package repository machine and the slave
machine before and after each package is built?
- security
- support for Kerberos?
====================================================================
Implementation Thoughts
====================================================================
- Can this all be written around using ssh to send out tasks? How do
we monitor slaves for signs of life? How do we indicate 'build
failed/build succeeded/slave failed' conditions?
- Maybe we could have a file listing slaves and the master consults
this each time it needs a slave. That would make adding/removing
slaves easy. There would need to be another file to keep track of
which slaves are busy (and with what).
- Do we want to use something like pvm instead? There is a
p5-Parallel-Pvm package and perl nicely deals with parsing some of
these files and sorting dependencies although I hate to add any
extra dependencies to the build system.

722
mk/bulk/post-build Normal file
View File

@@ -0,0 +1,722 @@
#!/usr/pkg/bin/perl
# $NetBSD: post-build,v 1.71 2008/06/13 21:52:16 sketch Exp $
#
# Collect stuff after a pkg bulk build
#
# (c) 2000 Hubert Feyrer, All Rights Reserved.
#
use File::Basename;
use POSIX qw(strftime);
use strict;
use warnings;
#
# Global variables
#
my %vars;
my $verbose = 1; # set to 2 to see more command execution detail
#
# Helper functions
#
sub pb_die($$) {
my ($fname, $msg) = @_;
my ($text, $sep);
$text = "[post-build] error: ";
$sep = "";
if (defined($fname)) {
$text .= "${sep}${fname}";
$sep = ": ";
}
$text .= "${sep}${msg}";
die "${text}\n";
}
sub my_system (@) {
print STDERR '> '.join(' ', @_)."\n" if ($verbose >= 2);
return system(@_);
}
sub readfirstline($) {
my ($fname) = @_;
my ($contents);
open(F, "<", $fname)
or pb_die($fname, "Cannot be read: $!");
defined($contents = <F>)
or pb_die($fname, "Must not be empty.");
chomp($contents);
close(F)
or pb_die($fname, "Cannot be closed: $!");
return $contents;
}
#
# Load configuration variables from the bulk.conf file, which is a shell
# script.
#
my $BULK_BUILD_CONF = $ENV{BULK_BUILD_CONF} || (dirname($0).'/build.conf');
$BULK_BUILD_CONF = "./$BULK_BUILD_CONF" if ($BULK_BUILD_CONF !~ m:^/:);
if (!-f $BULK_BUILD_CONF) {
pb_die($BULK_BUILD_CONF, "Does not exist.");
}
# Dig given variable out of config file, and set it
sub get_build_conf_vars(@) {
my (@varnames) = @_;
my ($is_set, $value);
foreach my $varname (@varnames) {
my $cmd = join("\n", (
#"set -eu", # TODO: Should be enabled soon
". '${BULK_BUILD_CONF}'",
". mk/bulk/post-build-conf",
"check_config_vars",
"echo \"\${${varname}+set}\"",
"echo \"\${${varname}-}\""
));
open(CMD, "${cmd} |")
or pb_die($BULK_BUILD_CONF, "Could not evaluate configuration file.");
chomp($is_set = <CMD>);
{ local $/ = undef; $value = <CMD>; }
chomp($value); # This must be outside the above {...} block
close(CMD) or pb_die($BULK_BUILD_CONF, "Could not evaluate configuration file (close).");
#
# Sanity checks
#
if ($is_set ne "set") {
pb_die($BULK_BUILD_CONF, "${varname} must be set.");
}
if ($value =~ qr"^\s+$") {
pb_die($BULK_BUILD_CONF, "${varname} must be non-empty.");
}
if ($value =~ qr"\n") {
pb_die($BULK_BUILD_CONF, "${varname} must not contain newlines.");
}
$vars{$varname} = $value;
if ($verbose >= 2) {
print STDERR "> $varname=$vars{$varname}\n";
}
}
}
get_build_conf_vars(
'ADMINSIG', # "-Your Name"
'REPORTS_URL', # "ftp://ftp.example.com/pub/pkgsrc/misc/pkgstat"
'REPORTS_DIR', # "$HOME/bulk-logs"
# REPORT_BASEDIR often depends on a timestamp, which has been saved at
# the beginning of the bulk build in the BULK_BUILD_ID_FILE. It will be
# retrieved later.
'REPORT_HTML_FILE', # "report.html"
'REPORT_TXT_FILE', # "report.txt"
'USR_PKGSRC', # "/usr/pkgsrc"
'osrev', # `uname -r`
);
my $os = `uname -s`;
chomp $os;
my $BMAKE = $ENV{BMAKE} || pb_die(undef, "The BMAKE environment variable must be set.");
sub get_mk_conf_vars (@) {
my ($rest);
open(I, "set -e; . '$BULK_BUILD_CONF'; . '$vars{USR_PKGSRC}/mk/bulk/post-build-conf'; export_config_vars; cd $vars{USR_PKGSRC}/pkgtools/lintpkgsrc && $BMAKE show-vars BATCH=1 VARNAMES='".join(' ', @_)."' USE_TOOLS=\"pax\" |")
or pb_die(undef, "Cannot get mk.conf variables.");
foreach my $var (@_) {
chomp($vars{$var} = <I>);
if ($vars{$var} eq "") {
pb_die(undef, "\${$var} must be defined in your mk.conf");
}
print STDERR "> $var=$vars{$var}\n" if ($verbose >= 2);
}
{ local $/ = undef; $rest = <I>; }
if (defined($rest) && $rest ne "") {
pb_die(undef, "Output of $BMAKE show-vars too long:\n${rest}");
}
close(I) or die pb_die(undef, "Cannot get mk.conf variables (close).");
}
# Extract the names of the files used for the build log and broken build logs.
# These have defaults set by bsd.bulk-pkg.mk and may be overridden in
# /etc/mk.conf
get_mk_conf_vars(qw(
BROKENFILE
BROKENWRKLOG
BULKFILESDIR
BULK_DBFILE
DEPENDSFILE
DEPENDSTREEFILE
FIND
INDEXFILE
LOCALBASE
MACHINE_ARCH
NOT_AVAILABLE_FILE
ORDERFILE
PAX
PKG_DBDIR
PKGSRC_COMPILER
STARTFILE
SUPPORTSFILE
X11BASE
PKG_TOOLS_BIN
BULK_BUILD_ID_FILE
));
my $bulk_dbfile_base = basename($vars{BULK_DBFILE});
my $dependstreefile_base = basename($vars{DEPENDSTREEFILE});
my $dependsfile_base = basename($vars{DEPENDSFILE});
my $supportsfile_base = basename($vars{SUPPORTSFILE});
my $indexfile_base = basename($vars{INDEXFILE});
my $orderfile_base = basename($vars{ORDERFILE});
my $reports_url = $vars{"REPORTS_URL"};
my $reports_dir = $vars{"REPORTS_DIR"};
my $report_basedir = readfirstline($vars{"BULK_BUILD_ID_FILE"});
my $report_html_file = $vars{"REPORT_HTML_FILE"};
my $report_txt_file = $vars{"REPORT_TXT_FILE"};
my $report_url = "${reports_url}/${report_basedir}";
my $report_dir = "${reports_dir}/${report_basedir}";
my $report_html_path = "${report_dir}/${report_html_file}";
my $report_txt_path = "${report_dir}/${report_txt_file}";
my $startdate = (stat($vars{STARTFILE}))[9];
my $enddate = '';
if (!defined($startdate) || $startdate == 0) {
$startdate = "unknown";
} else {
local $ENV{TZ} = "UTC";
$startdate = strftime("%c %Z", gmtime($startdate));
$enddate = strftime("%c %Z", gmtime(time()));
}
sub print_summary_line($$) {
my ($name, $value) = @_;
printf(" %-30s %s\n", $name, $value);
}
sub print_report_line($$$) {
my ($pkgpath, $breaks, $maintainer) = @_;
printf("%-26s %-7s %s\n", $pkgpath, $breaks, $maintainer);
}
sub print_report_header() {
print_report_line("Package", "Breaks", "Maintainer");
print("--------------------------------------------------------------\n");
}
my_system("mkdir", "-p", "--", $report_dir);
# Copy over the output from the build process
chdir($vars{"BULKFILESDIR"}) or pb_die($vars{"BULKFILESDIR"}, "Cannot change directory.");
my_system("find . -name $vars{BROKENFILE} -print -o -name $vars{BROKENWRKLOG} -print | $vars{PAX} -r -w -X ${report_dir}");
# Copy over the cache files used during the build
foreach my $f qw(BULK_DBFILE DEPENDSTREEFILE DEPENDSFILE SUPPORTSFILE INDEXFILE ORDERFILE) {
if (-f $vars{$f}) {
my_system("cp", "--", $vars{$f}, $report_dir);
}
}
chdir($report_dir) or pb_die($report_dir, "Cannot change directory.");
writeReport();
#
# Adjust "last" symlink
#
unlink("${reports_dir}/last");
symlink($report_basedir, "${reports_dir}/last");
#
# Generate leftovers-$vars{MACHINE_ARCH}.html: files not deleted
# Leftover files are copied to leftovers-$vars{MACHINE_ARCH} dir,
# and linked from leftovers-$vars{MACHINE_ARCH}.html
#
{
chdir($report_dir) or pb_die($report_dir, "Cannot change directory.");
my_system("mkdir", "-p", "leftovers-$vars{MACHINE_ARCH}");
# Find files since last build:
my $leftovers_txt = "leftovers-$vars{MACHINE_ARCH}.txt";
my $leftovers_html = "leftovers-$vars{MACHINE_ARCH}.html";
my_system("$vars{FIND} $vars{LOCALBASE}/ -newer $vars{STARTFILE} -type f -print >>$leftovers_txt");
my_system("$vars{FIND} $vars{X11BASE}/ -newer $vars{STARTFILE} -type f -print >>$leftovers_txt");
# Strip perl-files:
my $perlfiles;
{
local $/;
undef $/;
$perlfiles = `$vars{PKG_TOOLS_BIN}/pkg_info -qL perl*`;
}
my $perlfiles_pattern = $perlfiles;
$perlfiles_pattern =~ s/\n/|/g;
$perlfiles_pattern =~ s/|$//;
open (LEFT, $leftovers_txt) or die "can't read $leftovers_txt: $!";
my @left = <LEFT>;
close (LEFT);
my @leftovers = grep(!/^(?:${perlfiles_pattern})$/, @left);
if (index($vars{PKG_DBDIR}, $vars{LOCALBASE}) == 0) {
# If PKG_DBDIR is inside LOCALBASE, exclude it from the leftovers.
@leftovers = grep { index($_, $vars{PKG_DBDIR}) != 0 } @leftovers;
}
open (LEFT, ">$leftovers_txt") or die "can't write $leftovers_txt: $!";
print LEFT @leftovers;
close (LEFT);
if (scalar(@leftovers)) {
# Store leftovers, for easier identification:
my_system("$vars{PAX} -r -w -X leftovers-$vars{MACHINE_ARCH} < $leftovers_txt");
}
# Add links to leftover list:
open (OUT, "> $leftovers_html")
or die "can't write $leftovers_html";
print OUT <<EOOUT;
<html>
<body>
<pre>
EOOUT
foreach (@leftovers) {
chomp;
print OUT "<a href=\"${report_url}/leftovers-$vars{MACHINE_ARCH}$_\">$_</a>\n";
}
print OUT <<EOOUT2;
</pre>
</body>
</html>
EOOUT2
close(OUT);
}
# print the result of a single broken package
sub pkgResult ($$) {
my ($pinfo, $state) = @_;
my $pkg = $pinfo->{pkg};
my $nbrokenby = $pinfo->{nbrokenby};
my $nerrors = $pinfo->{nerrors};
my $pkgdirmissing = 0;
my $DIR;
if (not opendir($DIR, "$vars{USR_PKGSRC}/$pkg")) {
$pkgdirmissing=1;
}
else {
closedir($DIR);
}
my @idents = "";
if (not $pkgdirmissing) {
@idents = `$vars{FIND} $vars{USR_PKGSRC}/$pkg -type f -print | xargs grep \\\$NetBSD`;
}
my $datetime = "";
my $file = "";
my $ver = "";
foreach my $ident (@idents) {
$ident =~ /\$[N]etBSD: ([^ ]*),v [^ ]* ([^ ]*) ([^ ]*) [^ ]* Exp \$/;
if (defined($2) && defined($3) && ("$2 $3" gt $datetime)) {
$datetime = "$2 $3";
$file = $1;
$ver = $1;
}
}
my $maintainer;
if (not $pkgdirmissing) {
$maintainer = `grep ^MAINTAINER $vars{USR_PKGSRC}/$pkg/Makefile`;
} else {
$maintainer = "directory_does_not_exist";
}
$maintainer =~ s/MAINTAINER=[ \t]*//;
if (! $maintainer) {
$maintainer = `cd $vars{USR_PKGSRC}/$pkg ; $BMAKE show-var VARNAME=MAINTAINER`;
}
$maintainer =~ s/</&lt;/g;
$maintainer =~ s/>/&gt;/g;
chomp($maintainer);
(my $state_style = $state) =~ s/ //g;
my $nbrokenby_html = '<td>&nbsp;</td>';
$nbrokenby_html =
'<td align="right" class="pkg-'.$state_style.'">'.$nbrokenby.'</td>'
if $nbrokenby > 0;
if ($pinfo->{nerrors} != 0 && $verbose && ($state eq "broken" || $state eq "topten")) {
print_report_line($pkg, $nbrokenby > 0 ? $nbrokenby : "", $maintainer);
}
return <<EOHTML;
<tr>
<td><a class="pkg-$state_style" href="$pinfo->{bf}" title="build log for $pkg">$pkg</a></td>
$nbrokenby_html
<td>$file</td>
<td>$maintainer</td>
</tr>
EOHTML
}
# write the build report
sub writeReport {
my $broken = getBroken();
my $nbroken = scalar(@{$broken->{"broken"}});
my $nbrokendep = scalar(@{$broken->{"broken depends"}});
my $nunpackaged = scalar(@{$broken->{"not packaged"}});
my $nnot_available = scalar(@{$broken->{"not available"}});
my $nbrokentot = $nbroken + $nbrokendep;
my $ntotal = $nunpackaged + $nbroken + $nbrokendep;
# determine the number of packages attempted, and then successful
open(ORDER, $vars{ORDERFILE}) || die "can't open $vars{ORDERFILE}: $!";
my @order = <ORDER>;
close(ORDER);
my $nattempted = scalar(@order);
my $nsuccessful = $nattempted - $ntotal;
if ($verbose) {
print <<EOF;
pkgsrc bulk build results
$os $vars{osrev}/$vars{MACHINE_ARCH}
Compiler: $vars{PKGSRC_COMPILER}
Summary:
EOF
print_summary_line("Build started:", $startdate);
print_summary_line("Build ended:", $enddate);
print("\n");
print_summary_line("Successfully packaged:", $nsuccessful);
print_summary_line("Packages really broken:", $nbroken);
print_summary_line("Pkgs broken due to them:", $nbrokendep);
print_summary_line("Total broken:", $nbrokentot);
print_summary_line("Not packaged:", $nunpackaged);
print_summary_line("Not available:", $nnot_available);
print_summary_line("Total:", $ntotal);
print <<EOF;
Packages not listed here resulted in a binary package. The build
report, including logs of failed/not-packaged is available from:
${report_url}/${report_html_file}
EOF
}
open(HTML, ">", $report_html_path) or die "Can't write ${report_html_path}: $!";
print HTML <<EOHTML;
<html>
<head>
<title>$os $vars{osrev}/$vars{MACHINE_ARCH} bulk package build</title>
<style type="text/css">
<!--
body {
Font-Family: Tahoma, Verdana, sans-serif;
Line-Height: 1.3em;
Text-Decoration: None;
Color: black;
Background-Color: white;
Border-Width: 0;
}
table {
Border-Width: 0;
}
table td {
Font-Family: Tahoma, Verdana, sans-serif;
line-height: 1em;
}
a:link {
Color: #3535c5;
}
a:visited {
Color: #700080;
}
a:hover {
Color: #6565e5;
Text-Decoration: underline;
}
tr {
Vertical-Align: top;
}
td {
Vertical-Align: top;
}
h1 {
Font-Size: 3.5ex;
Line-Height: 1em;
Color: #000066;
}
h2 {
Font-Size: 2.5ex;
Line-Height: 1em;
Color: #660000;
}
h3 {
Font-Size: 2ex;
Color: #660066;
}
h4 {
Font-Size: 1.8ex;
Color: #006600;
}
tt.filename {
Line-Height: 1.3em;
Color: #AA0000;
}
.pkgname {
Font-Family: Arial, Helvetica, Courier, fixed;
Font-Style: Italic;
Text-Decoration: none;
Line-Height: 1.3em;
}
.pkg-broken {
Color: red;
}
.pkg-brokendepends {
Color: orange;
}
.pkg-notpackaged {
Color: blue;
}
-->
</style>
</head>
<body bgcolor="white" text="black" link="#3535c5" vlink="#700080" alink="#3535c5">
<a name="top"></a>
<h1>pkgsrc bulk build results</h1>
<h2>$os $vars{osrev}/$vars{MACHINE_ARCH}</h2>
<h3>Summary</h3>
<table>
<tr>
<td>Build started: <td align="right">$startdate</td>
</tr>
<tr>
<td>Build ended: <td align="right">$enddate</td>
</tr>
<tr>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr>
<tr>
<td>Successfully packaged:</td> <td align="right">$nsuccessful</td>
</tr>
<tr class="pkg-broken">
<td>Packages really broken:</td> <td align="right">$nbroken</td>
</tr>
<tr class="pkg-brokendepends">
<td>Packages broken due to them:</td> <td align="right">$nbrokendep</td>
</tr>
<tr>
<td>Total broken:</td> <td align="right">$nbrokentot</td>
</tr>
<tr class="pkg-notpackaged">
<td>Not packaged:</td> <td align="right">$nunpackaged</td>
</tr>
<tr class="pkg-notavailable">
<td>Not available:</td> <td align="right">$nnot_available</td>
</tr>
<tr>
<td>Total:</td> <td align="right">$ntotal</td>
</tr>
</table>
<p>
Packages not listed here resulted in a <a
href="../../packages/" title="binary packages for $os $vars{osrev}/$vars{MACHINE_ARCH}">binary
package</a>. Results of failed packages are available below.
</p>
<p>
Files leftover from the build (because of broken PLISTs, etc.) can be
found in <a href="leftovers-$vars{MACHINE_ARCH}.html" title="leftover files">this
list</a>.
</p>
<p>
Jump to:<br/>
<ul>
<li><a href="#topten">Top Ten Offenders</a></li>
<li><a href="#broken">Broken packages</a></li>
<li><a href="#broken depends">Broken dependencies</a></li>
<li><a href="#not packaged">Not packaged</a></li>
<li><a href="#not available">Not available</a></li>
</ul>
</p>
EOHTML
my %state_head = (
"topten" => "Top Ten Offenders",
"broken" => "Broken packages",
"broken depends" => "Broken dependencies",
"not packaged" => "Not packaged",
"not available" => "Not available",
);
foreach my $state ("topten", "broken", "broken depends", "not packaged", "not available") {
next unless scalar(@{$broken->{$state}});
if ($verbose && ($state eq "topten" || $state eq "broken")) {
print "\n\n$state_head{$state}\n\n";
print_report_header();
}
print HTML <<EOHTML;
<a name="$state"></a>
<h2>$state_head{$state}</h2>
<table width="100%">
<tr align="left">
<th width="30%">Package</th>
<th>Breaks</th>
<th>File touched last</th>
<th>Maintainer</th>
</tr>
EOHTML
foreach my $pinfo (@{$broken->{$state}}) {
print HTML pkgResult($pinfo, $state);
}
print HTML <<EOHTML;
</table>
<hr>
<a href="#top">Up to top</a><br/>
<hr>
EOHTML
}
print HTML <<EOHTML;
<hr>
<p>
The following cache files were used during the build:
</p>
<ul>
<li>The <a href="$bulk_dbfile_base">SPECIFIC_PKGS bulk database file</a>.</li>
<li>The <a href="$dependstreefile_base">depends tree file</a>.</li>
<li>The <a href="$dependsfile_base">depends file</a>.</li>
<li>The <a href="$supportsfile_base">supports file</a>.</li>
<li>The <a href="$indexfile_base">index file</a>.</li>
<li>The <a href="$orderfile_base">build order file</a>.</li>
</ul>
<hr>
<p>
<ul>
<!-- <li>See the list of <a href="../index.html">all log files</a>. -->
<li>Visit the <a href="http://www.NetBSD.org">NetBSD web site</a>.
<li>Learn more about
<a href="http://www.NetBSD.org/docs/software/packages.html">
The NetBSD Packages Collection</a>.
</ul>
</p>
</body>
</html>
EOHTML
close(HTML);
if ($verbose) {
print "\n\n$vars{ADMINSIG}\n\n";
print "[* This message was created by the Packages Collection bulk build software *]\n";
}
}
# get and sort the broken packages
sub getBroken {
my $res = {
'broken' => [],
'broken depends' => [],
'not packaged' => [],
'topten' => [],
"not available" => [],
};
open (BF, $vars{BROKENFILE}) || return $res;
my @in = <BF>;
close (BF);
foreach (@in) {
chomp;
my ($nerrors, $bf, $nbrokenby) = split;
my $pkg = $bf;
$pkg =~ s,/$vars{BROKENFILE},,;
my $tmp = {
bf => $bf,
pkg => $pkg,
nbrokenby => $nbrokenby,
nerrors => $nerrors,
};
if (-f "$vars{BULKFILESDIR}/$pkg/$vars{NOT_AVAILABLE_FILE}") {
push(@{$res->{"not available"}}, $tmp);
} elsif ($nerrors > 0) {
push(@{$res->{"broken"}}, $tmp);
} elsif ($nerrors == -1) {
push(@{$res->{"broken depends"}}, $tmp);
} else {
push(@{$res->{"not packaged"}}, $tmp);
}
}
# sort pkgs in each state
foreach my $state ("broken", "broken depends", "not packaged", "not available") {
$res->{$state} = [ sort { $a->{pkg} cmp $b->{pkg} } @{$res->{$state}} ];
}
$res->{"topten"} = [ sort { $b->{nbrokenby} <=> $a->{nbrokenby} } @{$res->{"broken"}} ];
for (my $count = $#{$res->{"topten"}}; $count >= 10; $count--) {
pop(@{$res->{"topten"}});
}
return $res;
}

203
mk/bulk/post-build-conf Normal file
View File

@@ -0,0 +1,203 @@
# $NetBSD: post-build-conf,v 1.14 2007/03/06 10:57:11 rillig Exp $
#
# This file is included after the build.conf file by the "build" and
# "pre-build" scripts. It provides functions for printing, checking and
# exporting the configuration variables.
# Note: All functions whose names start with "pbc_" are considered private
# to this file. The "pbc" prefix is an abbreviation for "post-build-conf".
# usage: pbc_showvar varname
pbc_showvar() {
eval "pbc_isset=\${$1+set}"
case $pbc_isset in
"set") eval "fnv_val=\${$1-}"
printf " %-25s = %s\\n" "$1" "${fnv_val}"
;;
*) printf " %-25s (undefined)\\n" "$1"
;;
esac
}
# usage: pbc_section title varname...
pbc_section() {
printf "%s\\n" "$1"
shift
for pbc_var in "$@"; do
pbc_showvar "${pbc_var}"
done
printf "\\n"
}
# usage: show_config_vars
show_config_vars() {
pbc_section "System information" \
osrev BULK_BUILD_CONF USR_PKGSRC MAKECONF
pbc_section "Getting distfiles" \
PRUNEDISTFILES ftp_proxy http_proxy
pbc_section "Building the packages" \
PKGLIST NICE_LEVEL
pbc_section "Generating the report" \
ADMIN ADMINSIG \
REPORTS_URL REPORTS_DIR \
REPORT_BASEDIR REPORT_HTML_FILE REPORT_TXT_FILE
pbc_section "Uploading binary packages" \
UPDATE_VULNERABILITY_LIST PRUNEPACKAGES MKSUMS SIGN_AS \
RSYNC_DST RSYNC_OPTS
}
# usage: export_config_vars
export_config_vars() {
export osrev BULK_BUILD_CONF USR_PKGSRC
export PRUNEDISTFILES ftp_proxy http_proxy
export PKGLIST NICE_LEVEL ADMIN ADMINSIG
export UPDATE_VULNERABILITY_LIST PRUNEPACKAGES MKSUMS SIGN_AS
export RSYNC_DST RSYNC_OPTS
case ${MAKECONF+set} in
"set") export MAKECONF;;
esac
}
# usage: pbc_die error-message
pbc_die() {
exec 1>&2
printf "error: %s\\n" "$@"
printf " Please check your bulk build configuration file:\\n"
case ${BULK_BUILD_CONF+set} in
"set") printf " %s\\n" "${BULK_BUILD_CONF}"
esac
exit 1
}
# usage: pbc_checkyesno varname
pbc_checkyesno() {
eval "pbc_val=\${$1-}"
case $pbc_val in
[Yy][Ee][Ss]|[Nn][Oo]) ;;
*) pbc_die "$1 must be set to one of YES, yes, NO, no.";;
esac
}
# usage: pbc_checkpathname varname
pbc_checkpathname() {
eval "pbc_val=\${$1-}"
case $pbc_val in
/*) ;;
*) pbc_die "$1 must be an absolute pathname.";;
esac
}
# usage: pbc_checkbasename varname
pbc_checkbasename() {
eval "pbc_val=\${$1-}"
case $pbc_val in
*/*) pbc_die "$1 must not contain slashes.";;
esac
}
# usage: pbc_checkexistingfile varname
pbc_checkexistingfile() {
pbc_checkpathname "$1"
eval "pbc_val=\${$1-}"
test -f "${pbc_val}" \
|| pbc_die "$1 must be the name of an existing file."
}
# usage: pbc_checkexistingdir varname
pbc_checkexistingdir() {
pbc_checkpathname "$1"
eval "pbc_val=\${$1-}"
test -d "${pbc_val}" \
|| pbc_die "$1 must be the name of an existing directory."
}
# usage: pbc_checkurl varname
pbc_checkurl() {
eval "pbc_val=\${$1-}"
case $pbc_val in
file:///*|ftp://*|http://*)
;;
*) pbc_die "$1 is not a valid URL.";;
esac
}
# usage: pbc_checknonempty varname
pbc_checknonempty() {
eval "pbc_isset=\${$1+set}"
eval "pbc_val=\${$1-}"
case $pbc_isset in
"set") case $pbc_val in
"") pbc_die "$1 must be non-empty.";;
esac;;
*) pbc_die "$1 must be defined and non-empty.";;
esac
}
# usage: pbc_checkdefined varname
pbc_checkdefined() {
eval "pbc_val=\${$1+set}"
case $pbc_val in
"set") ;;
*) pbc_die "$1 must be defined.";;
esac
}
# usage: check_config_vars
check_config_vars() {
case ${FTP+set},${REPORTS_DIR+set} in
set,set)
pbc_die "FTP and REPORTS_DIR must not be set both.";;
esac
# section "System information"
pbc_checknonempty osrev
pbc_checkexistingfile BULK_BUILD_CONF
pbc_checkexistingdir USR_PKGSRC
case ${MAKECONF+set} in
"set") pbc_checkexistingfile MAKECONF;;
esac
# section "Getting distfiles"
case ${PRUNEDISTFILES+set} in
"set") pbc_checkyesno PRUNEDISTFILES
esac
# no checks for ftp_proxy
# no checks for http_proxy
# section "Building the packages"
# no checks for PKGLIST
# no checks for NICE_LEVEL
# section "Generating the report"
# no checks for ADMIN
# no checks for ADMINSIG
pbc_checkurl REPORTS_URL
pbc_checkpathname REPORTS_DIR
pbc_checkbasename REPORT_BASEDIR
pbc_checkbasename REPORT_HTML_FILE
pbc_checkbasename REPORT_TXT_FILE
# section "Uploading binary packages"
pbc_checkyesno UPDATE_VULNERABILITY_LIST
case ${PRUNEPACKAGES+set} in
"set") pbc_checkyesno PRUNEPACKAGES
esac
pbc_checkyesno MKSUMS
# no checks for SIGN_AS
# no checks for RSYNC_DST
# no checks for RSYNC_OPTS
}

287
mk/bulk/pre-build Normal file
View File

@@ -0,0 +1,287 @@
#!/bin/sh
# $NetBSD: pre-build,v 1.76 2010/05/11 18:36:15 mbalmer Exp $
#
# Clean up system to be ready for bulk pkg build
#
# (c) 2000 Hubert Feyrer, All Rights Reserved.
#
#set -v # Debug
# Pull in USR_PKGSRC:
if [ -f "$BULK_BUILD_CONF" ]; then
. "$BULK_BUILD_CONF"
else
. `dirname $0`/build.conf
fi
PRUNEDISTFILES=${PRUNEDISTFILES:-"no"}
PRUNEPACKAGES=${PRUNEPACKAGES:-"yes"}
PRUNELINKS=${PRUNEPACKAGES:-"yes"}
PKG_ADMIN="pkg_admin"
PKG_INFO="pkg_info"
some_package_dir=${USR_PKGSRC}/pkgtools/lintpkgsrc
# Extract the name of the files used for the build log and broken build log.
# These have defaults set by bsd.bulk-pkg.mk and may be overridden in
# /etc/mk.conf
BULKFILESDIR=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BULKFILESDIR )`;
if [ "$BULKFILESDIR" = "" ]; then
echo "pre-build> Had problems determining the directory of .broken* files"
exit 1
fi
BROKENF=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BROKENFILE )`;
if [ "$BROKENF" = "" ]; then
echo "pre-build> Had problems determining the name of the .broken files"
exit 1
fi
NOTAVAILF=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=NOT_AVAILABLE_FILE )`;
if [ "$NOTAVAILF" = "" ]; then
echo "pre-build> Had problems determining the name of the .bulk-not_available files"
exit 1
fi
BRKWRKLOG=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BROKENWRKLOG )`;
if [ "$BRKWRKLOG" = "" ]; then
echo "pre-build> Had problems determining the name of the .broken.work files"
exit 1
fi
BLDLOG=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=BUILDLOG )`;
if [ "$BLDLOG" = "" ]; then
echo "pre-build> Had problems determining the name of the .make files"
exit 1
fi
LINTPKGSRC_DB=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=LINTPKGSRC_DB )`;
if [ "$LINTPKGSRC_DB" = "" ]; then
echo "pre-build> Had problems determining the name of the .lintpkgsrc.db file"
exit 1
fi
STARTFILE=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=STARTFILE )`;
if [ "$STARTFILE" = "" ]; then
echo "pre-build> Had problems determining the name of the .start file"
exit 1
fi
LOCALBASE=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=LOCALBASE )`;
X11BASE=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=X11BASE )`;
DISTDIR=`( cd ${some_package_dir} ; ${BMAKE} show-var VARNAME=DISTDIR )`;
# Create ${BULKFILESDIR} if necessary
echo "pre-build> Creating ${BULKFILESDIR} if necessary"
mkdir -p "${BULKFILESDIR}"
# Make sure the pkg-vulnerabilities file is up to date
_INFO_VER=`${PKG_INFO} -V`;
echo "pre-build> Making sure vulnerability-list is up to date:"
if [ -z "$UPDATE_VULNERABILITY_LIST" -o "$UPDATE_VULNERABILITY_LIST" = yes ]; then
_PKGVULNDIR=`audit-packages ${AUDIT_PACKAGES_FLAGS} -Q PKGVULNDIR`
download-vulnerability-list ${DOWNLOAD_VULNERABILITY_LIST_FLAGS}
if [ "x${_PKGVULNDIR}" != "x${DISTDIR}" ]; then
cp ${_PKGVULNDIR}/pkg-vulnerabilities ${DISTDIR}
fi
echo 'pre-build> done.'
else
echo 'pre-build> (skipped)'
fi
# On non-NetBSD platforms we need to keep the bootstrap-files!
if [ x"$BMAKE" = x"bmake" ]; then
( cd "$LOCALBASE" && tar cf /tmp/$$.tar \
sbin/audit-packages sbin/download-vulnerability-list \
sbin/pkg_add sbin/pkg_admin sbin/pkg_create \
sbin/pkg_delete sbin/pkg_info \
share/mk/sys.mk share/mk/bsd.dep.mk share/mk/bsd.depall.mk \
share/mk/bsd.files.mk share/mk/bsd.hostprog.mk \
share/mk/bsd.doc.mk share/mk/bsd.inc.mk share/mk/bsd.info.mk \
share/mk/bsd.kernobj.mk share/mk/bsd.kinc.mk \
share/mk/bsd.kmod.mk share/mk/bsd.lib.mk \
share/mk/bsd.links.mk share/mk/bsd.man.mk \
share/mk/bsd.nls.mk share/mk/bsd.obj.mk \
share/mk/bsd.prog.mk share/mk/bsd.subdir.mk \
share/mk/bsd.sys.mk share/mk/bsd.own.mk share/mk/bsd.README \
bin/bmake bin/nawk bin/nbsed bin/pdksh bin/install-sh \
man/cat1/nbsed.0 man/cat1/pkg_add.0 man/cat1/pkg_admin.0 \
man/cat1/pkg_create.0 man/cat1/pkg_delete.0 \
man/cat1/pkg_info.0 man/cat5/pkg_install.conf.0 \
man/cat5/pkg_summary.0 man/cat7/pkgsrc.0 man/man1/bmake.1 \
man/man1/nawk.1 man/man1/nbsed.1 man/man1/pkg_add.1 \
man/man1/pkg_admin.1 man/man1/pkg_create.1 \
man/man1/pkg_delete.1 man/man1/pkg_info.1 man/man1/pdksh.1 \
man/man5/pkg_install.conf.5 man/man5/pkg_summary.5 \
man/man7/pkgsrc.7 etc/mk.conf )
fi
#
# Clean out everything and its mother
#
PKG_DBDIR=`(cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=PKG_DBDIR)`
DEPOTBASE=`(cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=DEPOTBASE)`
PKG_TOOLS_BIN=`(cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=PKG_TOOLS_BIN)`
for dbdir in "${PKG_DBDIR}" "${DEPOTBASE}"; do
echo "pre-build> Removing all installed packages in ${dbdir}"
# The Solaris /bin/sh requires the following weird-looking code.
if (cd "$dbdir" 1>/dev/null 2>&1); then
cd "$dbdir"
for pkg in *
do
if ${PKG_TOOLS_BIN}/pkg_info -K "$dbdir" -qe "$pkg"; then
echo "pre-build> ${PKG_TOOLS_BIN}/pkg_delete -r ${pkg}"
${PKG_TOOLS_BIN}/pkg_delete -K "$dbdir" -r "$pkg"
fi
done
#
# this should have removed everything.
# Now force any broken pkgs to deinstall.
#
for pkg in *
do
if ${PKG_TOOLS_BIN}/pkg_info -K "$dbdir" -qe "$pkg"; then
echo "pre-build> ${PKG_TOOLS_BIN}/pkg_delete -f ${pkg}"
${PKG_TOOLS_BIN}/pkg_delete -K "$dbdir" -f "$pkg"
fi
done
# We've tried our best to get rid of the pkgs, now do it
# the hard way. If it wasn't for stuff in $X11BASE, I
# wouldn't have hard feelings about this!
rm -fr *
fi
done
cd "$LOCALBASE" && rm -fr * && rm -fr .??*;
if [ x"$BMAKE" = x"bmake" ]; then
( cd "$LOCALBASE" && tar xf /tmp/$$.tar )
fi
# Stuff known to be broken
rm -fr "$X11BASE/share/gimp"
rm -fr "$X11BASE/share/gnome"
rm -fr "$X11BASE/share/kde"
rm -fr "$X11BASE/share/netscape"
rm -fr /var/tmp/inst*
rm -fr "$X11BASE/lib/libgimp"* # gimp doesn't build with old libs around
rm -fr /nonexistent # broken useradd on pop3d
rm -fr /home/majordom # mail/majordomo pkg
rm -fr /home/nut # sysutils/ups-net
rm -fr /var/wwwoffle # www/wwwoffle
rm -fr /tmp/config-guess-*
rm -fr /tmp/mod*
# Clean up state files
cd "${USR_PKGSRC}"
echo "pre-build> Cleaning up leftover state files from previous runs"
rm -f "${BULKFILESDIR}"/*/*/$BROKENF "${BULKFILESDIR}"/*/*/$BRKWRKLOG "${BULKFILESDIR}"/*/*/$BLDLOG
rm -f "${BULKFILESDIR}"/*/*/$NOTAVAILF
rm -f "${BULKFILESDIR}/$BROKENF" "${BULKFILESDIR}/$BRKWRKLOG" "${BULKFILESDIR}/$BLDLOG" "$STARTFILE"
#
# Remove old/broken distfiles and binary packages
#
PACKAGES=`( cd "${some_package_dir}" && ${BMAKE} show-var VARNAME=PACKAGES )`
case "$LINTPKGSRC_CACHE$PRUNEDISTFILES$PRUNEPACKAGES" in
*yes*|*YES*)
# install lintpkgsrc to support any of these options
( cd "${USR_PKGSRC}/pkgtools/lintpkgsrc" && ${BMAKE} PRECLEAN=yes bulk-install )
;;
esac
case "$LINTPKGSRC_CACHE" in
yes|YES)
echo "pre-build> Creating lintpkgsrc cache database."
lintpkgsrc -K "$PACKAGES" -P "$USR_PKGSRC" -M "$DISTDIR" -E "$LINTPKGSRC_DB"
lintpkgsrc_cache="-I $LINTPKGSRC_DB"
echo "pre-build> done."
;;
*)
lintpkgsrc_cache=''
;;
esac
case "$PRUNEDISTFILES" in
yes|YES)
echo "pre-build> Removing old/broken distfiles"
lintpkgsrc $lintpkgsrc_cache -K "$PACKAGES" -P "$USR_PKGSRC" -M "$DISTDIR" -o -m -r
echo "pre-build> done."
;;
*)
echo "pre-build> Skipping distfile pruning."
;;
esac
case "$PRUNEPACKAGES" in
yes|YES)
echo "pre-build> Removing old (out of date) binary packages"
lintpkgsrc $lintpkgsrc_cache -K "$PACKAGES" -P "$USR_PKGSRC" -M "$DISTDIR" -p -r
echo "pre-build> done."
;;
*)
echo "pre-build> Skipping packages pruning."
;;
esac
case "$PRUNELINKS" in
yes|YES)
echo "pre-build> Checking for and removing orphaned packages links"
find "$PACKAGES" -type l -print | \
while read f
do
if [ ! -d "$f" -a ! -f "$f" ]; then
echo "pre-build> Removing orphaned link: \"$f\""
rm "$f"
fi
done
echo "pre-build> done."
;;
*)
echo "pre-build> Skipping pruning of packages links."
;;
esac
# Clean out the packages added above so that the real bulk build
# is started in a consistent state.
for dbdir in "${PKG_DBDIR}" "${DEPOTBASE}"; do
echo "pre-build> Removing all installed packages in ${dbdir}"
if [ -d "$dbdir" ]; then
cd "$dbdir"
for pkg in *
do
if ${PKG_TOOLS_BIN}/pkg_info -K "$dbdir" -qe "$pkg"; then
echo "pre-build> ${PKG_TOOLS_BIN}/pkg_delete -r ${pkg}"
${PKG_TOOLS_BIN}/pkg_delete -K "$dbdir" -r "$pkg"
fi
done
fi
done
# on non-NetBSD, we don't want these to build as they overwrite
# bootstrap-pkgsrc generated files and thus would break the following builds.
if [ x"$BMAKE" = x"bmake" ]; then
for pkg in devel/bmake devel/mk-files lang/nawk \
pkgtools/bootstrap-mk-files pkgtools/bootstrap-extras \
pkgtools/pkg_install \
shells/pdksh sysutils/install-sh textproc/nbsed; do
mkdir -p "${BULKFILESDIR}/${pkg}"
echo "Don't blow away bootstrap-pkgsrc stuff!" \
> "${BULKFILESDIR}/${pkg}/${BROKENF}"
done
fi
cd "${USR_PKGSRC}"
if [ -f mk/bulk/pre-build.local ]; then
export BROKENF
. mk/bulk/pre-build.local
fi
if [ ! -d "${PKG_DBDIR}" ]; then
mkdir -p "${PKG_DBDIR}"
fi
echo "This file marks the start time of the bulk build." > "$STARTFILE"

164
mk/bulk/printdepends Normal file
View File

@@ -0,0 +1,164 @@
#!/bin/sh
# $NetBSD: printdepends,v 1.25 2008/01/04 15:49:08 rillig Exp $
#
# Copyright (c) 1999, 2000 Hubert Feyrer <hubertf@NetBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Hubert Feyrer for
# the NetBSD Project.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# usage: printdepends [brokenfile [bulkfilesdir]]
#
# Generates a list of package dependencies suitable for tsort(1) on
# stdout. Each line of the output has two fields: the package directory
# of the dependency and the package directory of the depending package
# (both in the form category/package).
#
# If <brokenfile> is given, package-specific errors are logged to
# <bulkfilesdir>/${pkgdir}/<brokenfile>. Otherwise no additional logging
# takes place.
#
# The default for <bulkfilesdir> is the pkgsrc directory itself. If
# <bulkfilesdir> differs from the pkgsrc directory, all directories
# that are needed for the log files are created automatically.
#
# Note: printdepends must be called from a pkgsrc root directory.
set -e
# Pull in PKGLIST
if [ -f "$BULK_BUILD_CONF" ]; then
. $BULK_BUILD_CONF
else
. `dirname $0`/build.conf
fi
#
# Global variables
#
# The brokenfile_flag variable tells whether we want package-specific
# log files at all. If it is set to "yes", the mkdirs_flag
# variable tells whether the directories of the package-specific log
# files are created if necessary.
brokenfile_flag="yes"
mkdirs_flag="no"
pkgsrcdir="${PWD}"
bulkfilesdir="${pkgsrcdir}"
brokenfile=""
#
# Command line parsing
#
case $# in
0) brokenfile_flag="no"
;;
1) brokenfile="$1"
;;
2) brokenfile="$1"
bulkfilesdir="$2"
if [ "${bulkfilesdir}" != "${pkgsrcdir}" ]; then
mkdirs_flag="yes"
fi
;;
*) echo "usage: $0 [brokenfile [bulkfilesdir]]" 1>&2
exit 1
;;
esac
#
# Sanity checks
#
case ${BMAKE-""} in
"") echo "$0: error: BMAKE must be set and non-empty." 1>&2
exit 1;;
esac
case ${bulkfilesdir} in
/*) ;;
*) echo "$0: error: The <bulkfilesdir> argument must be absolute." 1>&2
exit 1;;
esac
case ${brokenfile} in
*/*) echo "$0: error: The <brokenfile> argument must not contain a slash." 1>&2
exit 1;;
esac
#
# Get additional system information
#
cd "${pkgsrcdir}/pkgtools/lintpkgsrc"
GREP=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep`
MKDIR=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir`
SED=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed`
cd "${pkgsrcdir}"
case $mkdirs_flag in
yes) mkbulkdir="${MKDIR}";;
*) mkbulkdir=":";;
esac
case ${PKGLIST} in
"") # List of all packages, from pkgsrc/*/Makefile
list=`${GREP} '^SUBDIR+=' */Makefile | ${GREP} -v '^regress/' | ${SED} -e 's,/Makefile:SUBDIR+=[[:space:]]*,/,' -e 's,#.*,,'`
;;
*) list="${PKGLIST}"
;;
esac
for pkgdir in $list; do
if cd "${pkgsrcdir}/${pkgdir}"; then
if deps=`${BMAKE} show-depends-dirs`; then
case ${deps} in
"") # Make the package depend on itself.
# Otherwise it would not show up in the
# dependency graph.
echo "${pkgdir} ${pkgdir}";;
*) for dep in $deps; do
echo "${dep} ${pkgdir}"
done;;
esac
else
echo "$0: error: could not extract dependencies for ${pkgdir} -- skipping." 1>&2
[ $brokenfile_flag = yes ] || continue
${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
{ echo "[printdepends] command failed: ${BMAKE} show-depends-dirs"
( ${BMAKE} show-depends-dirs
) || true
} >> "${bulkfilesdir}/${pkgdir}/${brokenfile}" 2>&1
fi
else
${mkbulkdir} "${bulkfilesdir}"
{ echo "[printdepends] command failed: cd ${pkgsrcdir}/${pkgdir}"
( cd "${pkgsrcdir}/${pkgdir}"
) || true
} 1>&2
fi
done

202
mk/bulk/printindex Normal file
View File

@@ -0,0 +1,202 @@
#!/bin/sh
# $NetBSD: printindex,v 1.32 2008/04/29 05:46:09 martin Exp $
#
# Copyright (c) 2001 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set -e
#
# Global variables
#
# The brokenfile_flag variable tells whether we want package-specific
# log files at all. If it is set to "yes", the mkdirs_flag
# variable tells whether the directories of the package-specific log
# files are created if necessary.
brokenfile_flag="yes"
mkdirs_flag="no"
pkgsrcdir="${PWD}"
bulkfilesdir="${pkgsrcdir}"
brokenfile=""
#
# Command line parsing
#
case $# in
0) brokenfile_flag="no"
;;
1) brokenfile="$1"
;;
2) brokenfile="$1"
bulkfilesdir="$2"
if [ "${bulkfilesdir}" != "${pkgsrcdir}" ]; then
mkdirs_flag="yes"
fi
;;
*) echo "usage: $0 [brokenfile [bulkfilesdir]]" 1>&2
exit 1
;;
esac
#
# Sanity checks
#
case ${BMAKE-""} in
"") echo "$0: error: BMAKE must be set and non-empty." 1>&2
exit 1;;
esac
case ${bulkfilesdir} in
/*) ;;
*) echo "$0: error: The <bulkfilesdir> argument must be absolute." 1>&2
exit 1;;
esac
case ${brokenfile} in
*/*) echo "$0: error: The <brokenfile> argument must not contain a slash." 1>&2
exit 1;;
esac
#
# Get additional system information
#
cd "${pkgsrcdir}/pkgtools/lintpkgsrc"
BULK_PREREQ=`${BMAKE} show-var VARNAME=BULK_PREREQ`
GREP=`${BMAKE} show-var VARNAME=GREP USE_TOOLS=grep`
MKDIR=`${BMAKE} show-var VARNAME=MKDIR USE_TOOLS=mkdir`
SED=`${BMAKE} show-var VARNAME=SED USE_TOOLS=sed`
cd "${pkgsrcdir}"
case $mkdirs_flag in
yes) mkbulkdir="${MKDIR}";;
*) mkbulkdir=":";;
esac
case ${PKGLIST-""} in
"") # List of all packages, from pkgsrc/*/Makefile
list=`${GREP} '^[[:space:]]*'SUBDIR */Makefile | ${GREP} -v regress/ | ${SED} 's,/Makefile.*=[[:space:]]*,/,'`
;;
*) list="${PKGLIST}"
;;
esac
#
# Sanity checks, part 2
#
allowed="
+./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
case $BULK_PREREQ in
*[!-"${allowed}"]*)
inval=`echo "${BULK_PREREQ}" | tr -d " +\\\\-${allowed}"`
echo "$0: error: BULK_PREREQ contains invalid characters (${inval})." 1>&2
exit 1
esac
case $list in
*[!-"${allowed}"]*)
inval=`echo "${list}" | tr -d " +\\\\-${allowed}"`
echo "$0: error: The package list contains invalid characters (${inval})." 1>&2
exit 1
esac
newline="
"
#
# Print the table of PKGPATH and PKGNAME.
#
# The check for duplicates is necessary to prevents double entries in
# the table. The use of the :detect_duplicates: delimiter prevents the
# inner "case" from occuring too often, as the $done_pkgs string grows
# to about 100k during one run of the program. This saves about
# 40 seconds on a 1 GHz Athlon.
#
done_pkgs=""
detect_duplicates=no
for pkgdir in $list :detect_duplicates: $BULK_PREREQ; do
case $pkgdir in :detect_duplicates:)
detect_duplicates=yes
continue;;
esac
case $detect_duplicates in yes)
case $done_pkgs in *="${pkgdir}"=*)
continue;;
esac;;
esac
if cd "${pkgsrcdir}/${pkgdir}"; then
# The NetBSD /bin/sh creates lots of zombies for the backticks
# line below, and it doesn't clean them up until a real
# command is executed. (See PR 35227)
#
cat </dev/null
if output=`${BMAKE} show-var VARNAME=PKGNAME can-be-built-here`; then
reasons=""
{
read pkgname
read can_be_built_here
while read reason; do
reasons="$reasons$reason$newline"
done
} <<EOF
$output
EOF
echo "${pkgdir} ${pkgname}"
done_pkgs="${done_pkgs} =${pkgdir}="
if [ "$can_be_built_here" != "yes" ]; then
${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
echo "$reasons" > "${bulkfilesdir}/${pkgdir}/${brokenfile}"
fi
else
echo "$0: error: could not extract PKGNAME for ${pkgdir} -- skipping." 1>&2
case $brokenfile_flag in
no) continue;;
esac
${mkbulkdir} "${bulkfilesdir}/${pkgdir}"
{ echo "[printindex] command failed: ${BMAKE} show-var VARNAME=PKGNAME"
( ${BMAKE} show-var VARNAME=PKGNAME
) || true
} >> "${bulkfilesdir}/${pkgdir}/${brokenfile}" 2>&1
fi
else
${mkbulkdir} "${bulkfilesdir}"
{ echo "[printindex] command failed: cd ${pkgsrcdir}/${pkgdir}"
( cd "${pkgsrcdir}/${pkgdir}"
) || true
} 1>&2
fi
done

104
mk/bulk/printindex.1 Normal file
View File

@@ -0,0 +1,104 @@
.\" $NetBSD: printindex.1,v 1.8 2006/12/23 08:11:30 wiz Exp $
.\"
.\" Copyright (c) 2005 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Roland Illig <rillig@NetBSD.org>.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 26, 2006
.Dt PRINTINDEX 1
.Os
.Sh NAME
.Nm printindex
.Nd generate a PKGPATH to PKGNAME mapping database file
.Sh SYNOPSIS
.Nm
.Op Ar brokenfile Op Ar bulkfilesdir
.Sh DESCRIPTION
Generates a mapping from pkgsrc directories to the current package
version and prints it on stdout.
It also checks whether the package can be built on this system at all
and marks those that cannot be built as broken.
.Pp
Each line of the output has two fields:
the package directory (in the form
.Ql category/package )
and the package version (in the form
.Ql package-1.456nb3 ) .
.Pp
If
.Ar brokenfile
is given, package-specific errors are logged to
.Ar bulkfilesdir Ns / Ns
.Va ${pkgdir} Ns / Ns
.Ar brokenfile .
Otherwise no additional logging takes place.
.Pp
The default for
.Ar bulkfilesdir
is the pkgsrc directory itself.
If
.Ar bulkfilesdir
differs from the pkgsrc directory, all directories that are needed for
the log files are created automatically.
.Sh LIMITATIONS
.Nm
must be called from a pkgsrc root directory.
.Sh EXIT STATUS
Non-zero if writing to a log file fails, zero otherwise.
.Sh ENVIRONMENT
.Bl -tag -width XXXXXX
.It Ev BMAKE Pq mandatory
The
.Xr make 1
program used to build packages.
.It Ev PKGLIST Pq optional
The list of packages from which to build an index.
.El
.\" .Sh EXAMPLES
.Sh DIAGNOSTICS
Diagnostics have one of the two forms
.Ql printindex: error: ...
or
.Ql [printindex] ... .
The latter may span multiple lines.
.Sh SEE ALSO
.Xr printdepends 1
.\" .Sh STANDARDS
.Sh HISTORY
.Nm
appeared in 2001 as part of the bulk build framework.
.Sh AUTHORS
Many (see the CVS ChangeLog).
.\" .Sh CAVEATS
.\" .Sh BUGS
.\" .Sh SECURITY CONSIDERATIONS

83
mk/bulk/sort-packages Normal file
View File

@@ -0,0 +1,83 @@
#! /bin/sh
# $NetBSD: sort-packages,v 1.16 2011/08/04 14:39:33 reinoud Exp $
# This program scans all binary packages in the current directory and
# creates two lists of files in OUTDIR:
#
# restricted_packages
# contains all packages that must not be published on the FTP
# server, for whatever reason
#
# regular_packages
# contains all the other ("good") packages.
#
set -eu
: ${OUTDIR="/tmp"}
: ${PKG_SUFX=".tgz"}
: ${PKG_ADMIN="pkg_admin"}
: ${PKG_INFO="pkg_info"}
regular_packages="${OUTDIR}/regular_packages"
restricted_packages="${OUTDIR}/restricted_packages"
newline="
"
: > "${regular_packages}"
: > "${restricted_packages}"
for pkg in *${PKG_SUFX}; do
build_info=`${PKG_INFO} -B "${pkg}"`
# Note: this code needs to be that complicated because licensing
# issues are critical to pkgsrc, and we really don't want
# anything unexpected to happen here. The worst case would be
# that some file is sorted wrongly because some change in the
# output of pkg_info which had not been foreseen. Therefore it
# is better to check as strictly as possible to make those
# changes immediately visible.
no_bin_on_ftp="unknown"
case "${newline}${build_info}${newline}" in
*"${newline}NO_BIN_ON_FTP=${newline}"*)
no_bin_on_ftp="no"
;;
*"${newline}NO_BIN_ON_FTP="*)
no_bin_on_ftp="yes"
;;
esac
restricted="unknown"
case "${newline}${build_info}${newline}" in
*"${newline}RESTRICTED=${newline}"*)
restricted="no"
;;
*"${newline}RESTRICTED="*)
restricted="yes"
;;
esac
category="unknown"
if [ "${restricted}" = "no" ] && [ "${no_bin_on_ftp}" = "no" ]; then
category="regular"
else
if [ "${restricted}" = "yes" ] || [ "${no_bin_on_ftp}" = "yes" ]; then
category="restricted"
fi
fi
: echo "upload> ${pkg} is ${category}."
case "${category}" in
"regular")
echo "${pkg}" >> "${regular_packages}"
;;
"restricted")
echo "${pkg}" >> "${restricted_packages}"
;;
*)
echo "sort-packages> WARNING: Could not sort ${pkg} into a category." 1>&2
;;
esac
done

121
mk/bulk/tflat Executable file
View File

@@ -0,0 +1,121 @@
# $NetBSD: tflat,v 1.15 2005/10/26 16:54:04 tv Exp $
#
# Copyright (c) 2001, 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Dan McMahill and Todd Vierling.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# This perl version is very fast compared to other alternatives, which would
# likely use things like forking "sort" subprocesses.
#
use strict;
sub usage () {
print STDERR <<EOF ;
tflat -- flatten a depends tree. tflat is used to show all
packages which depend upon a given package, and
all packages which are depend upon by a given package.
usage: $0 upfile downfile < depfile
Input file format is in the form
foo bar
foo baz
libbar bar
meaning "foo is depended upon by bar,
foo is depended upon by baz,
libbar is depended upon by bar"
The typical use is:
cd /usr/pkgsrc
./mk/bulk/printdepends > .depends
perl ./mk/bulk/tflat .supports .requires < .depends
EOF
exit 1;
}
my $upfile = shift(@ARGV) || usage();
my $downfile = shift(@ARGV) || usage();
scalar(@ARGV) && usage();
open(UPF, ">$upfile") || die $!;
open(DOWNF, ">$downfile") || die $!;
# read in dependstree file
my %depended;
my %depends;
while (<>) {
chomp;
my ($dep, $pkg) = split;
push(@{$depended{$dep}}, $pkg);
push(@{$depends{$pkg}}, $dep);
}
# print out upfile and downfile
sub getdeps ($$$@) {
my $curhash = shift;
my $alldeps = shift;
my $what = shift;
foreach my $dep (@{$curhash->{$what}}) {
if ($what eq $dep) {
next;
} elsif (grep { $_ eq $dep } @_) {
print STDERR "circular dependency in $dep\n";
} elsif (!grep { $_ eq $dep } @$alldeps) {
push(@$alldeps, $dep);
getdeps($curhash, $alldeps, $dep, $what, @_);
}
}
}
foreach my $pkg (sort(keys(%depended))) {
my @alldeps;
getdeps(\%depended, \@alldeps, $pkg);
print UPF "$pkg is depended on by: ".join(' ', @alldeps)."\n";
}
foreach my $pkg (sort(keys(%depends))) {
my @alldeps;
getdeps(\%depends, \@alldeps, $pkg);
print DOWNF "$pkg depends on: ".join(' ', @alldeps)."\n";
}
close(UPF);
close(DOWNF);

356
mk/bulk/upload Normal file
View File

@@ -0,0 +1,356 @@
#!/bin/sh
# $NetBSD: upload,v 1.48 2010/04/10 21:44:44 wiz Exp $
#
# Upload non-restricted binary pkgs to ftp server
#
AWK=${AWK:-/usr/bin/awk}
PKG_ADMIN="pkg_admin"
PKG_INFO="pkg_info"
set -eu
#
# Find out where we are
#
scriptdir=`dirname "$0"`
scriptdir=`cd "${scriptdir}" && pwd`
usage()
{
cat << EOF
$prog: Uploads binary packages.
Usage: $prog [-c|--config <file>] [-n|--no-upload] [-d|--debug] [-v|--verbose]
$prog -h|--help
$prog -V|--version
-c | --config <file>
Load the following configuration file instead of
the default one.
-d|--debug Preserves some intermediate files to help
debug any problems.
-h|--help Displays this help message and exits.
-n|--no-upload Does all of the work except for the actual upload.
This option may be used to generate the upload script
along with the list of packages to be excluded.
-i|--no-install Do not install the required packages; assume instead
that they are already available.
-v|--verbose Enables verbose output.
-V|--version Displays the version of this script and exits.
Example:
cd /usr/pkgsrc && $prog
Environment Variables:
AWK -- If specified, sets the awk program to be used
Files:
pkgsrc/mk/bulk/build.conf
EOF
}
# print out error message and exit 1
die () {
echo "$0: error:" 1>&2
for i in "$@"; do
echo " $i" 1>&2
done
exit 1
}
prog=$0
debug=no
do_upload=yes
do_install=yes
verbose=no
while test $# -gt 0; do
case "$1" in
-c|--config)
shift
BULK_BUILD_CONF=$1; shift
;;
-d|--debug)
debug=yes
shift
;;
-h|--help)
usage
exit 0
;;
-i|--no-install)
do_install=no
shift
;;
-n|--no-upload)
do_upload=no
shift
;;
-v|--verbose)
verbose=yes
shift
;;
-V|--version)
${AWK} '/^#[ \t]*\$NetBSD/ {gsub(/,v/,"",$3);printf("%s: Version %s, %s\n",$3,$4,$5); exit 0;}' $prog
exit 0
;;
-*)
echo "$prog: Unknown option: $1" 1>&2
usage
exit 1
;;
*)
break
;;
esac
done
if test "$#" -gt 0; then
echo "$prog: Unknown argument: $1" 1>&2
usage
exit 1
fi
install_required()
{
[ "$do_install" = "yes" ] || return 0
pkg=$1
if [ "${verbose}" = "yes" ]; then
echo "upload> Installing ${pkg}"
fi
(cd "$USR_PKGSRC" && cd "$pkg" && ${BMAKE} bulk-install) \
|| {
echo "upload> ERROR: Unable to install required package $pkg!" 1>&2
echo " Bailing out -- you're on your own." 1>&2
exit 1
}
}
MD5="digest md5";
SHA1="digest sha1";
_INFO_VER=`${PKG_INFO} -V`;
REQUIRED_PACKAGES="pkgtools/lintpkgsrc net/rsync"
opsys=`uname -s`
case "$opsys" in
NetBSD) BMAKE=make;
BSDSUM="sum -o 1";
CKSUM="cksum";
SYSVSUM="sum -o 2";
;;
IRIX*) BMAKE=bmake;
BSDSUM="sum -r";
CKSUM="cksum";
SYSVSUM="sum";
;;
*) BMAKE=bmake;
BSDSUM="";
CKSUM="";
SYSVSUM="";
;;
esac
export BMAKE
# Bring in variables for bulk-install
BATCH=1
DEPENDS_TARGET=bulk-install
export BATCH DEPENDS_TARGET
#
# Find the configuration file.
#
BULK_BUILD_CONF="${BULK_BUILD_CONF-${scriptdir}/build.conf}"
case $BULK_BUILD_CONF in
/*) ;;
*) BULK_BUILD_CONF="${PWD}/${BULK_BUILD_CONF}"
esac
#
# Get the variables MAKECONF, RSYNC_DST, RSYNC_OPTS from the bulk build
# configuration file.
#
{ test -f "${BULK_BUILD_CONF}" \
&& . "${BULK_BUILD_CONF}" \
&& . "${scriptdir}/post-build-conf" \
&& check_config_vars \
&& export_config_vars
} || die "Cannot load config file ${BULK_BUILD_CONF}, aborting."
cd $USR_PKGSRC
if [ -z "$RSYNC_DST" ]; then
echo "upload> ERROR: You must set the variable RSYNC_DST, see build.conf-example." 1>&2
exit 1
fi
#
# Some temp files
#
umask 022
TMPDIR="${TMPDIR:-/tmp}"
TMP="${TMPDIR}"/pkg_upload.$$
(umask 077 && mkdir "${TMP}") \
|| {
echo "upload> ERROR: cannot create temporary directory \"${TMP}\"." 1>&2
exit 1
}
restricted_packages="$TMP/restricted_packages"
old_packages="$TMP/old_packages"
good_packages="$TMP/regular_packages"
all_good_packages="$TMP/all_regular_packages"
upload_general="$TMP"/upload_general
# May be different than $USR_PKGSRC:
echo "upload> Running ${BMAKE} to get the pkgsrc variables"
pkgsrcdir=`cd pkgtools/lintpkgsrc ; ${BMAKE} show-var VARNAME=_PKGSRCDIR`
packages=`cd pkgtools/lintpkgsrc ; ${BMAKE} show-var VARNAME=PACKAGES`
distdir=`cd pkgtools/lintpkgsrc ; ${BMAKE} show-var VARNAME=DISTDIR`
gzip_cmd=`cd pkgtools/lintpkgsrc; ${BMAKE} show-var VARNAME=GZIP_CMD USE_TOOLS=gzip`
pkg_info=`cd pkgtools/lintpkgsrc && ${BMAKE} show-var VARNAME=PKG_INFO`
shell=`cd pkgtools/lintpkgsrc && ${BMAKE} show-var VARNAME=TOOLS_PLATFORM.sh`
# Pull in some pkgs needed
for pkg in ${REQUIRED_PACKAGES}; do
install_required $pkg
done
case $LINTPKGSRC_CACHE in
yes|YES)
lintpkgsrc_cache="-I `cd pkgtools/lintpkgsrc ; ${BMAKE} show-var VARNAME=LINTPKGSRC_DB`"
;;
*)
lintpkgsrc_cache=''
;;
esac
echo "upload> Checking for out of date packages:"
# -p = report old versions of packages
lintpkgsrc $lintpkgsrc_cache -K $packages -P $pkgsrcdir -p > "${old_packages}.tmp"
sed 's@'$packages'/@@' < "${old_packages}.tmp" > "$old_packages"
RSFLAGS="-vap --progress $RSYNC_OPTS"
failed=no
cd $packages
echo "upload> Checking for restricted packages"
(cd All && env PKG_INFO="${pkg_info}" OUTDIR="${TMP}" \
${shell} "${pkgsrcdir}/mk/bulk/sort-packages")
# Add the name of the package file, including all its symlinks to the
# list of files to be uploaded.
while read package; do
ls -1 */"$package"
done < "$good_packages" > "$all_good_packages"
if [ "${MKSUMS}" = "yes" -o "${MKSUMS}" = "YES" ]; then
echo "upload> Calculating checksum files..."
SUMFILES="BSDSUM CKSUM MD5 SHA1 SYSVSUM"
rm -f ${SUMFILES}
if [ "${SIGN_AS-}" != "" ]; then
install_required "security/gnupg"
for i in ${SUMFILES}; do
echo > $i
echo "This file is signed with ${SIGN_AS}'s PGP key." >> $i
echo >> $i
done
fi
install_required "pkgtools/digest"
[ -z "${BSDSUM}" ] && BSDSUM="echo"
[ -z "${CKSUM}" ] && CKSUM="echo"
[ -z "${SYSVSUM}" ] && SYSVSUM="echo"
for pkg in `cat "${good_packages}"`; do
pkg="All/$pkg"
${BSDSUM} "$pkg" >> BSDSUM
${CKSUM} "$pkg" >> CKSUM
${MD5} "$pkg" >> MD5
${SHA1} "$pkg" >> SHA1
${SYSVSUM} "$pkg" >> SYSVSUM
done
[ "${BSDSUM}" = "echo" ] && rm BSDSUM
[ "${CKSUM}" = "echo" ] && rm CKSUM
[ "${SYSVSUM}" = "echo" ] && rm SYSVSUM
if [ "${SIGN_AS-}" != "" ]; then
for i in ${SUMFILES}; do
if [ -s $i ]; then
echo "upload> Signing $i"
gpg --clearsign $i && rm $i
fi
done
else
echo "upload> Checksum files not PGP-signed. Please do so manually!"
echo " (Run 'gpg --clearsign' on all of them)"
fi
fi
if [ "${MKSUMMARY-}" = "yes" -o "${MKSUMMARY-}" = "YES" ]; then
echo "upload> Creating summary file..."
(cd "${packages}/All" \
&& ls -t | grep '\.t[gb]z$' | while read n; do pkg_info -X "$n"; done) \
| ${gzip_cmd} > "${packages}"/All/pkg_summary.gz
fi
cat <<EOF > "$upload_general"
#! /bin/sh
set -e
cd "$packages"
rsync $RSFLAGS --files-from="${all_good_packages}" --exclude-from="${old_packages}" . "$RSYNC_DST/"
EOF
chmod +x "$upload_general"
if [ "$do_upload" = "yes" ]; then
echo "upload> Uploading packages"
${shell} "$upload_general" \
|| {
echo "upload> ERROR: rsync failed. To retry later, you can run $upload_general" 1>&2
failed=yes
}
else
echo "upload> Skipping upload of packages."
echo " Run \"$upload_general\" to upload them later."
fi
# clean up temp files
if [ "$failed,$debug,$do_upload" = "no,no,yes" ]; then
rm -fr "$TMP"
else
echo "upload> Preserving temporary directory ${TMP}"
fi
if [ "$failed" = "yes" ]; then
exit 1
fi

View File

@@ -0,0 +1,21 @@
# $NetBSD: bsd.check-vars.mk,v 1.7 2009/07/26 05:32:43 agc Exp $
#
# This Makefile fragment is included separately by bsd.pkg.mk and
# defines some variables which must be defined earlier than where
# bsd.check.mk is included.
#
CHECK_FILES_SUPPORTED?= yes
CHECK_SHLIBS_SUPPORTED?= yes
.if ${_OPSYS_CAN_CHECK_SHLIBS} == "yes"
USE_CHECK_SHLIBS_ELF?= yes
.else
USE_CHECK_SHLIBS_ELF?= no
.endif
USE_TOOLS+= awk cat cmp diff echo find grep rm sed test touch true
.if !empty(USE_CHECK_SHLIBS_ELF:M[yY][eE][sS])
USE_TOOLS+= readelf
.endif

51
mk/check/bsd.check.mk Normal file
View File

@@ -0,0 +1,51 @@
# $NetBSD: bsd.check.mk,v 1.8 2008/02/13 15:02:20 rillig Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and provides all
# variables and targets related to build and install checks.
#
# There are some predefined hooks where checks can be added:
#
# pre-configure-checks-hook
# Is run before configuring the package.
#
# pre-build-checks-hook
# Is run before building the package.
#
# #notyet post-install-privileged-checks-hook
# Is run after the installation, as the user who installed
# the package.
#
# #notyet post-install-checks-hook
# Is run after the installation, as the user who built
# the package.
#
# The following are the "public" targets provided this module:
#
# check-files-pre, check-files-post, check-files
# check-interpreter, check-shlibs, check-vulnerable, check-wrkref
#
.include "check-files.mk"
.include "check-headers.mk"
.include "check-interpreter.mk"
.include "check-perms.mk"
.include "check-portability.mk"
.include "check-shlibs.mk"
.include "check-stripped.mk"
.include "check-vulnerable.mk"
.include "check-wrkref.mk"
.include "check-fakehome.mk"
pre-configure-checks-hook \
pre-build-checks-hook: .PHONY
@${DO_NADA}
######################################################################
### check-clean (PRIVATE)
######################################################################
### check-clean is a helper target onto which one can hook all of the
### targets that clean up the output of "check" targets.
###
.PHONY: check-clean
check-clean:
@${DO_NADA}

View File

@@ -0,0 +1,40 @@
# $NetBSD: check-fakehome.mk,v 1.3 2010/08/24 19:08:29 bad Exp $
#
# This file checks that the package does not install files to $HOME.
#
# User-settable variables:
#
# CHECK_FAKEHOME
# Specifies whether the check should be run at all.
#
# Possible values: yes, no.
#
# Default value: yes for PKG_DEVELOPER, no otherwise.
#
# Package-settable variables:
#
_VARGROUPS+= check-fakehome
_USER_VARS.check-fakehome= CHECK_FAKEHOME
_PKG_VARS.check-fakehome= # None for now. One might be added to override
# the test if the fakehome test is made fatal.
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_FAKEHOME?= yes
.else
CHECK_FAKEHOME?= no
.endif
.if ${CHECK_FAKEHOME:M[Yy][Ee][Ss]}
privileged-install-hook: _check-fakehome
.endif
_check-fakehome: .PHONY
${RUN} if [ `ls -a ${FAKEHOMEDIR:Q} | ${AWK} \
'{if ($$0 != "." && $$0 != "..") {x=1; exit}} \
END {print x + 0}' \
` = 1 ]; then \
${WARNING_MSG} "[check-fakehome.mk] fake home directory not empty:"; \
find ${FAKEHOMEDIR} -print | ${SED} 's/^/ /'; \
exit 0; \
fi

384
mk/check/check-files.mk Normal file
View File

@@ -0,0 +1,384 @@
# $NetBSD: check-files.mk,v 1.29 2013/03/08 15:32:52 wiz Exp $
#
# This file checks that the list of installed files matches the PLIST.
# For that purpose it records the file list of LOCALBASE before and
# after the installation of the package and compares these lists with
# the PLIST.
#
# User-settable variables:
#
# CHECK_FILES
# "yes" to enable the check, "no" to disable it.
#
# Default value: "yes" for PKG_DEVELOPERs, "no" otherwise.
#
# CHECK_FILES_STRICT
# When set to "yes", VARBASE and PKG_SYSCONFDIR are checked in
# addition to LOCALBASE.
#
# Package-settable variables:
#
# CHECK_FILES_SKIP
# A list of regular expressions (FIXME: all other checks use shell
# patterns) that names files to be skipped. This is useful to
# avoid getting errors triggered by changes in directories not
# really handled by pkgsrc.
#
_VARGROUPS+= check-files
_USER_VARS.check-files= CHECK_FILES CHECK_FILES_STRICT
_PKG_VARS.check-files= CHECK_FILES_SKIP
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_FILES?= yes
.endif
CHECK_FILES?= no
CHECK_FILES_STRICT?= no
# Info index files updated when a new info file is added.
.if defined(INFO_FILES)
CHECK_FILES_SKIP+= ${PREFIX}/.*/dir
.endif
# Perl's perllocal.pod index that is regenerated when a local module
# is added.
#
CHECK_FILES_SKIP+= ${PERL5_INSTALLARCHLIB}/perllocal.pod
# R's index files that are regenerated when a local module
# is added.
#
CHECK_FILES_SKIP+= ${PREFIX}/lib/R/doc/html/packages.html
CHECK_FILES_SKIP+= ${PREFIX}/lib/R/doc/html/search/index.txt
CHECK_FILES_SKIP+= ${PKG_DBDIR}/.*
# We don't care about what's under linux/proc and linux32/proc in Linux
# emulation, which just holds run-time generated data.
#
CHECK_FILES_SKIP+= ${PREFIX}/emul/linux/proc.*
CHECK_FILES_SKIP+= ${PREFIX}/emul/linux32/proc.*
# The reference-count meta-data directory used by the pkginstall framework.
CHECK_FILES_SKIP+= ${PKG_DBDIR}.refcount.*
# Some people have their distfiles and binary packages below ${LOCALBASE}.
CHECK_FILES_SKIP+= ${PACKAGES}/.*
CHECK_FILES_SKIP+= ${DISTDIR}/.*
# For unprivileged builds, VARBASE is below LOCALBASE.
.if !empty(CHECK_FILES_STRICT:M[Nn][Oo])
CHECK_FILES_SKIP+= ${VARBASE}/.*
.endif
# File that are outside of ${PREFIX} in directories we already know we'll
# be using for mutable data.
#
.for d in ${MAKE_DIRS} ${OWN_DIRS}
CHECK_FILES_SKIP+= ${d:C/^([^\/])/${PREFIX}\/\1/}.*
.endfor
.for d o g m in ${MAKE_DIRS_PERMS} ${OWN_DIRS_PERMS}
CHECK_FILES_SKIP+= ${d:C/^([^\/])/${PREFIX}\/\1/}.*
.endfor
# Mutable X11 font database files
.if (defined(FONTS_DIRS.x11) && !empty(FONTS_DIRS.x11:M*))
CHECK_FILES_SKIP+= ${PREFIX}/.*/encodings.dir
CHECK_FILES_SKIP+= ${PREFIX}/.*/fonts.dir
.endif
.if (defined(FONTS_DIRS.ttf) && !empty(FONTS_DIRS.ttf:M*)) || \
(defined(FONTS_DIRS.type1) && !empty(FONTS_DIRS.type1:M*))
CHECK_FILES_SKIP+= ${PREFIX}/.*/fonts.scale
.endif
.if (defined(FONTS_DIRS.ttf) && !empty(FONTS_DIRS.ttf:M*)) || \
(defined(FONTS_DIRS.type1) && !empty(FONTS_DIRS.type1:M*)) || \
(defined(FONTS_DIRS.x11) && !empty(FONTS_DIRS.x11:M*))
CHECK_FILES_SKIP+= ${PREFIX}/.*/fonts.cache-1
.endif
# Mutable charset.alias file
CHECK_FILES_SKIP+= ${PREFIX}/lib/charset.alias
# Mutable locale.alias file
CHECK_FILES_SKIP+= ${PREFIX}/share/locale/locale.alias
_CHECK_FILES_SKIP_FILTER= ${GREP} -vx ${CHECK_FILES_SKIP:@f@-e ${DESTDIR:Q}${f:Q}@}
###########################################################################
# These are the files generated and used by the check-files implementation
# used across several check-files targets.
#
# _CHECK_FILES_ERRMSG.* are the files that contain the error
# messages discovered during each stage of file-checking.
#
# _CHECK_FILES_PRE.* are the file lists generated before any files
# from the package are installed.
#
# _CHECK_FILES_POST.* are the file lists generated after all files
# from the package are installed.
#
# The "pre" and "post" file lists are compared against each other to
# determine if the package is installing files where it shouldn't be.
#
_CHECK_FILES_ERRMSG.prefix= ${ERROR_DIR}/check-files-prefix
_CHECK_FILES_PRE.prefix= ${WRKDIR}/.prefix.pre
_CHECK_FILES_POST.prefix= ${WRKDIR}/.prefix.post
_CHECK_FILES_ERRMSG.sysconfdir= ${ERROR_DIR}/.check-files-sysconfdir
_CHECK_FILES_PRE.sysconfdir= ${WRKDIR}/.sysconfdir.pre
_CHECK_FILES_POST.sysconfdir= ${WRKDIR}/.sysconfdir.post
_CHECK_FILES_ERRMSG.varbase= ${ERROR_DIR}/.check-files-varbase
_CHECK_FILES_PRE.varbase= ${WRKDIR}/.varbase.pre
_CHECK_FILES_POST.varbase= ${WRKDIR}/.varbase.post
_CHECK_FILES_ERRMSGS= # empty
_CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.prefix}
.if empty(CHECK_FILES_STRICT:M[nN][oO])
_CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.sysconfdir}
_CHECK_FILES_ERRMSGS+= ${_CHECK_FILES_ERRMSG.varbase}
.endif
###########################################################################
# _CHECK_FILES_PRE holds the list of targets that are built as part of
# building the check-files-pre target. These targets should cause the
# "pre" file lists to be generated.
#
_CHECK_FILES_PRE= check-files-pre-message
_CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.prefix}
.if empty(CHECK_FILES_STRICT:M[nN][oO])
_CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.sysconfdir}
_CHECK_FILES_PRE+= ${_CHECK_FILES_PRE.varbase}
.endif
###########################################################################
# _CHECK_FILES_POST holds the list of targets that are built as part of
# building the check-files-post target. These targets should cause the
# "post" file lists to be generated.
#
_CHECK_FILES_POST= check-files-post-message
_CHECK_FILES_POST+= ${_CHECK_FILES_POST.prefix}
.if empty(CHECK_FILES_STRICT:M[nN][oO])
_CHECK_FILES_POST+= ${_CHECK_FILES_POST.sysconfdir}
_CHECK_FILES_POST+= ${_CHECK_FILES_POST.varbase}
.endif
.if empty(CHECK_FILES:M[nN][oO])
privileged-install-hook: check-files
.endif
###########################################################################
# check-files-pre and check-files-post targets and subtargets
#
.PHONY: check-files-pre check-files-post
check-files-pre: ${_CHECK_FILES_PRE}
check-files-post: ${_CHECK_FILES_POST}
.PHONY: check-files-pre-message check-files-post-message
check-files-pre-message:
@${STEP_MSG} "Generating pre-install file lists"
check-files-post-message:
@${STEP_MSG} "Generating post-install file lists"
${_CHECK_FILES_PRE.prefix} ${_CHECK_FILES_POST.prefix}:
${RUN} \
${FIND} ${DESTDIR}${PREFIX}/. \( -type f -o -type l \) -print 2>/dev/null \
| ${SED} -e 's,/\./,/,' \
| ${_CHECK_FILES_SKIP_FILTER} \
| ${SORT} > ${.TARGET} \
|| ${TRUE}
${_CHECK_FILES_PRE.sysconfdir} ${_CHECK_FILES_POST.sysconfdir}:
${RUN} \
${FIND} ${DESTDIR}${PKG_SYSCONFDIR}/. -print 2>/dev/null \
| ${SED} -e 's,/\./,/,' \
| ${_CHECK_FILES_SKIP_FILTER} \
| ${SORT} > ${.TARGET} \
|| ${TRUE}
${_CHECK_FILES_PRE.varbase} ${_CHECK_FILES_POST.varbase}:
${RUN} \
${FIND} ${DESTDIR}${VARBASE}/. -print 2>/dev/null \
| ${SED} -e 's,/\./,/,' \
| ${_CHECK_FILES_SKIP_FILTER} \
| ${SORT} > ${.TARGET} \
|| ${TRUE}
###########################################################################
# check-files targets and subtargets
#
.PHONY: check-files-prefix check-files-sysconfdir check-files-varbase
check-files-prefix: ${_CHECK_FILES_ERRMSG.prefix}
check-files-sysconfdir: ${_CHECK_FILES_ERRMSG.sysconfdir}
check-files-varbase: ${_CHECK_FILES_ERRMSG.varbase}
# The check-files target looks at the cookie files generated by the
# check-files-* subtargets, and if they are non-empty, then they
# contain the error messages collected during the build of each
# subtarget.
#
.PHONY: check-files
.if !empty(CHECK_FILES_SUPPORTED:M[nN][oO])
check-files:
@${DO_NADA}
.else
check-files: check-files-message ${_CHECK_FILES_ERRMSGS} error-check
.endif
.PHONY: check-files-message
check-files-message:
@${STEP_MSG} "Checking file-check results for ${PKGNAME}"
# Check ${PREFIX} for files which are not listed in the generated ${PLIST}
# and vice-versa.
#
_CHECK_FILES_DIFF= ${WRKDIR}/.check_files_diff
_CHECK_FILES_ADDED= ${WRKDIR}/.check_files_added
_CHECK_FILES_DELETED= ${WRKDIR}/.check_files_deleted
_CHECK_FILES_EXPECTED= ${WRKDIR}/.check_files_expected
_CHECK_FILES_MISSING= ${WRKDIR}/.check_files_missing
_CHECK_FILES_MISSING_SKIP= ${WRKDIR}/.check_files_missing_skip
_CHECK_FILES_MISSING_REAL= ${WRKDIR}/.check_files_missing_real
_CHECK_FILES_EXTRA= ${WRKDIR}/.check_files_extra
${_CHECK_FILES_DIFF}: ${_CHECK_FILES_PRE.prefix} ${_CHECK_FILES_POST.prefix}
${RUN} \
${DIFF} -u ${_CHECK_FILES_PRE.prefix} \
${_CHECK_FILES_POST.prefix} \
> ${.TARGET} || ${TRUE}
${_CHECK_FILES_ADDED}: ${_CHECK_FILES_DIFF}
${RUN} \
${GREP} '^+/' ${_CHECK_FILES_DIFF} | ${SED} "s|^+||" | ${SORT} \
> ${.TARGET}
${_CHECK_FILES_DELETED}: ${_CHECK_FILES_DIFF}
${RUN} \
${GREP} '^-/' ${_CHECK_FILES_DIFF} | ${SED} "s|^-||" | ${SORT} \
> ${.TARGET}
${_CHECK_FILES_EXPECTED}: plist
${RUN} \
${GREP} '^[^@]' ${PLIST} | ${SED} "s|^|${DESTDIR}${PREFIX}/|" | ${SORT} \
> ${.TARGET}
${_CHECK_FILES_MISSING}: ${_CHECK_FILES_EXPECTED} ${_CHECK_FILES_ADDED}
${RUN} \
${DIFF} -u ${_CHECK_FILES_EXPECTED} ${_CHECK_FILES_ADDED} | \
${GREP} '^-[^-]' | ${SED} "s|^-||" | \
while read file; do \
${TEST} -f "$$file" -o -h "$$file" || ${ECHO} "$$file"; \
done > ${.TARGET}
${_CHECK_FILES_MISSING_REAL}: ${_CHECK_FILES_MISSING}
${RUN} \
${CAT} ${_CHECK_FILES_MISSING} | ${_CHECK_FILES_SKIP_FILTER} \
> ${.TARGET} || ${TRUE}
${_CHECK_FILES_MISSING_SKIP}: \
${_CHECK_FILES_MISSING} \
${_CHECK_FILES_MISSING_REAL}
${RUN} \
${DIFF} -u ${_CHECK_FILES_MISSING} \
${_CHECK_FILES_MISSING_REAL} | \
${GREP} '^-[^-]' | ${SED} "s|^-||" \
> ${.TARGET}
${_CHECK_FILES_EXTRA}: ${_CHECK_FILES_EXPECTED} ${_CHECK_FILES_ADDED}
${RUN} \
${DIFF} -u ${_CHECK_FILES_EXPECTED} ${_CHECK_FILES_ADDED} | \
${GREP} '^+[^+]' | ${SED} "s|^+||" | \
while read file; do \
${TEST} ! -f "$$file" -a ! -h "$$file" || ${ECHO} "$$file"; \
done > ${.TARGET}
${_CHECK_FILES_ERRMSG.prefix}: \
${_CHECK_FILES_DELETED} \
${_CHECK_FILES_MISSING} \
${_CHECK_FILES_MISSING_REAL} \
${_CHECK_FILES_MISSING_SKIP} \
${_CHECK_FILES_EXTRA}
${RUN}${RM} -f ${.TARGET}
${RUN} \
if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_DELETED}; then \
${ECHO} "The following files have been deleted" \
"from ${PREFIX}!"; \
${SED} "s|^| |" ${_CHECK_FILES_DELETED}; \
fi >> ${.TARGET}
${RUN} \
if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_MISSING_REAL}; then \
${ECHO} "************************************************************"; \
${ECHO} "The following files are in the" \
"PLIST but not in ${DESTDIR}${PREFIX}:"; \
${SED} "s|^| |" ${_CHECK_FILES_MISSING_REAL}; \
fi >> ${.TARGET}
${RUN} \
if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_EXTRA}; then \
${ECHO} "************************************************************"; \
${ECHO} "The following files are in" \
"${DESTDIR}${PREFIX} but not in the PLIST:"; \
${SED} "s|^| |" ${_CHECK_FILES_EXTRA}; \
fi >> ${.TARGET}
${RUN} \
if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_MISSING_SKIP}; then \
${ECHO} "************************************************************"; \
${ECHO} "The following files are in both the" \
"PLIST and CHECK_FILES_SKIP:"; \
${SED} "s|^| |" ${_CHECK_FILES_MISSING_SKIP}; \
fi >> ${.TARGET}
# Check ${SYSCONFDIR} for files which are not in the PLIST and are also
# not copied into place by the INSTALL scripts.
#
${_CHECK_FILES_ERRMSG.sysconfdir}: \
${_CHECK_FILES_PRE.sysconfdir} \
${_CHECK_FILES_POST.sysconfdir}
${RUN} \
if ${CMP} -s ${_CHECK_FILES_PRE.sysconfdir} \
${_CHECK_FILES_POST.sysconfdir}; then \
${DO_NADA}; \
else \
${ECHO} "************************************************************"; \
${ECHO} "The package has modified ${PKG_SYSCONFDIR}" \
"contents directly!"; \
${ECHO} " The offending files/directories are:"; \
${DIFF} -u ${_CHECK_FILES_PRE.sysconfdir} \
${_CHECK_FILES_POST.sysconfdir} | \
${GREP} '^+[^+]' | ${SED} "s|^+| |"; \
fi > ${.TARGET}
# Check ${VARBASE} for files which are not in the PLIST and are also
# not created by the INSTALL scripts.
#
${_CHECK_FILES_ERRMSG.varbase}: \
${_CHECK_FILES_PRE.varbase} \
${_CHECK_FILES_POST.varbase}
${RUN} \
if ${CMP} -s ${_CHECK_FILES_PRE.varbase} \
${_CHECK_FILES_POST.varbase}; then \
${DO_NADA}; \
else \
${ECHO} "************************************************************"; \
${ECHO} "The package has modified ${VARBASE}" \
"contents directly!"; \
${ECHO} " The offending files/directories are:"; \
${DIFF} -u ${_CHECK_FILES_PRE.varbase} \
${_CHECK_FILES_POST.varbase} | \
${GREP} '^+[^+]' | ${SED} "s|^+| |"; \
fi > ${.TARGET}
###########################################################################
# check-files-clean removes the state files related to the "check-files"
# target so that the check-files-{pre,post} targets may be re-run.
#
.PHONY: check-files-clean
check-clean: check-files-clean
check-files-clean:
${RUN} \
${RM} -f ${_CHECK_FILES_ERRMSGS} \
${_CHECK_FILES_PRE} ${_CHECK_FILES_POST} \
${_CHECK_FILES_DIFF} ${_CHECK_FILES_ADDED} \
${_CHECK_FILES_DELETED} ${_CHECK_FILES_EXPECTED} \
${_CHECK_FILES_MISSING} ${_CHECK_FILES_MISSING_SKIP} \
${_CHECK_FILES_MISSING_REAL} ${_CHECK_FILES_EXTRA}

40
mk/check/check-headers.mk Normal file
View File

@@ -0,0 +1,40 @@
# $NetBSD: check-headers.mk,v 1.6 2010/08/24 19:08:29 bad Exp $
#
# This file checks the C and C++ header files for possible problems.
#
# User-settable variables:
#
# CHECK_HEADERS
# Whether the header files should be checked.
#
# Default value: "yes" for PKG_DEVELOPERs, "no" otherwise.
#
# Package-settable-variables:
#
# CHECK_HEADERS_SKIP
# A list of filename patterns that should be skipped for this test.
#
_VARGROUPS+= check-headers
_USER_VARS.check-headers= CHECK_HEADERS
_PKG_VARS.check-headers= CHECK_HEADERS_SKIP
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
# still experimental
#CHECK_HEADERS?= yes
.endif
CHECK_HEADERS?= no
CHECK_HEADERS_SKIP?= # none
.if !empty(CHECK_HEADERS:M[Yy][Ee][Ss])
pre-build-checks-hook: _check-headers
.endif
.PHONY: _check-headers
_check-headers:
@${STEP_MSG} "Checking for possible problems in header files"
${RUN} \
[ -d ${WRKSRC}/. ] || exit 0; \
cd ${WRKSRC}; \
env SKIP_FILTER=${CHECK_HEADERS_SKIP:@p@${p}) skip=yes;;@:Q} \
sh ${PKGSRCDIR}/mk/check/check-headers.sh

82
mk/check/check-headers.sh Normal file
View File

@@ -0,0 +1,82 @@
# $NetBSD: check-headers.sh,v 1.10 2008/01/21 06:11:09 rillig Exp $
#
# This program checks the header files for possible problems.
#
# When a macro definition contains the characters "${", it is likely
# that is comes from a GNU-style configure script that didn't use the
# ${prefix} or ${exec_prefix} variable correctly.
#
set -eu
checkdir=`dirname "$0"`
. "$checkdir/check-subr.sh"
cs_setprogname "$0"
found_unresolved_variable=no
# usage: check_header <fname>
check_header() {
# See the end of the loop for the redirection.
while read line; do
# Check for "${" in macro definitions.
case "$line" in
"#"*define*[\":]\$\{[A-Za-z]*\}/*\"*)
found_unresolved_variable=yes
cs_error_heading "Found unresolved variable in macro:"
cs_error_msg "$fname: $line"
;;
esac
done < "$1"
}
find * -type f -print 2>/dev/null \
| {
while read fname; do
skip=no
eval "case \"\$fname\" in $SKIP_FILTER *.orig) skip=yes;; esac"
[ $skip = no ] || continue
case "$fname" in
*.h | *.hpp | *.h++ | *.hxx)
check_header "$fname"
;;
esac
done
if [ $found_unresolved_variable = yes ]; then
cs_explain <<EOF
The above macros may contain references to shell variables.
The cause of this problem is usually that in a configure.ac or
configure.in file, there is some code like
FOO_DIR="\${bindir}"
# ...
AC_DEFINE_UNQUOTED(FOO_DIR, "\$FOO_DIR", [Directory where foo files go])
You can fix this by telling the original package author not to use
AC_DEFINE_UNQUOTED for directories. Instead, {he,she} should do
something like this:
# in configure.ac:
foodir="\${bindir}"
AC_SUBST(FOO_DIR)
# in the Makefile.am files (can be more than one):
AM_CPPFLAGS= -DFOO_DIR=\\"@FOO_DIR@\\"
See also:
http://www.gnu.org/software/autoconf/manual/html_node/Defining-Directories.html
If this check is wrong and the package really wants to have "\${" in the
macros, append the above filenames to the CHECK_HEADERS_SKIP variable in
the package Makefile.
EOF
fi
cs_exit
}

View File

@@ -0,0 +1,88 @@
# $NetBSD: check-interpreter.mk,v 1.27 2011/04/19 15:31:45 roy Exp $
#
# This file checks that after installation, all files of the package
# that start with a "#!" line will find their interpreter. Files that
# have a "#!" line with a non-existent interpreter will generate an
# error message if they are executable, and a warning message otherwise.
#
# Files are not allowed to use /bin/env or /usr/bin/env as an interpreter
# due the use dynamic paths and package developers not checking that they work.
# A classic example is: #!/usr/bin/env python
#
# User-settable variables:
#
# CHECK_INTERPRETER
# Whether this check should be enabled or not.
#
# Default value: "yes" for PKG_DEVELOPER, "no" otherwise.
#
# Package-settable variables:
#
# CHECK_INTERPRETER_SKIP
# The list of file patterns that are skipped by the check.
# All files in share/examples and share/doc are skipped as well.
#
# Default value: (empty)
#
# Example: share/package1/* share/package2/somefile
#
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_INTERPRETER?= yes
.else
CHECK_INTERPRETER?= no
.endif
CHECK_INTERPRETER_SKIP?= # empty
_CHECK_INTERP_SKIP= share/doc/*
_CHECK_INTERP_SKIP+= share/examples/*
_CHECK_INTERP_SKIP+= ${CHECK_INTERPRETER_SKIP}
_CHECK_INTERP_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST}
.if !empty(CHECK_INTERPRETER:M[Yy][Ee][Ss])
privileged-install-hook: _check-interpreter
.endif
_check-interpreter: error-check .PHONY
@${STEP_MSG} "Checking for non-existent script interpreters in ${PKGNAME}"
${RUN} cd ${DESTDIR}${PREFIX}; \
${_CHECK_INTERP_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g' |\
while read file; do \
case "$$file" in \
${_CHECK_INTERP_SKIP:@p@${p}) continue ;;@} \
*) ;; \
esac; \
if [ ! -f "$$file" ]; then \
continue; \
fi; \
if [ ! -r "$$file" ]; then \
${DELAYED_WARNING_MSG} "[check-interpreter.mk] File \"${DESTDIR}${PREFIX}/$$file\" cannot be read."; \
continue; \
fi; \
${SHCOMMENT} "[$$file]"; \
interp=`${SED} -n -e '1s/^#![[:space:]]*\([^[:space:]]*\).*/\1/p' -e '1q' < "$$file"` \
|| { ${DELAYED_WARNING_MSG} "[check-interpreter.mk] sed(1) failed for \"${DESTDIR}${PREFIX}/$$file\"."; \
continue; \
}; \
case "$$interp" in \
"") continue;; \
/bin/env|/usr/bin/env) if [ -x "$$file" ]; then \
${DELAYED_ERROR_MSG} "[check-interpreter.mk] The interpreter \"$$interp\" of \"${DESTDIR}${PREFIX}/$$file\" is not allowed."; \
else \
${DELAYED_WARNING_MSG} "[check-interpreter.mk] The interpreter \"$$interp\" of \"${DESTDIR}${PREFIX}/$$file\" is not allowed."; \
fi; \
continue;; \
esac; \
\
if { [ ! -f ${DESTDIR:Q}"$$interp" ] && \
[ ! -f "$$interp" ]; }; then \
\
if [ -x "$$file" ]; then \
${DELAYED_ERROR_MSG} "[check-interpreter.mk] The interpreter \"$$interp\" of \"${DESTDIR}${PREFIX}/$$file\" does not exist."; \
else \
\
${DELAYED_WARNING_MSG} "[check-interpreter.mk] The interpreter \"$$interp\" of \"${DESTDIR}${PREFIX}/$$file\" does not exist."; \
fi; \
fi; \
done

95
mk/check/check-perms.mk Normal file
View File

@@ -0,0 +1,95 @@
# $NetBSD: check-perms.mk,v 1.14 2013/05/09 23:37:25 riastradh Exp $
#
# This file checks that after installation of a package, all files and
# directories of that package have sensible permissions set.
#
# To use this check in bulk builds, add
# BULK_PREREQ+= sysutils/checkperms
# to your mk.conf file.
#
# User-settable variables:
#
# CHECK_PERMS
# Specifies whether the permissions check should be run at all.
#
# Possible values: yes, no.
#
# Default value: yes for PKG_DEVELOPER, no otherwise.
#
# Package-settable variables:
#
# CHECK_PERMS_SKIP
# A list of shell patterns (like man/*) that should be excluded
# from the check. Note that a * in a pattern also matches a slash
# in a pathname.
#
# Default value: empty.
#
# CHECK_PERMS_AUTOFIX
# If set to yes, any unusual permissions are fixed automatically.
#
# Possible values: yes, no.
#
_VARGROUPS+= check-perms
_USER_VARS.check-perms= CHECK_PERMS
_PKG_VARS.check-perms= CHECK_PERMS_SKIP CHECK_PERMS_AUTOSKIP
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_PERMS?= yes
.else
CHECK_PERMS?= no
.endif
CHECK_PERMS_SKIP?= # none
CHECK_PERMS_AUTOFIX?= no
# The checkperms command does not yet support Interix with the -c flag.
# See PR 34968.
.if !empty(MACHINE_PLATFORM:MInterix-*-*)
_CHECK_PERMS_FLAGS=
.elif !empty(CHECK_PERMS_AUTOFIX:M[Yy][Ee][Ss])
_CHECK_PERMS_FLAGS= -cff
.else
_CHECK_PERMS_FLAGS= -c
.endif
.if !empty(CHECK_PERMS:M[Yy][Ee][Ss])
TOOL_DEPENDS+= checkperms>=1.1:../../sysutils/checkperms
privileged-install-hook: _check-perms
.endif
_CHECK_PERMS_CMD= ${LOCALBASE}/bin/checkperms
_CHECK_PERMS_GETDIRS_AWK= \
/.*/ { \
print $$0; \
dir = $$0; \
while (sub("/[^/]*$$", "", dir) && dir != "") { \
if (!(dir in dirs)) { \
dirs[dir] = "done"; \
print dir; \
} \
} \
}
_check-perms: .PHONY
@${STEP_MSG} "Checking file permissions in ${PKGNAME}"
${RUN} ${HOST_PKG_INFO} -qe "checkperms>=1.1" \
|| { \
${WARNING_MSG} "[check-perms.mk] Skipping file permissions check."; \
${WARNING_MSG} "[check-perms.mk] Install sysutils/checkperms to enable this check."; \
exit 0; \
}; \
${PKG_FILELIST_CMD} \
| sort \
| sed -e 's,\\,\\\\,g' \
| while read file; do \
case "$$file" in \
${CHECK_PERMS_SKIP:@p@${PREFIX}/${p}|${p}) continue ;;@}\
*) ;; \
esac; \
printf "%s\\n" "${DESTDIR}$$file"; \
done \
| awk ${_CHECK_PERMS_GETDIRS_AWK:Q} \
| ${_CHECK_PERMS_CMD} ${_CHECK_PERMS_FLAGS}

View File

@@ -0,0 +1,87 @@
# $NetBSD: check-portability.awk,v 1.4 2006/11/13 23:21:53 rillig Exp $
#
# Checks a shell file for possible portability problems.
#
# ENVIRONMENT
# (See check-subr.awk)
#
BEGIN {
found_random = no;
found_test_eqeq = no;
}
# Check for $RANDOM, which is specific to ksh and bash.
function check_random(line) {
# $RANDOM together with the PID is often found in GNU-style
# configure scripts and is considered acceptable.
if (line ~ /\$\$-\$RANDOM/ || line ~ /\$RANDOM-\$\$/) {
# Assume that this is ok.
} else if (line ~ /\$RANDOM[A-Z_]+/) {
# That's ok, too.
} else if (line ~ /\$RANDOM/) {
found_random = yes;
cs_warning_heading("Found $RANDOM:");
cs_warning_msg(cs_fname ": " $0);
}
}
function check_test_eqeq(line, n, word, i) {
n = split(line, word);
for (i = 3; i < n; i++) {
if (word[i] == "==") {
if (word[i-2] == "test" || word[i-2] == "[") {
found_test_eqeq = yes;
cs_error_heading("Found test ... == ...:");
cs_error_msg(cs_fname ": " $0);
}
}
}
}
/./ {
# Note: This code does not find _all_ instances of
# unportable code. If a single line contains an unsafe and
# a safe usage of $RANDOM, it will pass the test.
# Strip comments
line = $0;
gsub(/^#.*/, "", line);
gsub(/[[:space:]]#.*/, "", line);
check_random(line);
check_test_eqeq(line);
}
END {
if (found_random) {
h = "The variable $RANDOM is not required for a POSIX-conforming shell, and\n";
h = h "many implementations of /bin/sh do not support it. It should therefore\n";
h = h "not be used in shell programs that are meant to be portable across a\n";
h = h "large number of POSIX-like systems.\n"
cs_explain(h);
}
if (found_test_eqeq) {
h = "The \"test\" command, as well as the \"[\" command, are not required to know\n";
h = h "the \"==\" operator. Only a few implementations like bash and some\n";
h = h "versions of ksh support it.\n";
h = h "\n";
h = h "When you run \"test foo == foo\" on a platform that does not support the\n";
h = h "\"==\" operator, the result will be \"false\" instead of \"true\". This can\n";
h = h "lead to unexpected behavior.\n";
h = h "\n";
h = h "There are two ways to fix this error message. If the file that contains\n";
h = h "the \"test ==\" is needed for building the package, you should create a\n";
h = h "patch for it, replacing the \"==\" operator with \"=\". If the file is not\n";
h = h "needed, add its name to the CHECK_PORTABILITY_SKIP variable in the\n";
h = h "package Makefile.\n";
cs_explain(h);
}
cs_exit();
}

View File

@@ -0,0 +1,55 @@
# $NetBSD: check-portability.mk,v 1.7 2010/08/24 19:08:29 bad Exp $
#
# This file contains some checks that are applied to the configure
# scripts to check for certain constructs that are known to cause
# problems on some platforms.
#
# The following variables may be set by the pkgsrc user in mk.conf:
#
# CHECK_PORTABILITY
# Whether to enable some portability checks for the configure
# scripts before they are run.
#
# Default value: yes for PKG_DEVELOPERs, no otherwise.
#
# The following variables may be set by the package:
#
# SKIP_PORTABILITY_CHECK
# Whether the above checks should be skipped for the current
# package.
#
# Default value: no
# Deprecated: Use CHECK_PORTABILITY_SKIP instead.
# Obsolete since 2008-02-20.
#
# CHECK_PORTABILITY_SKIP
# The list of files that should be skipped in the portability
# check.
#
# Default value: empty.
# Example: debian/*
_VARGROUPS+= check-portability
_USER_VARS.check-portability= CHECK_PORTABILITY
_PKG_VARS.check-portability= CHECK_PORTABILITY_SKIP
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_PORTABILITY?= yes
.endif
CHECK_PORTABILITY?= no
.if defined(SKIP_PORTABILITY_CHECK)
PKG_FAIL_REASON+= "[check-portability.mk] SKIP_PORTABILITY_CHECK is obsolete."
.endif
CHECK_PORTABILITY_SKIP?= # none
.if ${CHECK_PORTABILITY:M[Yy][Ee][Ss]} != ""
pre-configure-checks-hook: _check-portability
.endif
.PHONY: _check-portability
_check-portability:
@${STEP_MSG} "Checking for portability problems in extracted files"
${RUN} \
[ -d ${WRKSRC}/. ] || exit 0; \
cd ${WRKSRC}; \
env SKIP_FILTER=${CHECK_PORTABILITY_SKIP:@p@${p}) skip=yes;;@:Q} \
sh ${PKGSRCDIR}/mk/check/check-portability.sh

View File

@@ -0,0 +1,65 @@
# $NetBSD: check-portability.sh,v 1.9 2013/01/04 10:51:57 jperkin Exp $
#
# This program checks all files in the current directory and any
# subdirectories for portability issues that are likely to result in
# false assumptions by the package.
#
# The most prominent example is the "==" operator of test(1), which is
# only implemented by bash and some versions of the ksh.
#
# usage: check-portability.sh
#
set -eu
checkdir=`dirname "$0"`
. "$checkdir/check-subr.sh"
cs_setprogname "$0"
: ${SKIP_FILTER:=""}
# usage: check_shell <fname>
check_shell() {
env \
CK_FNAME="$1" \
CK_PROGNAME="check-portability.awk" \
awk -f "$checkdir/check-subr.awk" \
-f "$checkdir/check-portability.awk" \
< "$1" 1>&2 \
|| cs_exitcode=1
}
find * -type f -print 2>/dev/null \
| {
opsys=`uname -s`-`uname -r`
while read fname; do
skip=no
eval "case \"\$fname\" in $SKIP_FILTER *.orig) skip=yes;; esac"
[ $skip = no ] || continue
case "$opsys" in
SunOS-5.9)
# See also (if you can):
# http://sunsolve.sun.com/search/document.do?assetkey=1-1-4250902-1
firstline=`sed 1q < "$fname"`
;;
*) read firstline < "$fname" || continue
;;
esac
case "$firstline" in
"#!"*"/bin/sh")
check_shell "$fname"
case "$opsys" in
SunOS-5.[0-9]|SunOS-5.10)
echo "WARNING: [check-portability.sh] $fname has /bin/sh as interpreter, which is horribly broken on Solaris." 1>&2
;;
esac
;;
esac
done
cs_exit
}

View File

@@ -0,0 +1,156 @@
# $NetBSD: check-shlibs-elf.awk,v 1.5 2012/06/16 11:58:07 obache Exp $
#
# Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
# All rights reserved.
#
# This code was developed as part of Google's Summer of Code 2007 program.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Read a list of potential ELF binaries from stdin.
# For each, extract the DT_RPATH and DT_NEEDED fields.
# Check that DT_RPATH is not relative to WRKDIR.
# Check that DT_NEEDED can be resolved either via DT_RPATH
# or a system specific default path.
# Check that the resolved DSO belongs to full dependency.
#
function shquote(IN, out) {
out = IN;
gsub("\\\\", "\\\\", out);
gsub("\\\n", "\\n", out);
gsub("\\\t", "\\t", out);
gsub(" ", "\\ ", out);
gsub("'", "\\'", out);
gsub("`", "\\`", out);
gsub("\"", "\\\"", out);
gsub(";", "\\;", out);
gsub("&", "\\&", out);
gsub("<", "\\<", out);
gsub(">", "\\>", out);
gsub("\\(", "\\(", out);
gsub("\\)", "\\)", out);
gsub("\\|", "\\|", out);
gsub("\\*", "\\*", out);
gsub("\\?", "\\?", out);
gsub("\\{", "\\{", out);
gsub("\\}", "\\}", out);
gsub("\\[", "\\[", out);
gsub("\\]", "\\]", out);
gsub("\\$", "\\$", out);
gsub("!", "\\!", out);
gsub("#", "\\#", out);
gsub("\\^", "\\^", out);
gsub("~", "\\~", out);
return out;
}
function check_pkg(DSO, pkg, found) {
if (destdir == "")
return 0
cmd = pkg_info_cmd " -Fe " shquote(DSO) " 2> /dev/null"
if ((cmd | getline pkg) < 0) {
close(cmd)
return 0
}
close(cmd)
if (pkg == "")
return 0
found=0
while ((getline < depends_file) > 0) {
if ($3 == pkg) {
found=1
if ($1 != "full")
continue
close(depends_file)
return 0
}
}
if (found)
print DSO ": " pkg " is not a runtime dependency"
# Not yet:
# print DSO ": " pkg " is not a dependency"
close(depends_file)
}
function checkshlib(DSO, needed, rpath, found, dso_rath, got_rpath) {
cmd = readelf " -Wd " shquote(DSO) " 2> /dev/null"
while ((cmd | getline) > 0) {
if ($2 == "(RPATH)") {
sub("^[[:space:]]*0[xX][[:xdigit:]]+[[:space:]]+\\(RPATH\\)[[:space:]]+Library rpath: \\[", "")
dso_rpath = substr($0, 1, length($0) - 1)
if (length(system_rpath) > 0)
split(dso_rpath ":" system_rpath, rpath, ":")
else
split(dso_rpath, rpath, ":")
got_rpath = 1
}
if ($2 == "(NEEDED)") {
sub("^[[:space:]]*0[xX][[:xdigit:]]+[[:space:]]+\\(NEEDED\\)[[:space:]]+Shared library: \\[", "")
needed[substr($0, 1, length($0) - 1)] = ""
}
}
if (!got_rpath)
split(system_rpath, rpath, ":")
close(cmd)
for (p in rpath) {
if (rpath[p] == wrkdir ||
substr(rpath[p], 1, length(wrkdir) + 1) == wrkdir "/") {
print DSO ": rpath relative to WRKDIR"
}
}
for (lib in needed) {
for (p in rpath) {
if (!system("test -f " shquote(cross_destdir rpath[p] "/" lib))) {
check_pkg(rpath[p] "/" lib)
found = 1
break
}
if (!system("test -f " shquote(destdir rpath[p] "/" lib))) {
found = 1
break
}
}
if (found == 0)
print DSO ": missing library: " lib;
}
delete rpath
delete needed
}
BEGIN {
system_rpath = ENVIRON["PLATFORM_RPATH"]
cross_destdir = ENVIRON["CROSS_DESTDIR"]
destdir = ENVIRON["DESTDIR"]
readelf = ENVIRON["PLATFORM_READELF"]
wrkdir = ENVIRON["WRKDIR"]
pkg_info_cmd = ENVIRON["PKG_INFO_CMD"]
depends_file = ENVIRON["DEPENDS_FILE"]
if (readelf == "")
readelf = "readelf"
}
{ checkshlib($0); }

96
mk/check/check-shlibs.mk Normal file
View File

@@ -0,0 +1,96 @@
# $NetBSD: check-shlibs.mk,v 1.22 2013/02/20 06:00:51 obache Exp $
#
# This file verifies that all libraries used by the package can be found
# at run-time.
#
# User-settable variables:
#
# CHECK_SHLIBS
# Whether the check should be enabled or not.
#
# Default value: "yes" for PKG_DEVELOPERs, "no" otherwise.
#
# Package-settable variables:
#
# CHECK_SHLIBS_SUPPORTED
# Whether the check should be enabled for this package or not.
#
# Default value: yes
#
_VARGROUPS+= check-shlibs
_USER_VARS.check-shlibs= CHECK_SHLIBS
_PKG_VARS.check-shlibs= CHECK_SHLIBS_SUPPORTED
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_SHLIBS?= yes
.endif
CHECK_SHLIBS?= no
CHECK_SHLIBS_SUPPORTED?= yes
# All binaries and shared libraries.
_CHECK_SHLIBS_ERE= (bin/|sbin/|libexec/|\.so$$|lib/lib.*\.so|lib/lib.*\.dylib|lib/lib.*\.sl)
_CHECK_SHLIBS_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST} | \
(while read file; do \
${TEST} -h "$$file" || ${ECHO} "$$file"; \
done)
.if !empty(CHECK_SHLIBS:M[Yy][Ee][Ss]) && \
!empty(CHECK_SHLIBS_SUPPORTED:M[Yy][Ee][Ss])
privileged-install-hook: _check-shlibs
.endif
.if !empty(USE_CHECK_SHLIBS_ELF:M[yY][eE][sS])
CHECK_SHLIBS_ELF= ${PKGSRCDIR}/mk/check/check-shlibs-elf.awk
CHECK_SHLIBS_ELF_ENV= PLATFORM_RPATH=${_OPSYS_SYSTEM_RPATH:Q}
CHECK_SHLIBS_ELF_ENV+= READELF=${TOOLS_PATH.readelf:Q}
CHECK_SHLIBS_ELF_ENV+= CROSS_DESTDIR=${_CROSS_DESTDIR:Q}
CHECK_SHLIBS_ELF_ENV+= PKG_INFO_CMD=${PKG_INFO:Q}
CHECK_SHLIBS_ELF_ENV+= DEPENDS_FILE=${_RRDEPENDS_FILE:Q}
. if ${_USE_DESTDIR} != "no"
CHECK_SHLIBS_ELF_ENV+= DESTDIR=${DESTDIR:Q}
. endif
CHECK_SHLIBS_ELF_ENV+= WRKDIR=${WRKDIR:Q}
_check-shlibs: error-check .PHONY
@${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"
${RUN} rm -f ${ERROR_DIR}/${.TARGET}
${RUN} \
cd ${DESTDIR:Q}${PREFIX:Q}; \
${_CHECK_SHLIBS_FILELIST_CMD} | \
${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} | \
${PKGSRC_SETENV} ${CHECK_SHLIBS_ELF_ENV} ${AWK} -f ${CHECK_SHLIBS_ELF} > ${ERROR_DIR}/${.TARGET}
.else
. if ${_USE_DESTDIR} != "no"
_check-shlibs: error-check .PHONY
@${WARNING_MSG} "Skipping missing run-time search-path check in DESTDIR mode."
. else
_check-shlibs: error-check .PHONY
@${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"
${RUN} rm -f ${ERROR_DIR}/${.TARGET}
${RUN} \
exec 1>${ERROR_DIR}/${.TARGET}; \
case ${LDD:Q}"" in \
"") ldd=`${TYPE} ldd 2>/dev/null | ${AWK} '{ print $$NF }'` ;; \
*) ldd=${LDD:Q} ;; \
esac; \
${TEST} -x "$$ldd" || exit 0; \
cd ${DESTDIR}${PREFIX}; \
${_CHECK_SHLIBS_FILELIST_CMD} | \
${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} | \
while read file; do \
err=`$$ldd $$file 2>&1 | ${GREP} "not found" || ${TRUE}`; \
${TEST} -z "$$err" || ${ECHO} "${DESTDIR}${PREFIX}/$$file: $$err"; \
done
${RUN} \
exec 1>>${ERROR_DIR}/${.TARGET}; \
if ${_NONZERO_FILESIZE_P} ${ERROR_DIR}/${.TARGET}; then \
${ECHO} "*** The programs/libs shown above will not find the listed"; \
${ECHO} " shared libraries at runtime."; \
${ECHO} " Please fix the package (add -Wl,-R.../lib in the right places)!"; \
${SHCOMMENT} Might not error-out for non-pkg-developers; \
fi
. endif
.endif

View File

@@ -0,0 +1,62 @@
# $NetBSD: check-stripped.mk,v 1.5 2013/05/12 06:17:50 obache Exp $
#
# This file checks that after installation, all binaries conform to the
# setting of INSTALL_UNSTRIPPED.
#
# User-settable variables:
#
# CHECK_STRIPPED
# Whether this check should be enabled or not.
#
# Default value: "no".
#
# Package-settable variables:
#
# CHECK_STRIPPED_SKIP
# The list of file patterns that are skipped by the check.
#
# Default value: (empty)
#
# Example: bin/* sbin/foo
#
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_STRIPPED?= no # XXX: change to "yes" later
.else
CHECK_STRIPPED?= no
.endif
CHECK_STRIPPED_SKIP?= # empty
_CHECK_STRIPPED_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST}
.if !empty(CHECK_STRIPPED:M[Yy][Ee][Ss])
privileged-install-hook: _check-stripped
. if empty(USE_TOOLS:Mfile)
USE_TOOLS+= file
. endif
.endif
_check-stripped: error-check .PHONY
@${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."
${RUN} cd ${DESTDIR}${PREFIX}; \
want_stripped=${_INSTALL_UNSTRIPPED:Dno:Uyes}; \
${_CHECK_STRIPPED_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g'\
| while read file; do \
case "$$file" in \
${CHECK_STRIPPED_SKIP:@p@${p}) continue ;;@} \
*) ;; \
esac; \
dpfile=${DESTDIR}${PREFIX}/$$file; \
test -x "$$dpfile" || continue; \
if [ ! -r "$$dpfile" ]; then \
${DELAYED_WARNING_MSG} "[check-stripped.mk] File \"$$dpfile\" cannot be read."; \
continue; \
fi; \
ftype=`LC_ALL=C ${FILE_CMD} $$dpfile`; \
case $$want_stripped,$$ftype in \
yes,*:*\ ELF\ *,\ not\ stripped*) ${DELAYED_ERROR_MSG} "[check-stripped.mk] $$dpfile should be stripped, but is not.";; \
no,*:*\ ELF\ *,\ stripped*) ${DELAYED_ERROR_MSG} "[check-stripped.mk] $$dpfile should NOT be stripped, but it is.";; \
no,*:*\ ELF\ *,\ not\ stripped*) : ${INFO_MSG} "[check-stripped.mk] $$dpfile is not stripped (ok).";; \
yes,*:*\ ELF\ *,\ stripped*) : ${INFO_MSG} "[check-stripped.mk] $$dpfile is stripped (ok).";; \
esac; \
done

56
mk/check/check-subr.awk Normal file
View File

@@ -0,0 +1,56 @@
# $NetBSD: check-subr.awk,v 1.3 2006/12/31 13:35:10 rillig Exp $
#
# This file contains functions that are used by the various awk
# programs that check things in pkgsrc. All these programs must be
# called with the following environment variables set:
#
# CK_FNAME
# The name of the file that is checked. Since awk interprets
# command line arguments in a weird way, the input file must be
# passed via stdin.
#
# CK_PROGNAME
# The program name to be used in diagnostic messages.
#
BEGIN {
cs_exitcode = 0;
cs_fname = ENVIRON["CK_FNAME"];
cs_progname = ENVIRON["CK_PROGNAME"];
cs_last_heading = "";
cs_hline = "=========================";
cs_hline = cs_hline cs_hline cs_hline;
no = 0;
yes = 1;
}
function cs_error_heading(new_heading) {
if (new_heading != cs_last_heading) {
cs_last_heading = new_heading;
cs_error_msg("=> " new_heading);
}
}
function cs_warning_heading(new_heading) {
if (new_heading != cs_last_heading) {
cs_last_heading = new_heading;
cs_warning_msg("=> " new_heading);
}
}
function cs_error_msg(msg) {
printf("ERROR: [%s] %s\n", cs_progname, msg);
cs_exitcode = 1;
}
function cs_warning_msg(msg) {
printf("WARNING: [%s] %s\n", cs_progname, msg);
}
function cs_explain(msg) {
printf("\nExplanation:\n%s\n%s%s\n\n", cs_hline, msg, cs_hline);
}
function cs_exit() {
exit(cs_exitcode);
}

98
mk/check/check-subr.sh Normal file
View File

@@ -0,0 +1,98 @@
# $NetBSD: check-subr.sh,v 1.5 2007/01/02 17:58:11 rillig Exp $
#
# This file contains shell functions that are used by the various shell
# programs that check things in pkgsrc. All these programs must be
# called with the following environment variables set:
#
# SKIP_FILTER
# A shell expression of the form
#
# */pattern.*) continue;; *.txt) continue;;
#
# that can be passed to eval(1) in order to skip the files
# that are chosen by the respective *_SKIP variable in
# make(1).
#
# Implementation notes:
#
# 1. The SKIP_FILTER variable should only be used in the following
# pattern, usually inside a "for" or "while" loop.
#
# skip=no
# eval "case \"\$fname\" in $SKIP_FILTER *.orig) skip=yes;; esac"
# [ $skip = no ] || continue
#
# 2. The programs using this file are run with the tools wrapper
# directory in the PATH, so they call the utilities by their base names.
# They may also assume to be interpreted by a POSIX-conforming shell, in
# particular _not_ by the Solaris /bin/sh.
#
# All programs that check something are very strict.
set -eu
cs_exitcode=0
# usage: cs_setprogname "progname"
#
# This function sets the variable that will later be used in diagnostic
# messages to identify the program that generated the message.
cs_setprogname() {
cs_progname="${1##*/}"
}
# Each diagnostic message can be preceded by a heading to better identify
# messages that belong together. The heading will only be printed if it
# differs from the last one.
cs_last_heading=""
# usage: cs_error_heading "new heading"
cs_error_heading() {
if [ x"$1" != x"$cs_last_heading" ]; then
cs_last_heading="$1"
cs_error_msg "=> $1"
fi
}
# usage: cs_warning_heading "new heading"
cs_warning_heading() {
if [ x"$1" != x"$cs_last_heading" ]; then
cs_last_heading="$1"
cs_warning_msg "=> $1"
fi
}
# usage: cs_error_msg "error message"
cs_error_msg() {
echo "ERROR: [$cs_progname] $*" 1>&2
cs_exitcode=1
}
# usage: cs_warning_msg "warning message"
cs_warning_msg() {
echo "WARNING: [$cs_progname] $*" 1>&2
}
cs_hline=\
"==========================================================================="
# usage: cs_explain <<EOF
cs_explain() {
{ echo ""
echo "Explanation:"
echo "$cs_hline"
cat
echo "$cs_hline"
echo ""
} 1>&2
}
# usage: cs_exit
#
# At the end of the program, cs_exit should be called to return the
# appropriate exit status to the calling process. It is non-zero when
# any error messages have been printed and zero otherwise.
cs_exit() {
exit "$cs_exitcode"
}

View File

@@ -0,0 +1,22 @@
# $NetBSD: check-vulnerable.mk,v 1.5 2011/10/15 00:23:08 reed Exp $
#
# Public targets:
#
# check-vulnerable:
# Checks for vulnerabilities in the package.
#
.if defined(ALLOW_VULNERABLE_PACKAGES)
check-vulnerable: .PHONY
@${DO_NADA}
. else
check-vulnerable: .PHONY _pkgformat-check-vulnerable
@${DO_NADA}
.endif
# A package format does not need to implement this target, so provide a
# default implementation.
.if !target(_pkgformat-check-vulnerable)
_pkgformat-check-vulnerable:
@${PHASE_MSG} "Skipping vulnerability checks."
.endif

101
mk/check/check-wrkref.mk Normal file
View File

@@ -0,0 +1,101 @@
# $NetBSD: check-wrkref.mk,v 1.21 2010/08/24 19:08:29 bad Exp $
#
# This file checks that the installed files don't contain any strings
# that point to the directory where the package had been built, to make
# sure that the package still works after the source code has been
# cleaned up.
#
# User-settable variables:
#
# CHECK_WRKREF
# The list of directory names that must not appear in installed files.
#
# * "tools" for the tool wrapper directory
# * "home" for FAKEHOMEDIR
# * "wrksrc" for WRKSRC
# * "work" for WRKDIR
# * "wrkobjdir" for WRKOBJDIR
# * "pkgsrc" for PKGSRCDIR
# * "buildlink" for BUILDLINK_DIR and BUILDLINK_X11_DIR
# * "extra" for CHECK_WRKREF_EXTRA_DIRS
#
# Default value: "tools home" for PKG_DEVELOPERs, "no" otherwise.
# The "buildlink" option works best in combination with
# STRIP_DEBUG=yes.
#
# CHECK_WRKREF_EXTRA_DIRS
# A list of additional directories (or other strings) that must
# not appear in the installed files. For pbulk builds, the
# location where the pbulk tools are installed should be added
# here.
#
# Package-settable variables:
#
# CHECK_WRKREF_SKIP
# The list of filename patterns that should be excluded from this
# test, either absolute or relative to PREFIX.
#
_VARGROUPS+= check-wrkref
_USER_VARS.check-wrkref= CHECK_WRKREF
_PKG_VARS.check-wrkref= CHECK_WRKREF_SKIP
.if defined(PKG_DEVELOPER) && ${PKG_DEVELOPER} != "no"
CHECK_WRKREF?= tools home
.endif
CHECK_WRKREF?= no
CHECK_WRKREF_SKIP?= # none
_CHECK_WRKREF_FILELIST_CMD?= ${PKG_FILELIST_CMD}
_CHECK_WRKREF_DIR.no= # none
_CHECK_WRKREF_DIR.work= ${WRKDIR}
_CHECK_WRKREF_DIR.tools= ${TOOLS_DIR}
_CHECK_WRKREF_DIR.home= ${FAKEHOMEDIR}
_CHECK_WRKREF_DIR.wrkobjdir= ${WRKOBJDIR}
_CHECK_WRKREF_DIR.wrksrc= ${WRKSRC}
_CHECK_WRKREF_DIR.pkgsrc= ${PKGSRCDIR}
_CHECK_WRKREF_DIR.buildlink= ${BUILDLINK_DIR}
.if defined(USE_X11) && ${X11_TYPE} != "modular"
_CHECK_WRKREF_DIR.buildlink+= ${BUILDLINK_X11_DIR}
.endif
_CHECK_WRKREF_DIR.extra= ${CHECK_WRKREF_EXTRA_DIRS}
_CHECK_WRKREF_DIRS= # none
.for d in ${CHECK_WRKREF}
. if !defined(_CHECK_WRKREF_DIR.${d})
PKG_FAIL_REASON+= "[check-wrkref.mk] Invalid value "${d:Q}" for CHECK_WRKREF."
PKG_FAIL_REASON+= "[check-wrkref.mk] Try one of { tools home wrksrc work objwrkdir } instead."
. else
_CHECK_WRKREF_DIRS+= ${_CHECK_WRKREF_DIR.${d}}
. endif
.endfor
.if empty(CHECK_WRKREF:M[nN][oO]) && !empty(_CHECK_WRKREF_DIRS:M*)
privileged-install-hook: _check-wrkref
.endif
_check-wrkref: error-check .PHONY
@${STEP_MSG} "Checking for work-directory references in ${PKGNAME}"
${RUN} rm -f ${ERROR_DIR}/${.TARGET}
${RUN} \
exec 1>${ERROR_DIR}/${.TARGET}; \
${_CHECK_WRKREF_FILELIST_CMD} | ${SORT} | \
while read file; do \
case "$$file" in \
${CHECK_WRKREF_SKIP:@p@${p} | ${PREFIX}/${p}) continue;; @} \
*) ;; \
esac; \
${SHCOMMENT} "[$$file]"; \
for d in ${_CHECK_WRKREF_DIRS}; do \
grep "$$d" "${DESTDIR}$$file" 2>/dev/null | \
sed -e "s|^|$$file: |"; \
done; \
done
${RUN} \
exec 1>>${ERROR_DIR}/${.TARGET}; \
if ${_NONZERO_FILESIZE_P} ${ERROR_DIR}/${.TARGET}; then \
${ECHO} "*** The above files still have references to the build directory."; \
${ECHO} " This is possibly an error that should be fixed by unwrapping"; \
${ECHO} " the files or adding missing tools to the package makefile!"; \
fi

View File

@@ -0,0 +1,16 @@
# $NetBSD: bsd.checksum-vars.mk,v 1.2 2008/05/22 16:27:22 joerg Exp $
#
# This Makefile fragment is included separately by bsd.pkg.mk and
# defines some variables which must be defined earlier than where
# bsd.checksum.mk is included.
#
# The following variables may be set in a package Makefile:
#
# DISTINFO_FILE is the path to file containing the checksums.
#
DISTINFO_FILE?= ${PKGDIR}/distinfo
.if !empty(_CKSUMFILES)
USE_TOOLS+= digest:bootstrap
.endif

View File

@@ -0,0 +1,51 @@
# $NetBSD: bsd.checksum.mk,v 1.10 2009/07/15 09:40:30 joerg Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and defines the
# relevant variables and targets for the "checksum" phase.
#
# Public targets for pkgsrc users:
#
# checksum:
# Check that the distfiles have the correct checksums. If they
# aren't yet fetched, fetch them. This target can be run at
# any time and is meant to be run by the user.
#
# checksum-phase:
# Same as "checksum" but is meant to run automatically by pkgsrc.
# This target does not run after the "extract" phase is complete.
#
# depends-checksum:
# Run checksum for the current package and all dependencies.
#
# Public targets for pkgsrc developers:
#
# makesum:
# Add or update the checksums of the distfiles to ${DISTINFO_FILE}.
#
# See also: patchsum
#
# makepatchsum, mps:
# Add or update the checksums of the patches to ${DISTINFO_FILE}.
#
# makedistinfo, distinfo, mdi:
# Create or update the checksums in ${DISTINFO_FILE}.
#
# Package-settable variables:
#
# NO_CHECKSUM
# When defined, no checksums are validated for patches or
# distfiles.
#
# Note: This does not alter the behaviour of FAILOVER_FETCH.
#
# Default value: undefined
#
.PHONY: checksum checksum-phase
.PHONY: makesum makepatchsum mps mdi makedistinfo distinfo
checksum checksum-phase distinfo makesum: fetch
makedistinfo mdi: distinfo
mps: makepatchsum
.include "checksum.mk"

198
mk/checksum/checksum Executable file
View File

@@ -0,0 +1,198 @@
#!/bin/sh
#
# $NetBSD: checksum,v 1.15 2013/06/14 15:09:47 tron Exp $
#
# Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
######################################################################
#
# NAME
# checksum -- checksum files
#
# SYNOPSIS
# checksum [options] distinfo [file ...]
#
# DESCRIPTION
# checksum will verify the checksums in the distinfo file for each
# of the files specified.
#
# The checksum utility exits with one of the following values:
#
# 0 All of the file checksums verify.
#
# 1 At least one of the file checksums did not match.
#
# 2 At least one of the files is missing any checksum.
#
# >2 An error occurred.
#
# OPTIONS
# -a algorithm Only verify checksums for the specified algorithm.
#
# -p The specified files are patches, so strip out any
# lines containing NetBSD RCS ID tags before
# computing the checksums for verification.
#
# -s suffix Strip the specified suffix from the file names
# when searching for the checksum.
#
######################################################################
set -e # exit on errors
: ${DIGEST:=digest}
: ${CAT:=cat}
: ${ECHO:=echo}
: ${SED:=sed}
: ${TEST:=test}
self="${0##*/}"
usage() {
${ECHO} 1>&2 "usage: $self [-a algorithm] [-p] [-s suffix] distinfo [file ...]"
}
# Process optional arguments
algorithm=
patch=
suffix=
while ${TEST} $# -gt 0; do
case "$1" in
-a) algorithm="$2"; shift 2 ;;
-p) patch=yes; shift ;;
-s) suffix="$2"; shift 2 ;;
--) shift; break ;;
-*) ${ECHO} 1>&2 "$self: unknown option -- ${1#-}"
usage
exit 128
;;
*) break ;;
esac
done
# Process required arguments
${TEST} $# -gt 0 || { usage; exit 128; }
distinfo="$1"; shift
files="$@"
files_left="$@"
if ${TEST} ! -f "$distinfo"; then
${ECHO} 1>&2 "$self: distinfo file missing: $distinfo"
exit 128
fi
digestcmd=
case "${DIGEST}" in
/*)
if ${TEST} -x "${DIGEST}"; then
digestcmd="${DIGEST}"
fi
;;
*)
SAVEIFS="$IFS"; IFS=:
for i in $PATH; do
if ${TEST} -x "$i/${DIGEST}"; then
digestcmd="$i/${DIGEST}"
break
fi
done
IFS="$SAVEIFS"
;;
esac
if ${TEST} -z "$digestcmd"; then
${ECHO} 1>&2 "$self: \`\`${DIGEST}'' is missing"
exit 128
fi
{ exitcode=0
while read d_alg d_file d_equals d_checksum; do
case "$d_alg" in
"#"*) continue ;; # skip comments
"\$"*) continue ;; # skip RCS ID
"") continue ;; # skip empty lines
Size) continue ;; # skip lines holding filesizes, not checksums
esac
if ${TEST} -n "$algorithm"; then
${TEST} "$d_alg" = "$algorithm" || continue
fi
for file in $files; do
sfile="${file%$suffix}"
${TEST} -z "$patch" || sfile="${sfile##*/}"
${TEST} "$d_file" = "($sfile)" || continue
new_files_left=
for file_left in $files_left; do
${TEST} "${file_left}" = "${file}" || \
new_files_left="${new_files_left} ${file_left}"
done
files_left="${new_files_left}"
if ${TEST} "$d_checksum" = "IGNORE"; then
${ECHO} 1>&2 "$self: Ignoring checksum for $sfile"
continue
fi
if ${TEST} ! -f $file; then
${ECHO} 1>&2 "$self: $file does not exist"
exit 128
fi
if ${TEST} -z "$patch"; then
checksum=`${DIGEST} $d_alg < $file`
else
checksum=`${SED} -e '/[$]NetBSD.*/d' $file | ${DIGEST} $d_alg`
fi
if ${TEST} "$d_checksum" = "$checksum"; then
${ECHO} "=> Checksum $d_alg OK for $sfile"
else
${ECHO} 1>&2 "$self: Checksum $d_alg mismatch for $sfile"
exit 1
fi
break
done
done
if ${TEST} -n "$files_left"; then
for file in $files_left; do
if ${TEST} -n "$algorithm"; then
${ECHO} 1>&2 "$self: No $algorithm checksum recorded for $file"
else
${ECHO} 1>&2 "$self: No checksum recorded for $file"
fi
exitcode=2
done
fi
exit $exitcode; } < $distinfo

126
mk/checksum/checksum.mk Normal file
View File

@@ -0,0 +1,126 @@
# $NetBSD: checksum.mk,v 1.19 2013/06/14 15:09:47 tron Exp $
#
# See bsd.checksum.mk for helpful comments.
#
_DIGEST_ALGORITHMS?= SHA1 RMD160
_PATCH_DIGEST_ALGORITHMS?= SHA1
# These variables are set by pkgsrc/mk/fetch/bsd.fetch-vars.mk.
#_CKSUMFILES?= # empty
#_IGNOREFILES?= # empty
# _COOKIE.checksum
# The file whose presence determines whether or not the checksum
# process is run.
#
# This is not a traditional cookie file. We do not actually
# wish to create a cookie file for the completion of the checksum
# phase because we want to be able to detect if any of the files
# have changed right up until the distfiles are extracted.
# Therefore, we use the presence of the cookie file from the
# "extract" phase to determine whether we need to continue to
# verify checksums.
#
# _COOKIE.extract is defined in pkgsrc/mk/extract/extract.mk.
#
_COOKIE.checksum= ${_COOKIE.extract}
_CHECKSUM_CMD= \
${PKGSRC_SETENV} DIGEST=${TOOLS_DIGEST:Q} CAT=${TOOLS_CAT:Q} \
ECHO=${TOOLS_ECHO:Q} SED=${TOOLS_CMDLINE_SED:Q} \
TEST=${TOOLS_TEST:Q} \
${SH} ${PKGSRCDIR}/mk/checksum/checksum \
.if defined(NO_CHECKSUM) || empty(_CKSUMFILES)
checksum checksum-phase:
@${DO_NADA}
.else
checksum checksum-phase:
${RUN} set -e; \
case ${.TARGET:Q} in \
*-phase) ${TEST} ! -f ${_COOKIE.checksum} || exit 0 ;; \
esac; \
if cd ${DISTDIR} && ${_CHECKSUM_CMD} ${DISTINFO_FILE} ${_CKSUMFILES}; then \
${TRUE}; \
else \
${ERROR_MSG} "Make sure the Makefile and checksum file (${DISTINFO_FILE})"; \
${ERROR_MSG} "are up to date. If you want to override this check, type"; \
${ERROR_MSG} "\"${MAKE} NO_CHECKSUM=yes [other args]\"."; \
exit 1; \
fi
.endif
_DISTINFO_CMD= ${PKGSRC_SETENV} DIGEST=${TOOLS_DIGEST:Q} SED=${TOOLS_SED:Q} \
TEST=${TOOLS_TEST:Q} WC=${TOOLS_WC:Q} \
${AWK} -f ${PKGSRCDIR}/mk/checksum/distinfo.awk --
.if exists(${DISTDIR})
_DISTINFO_ARGS_COMMON+= -d ${DISTDIR}
.endif
.if exists(${DISTINFO_FILE})
_DISTINFO_ARGS_COMMON+= -f ${DISTINFO_FILE}
.endif
.if defined(_DIGEST_ALGORITHMS) && !empty(_DIGEST_ALGORITHMS)
_DISTINFO_ARGS_COMMON+= ${_DIGEST_ALGORITHMS:S/^/-a /}
.endif
.if defined(_PATCH_DIGEST_ALGORITHMS) && !empty(_PATCH_DIGEST_ALGORITHMS)
_DISTINFO_ARGS_COMMON+= ${_PATCH_DIGEST_ALGORITHMS:S/^/-p /}
.endif
.if defined(_CKSUMFILES) && !empty(_CKSUMFILES)
_DISTINFO_ARGS_DISTSUM+= ${_CKSUMFILES:S/^/-c /}
.endif
.if defined(_IGNOREFILES) && !empty(_IGNOREFILES)
_DISTINFO_ARGS_DISTSUM+= ${_IGNOREFILES:S/^/-i /}
.endif
_DISTINFO_ARGS_PATCHSUM+= ${PATCHDIR}/patch-*
_DISTINFO_ARGS_PATCHSUM+= ${PATCHDIR}/emul-*-patch-*
distinfo:
${RUN}set -e; \
newfile=${DISTINFO_FILE}.$$$$; \
if ${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON} \
${_DISTINFO_ARGS_DISTSUM} \
${_DISTINFO_ARGS_PATCHSUM} > $$newfile; \
then \
${RM} -f $$newfile; \
${ECHO_MSG} "=> distinfo: unchanged."; \
else \
${MV} -f $$newfile ${DISTINFO_FILE}; \
fi
makesum:
${RUN}set -e; \
newfile=${DISTINFO_FILE}.$$$$; \
if ${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON} \
${_DISTINFO_ARGS_DISTSUM} > $$newfile; \
then \
${RM} -f $$newfile; \
${ECHO_MSG} "=> distinfo: distfiles part unchanged."; \
else \
${MV} -f $$newfile ${DISTINFO_FILE}; \
fi
makepatchsum:
${RUN}set -e; \
newfile=${DISTINFO_FILE}.$$$$; \
if ${_DISTINFO_CMD} ${_DISTINFO_ARGS_COMMON} \
${_DISTINFO_ARGS_PATCHSUM} > $$newfile; \
then \
${RM} -f $$newfile; \
${ECHO_MSG} "=> distinfo: patches part unchanged."; \
else \
${MV} -f $$newfile ${DISTINFO_FILE}; \
fi
.PHONY: depends-checksum
depends-checksum:
${RUN} \
${_DEPENDS_WALK_CMD} ${PKGPATH} | \
while read dir; do \
${ECHO} "===> Checksumming for $${dir}" && \
cd ${.CURDIR}/../../$$dir && \
${RECURSIVE_MAKE} ${MAKEFLAGS} checksum; \
done

351
mk/checksum/distinfo.awk Normal file
View File

@@ -0,0 +1,351 @@
#!/usr/bin/awk -f
#
# $NetBSD: distinfo.awk,v 1.4 2007/08/16 16:29:27 jlam Exp $
#
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###########################################################################
#
# NAME
# distinfo.awk -- print distinfo information to standard output
#
# SYNOPSIS
# distinfo.awk -- [options] [patch ...]
#
# DESCRIPTION
# distinfo.awk generates distinfo information for the named
# cksumfiles, ignorefiles and patches. The format of a distinfo
# file is:
#
# 1. NetBSD RCS ID header
# 2. a blank line
# 3. digests and size information for each cksumfile and ignorefile
# 4. digests for patches
#
# For example:
#
# $NetBSD: distinfo.awk,v 1.4 2007/08/16 16:29:27 jlam Exp $
#
# SHA1 (make-3.81.tar.gz) = cd4fa5a3184176492bf0799593a8f250a728210c
# RMD160 (make-3.81.tar.gz) = a713a72875cb9a29568677c98022465c6f55cbbf
# Size (make-3.81.tar.gz) = 1564560 bytes
# SHA1 (patch-aa) = ba88ee2175c7c2258fc647b3654b2f725cf75a50
# SHA1 (patch-ac) = de18956fde66fa3fc61a991bb3e6724d9c5b1eac
# SHA1 (patch-af) = 067cac366694ce33e5bc52ef937603ae17d3bc2e
#
# OPTIONS
# The following command line arguments are supported.
#
# -- This is a mandatory option and must always be the
# first option specified.
#
# -a algorithm Generate a digest for the specified distfiles
# using the named digest algorithm. If this option
# is given more than once, then digests are
# generated using each algorithm in the order
# given.
#
# -c cksumfile Generate distinfo information for the named
# cksumfile. If this option is given more than
# once, then generate information for each
# cksumfile in alphabetical order.
#
# -d distdir Directory under which cksumfiles and ignorefiles
# are found.
#
# -f distinfo Path to an existing distinfo file. If this
# option is given, then it is used to provide the
# distinfo information for either cksumfiles and
# ignorefiles or patches, depending on which
# are not given on the command line. Also, using
# this option causes the return code to be 0 if
# the generated distinfo information matches the
# contents of the existing distinfo file, or
# non-zero otherwise.
#
# -i ignorefile Generate distinfo information to ignore checksum
# verification for ignorefile. If this option is
# given more than once, then generate information
# for each ignore file in alphabetical order.
#
# -p algorithm Generate a digest for the patches using the named
# digest algorithm. If this option is given more
# than once, then digests are generated using each
# algorithm in the order given.
#
# patch ... Generate distinfo information for the named
# patches in alphabetical order.
#
###########################################################################
BEGIN {
DIGEST = ENVIRON["DIGEST"] ? ENVIRON["DIGEST"] : "digest"
SED = ENVIRON["SED"] ? ENVIRON["SED"] : "sed"
TEST = ENVIRON["TEST"] ? ENVIRON["TEST"] : "test"
WC = ENVIRON["WC"] ? ENVIRON["WC"] : "wc"
self = "distinfo.awk"
ARGSTART = 1
A = 0 # size of algorithms array
D = 0 # size of distfiles array
L = 0 # size of lines array
P = 0 # size of patch_algorithms array
N = 0 # size of patchfiles array
F = 0 # size of distinfo_lines array
distdir = "."
distinfo = ""
exitcode = 0
parse_options()
if (length(distdir) > 0) {
cmd = TEST " -d " distdir
if (system(cmd) != 0) {
print self ": " distdir " not found"
exitcode = 128
}
}
if (length(distinfo) > 0) {
cmd = TEST " -f " distinfo
if (system(cmd) != 0) {
print self ": " distinfo " not found"
exitcode = 128
}
while(getline < distinfo) { distinfo_lines[F++] = $0 }
close(distinfo)
}
if (exitcode > 0) exit(exitcode)
if (length(distinfo) == 0) { # no distinfo file
header()
distsum()
patchsum()
exitcode = 1
} else {
if (D > 0 && N > 0) { # distfiles & patches
header()
distsum()
patchsum()
} else if (D > 0 && N == 0) { # distfiles only
header()
distsum()
#
# Grab the patch distinfo lines from the existing
# distinfo file.
#
for (l = 0; l < F; l++) {
file = distinfo_lines[l]
sub("^[^(]*[(]", "", file)
sub("[)][^)]*$", "", file)
if (is_patch(file))
lines[L++] = distinfo_lines[l]
}
} else if (D == 0 && N > 0) { # patches only
#
# Grab the non-patch distinfo lines from the
# existing distinfo file.
#
for (l = 0; l < F; l++) {
file = distinfo_lines[l]
sub("^[^(]*[(]", "", file)
sub("[)][^)]*$", "", file)
if (!is_patch(file))
lines[L++] = distinfo_lines[l]
}
patchsum()
}
exitcode = is_same_distinfo() ? 0 : 1
}
# Print the new distinfo content to standard output.
for (l = 0; l < L; l++) { print lines[l] }
exit(exitcode)
}
function insertion_sort(a, nelem, temp, i, j) {
for (i = 1; i < nelem; ++i) {
for (j = i; a[j-1] > a[j]; --j) {
temp = a[j]
a[j] = a[j-1]
a[j-1] = temp
}
}
return
}
function parse_options( option) {
while (ARGSTART < ARGC) {
option = ARGV[ARGSTART]
if (option == "-a") {
algorithms[A++] = ARGV[ARGSTART + 1]
ARGSTART += 2
} else if (option == "-c") {
distfiles[D++] = ARGV[ARGSTART + 1]
cksumfiles[ARGV[ARGSTART + 1]] = 1
ARGSTART += 2
} else if (option == "-d") {
distdir = ARGV[ARGSTART + 1]
ARGSTART += 2
} else if (option == "-f") {
distinfo = ARGV[ARGSTART + 1]
ARGSTART += 2
} else if (option == "-i") {
distfiles[D++] = ARGV[ARGSTART + 1]
ignorefiles[ARGV[ARGSTART + 1]] = 1
ARGSTART += 2
} else if (option == "-p") {
patch_algorithms[P++] = ARGV[ARGSTART + 1]
ARGSTART += 2
} else if (option == "--") {
ARGSTART++
break
} else if (match(option, /^-.*/) != 0) {
option = substr(option, RSTART + 1, RLENGTH)
print self ": unknown option -- " option > "/dev/stderr"
print "usage: " self " -- [-a alg] [-c file] [-d distdir] [-f distinfo] [-i ignore] [-p alg] [patch ...]" > "/dev/stderr"
exit 1
} else {
break
}
}
while (ARGSTART < ARGC) {
patchfiles[N++] = ARGV[ARGSTART++]
}
# Sort each of the resulting arrays.
#insertion_sort(algorithms, A)
#insertion_sort(patch_algorithms, P)
insertion_sort(distfiles, D)
insertion_sort(patchfiles, N)
}
###
### header()
### Pull the NetBSD RCS ID file from the existing distinfo file
### if it's available, otherwise generate a new one.
###
function header() {
if (length(distinfo) > 0) {
cmd = SED " 1q " distinfo
cmd | getline; close(cmd)
if ($0 ~ /^[$]NetBSD/) {
lines[L++] = $0
lines[L++] = ""
return
}
}
lines[L++] = "$" "NetBSD" "$"
lines[L++] = ""
}
###
### is_patch(file)
### Return 1 if the file is a valid patch name, or 0 otherwise.
###
function is_patch(file) {
if (file ~ /^patch-local-|[.]orig$|[.]rej$|~$/) return 0
if (file ~ /^patch-|^emul-.*-patch-/) return 1
return 0
}
###
### distsum()
### Generate digests using the ones named in the algorithms
### array, and size information for each cksumfile. Generate
### an IGNORE line for each ignorefile.
###
function distsum( alg, file, cmd, a, i) {
for (i = 0; i < D; i++) {
file = distfiles[i]
cmd = "cd " distdir " && " TEST " -f " file
if (system(cmd) != 0) continue
for (a = 0; a < A; a++) {
alg = algorithms[a]
if (cksumfiles[file] == 1) {
cmd = "cd " distdir " && " DIGEST " " alg " " file
cmd | getline lines[L++]; close(cmd)
} else if (ignorefiles[file] == 1) {
lines[L++] = alg " (" file ") = IGNORE"
}
}
if (cksumfiles[file] == 1) {
cmd = "cd " distdir " && " WC " -c " file
cmd | getline; close(cmd)
sub("^[ ]+", ""); sub("[ ].*", "")
lines[L++] = "Size (" file ") = " $0 " bytes"
}
}
}
###
### patchsum()
### Generate digests using the ones named in patch_algorithms
### for each patch.
###
function patchsum( alg, dir, file, patch, cmd, a, i) {
for (i = 0; i < N; i++) {
patch = patchfiles[i]
dir = patch; sub("/[^/]*$", "", dir)
file = patch; sub("^.*/", "", file)
cmd = TEST " -f " patch
if ((system(cmd) != 0) || !is_patch(file)) continue
for (a = 0; a < P; a++) {
alg = patch_algorithms[a]
cmd = SED " -e '/[$]NetBSD.*/d' " patch " | " DIGEST " " alg
cmd | getline; close(cmd)
sub("^", alg " (" file ") = ")
lines[L++] = $0
}
}
}
###
### is_same_distinfo()
### Return 1 if the distinfo_lines and lines array match
### (so the new distinfo content and the old distinfo
### content match), and zero otherwise.
###
function is_same_distinfo( l) {
if (L != F) { return 0 }
for (l = 0; l < L; l++) {
if (distinfo_lines[l] != lines[l])
return 0
}
return 1
}

View File

@@ -0,0 +1,31 @@
SET(UNIX 1)
GET_FILENAME_COMPONENT(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
GET_FILENAME_COMPONENT(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH
# Standard
$ENV{BUILDLINK_DIR} $ENV{PREFIX} / /usr
)
SET(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH}
# Standard
$ENV{BUILDLINK_DIR}/include /include /usr/include
)
SET(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH}
# Standard
$ENV{BUILDLINK_DIR}/lib /lib /usr/lib
)
SET(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH}
$ENV{BUILDLINK_DIR}/bin /bin /usr/bin /sbin
)
LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
/lib /usr/lib /usr/lib32 /usr/lib64
)
# Enable use of lib64 search path variants by default.
SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)

212
mk/compiler.mk Normal file
View File

@@ -0,0 +1,212 @@
# $NetBSD: compiler.mk,v 1.80 2012/12/12 20:49:01 marino Exp $
#
# This Makefile fragment implements handling for supported C/C++/Fortran
# compilers.
#
# The following variables may be set by the pkgsrc user in mk.conf:
#
# PKGSRC_COMPILER
# A list of values specifying the chain of compilers to be used by
# pkgsrc to build packages.
#
# Valid values are:
# ccc Compaq C Compilers (Tru64)
# ccache compiler cache (chainable)
# clang Clang C and Objective-C compiler
# distcc distributed C/C++ (chainable)
# f2c Fortran 77 to C compiler (chainable)
# icc Intel C++ Compiler (Linux)
# ido SGI IRIS Development Option cc (IRIX 5)
# gcc GNU
# hp HP-UX C/aC++ compilers
# mipspro Silicon Graphics, Inc. MIPSpro (n32/n64)
# mipspro-ucode Silicon Graphics, Inc. MIPSpro (o32)
# pcc Portable C Compiler
# sunpro Sun Microsystems, Inc. WorkShip/Forte/Sun
# ONE Studio
# xlc IBM's XL C/C++ compiler suite (Darwin/MacOSX)
#
# The default is "gcc". You can use ccache and/or distcc with
# an appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc
# gcc". You can also use "f2c" to overlay the lang/f2c package
# over the C compiler instead of using the system Fortran
# compiler. The chain should always end in a real compiler.
# This should only be set in /etc/mk.conf.
#
# COMPILER_USE_SYMLINKS
# If set to yes, use symlinks for the compiler drivers, otherwise
# shell scripts are created. The default is yes.
#
# The following variables may be set by a package:
#
# USE_LANGUAGES
# Lists the languages used in the source code of the package,
# and is used to determine the correct compilers to install.
# Valid values are: c, c99, c++, fortran, fortran77, java, objc,
# obj-c++, and ada. The default is "c".
#
# The following variables are defined, and available for testing in
# package Makefiles:
#
# CC_VERSION
# The compiler and version being used, e.g.,
#
# .include "../../mk/compiler.mk"
#
# .if !empty(CC_VERSION:Mgcc-3*)
# ...
# .endif
#
# Keywords: compiler
.if !defined(BSD_COMPILER_MK)
BSD_COMPILER_MK= defined
_VARGROUPS+= compiler
_USER_VARS.compiler= PKGSRC_COMPILER USE_PKGSRC_GCC ABI COMPILER_USE_SYMLINKS
_PKG_VARS.compiler= USE_LANGUAGES GCC_REQD NOT_FOR_COMPILER ONLY_FOR_COMPILER
_SYS_VARS.compiler= CC_VERSION
.include "bsd.fast.prefs.mk"
# Since most packages need a C compiler, this is the default value.
USE_LANGUAGES?= c
# Add c support if c99 is set
.if !empty(USE_LANGUAGES:Mc99)
USE_LANGUAGES+= c
.endif
COMPILER_USE_SYMLINKS?= yes
_COMPILERS= ccc gcc icc ido mipspro mipspro-ucode \
sunpro xlc hp pcc clang
_PSEUDO_COMPILERS= ccache distcc f2c g95
.if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER)
. for _compiler_ in ${_COMPILERS}
. if ${NOT_FOR_COMPILER:M${_compiler_}} == ""
_ACCEPTABLE_COMPILERS+= ${_compiler_}
. endif
. endfor
.elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER)
. for _compiler_ in ${_COMPILERS}
. if ${ONLY_FOR_COMPILER:M${_compiler_}} != ""
_ACCEPTABLE_COMPILERS+= ${_compiler_}
. endif
. endfor
.else
_ACCEPTABLE_COMPILERS+= ${_COMPILERS}
.endif
.if defined(_ACCEPTABLE_COMPILERS)
. for _acceptable_ in ${_ACCEPTABLE_COMPILERS}
. for _compiler_ in ${PKGSRC_COMPILER}
. if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER)
_COMPILER= ${_compiler_}
. endif
. endfor
. endfor
.endif
.if !defined(_COMPILER)
PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}."
.endif
.for _compiler_ in ${PKGSRC_COMPILER}
. if !empty(_PSEUDO_COMPILERS:M${_compiler_})
_PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER}
. endif
.endfor
_PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER}
_COMPILER_STRIP_VARS= # empty
.for _compiler_ in ${_PKGSRC_COMPILER}
. include "compiler/${_compiler_}.mk"
.endfor
.undef _compiler_
.if !defined(PKG_CPP)
PKG_CPP:=${CPP}
.endif
# Ensure the Solaris linker is used by default.
.if ${OPSYS} == "SunOS"
. if exists(/usr/ccs/bin/ld)
PKG_LD?= /usr/ccs/bin/ld
. elif exists(/usr/bin/ld)
PKG_LD?= /usr/bin/ld
. endif
.endif
# Strip the leading paths from the toolchain variables since we manipulate
# the PATH to use the correct executable.
#
.for _var_ in ${_COMPILER_STRIP_VARS}
. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*)
${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T}
. else
${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*}
. endif
.endfor
.if defined(ABI) && !empty(ABI)
_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}}
_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}}
_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}}
.endif
# If the languages are not requested, force them not to be available
# in the generated wrappers.
#
_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper
_FAIL_WRAPPER.CXX= ${WRKDIR}/.compiler/bin/c++-fail-wrapper
_FAIL_WRAPPER.FC= ${WRKDIR}/.compiler/bin/fortran-fail-wrapper
_FAIL_WRAPPER.ADA= ${WRKDIR}/.compiler/bin/ada-fail-wrapper
${_FAIL_WRAPPER.CC}: fail-wrapper
${_FAIL_WRAPPER.CXX}: fail-wrapper
${_FAIL_WRAPPER.FC}: fail-wrapper
${_FAIL_WRAPPER.ADA}: fail-wrapper
.PHONY: fail-wrapper
fail-wrapper: .USE
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
exec 1>${.TARGET}; \
${ECHO} '#!'${TOOLS_SHELL:Q}; \
${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \
${ECHO} 'lang="${.TARGET:T:S/-fail-wrapper//}"'; \
${ECHO} 'msg="*** Please consider adding $$lang to USE_LANGUAGES in the package Makefile."'; \
${ECHO} '${ECHO} "$$msg" >> $$wrapperlog'; \
${ECHO} '${ECHO} "$$msg" > ${WARNING_DIR}/${.TARGET:T}'; \
${ECHO} '${ECHO} "PKGSRC-WARNING: Something is trying to run the $$lang compiler," 1>&2'; \
${ECHO} '${ECHO} "PKGSRC-WARNING: but it is not added to USE_LANGUAGES in the package Makefile." 1>&2'; \
${ECHO} 'exit 1'
${RUN}${CHMOD} +x ${.TARGET}
.if empty(USE_LANGUAGES:Mc) && empty(USE_LANGUAGES:Mobjc) && empty(USE_LANGUAGES:Mobjc-c++)
PKG_CC:= ${_FAIL_WRAPPER.CC}
ALL_ENV+= CPP=${CPP:Q}
override-tools: ${_FAIL_WRAPPER.CC}
.endif
.if empty(USE_LANGUAGES:Mc++)
PKG_CXX:= ${_FAIL_WRAPPER.CXX}
ALL_ENV+= CXXCPP=${CPP:Q} # to make some Autoconf scripts happy
override-tools: ${_FAIL_WRAPPER.CXX}
.endif
.if empty(USE_LANGUAGES:Mfortran) && empty(USE_LANGUAGES:Mfortran77)
PKG_FC:= ${_FAIL_WRAPPER.FC}
override-tools: ${_FAIL_WRAPPER.FC}
.endif
.if empty(USE_LANGUAGES:Mada)
PKG_ADA:= ${_FAIL_WRAPPER.ADA}
override-tools: ${_FAIL_WRAPPER.ADA}
.endif
.if !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly"
ALL_ENV+= CCVER=${DRAGONFLY_CCVER}
.endif
.endif # BSD_COMPILER_MK

145
mk/compiler/ccache.mk Normal file
View File

@@ -0,0 +1,145 @@
# $NetBSD: ccache.mk,v 1.34 2013/05/09 23:37:25 riastradh Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# === User-settable variables ===
#
# CCACHE_BASE
# The directory where ccache is installed. The build dependency on
# devel/ccache is only added when this is ${LOCALBASE}.
#
# Default: ${LOCALBASE}
#
# CCACHE_DIR
# The directory where the cached compiler results are stored. By
# default, they are stored inside WRKDIR, so they are lost after
# a "make clean".
#
# === Package-settable variables ===
#
# IGNORE_CCACHE
# Can be set to "yes" for packages that have problems with ccache.
#
# Keywords: ccache
#
.if !defined(COMPILER_CCACHE_MK)
COMPILER_CCACHE_MK= defined
_VARGROUPS+= ccache
_USER_VARS.ccache= CCACHE_BASE CCACHE_DIR
_PKG_VARS.ccache= IGNORE_CCACHE
.include "../bsd.fast.prefs.mk"
CCACHE_BASE?= ${LOCALBASE}
CCACHE_DIR?= ${WRKDIR}/.ccache-cache
_USE_CCACHE= yes
.if ${CCACHE_BASE} == ${LOCALBASE} && (${PKGPATH} == "devel/ccache" || ${PKGPATH} == "devel/patch" || ${PKGPATH} == "pkgtools/digest")
_USE_CCACHE= no
MAKEFLAGS+= _USE_CCACHE=${_USE_CCACHE}
.endif
.if defined(IGNORE_CCACHE)
_USE_CCACHE= no
.endif
# LANGUAGES.<compiler> is the list of supported languages by the compiler.
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones
# requested by the package in USE_LANGUAGES.
#
LANGUAGES.ccache= c c++
_LANGUAGES.ccache= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.ccache+= ${LANGUAGES.ccache:M${_lang_}}
.endfor
.if empty(_LANGUAGES.ccache)
_USE_CCACHE= no
.endif
.if ${_USE_CCACHE} == "yes"
_CCACHE_DIR= ${WRKDIR}/.ccache
_CCACHE_VARS= # empty
. if !empty(_LANGUAGES.ccache:Mc)
PKG_CC?= ${CC}
_CCACHE_VARS+= CC
_CCACHE_CC:= ${_CCACHE_DIR}/bin/${PKG_CC:T}
_ALIASES.CC+= cc
PKG_CC:= ${_CCACHE_CC}
. endif
. if !empty(_LANGUAGES.ccache:Mc++)
PKG_CXX?= ${CXX}
_CCACHE_VARS+= CXX
_CCACHE_CXX:= ${_CCACHE_DIR}/bin/${PKG_CXX:T}
_ALIASES.CXX+= c++
PKG_CXX:= ${_CCACHE_CXX}
. endif
PREPEND_PATH+= ${_CCACHE_DIR}/bin
# Add the dependency on ccache.
. if ${CCACHE_BASE} == ${LOCALBASE}
TOOL_DEPENDS+= ccache-[0-9]*:../../devel/ccache
. endif
# Override the compiler-specific hash with the version string for the
# compiler.
#
PKGSRC_MAKE_ENV+= CCACHE_COMPILERCHECK=echo\ ${CC_VERSION_STRING:Q}
PKGSRC_MAKE_ENV+= CCACHE_DIR=${CCACHE_DIR:Q}
# Create symlinks for the compiler into ${WRKDIR}.
. for _var_ in ${_CCACHE_VARS}
. if !target(${_CCACHE_${_var_}})
override-tools: ${_CCACHE_${_var_}}
${_CCACHE_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
${LN} -fs ${CCACHE_BASE}/bin/ccache ${.TARGET}
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -fs ${CCACHE_BASE}/bin/ccache ${_alias_}; \
fi
. endfor
. endif
. endfor
.endif # _USE_CCACHE == "yes"
.endif # COMPILER_CCACHE_MK

102
mk/compiler/ccc.mk Normal file
View File

@@ -0,0 +1,102 @@
# $NetBSD: ccc.mk,v 1.19 2009/06/02 22:32:49 joerg Exp $
#
# This is the compiler definition for the Compaq C Compilers.
#
.if !defined(COMPILER_CCC_MK)
COMPILER_CCC_MK= defined
.include "../../mk/bsd.prefs.mk"
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.ccc= # empty
_CCC_DIR= ${WRKDIR}/.ccc
_CCC_VARS= # empty
.if exists(/usr/bin/cc)
LANGUAGES.ccc+= c
_CCC_VARS+= CC
_CCC_CC= ${_CCC_DIR}/cc
_ALIASES.CC= cc
CCPATH= /usr/bin/cc
PKG_CC:= ${_CCC_CC}
.endif
.if exists(/usr/bin/cxx) && exists(/usr/lib/cmplrs/cxx)
LANGUAGES.ccc+= c++
_CCC_VARS+= CXX
_CCC_CXX= ${_CCC_DIR}/cxx
_ALIASES.CXX= c++ cxx
CXXPATH= /usr/bin/cxx
PKG_CXX:= ${_CCC_CXX}
.endif
_COMPILER_STRIP_VARS+= ${_CCC_VARS}
.if exists(${CCPATH}) && !defined(CC_VERSION_STRING)
CC_VERSION_STRING!= ${CCPATH} -V 2>&1 | ${AWK} '{print; exit(0);}'
CC_VERSION!= ${CCPATH} -V 2>&1 | ${AWK} '{print "CCC-"$3; exit(0);}'
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= CCC
.endif
# CCC passes rpath directives to the linker using "-rpath".
_LINKER_RPATH_FLAG= -rpath
# CCC passes rpath directives to the linker using "-rpath" tailing ",".
_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG},
# Most packages assume ieee floats, make that the default.
CFLAGS+= -ieee
CXXFLAGS+= -ieee
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.ccc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.ccc+= ${LANGUAGES.ccc:M${_lang_}}
.endfor
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.ccc)
PREPEND_PATH+= ${_CCC_DIR}/bin
.endif
# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_CCC_VARS}
. if !target(${_CCC_${_var_}})
override-tools: ${_CCC_${_var_}}
${_CCC_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s /usr/bin/${.TARGET:T} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec /usr/bin/${.TARGET:T} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET} ${_alias_}; \
fi
. endfor
. endif
.endfor
# Force the use of f2c-f77 for compiling Fortran.
_CCC_USE_F2C= no
FCPATH= /nonexistent
.if !exists(${FCPATH})
_CCC_USE_F2C= yes
.endif
.if !empty(_CCC_USE_F2C:M[yY][eE][sS])
. include "../../mk/compiler/f2c.mk"
.endif
.endif # COMPILER_CCC_MK

73
mk/compiler/clang.mk Normal file
View File

@@ -0,0 +1,73 @@
# $NetBSD: clang.mk,v 1.12 2013/05/29 13:19:02 joerg Exp $
#
# This is the compiler definition for the clang compiler.
#
# User-settable variables:
#
# CLANGBASE
# The base directory where the compiler is installed.
#
.if !defined(COMPILER_CLANG_MK)
COMPILER_CLANG_MK= defined
# Add the dependency on clang
# TODO: may be installed already, check for this
#TOOL_DEPENDS+= clang-[0-9]*:../../lang/clang
.include "../../mk/bsd.prefs.mk"
CLANGBASE?= ${LOCALBASE}
LANGUAGES.clang= # empty
.if exists(${CLANGBASE}/bin/clang)
LANGUAGES.clang+= c objc
_COMPILER_STRIP_VARS+= CC
CCPATH= ${CLANGBASE}/bin/clang
PKG_CC:= ${CCPATH}
.endif
.if exists(${CLANGBASE}/bin/clang++)
LANGUAGES.clang+= c++
_COMPILER_STRIP_VARS+= CXX
CXXPATH= ${CLANGBASE}/bin/clang++
PKG_CXX:= ${CXXPATH}
.endif
.if exists(${CLANGBASE}/bin/clang-cpp)
CPPPATH= ${CLANGBASE}/bin/clang-cpp
PKG_CPP:= ${CPPPATH}
.endif
.if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -v 2>&1
CC_VERSION!= ${CCPATH} --version 2>&1 | ${SED} -n "s/clang version /clang-/p"
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= clang
.endif
_COMPILER_ABI_FLAG.32= -m32
_COMPILER_ABI_FLAG.64= -m64
_COMPILER_LD_FLAG= -Wl,
_LINKER_RPATH_FLAG= -R
_COMPILER_RPATH_FLAG= ${_COMPILER_LD_FLAG}${_LINKER_RPATH_FLAG}
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.clang= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.clang+= ${LANGUAGES.clang:M${_lang_}}
.endfor
PKGSRC_FORTRAN?=g95
.if !empty(PKGSRC_FORTRAN) && (!empty(USE_LANGUAGES:Mfortran) || !empty(USE_LANGUAGES:Mfortran77))
. include "../../mk/compiler/${PKGSRC_FORTRAN}.mk"
.endif
_WRAP_EXTRA_ARGS.CC+= -Qunused-arguments
_WRAP_EXTRA_ARGS.CXX+= -Qunused-arguments
.endif # COMPILER_CLANG_MK

126
mk/compiler/distcc.mk Normal file
View File

@@ -0,0 +1,126 @@
# $NetBSD: distcc.mk,v 1.31 2013/05/09 23:37:26 riastradh Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
.if !defined(COMPILER_DISTCC_MK)
COMPILER_DISTCC_MK= defined
.include "../../mk/bsd.prefs.mk"
.if !empty(PKGPATH:Mdevel/distcc)
IGNORE_DISTCC= yes
MAKEFLAGS+= IGNORE_DISTCC=yes
.endif
.if defined(IGNORE_DISTCC)
_USE_DISTCC= NO
.endif
# LANGUAGES.<compiler> is the list of supported languages by the compiler.
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones
# requested by the package in USE_LANGUAGES.
#
LANGUAGES.distcc= c c++
_LANGUAGES.distcc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.distcc+= ${LANGUAGES.distcc:M${_lang_}}
.endfor
.if empty(_LANGUAGES.distcc)
_USE_DISTCC= NO
.endif
.if !defined(_USE_DISTCC)
_USE_DISTCC= YES
.endif
.if !empty(_USE_DISTCC:M[yY][eE][sS])
EVAL_PREFIX+= _DISTCCBASE=distcc
_DISTCCBASE_DEFAULT= ${LOCALBASE}
_DISTCC_DIR= ${WRKDIR}/.distcc
_DISTCC_VARS= # empty
. if !empty(_LANGUAGES.distcc:Mc)
PKG_CC?= ${CC}
_DISTCC_VARS+= CC
_DISTCC_CC:= ${_DISTCC_DIR}/bin/${PKG_CC:T}
_ALIASES.CC+= cc
PKG_CC:= ${_DISTCC_CC}
. endif
. if !empty(_LANGUAGES.distcc:Mc++)
PKG_CXX?= ${CXX}
_DISTCC_VARS+= CXX
_DISTCC_CXX:= ${_DISTCC_DIR}/bin/${PKG_CXX:T}
_ALIASES.CXX+= c++
PKG_CXX:= ${_DISTCC_CXX}
. endif
# Prepend the path to the compiler to the PATH.
. if !empty(_LANGUAGES.distcc)
PREPEND_PATH+= ${_DISTCC_DIR}/bin
. endif
# Add the dependency on distcc.
TOOL_DEPENDS+= distcc-[0-9]*:../../devel/distcc
. if defined(DISTCC_HOSTS) && !empty(DISTCC_HOSTS)
PKGSRC_MAKE_ENV+= DISTCC_HOSTS=${DISTCC_HOSTS:Q}
. endif
. if defined(DISTCC_SSH) && !empty(DISTCC_SSH)
PKGSRC_MAKE_ENV+= DISTCC_SSH=${DISTCC_SSH:Q}
. endif
. if defined(DISTCC_VERBOSE) && !empty(DISTCC_VERBOSE)
PKGSRC_MAKE_ENV+= DISTCC_VERBOSE=${DISTCC_VERBOSE:Q}
. endif
# Create symlinks for the compiler into ${WRKDIR}.
. for _var_ in ${_DISTCC_VARS}
. if !target(${_DISTCC_${_var_}})
override-tools: ${_DISTCC_${_var_}}
${_DISTCC_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
${LN} -fs ${_DISTCCBASE}/bin/distcc ${.TARGET}
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -fs ${_DISTCCBASE}/bin/distcc ${_alias_}; \
fi
. endfor
. endif
. endfor
.endif # _USE_DISTCC == "yes"
.endif # COMPILER_DISTCC_MK

135
mk/compiler/f2c.mk Normal file
View File

@@ -0,0 +1,135 @@
# $NetBSD: f2c.mk,v 1.16 2013/05/09 23:37:26 riastradh Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
.if !defined(COMPILER_F2C_MK)
COMPILER_F2C_MK= defined
.include "../../mk/bsd.prefs.mk"
# LANGUAGES.<compiler> is the list of supported languages by the compiler.
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones
# requested by the package in USE_LANGUAGES.
#
LANGUAGES.f2c= fortran fortran77
_LANGUAGES.f2c= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.f2c+= ${LANGUAGES.f2c:M${_lang_}}
.endfor
.if empty(_LANGUAGES.f2c)
_USE_F2C= NO
.endif
.if !defined(_USE_F2C)
_USE_F2C= YES
.endif
.if !empty(_USE_F2C:M[yY][eE][sS])
USE_LANGUAGES+= c
EVAL_PREFIX+= _F2CBASE=f2c
_F2CBASE_DEFAULT= ${LOCALBASE}
_F2C_DIR= ${WRKDIR}/.f2c
_F2C_VARS= # empty
. if !empty(_LANGUAGES.f2c:Mfortran) || !empty(_LANGUAGES.f2c:Mfortran77)
PKG_FC?= ${FC}
_F2C_VARS+= FC
_F2C_FC:= ${_F2C_DIR}/bin/${PKG_FC:T}
_ALIASES.FC+= f77 g77 f2c-f77
FCPATH= ${_F2CBASE}/bin/f2c-f77
PKG_FC:= ${_F2C_FC}
#
# The f2c-f77 shell script invokes the C compiler, so ensure that it finds
# the cc wrapper for proper transformations.
#
# XXX This shouldn't really be leaking into here, as it breaks encapsulation.
# XXX It should really be handled within the wrapper framework.
#
_WRAP_ENV.FC= PATH="${WRAPPER_BINDIR}:${_WRAP_PATH}"; export PATH
. endif
# Prepend the path the to the compiler to the PATH
. if !empty(_LANGUAGES.f2c)
PREPEND_PATH+= ${_F2C_DIR}/bin
. endif
# Dependencies:
TOOL_DEPENDS+= f2c>=20090411nb2:../../lang/f2c # translator
.if empty(PKGPATH:Mdevel/libtool-base) && empty(PKGPATH:Mcross/libtool-base) # See below
. include "../../devel/libf2c/buildlink3.mk" # library
.endif
. if defined(F2C_DIR) && !empty(F2C_DIR)
PKGSRC_MAKE_ENV+= F2C_DIR=${F2C_DIR:Q}
. endif
# libtool-base is special as it only needs f77 to extract linker flags etc.
.if !empty(PKGPATH:Mdevel/libtool-base) || !empty(PKGPATH:Mcross/libtool-base)
pre-configure: fake-f2c-libs
_WRAP_EXTRA_ARGS.FC+= -L${WRKDIR}/.f2c/lib -I${WRKDIR}/.f2c/include
fake-f2c-libs:
${MKDIR} ${WRKDIR}/.f2c/include
${MKDIR} ${WRKDIR}/.f2c/lib
${ECHO} 'int main(void) { return 0; }' > ${WRKDIR}/.f2c/lib/main.c
${CC} -c -o ${WRKDIR}/.f2c/lib/main.o ${WRKDIR}/.f2c/lib/main.c
${AR} cq ${WRKDIR}/.f2c/lib/libf2c.a ${WRKDIR}/.f2c/lib/main.o
${RANLIB} ${WRKDIR}/.f2c/lib/libf2c.a
${TOUCH} ${WRKDIR}/.f2c/include/f2c.h
.endif
# Create symlinks for the compiler into ${WRKDIR}.
. for _var_ in ${_F2C_VARS}
. if !target(${_F2C_${_var_}})
override-tools: ${_F2C_${_var_}}
${_F2C_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
${LN} -fs ${_F2CBASE}/bin/f2c-f77 ${.TARGET}
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -fs ${_F2CBASE}/bin/f2c-f77 ${_alias_}; \
fi
. endfor
. endif
. endfor
.endif # _USE_F2C == "yes"
.endif # COMPILER_F2C_MK

117
mk/compiler/g95.mk Normal file
View File

@@ -0,0 +1,117 @@
# $NetBSD: g95.mk,v 1.4 2012/12/15 21:23:31 markd Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Johnny C. Lam.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
.if !defined(COMPILER_G95_MK)
COMPILER_G95_MK= defined
.include "../../mk/bsd.prefs.mk"
.if !empty(PKGPATH:Mlang/g95) || !empty(PKGPATH:Mdevel/patch) || \
!empty(PKGPATH:Mdevel/libtool-base)
IGNORE_G95= yes
MAKEFLAGS+= IGNORE_G95=yes
.endif
.if defined(IGNORE_G95)
_USE_G95= NO
.endif
# LANGUAGES.<compiler> is the list of supported languages by the compiler.
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones
# requested by the package in USE_LANGUAGES.
#
LANGUAGES.g95= fortran fortran77
_LANGUAGES.g95= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.g95+= ${LANGUAGES.g95:M${_lang_}}
.endfor
.if empty(_LANGUAGES.g95)
_USE_G95= NO
.endif
.if !defined(_USE_G95)
_USE_G95= YES
.endif
.if !empty(_USE_G95:M[yY][eE][sS])
EVAL_PREFIX+= _G95BASE=g95
_G95BASE_DEFAULT= ${LOCALBASE}
FC= g95
_G95_DIR= ${WRKDIR}/.g95
_G95_VARS= # empty
. if !empty(_LANGUAGES.g95:Mfortran) || \
!empty(_LANGUAGES.g95:Mfortran77)
PKG_FC?= ${FC}
_G95_VARS+= FC
_G95_FC:= ${_G95_DIR}/bin/${PKG_FC:T}
_ALIASES.FC+= f77 g77 g95
FCPATH= ${_G95BASE}/bin/g95
PKG_FC:= ${_G95_FC}
. endif
# Prepend the path the to the compiler to the PATH
. if !empty(_LANGUAGES.g95)
PREPEND_PATH+= ${_G95_DIR}/bin
. endif
# Add the dependency on g95.
. include "../../lang/g95/buildlink3.mk"
. if defined(G95_DIR) && !empty(G95_DIR)
PKGSRC_MAKE_ENV+= G95_DIR=${G95_DIR:Q}
. endif
# Create symlinks for the compiler into ${WRKDIR}.
. for _var_ in ${_G95_VARS}
. if !target(${_G95_${_var_}})
override-tools: ${_G95_${_var_}}
${_G95_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
${LN} -fs ${_G95BASE}/bin/g95 ${.TARGET}
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -fs ${_G95BASE}/bin/g95 ${_alias_}; \
fi
. endfor
. endif
. endfor
.endif # _USE_G95 == "yes"
.endif # COMPILER_G95_MK

851
mk/compiler/gcc.mk Normal file
View File

@@ -0,0 +1,851 @@
# $NetBSD: gcc.mk,v 1.141 2013/06/15 22:32:18 wiz Exp $
#
# This is the compiler definition for the GNU Compiler Collection.
#
# User-settable variables:
#
# GCCBASE
# If using a native GCC and the compiler is not in $PATH then
# this should be set to the base installation directory.
#
# USE_NATIVE_GCC
# When set to "yes", the native gcc is used, no matter which
# compiler version a package requires.
#
# USE_PKGSRC_GCC
# Force using the appropriate version of GCC from pkgsrc based on
# GCC_REQD instead of the native compiler.
#
# This should be disabled only for debugging.
#
# USE_PKGSRC_GCC_RUNTIME
# When set to "yes", the runtime gcc libraries (libgcc, libstdc++
# etc) will be used from pkgsrc rather than the native compiler.
#
# Package-settable variables:
#
# GCC_REQD
# The minimum version of the GNU Compiler Collection that is
# required to build this package. Setting this variable doesn't
# change the compiler that is used for building packages. See
# ONLY_FOR_COMPILER for that purpose. This is a list of version
# numbers, of which the maximum version is the definitive one.
#
# 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_GCC_RUNTIME
# Packages which build shared libraries but do not use libtool to
# do so should define this variable. It is used to determine whether
# the gcc runtime should be depended upon when a user has enabled
# USE_PKGSRC_GCC_RUNTIME.
#
# System-defined variables:
#
# CC_VERSION
# A string of the form "gcc-4.3.2"
#
# CC_VERSION_STRING
# The same(?) as CC_VERSION. FIXME: What's the difference between
# the two?
#
# Keywords: gcc
#
.if !defined(COMPILER_GCC_MK)
COMPILER_GCC_MK= defined
_VARGROUPS+= gcc
_USER_VARS.gcc= USE_NATIVE_GCC USE_PKGSRC_GCC
_PKG_VARS.gcc= GCC_REQD
_SYS_VARS.gcc= CC_VERSION CC_VERSION_STRING LANGUAGES.gcc
_DEF_VARS.gcc= \
CCPATH CPPPATH CXXPATH \
F77PATH FCPATH \
ADAPATH GMKPATH GLKPATH GDBPATH CHPPATH GLSPATH GNTPATH PRPPATH \
IMAKEOPTS \
LDFLAGS \
PKG_CC PKG_CPP PKG_CXX PKG_FC \
PKG_ADA PKG_GMK PKG_GLK PKG_GDB PKG_CHP PKG_GLK PKG_GNT PKG_PRP \
_CC _COMPILER_RPATH_FLAG _COMPILER_STRIP_VARS \
_GCCBINDIR _GCC_ARCHDIR _GCC_BIN_PREFIX _GCC_CC \
_GCC_CPP _GCC_CXX _GCC_DEPENDENCY _GCC_DEPENDS \
_GCC_FC _GCC_LDFLAGS _GCC_LIBDIRS _GCC_PKG \
_GCC_PKGBASE _GCC_PKGSRCDIR _GCC_PKG_SATISFIES_DEP \
_GCC_PREFIX _GCC_REQD _GCC_STRICTEST_REQD _GCC_SUBPREFIX \
_GCC_TEST_DEPENDS _GCC_NEEDS_A_FORTRAN _GCC_VARS _GCC_VERSION \
_GCC_VERSION_STRING \
_GCC_ADA _GCC_GMK _GCC_GLK _GCC_GDB _GCC_CHP _GCC_GLS _GCC_GNT _GCC_PRP \
_IGNORE_GCC _IGNORE_GCC3CXX _IGNORE_GCC3F77 _IGNORE_GCC3OBJC \
_IS_BUILTIN_GCC \
_LANGUAGES.gcc \
_LINKER_RPATH_FLAG \
_NEED_GCC2 _NEED_GCC3 _NEED_GCC34 _NEED_GCC44 _NEED_NEWER_GCC \
_PKGSRC_GCC_VERSION \
_USE_GCC_SHLIB _USE_PKGSRC_GCC \
_WRAP_EXTRA_ARGS.CC
.include "../../mk/bsd.prefs.mk"
USE_NATIVE_GCC?= no
USE_PKGSRC_GCC?= no
USE_PKGSRC_GCC_RUNTIME?=no
GCC_REQD+= 2.8.0
# gcc2 doesn't support c99 and amd64
.if !empty(USE_LANGUAGES:Mc99) || ${MACHINE_ARCH} == "x86_64"
GCC_REQD+= 3.0
.endif
# Only one compiler defined here supports Ada: lang/gcc-aux
# If the Ada language is requested, force lang/gcc-aux to be selected
.if !empty(USE_LANGUAGES:Mada)
GCC_REQD+= 20120614
.endif
# _GCC_DIST_VERSION is the highest version of GCC installed by the pkgsrc
# without the PKGREVISIONs.
_GCC_DIST_NAME:= gcc48
.include "../../lang/${_GCC_DIST_NAME}/version.mk"
_GCC_DIST_VERSION:= ${${_GCC_DIST_NAME:tu}_DIST_VERSION}
# _GCC2_PATTERNS matches N s.t. N <= 2.95.3.
_GCC2_PATTERNS= [0-1].* 2.[0-9] 2.[0-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 < 3.4.
_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.[0-3] 3.[0-3].*
# _GCC34_PATTERNS matches N s.t. 3.4 <= N < 4.
_GCC34_PATTERNS= 3.[4-9] 3.[4-9].* 3.[1-9][0-9]*
# _GCC44_PATTERNS matches N s.t. 4.4 <= N < 4.5.
_GCC44_PATTERNS= 4.4 4.4.*
# _GCC45_PATTERNS matches N s.t. 4.5 <= N < 4.6.
_GCC45_PATTERNS= 4.5 4.5.*
# _GCC46_PATTERNS matches N s.t. 4.6 <= N < 4.7.
_GCC46_PATTERNS= 4.6 4.6.*
# _GCC47_PATTERNS matches N s.t. 4.7 <= N < 4.8.
_GCC47_PATTERNS= 4.7 4.7.*
# _GCC48_PATTERNS matches N s.t. 4.8 <= N.
_GCC48_PATTERNS= 4.[8-9] 4.[8-9].* 4.[1-9][0-9]* [5-9]*
# _GCC_AUX_PATTERNS matches 8-digit date YYYYMMDD*
_GCC_AUX_PATTERNS= 20[1-2][0-9][0-1][0-9][0-3][0-9]*
# _CC is the full path to the compiler named by ${CC} if it can be found.
.if !defined(_CC)
_CC:= ${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
. if !empty(GCCBASE) && exists(${GCCBASE}/bin)
_EXTRA_CC_DIRS= ${GCCBASE}/bin
. endif
. for _dir_ in ${_EXTRA_CC_DIRS} ${PATH:C/\:/ /g}
. if empty(_CC:M/*)
. if exists(${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//})
_CC:= ${_dir_}/${CC:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
. endif
. endif
. endfor
MAKEFLAGS+= _CC=${_CC:Q}
.endif
.if !defined(_GCC_VERSION)
#
# FIXME: Ideally we'd use PKGSRC_SETENV here, but not enough of the tools
# infrastructure is loaded for SETENV to be defined when mk/compiler.mk is
# included first. LC_ALL is required here for similar reasons, as ALL_ENV
# is not defined at this stage.
#
_GCC_VERSION_STRING!= \
( env LC_ALL=C ${_CC} -v 2>&1 | ${GREP} 'gcc version') 2>/dev/null || ${ECHO} 0
. if !empty(_GCC_VERSION_STRING:Megcs*)
_GCC_VERSION= 2.8.1 # egcs is considered to be gcc-2.8.1.
. elif !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly"
_GCC_VERSION!= env CCVER=${DRAGONFLY_CCVER} ${_CC} -dumpversion
. elif !empty(_GCC_VERSION_STRING:Mgcc*)
_GCC_VERSION!= ${_CC} -dumpversion
. else
_GCC_VERSION= 0
. endif
.endif
_GCC_PKG= gcc-${_GCC_VERSION:C/-.*$//}
.if !empty(_CC:M${LOCALBASE}/*)
_IS_BUILTIN_GCC= NO
GCC_REQD+= ${_GCC_VERSION}
.else
. if !empty(_CC:M/*)
#
# GCC in older versions of Darwin report "Apple Computer ... based on gcc
# version ...", so we can't just grep for "^gcc".
#
. if ${_GCC_VERSION} != "0"
_IS_BUILTIN_GCC= YES
. else
_IS_BUILTIN_GCC= NO
. endif
. else
_IS_BUILTIN_GCC= NO
. endif
.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_} 2>/dev/null; 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.
_NEED_GCC2?= no
.for _pattern_ in ${_GCC2_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC2= yes
. endif
.endfor
_NEED_GCC3?= no
.for _pattern_ in ${_GCC3_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC3= yes
. endif
.endfor
_NEED_GCC34?= no
.for _pattern_ in ${_GCC34_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC34= yes
. endif
.endfor
_NEED_GCC44?= no
.for _pattern_ in ${_GCC44_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC44= yes
. endif
.endfor
_NEED_GCC45?= no
.for _pattern_ in ${_GCC45_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC45= yes
. endif
.endfor
_NEED_GCC46?= no
.for _pattern_ in ${_GCC46_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC46= yes
. endif
.endfor
_NEED_GCC47?= no
.for _pattern_ in ${_GCC47_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC47= yes
. endif
.endfor
_NEED_GCC48?= no
.for _pattern_ in ${_GCC48_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC48= yes
. endif
.endfor
_NEED_GCC_AUX?= no
.for _pattern_ in ${_GCC_AUX_PATTERNS}
. if !empty(_GCC_REQD:M${_pattern_})
_NEED_GCC_AUX= yes
_NEED_NEWER_GCC=NO
. endif
.endfor
.if !empty(_NEED_GCC2:M[nN][oO]) && !empty(_NEED_GCC3:M[nN][oO]) && \
!empty(_NEED_GCC34:M[nN][oO]) && !empty(_NEED_GCC44:M[nN][oO]) && \
!empty(_NEED_GCC45:M[nN][oO]) && !empty(_NEED_GCC46:M[nN][oO]) && \
!empty(_NEED_GCC47:M[nN][oO]) && !empty(_NEED_GCC48:M[nN][oO]) && \
!empty(_NEED_GCC_AUX:M[nN][oO])
_NEED_GCC48= yes
.endif
# Assume by default that GCC will only provide a C compiler.
LANGUAGES.gcc?= c
.if !empty(_NEED_GCC2:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran77 objc
.elif !empty(_NEED_GCC3:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran77 java objc
.elif !empty(_NEED_GCC34:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran77 objc
.elif !empty(_NEED_GCC44:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 java objc
.elif !empty(_NEED_GCC45:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 java objc
.elif !empty(_NEED_GCC46:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 java objc
.elif !empty(_NEED_GCC47:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
.elif !empty(_NEED_GCC48:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS])
LANGUAGES.gcc= c c++ fortran fortran77 objc ada
.endif
_LANGUAGES.gcc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.gcc+= ${LANGUAGES.gcc:M${_lang_}}
.endfor
.if !empty(USE_LANGUAGES:Mc99)
_WRAP_EXTRA_ARGS.CC+= -std=gnu99
.endif
# GCC has this annoying behaviour where it advocates in a multi-line
# banner the use of "#include" over "#import" when including headers.
# This generates a huge number of warnings when building practically all
# Objective-C code where it is convention to use "#import". Suppress
# the warning if we're building Objective-C code using GCC.
#
.if !empty(_LANGUAGES.gcc:Mobjc)
CFLAGS+= -Wno-import
.endif
.if !empty(_NEED_GCC2:M[yY][eE][sS])
#
# We require gcc-2.x in the lang/gcc directory.
#
_GCC_PKGBASE= gcc
. if !empty(PKGPATH:Mlang/gcc)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc
_GCC_DEPENDENCY= gcc>=${_GCC_REQD}:../../lang/gcc
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC3:M[yY][eE][sS])
#
# We require gcc-3.x in the lang/gcc3-* directories.
#
_GCC_PKGBASE= gcc3-c
. if !empty(PKGPATH:Mlang/gcc3-c)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc:Mc)
_GCC_PKGSRCDIR= ../../lang/gcc3-c
_GCC_DEPENDENCY= gcc3-c>=${_GCC_REQD}:../../lang/gcc3-c
. endif
.elif !empty(_NEED_GCC34:M[yY][eE][sS])
#
# We require gcc-3.4.x in the lang/gcc34 directory.
#
_GCC_PKGBASE= gcc34
. if !empty(PKGPATH:Mlang/gcc34)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc34
_GCC_DEPENDENCY= gcc34>=${_GCC_REQD}:../../lang/gcc34
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC44:M[yY][eE][sS])
#
# We require gcc-4.4.x in the lang/gcc44 directory.
#
_GCC_PKGBASE= gcc44
. if !empty(PKGPATH:Mlang/gcc44)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc44
_GCC_DEPENDENCY= gcc44>=${_GCC_REQD}:../../lang/gcc44
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC45:M[yY][eE][sS])
#
# We require gcc-4.5.x in the lang/gcc45 directory.
#
_GCC_PKGBASE= gcc45
. if !empty(PKGPATH:Mlang/gcc45)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc45
_GCC_DEPENDENCY= gcc45>=${_GCC_REQD}:../../lang/gcc45
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC46:M[yY][eE][sS])
#
# We require gcc-4.6.x in the lang/gcc46 directory.
#
_GCC_PKGBASE= gcc46
. if !empty(PKGPATH:Mlang/gcc46)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc46
_GCC_DEPENDENCY= gcc46>=${_GCC_REQD}:../../lang/gcc46
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC47:M[yY][eE][sS])
#
# We require gcc-4.7.x in the lang/gcc47 directory.
#
_GCC_PKGBASE= gcc47
. if !empty(PKGPATH:Mlang/gcc47)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc47
_GCC_DEPENDENCY= gcc47>=${_GCC_REQD}:../../lang/gcc47
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mgo) || \
!empty(_LANGUAGES.gcc:Mobjc) || \
!empty(_LANGUAGES.gcc:Mobj-c++)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC48:M[yY][eE][sS])
#
# We require gcc-4.8.x in the lang/gcc48 directory.
#
_GCC_PKGBASE= gcc48
. if !empty(PKGPATH:Mlang/gcc48)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc48
_GCC_DEPENDENCY= gcc48>=${_GCC_REQD}:../../lang/gcc48
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mgo) || \
!empty(_LANGUAGES.gcc:Mobjc) || \
!empty(_LANGUAGES.gcc:Mobj-c++)
_USE_GCC_SHLIB?= yes
. endif
. endif
.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS])
#
# We require Ada-capable compiler in the lang/gcc-aux directory.
#
_GCC_PKGBASE= gcc-aux
. if !empty(PKGPATH:Mlang/gcc-aux)
_IGNORE_GCC= yes
MAKEFLAGS+= _IGNORE_GCC=yes
. endif
. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
_GCC_PKGSRCDIR= ../../lang/gcc-aux
_GCC_DEPENDENCY= gcc-aux>=${_GCC_REQD}:../../lang/gcc-aux
. if !empty(_LANGUAGES.gcc:Mc++) || \
!empty(_LANGUAGES.gcc:Mfortran) || \
!empty(_LANGUAGES.gcc:Mfortran77) || \
!empty(_LANGUAGES.gcc:Mada) || \
!empty(_LANGUAGES.gcc:Mobjc)
_USE_GCC_SHLIB?= yes
. endif
. endif
.endif
_GCC_DEPENDS= ${_GCC_PKGBASE}>=${_GCC_REQD}
.if !empty(_NEED_GCC3:M[yY][eE][sS])
. if !empty(PKGPATH:Mlang/gcc3-c++)
_IGNORE_GCC3CXX= yes
MAKEFLAGS+= _IGNORE_GCC3CXX=yes
. endif
. if !defined(_IGNORE_GCC3CXX) && !empty(_LANGUAGES.gcc:Mc++)
_GCC_PKGSRCDIR+= ../../lang/gcc3-c++
_GCC_DEPENDENCY+= gcc3-c++>=${_GCC_REQD}:../../lang/gcc3-c++
_USE_GCC_SHLIB?= yes
. endif
. if !empty(PKGPATH:Mlang/gcc3-f77)
_IGNORE_GCC3F77= yes
MAKEFLAGS+= _IGNORE_GCC3F77=yes
. endif
. if !defined(_IGNORE_GCC3F77) && !empty(_LANGUAGES.gcc:Mfortran77)
_GCC_PKGSRCDIR+= ../../lang/gcc3-f77
_GCC_DEPENDENCY+= gcc3-f77>=${_GCC_REQD}:../../lang/gcc3-f77
_USE_GCC_SHLIB?= yes
. endif
. if !empty(PKGPATH:Mlang/gcc3-objc)
_IGNORE_GCC3OBJC= yes
MAKEFLAGS+= _IGNORE_GCC3OBJC=yes
. endif
. if !defined(_IGNORE_GCC3OBJC) && !empty(_LANGUAGES.gcc:Mobjc)
_GCC_PKGSRCDIR+= ../../lang/gcc3-objc
_GCC_DEPENDENCY+= gcc3-objc>=${_GCC_REQD}:../../lang/gcc3-objc
_USE_GCC_SHLIB?= yes
. endif
.endif
# When not using the GNU linker, gcc will always link shared libraries against
# the shared version of libgcc, and so _USE_GCC_SHLIB needs to be enabled on
# platforms with non-GNU linkers, such as SunOS.
#
# However, we cannot simply do this by default as it will create circular
# dependencies in packages which are required to build gcc itself, and so we
# enable it based on USE_LIBTOOL for the majority of packages, and support
# USE_GCC_RUNTIME for packages which create shared libraries but do not use
# libtool to do so.
#
.if ${OPSYS} == "SunOS" && (defined(USE_LIBTOOL) || defined(USE_GCC_RUNTIME))
_USE_GCC_SHLIB= yes
.endif
.if !empty(USE_NATIVE_GCC:M[yY][eE][sS]) && !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
_USE_PKGSRC_GCC= no
.elif !empty(USE_PKGSRC_GCC:M[yY][eE][sS])
# For environments where there is an external gcc too, but pkgsrc
# should use the pkgsrc one for consistency.
_USE_PKGSRC_GCC= yes
.endif
.if defined(_IGNORE_GCC)
_USE_PKGSRC_GCC= NO
.endif
.if !defined(_USE_PKGSRC_GCC)
_USE_PKGSRC_GCC= YES
. if !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
_GCC_TEST_DEPENDS= gcc>=${_GCC_REQD}
_USE_PKGSRC_GCC!= \
if ${PKG_ADMIN} pmatch '${_GCC_TEST_DEPENDS}' ${_GCC_PKG} 2>/dev/null; then \
${ECHO} "NO"; \
else \
${ECHO} "YES"; \
fi
. endif
.endif
# Check if any of the versions of GCC in pkgsrc can satisfy the _GCC_REQD
# requirement.
#
.if !defined(_NEED_NEWER_GCC)
_PKGSRC_GCC_VERSION= ${_GCC_PKGBASE}-${_GCC_DIST_VERSION}
_NEED_NEWER_GCC!= \
if ${PKG_ADMIN} pmatch '${_GCC_DEPENDS}' ${_PKGSRC_GCC_VERSION} 2>/dev/null; then \
${ECHO} "NO"; \
else \
${ECHO} "YES"; \
fi
#MAKEFLAGS+= _NEED_NEWER_GCC=${_NEED_NEWER_GCC}
.endif
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && \
!empty(_NEED_NEWER_GCC:M[yY][eE][sS])
PKG_FAIL_REASON= "Unable to satisfy dependency: ${_GCC_DEPENDS}"
.endif
# GNU ld option used to set the rpath
_LINKER_RPATH_FLAG= -R
# GCC passes rpath directives to the linker using "-Wl,-R".
_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG}
.if !empty(MACHINE_ARCH:Mmips*)
_COMPILER_ABI_FLAG.32= -mabi=n32 # ABI == "32" == "n32"
_COMPILER_ABI_FLAG.n32= -mabi=n32
_COMPILER_ABI_FLAG.o32= -mabi=32
_COMPILER_ABI_FLAG.64= -mabi=64
. if defined(ABI) && !empty(ABI)
MABIFLAG= ${_COMPILER_ABI_FLAG.${ABI}}
. endif
.endif
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
#
# Ensure that the correct rpath is passed to the linker if we need to
# link against gcc shared libs.
#
_GCC_SUBPREFIX!= \
if ${PKG_INFO} -qe ${_GCC_PKGBASE}; then \
${PKG_INFO} -f ${_GCC_PKGBASE} | \
${GREP} "File:.*bin/gcc" | \
${GREP} -v "/gcc[0-9][0-9]*-.*" | \
${SED} -e "s/.*File: *//;s/bin\/gcc.*//;q"; \
else \
case ${_CC} in \
${LOCALBASE}/*) \
subprefix="${_CC:H:S/\/bin$//:S/${LOCALBASE}\///:S/${LOCALBASE}//}"; \
case "$${subprefix}" in \
"") ${ECHO} "$${subprefix}" ;; \
*) ${ECHO} "$${subprefix}/" ;; \
esac; \
;; \
*) \
${ECHO} "_GCC_SUBPREFIX_not_found/"; \
;; \
esac; \
fi
_GCC_PREFIX= ${LOCALBASE}/${_GCC_SUBPREFIX}
_GCC_ARCHDIR!= \
if [ -x ${_GCC_PREFIX}bin/gcc ]; then \
${DIRNAME} `${_GCC_PREFIX}bin/gcc ${MABIFLAG} -print-libgcc-file-name 2>/dev/null`; \
else \
${ECHO} "_GCC_ARCHDIR_not_found"; \
fi
. if empty(_GCC_ARCHDIR:M*not_found*)
. if defined(MABIFLAG) && !empty(MABIFLAG)
_GCC_PREFIX:= ${_GCC_ARCHDIR:H:H:H:H:H}/
_GCC_SUBPREFIX:= ${_GCC_ARCHDIR:H:H:H:H:H:T}/
. else
_GCC_PREFIX:= ${_GCC_ARCHDIR:H:H:H:H}/
_GCC_SUBPREFIX:= ${_GCC_ARCHDIR:H:H:H:H:T}/
. endif
. endif
_GCC_LIBDIRS= ${_GCC_ARCHDIR} ${_GCC_PREFIX}lib
_GCC_LDFLAGS= # empty
. for _dir_ in ${_GCC_LIBDIRS:N*not_found*}
_GCC_LDFLAGS+= -L${_dir_} ${COMPILER_RPATH_FLAG}${_dir_}
. endfor
LDFLAGS+= ${_GCC_LDFLAGS}
.endif
# Point the variables that specify the compiler to the installed
# GCC executables.
#
_GCC_DIR= ${WRKDIR}/.gcc
_GCC_VARS= # empty
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
_GCCBINDIR= ${_GCC_PREFIX}bin
.elif !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
_GCCBINDIR= ${_CC:H}
.endif
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
_GCC_BIN_PREFIX= ${MACHINE_GNU_PLATFORM}-
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc)
_GCC_VARS+= CC
_GCC_CC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gcc
_ALIASES.CC= cc gcc
CCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc
PKG_CC:= ${_GCC_CC}
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp)
_GCC_VARS+= CPP
_GCC_CPP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}cpp
_ALIASES.CPP= cpp
CPPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp
PKG_CPP:= ${_GCC_CPP}
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++)
_GCC_VARS+= CXX
_GCC_CXX= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g++
_ALIASES.CXX= c++ g++
CXXPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++
PKG_CXX:= ${_GCC_CXX}
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77)
_GCC_VARS+= FC
_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g77
_ALIASES.FC= f77 g77
FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77
F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77
PKG_FC:= ${_GCC_FC}
PKGSRC_FORTRAN?= g77
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran)
_GCC_VARS+= FC
_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gfortran
_ALIASES.FC= gfortran
FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran
F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran
PKG_FC:= ${_GCC_FC}
PKGSRC_FORTRAN?= gfortran
.endif
.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada)
_GCC_VARS+= ADA GMK GLK GBD CHP PRP GLS GNT
_GCC_ADA= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}ada
_GCC_GMK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatmake
_GCC_GLK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatlink
_GCC_GBD= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatbind
_GCC_CHP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatchop
_GCC_PRP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatprep
_GCC_GLS= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatls
_GCC_GNT= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnat
_ALIASES.ADA= ada
_ALIASES.GMK= gnatmake
_ALIASES.GLK= gnatlink
_ALIASES.GBD= gnatbind
_ALIASES.CHP= gnatchop
_ALIASES.PRP= gnatprep
_ALIASES.GLS= gnatls
_ALIASES.GNT= gnat
ADAPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada
GMKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatmake
GLKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatlink
GBDPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatbind
CHPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatchop
PRPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatprep
GLSPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatls
GNTPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnat
PKG_ADA:= ${_GCC_ADA}
PKG_GMK:= ${_GCC_GMK}
PKG_GLK:= ${_GCC_GLK}
PKG_GBD:= ${_GCC_GBD}
PKG_CHP:= ${_GCC_CHP}
PKG_PRP:= ${_GCC_PRP}
PKG_GLS:= ${_GCC_GLS}
PKG_GNT:= ${_GCC_GNT}
PKGSRC_ADA?= ada
PKGSRC_GMK?= gnatmake
PKGSRC_GLK?= gnatlink
PKGSRC_GBD?= gnatbind
PKGSRC_CHP?= gnatchop
PKGSRC_PRP?= gnatprep
PKGSRC_GLS?= gnatls
PKGSRC_GNT?= gnat
.endif
_COMPILER_STRIP_VARS+= ${_GCC_VARS}
# Pass the required flags to imake to tell it we're using gcc on Solaris.
.if ${OPSYS} == "SunOS"
IMAKEOPTS+= -DHasGcc2=YES -DHasGcc2ForCplusplus=YES
.endif
.if ${OPSYS} == "Darwin" || ${OPSYS} == "Linux" || ${OPSYS} == "SunOS"
_COMPILER_ABI_FLAG.32= -m32
_COMPILER_ABI_FLAG.64= -m64
.endif
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
. if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -v 2>&1
CC_VERSION!= \
if ${CCPATH} -dumpversion > /dev/null 2>&1; then \
${ECHO} "gcc-`${CCPATH} -dumpversion`"; \
else \
${ECHO} "gcc-${_GCC_REQD}"; \
fi
. else
CC_VERSION_STRING= ${CC_VERSION}
CC_VERSION= gcc-${_GCC_REQD}
. endif
.else
CC_VERSION_STRING= ${CC_VERSION}
CC_VERSION= ${_GCC_PKG}
.endif
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.gcc)
PREPEND_PATH+= ${_GCC_DIR}/bin
.endif
# Add the dependency on GCC.
.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
. for _dir_ in ${_GCC_PKGSRCDIR}
. include "${_dir_}/buildlink3.mk"
. endfor
.endif
# Add dependency on GCC libraries if requested.
.if (defined(_USE_GCC_SHLIB) && !empty(_USE_GCC_SHLIB:M[Yy][Ee][Ss])) && !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
# Special case packages which are themselves a dependency of gcc runtime.
. if empty(PKGPATH:Mdevel/libtool-base) && empty(PKGPATH:Mdevel/binutils) && empty(PKGPATH:Mlang/gcc??)
. if !empty(_GCC_VERSION:M4.7*)
. include "../../lang/gcc47-libs/buildlink3.mk"
. elif !empty(_GCC_VERSION:M4.8*)
. include "../../lang/gcc48-libs/buildlink3.mk"
. else
PKG_FAIL_REASON= "No USE_PKGSRC_GCC_RUNTIME support for ${CC_VERSION}"
. endif
. endif
.endif
.for _var_ in ${_GCC_VARS}
. if !target(${_GCC_${_var_}})
override-tools: ${_GCC_${_var_}}
${_GCC_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${_GCCBINDIR}/${.TARGET:T} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${_GCCBINDIR}/${.TARGET:T} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET:T} ${_alias_}; \
fi
. endfor
. endif
.endfor
# On systems without a Fortran compiler, pull one in if needed.
# The default is g95 as it supports a modern dialect, but it can
# be overridden in mk.conf to use only f2c.
#
PKGSRC_FORTRAN?=g95
_GCC_NEEDS_A_FORTRAN= no
.if empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && !exists(${FCPATH})
_GCC_NEEDS_A_FORTRAN= yes
.else
. for _pattern_ in 0.* 1.[0-4] 1.[0-4].*
. if !empty(MACHINE_PLATFORM:MNetBSD-${_pattern_}-*)
_GCC_NEEDS_A_FORTRAN= yes
. endif
. endfor
.endif
.if !empty(_GCC_NEEDS_A_FORTRAN:M[yY][eE][sS])
. include "../../mk/compiler/${PKGSRC_FORTRAN}.mk"
.endif
.endif # COMPILER_GCC_MK

97
mk/compiler/hp.mk Normal file
View File

@@ -0,0 +1,97 @@
# $NetBSD: hp.mk,v 1.7 2009/06/02 22:32:49 joerg Exp $
#
# This is the compiler definition for the HP-UX C/aC++ compilers.
#
.if !defined(COMPILER_HP_MK)
COMPILER_HP_MK= defined
.include "../../mk/bsd.prefs.mk"
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.hp= # empty
_HP_DIR= ${WRKDIR}/.hp
_HP_VARS= # empty
.if exists(/usr/bin/cc)
LANGUAGES.hp+= c
_HP_VARS+= CC
_HP_CC= ${_HP_DIR}/cc
_ALIASES.CC= cc
CCPATH= /usr/bin/cc
PKG_CC:= ${_HP_CC}
.endif
.if exists(/opt/aCC/bin/aCC)
LANGUAGES.hp+= c++
_HP_VARS+= CXX
_HP_CXX= ${_HP_DIR}/aCC
_ALIASES.CXX= c++
CXXPATH= /opt/aCC/bin/aCC
PKG_CXX:= ${_HP_CXX}
.endif
_COMPILER_STRIP_VARS+= ${_HP_VARS}
.if exists(${CXXPATH}) && !defined(CC_VERSION_STRING)
CC_VERSION_STRING!= ${CXXPATH} -V 2>&1
CC_VERSION= ${CC_VERSION_STRING:S/ /_/Wg}
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= hp
.endif
# Turn ANSI C++ features like namespace std, STL and correct scoping
_WRAP_EXTRA_ARGS.CXX+= -AA -Aa
# HP comilers pass flags to the linker using "-Wl,".
_COMPILER_LD_FLAG= -Wl,
# linker syntax for rpath is +b /path1:/path2:...
_LINKER_RPATH_FLAG= +b
# HP compilers pass rpath directives to the linker using "-Wl,+b,"
_COMPILER_RPATH_FLAG= ${_COMPILER_LD_FLAG}${_LINKER_RPATH_FLAG},
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.hp= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.hp+= ${LANGUAGES.hp:M${_lang_}}
.endfor
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.hp)
PREPEND_PATH+= ${_HP_DIR}/bin
.endif
# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_HP_VARS}
. if !target(${_HP_${_var_}})
override-tools: ${_HP_${_var_}}
${_HP_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${${_var_}PATH} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${${_var_}PATH} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET} ${_alias_}; \
fi
. endfor
. endif
.endfor
_COMPILER_ABI_FLAG.32=+DD32
_COMPILER_ABI_FLAG.64=+DD64
.endif # COMPILER_HP_MK

128
mk/compiler/icc.mk Normal file
View File

@@ -0,0 +1,128 @@
# $NetBSD: icc.mk,v 1.8 2011/05/19 22:37:55 alnsn Exp $
#
# This is the compiler definition for the Intel compilers.
#
# User-settable variables:
#
# ICCBASE
# The base directory where the compiler is installed.
#
.if !defined(COMPILER_ICC_MK)
COMPILER_ICC_MK= defined
.include "../../mk/bsd.prefs.mk"
ICCBASE?= /opt/intel_cc_80
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.icc= # empty
_ICC_DIR= ${WRKDIR}/.icc
_ICC_VARS= # empty
.if exists(${ICCBASE}/bin/icc)
LANGUAGES.icc+= c
_ICC_VARS+= CC
_ICC_CC= ${_ICC_DIR}/bin/icc
_ALIASES.CC= cc
CCPATH= ${ICCBASE}/bin/icc
PKG_CC:= ${_ICC_CC}
_ICC_VARS+= CPP
_ICC_CPP= ${_ICC_DIR}/bin/cpp
PKG_CPP:= ${_ICC_CPP}
.endif
.if exists(${ICCBASE}/bin/icpc)
LANGUAGES.icc+= c++
_ICC_VARS+= CXX
_ICC_CXX= ${_ICC_DIR}/bin/icpc
_ALIASES.CXX= CC c++
CXXPATH= ${ICCBASE}/bin/icpc
PKG_CXX:= ${_ICC_CXX}
.endif
_COMPILER_STRIP_VARS+= ${_ICC_VARS}
# icc passes rpath directives to the linker using "-Wl,-R".
_LINKER_RPATH_FLAG= -Wl,-R
# icc passes rpath directives to the linker using "-Wl,-R".
_COMPILER_RPATH_FLAG= -Wl,-R
.if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -V 2>&1 | ${GREP} '^Intel'
_CC_VERSION!= ${CCPATH} -v 2>&1 || ${TRUE}
CC_VERSION= Intel C++ Compiler ${_CC_VERSION}
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= Intel C++ Compiler
.endif
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.icc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.icc+= ${LANGUAGES.icc:M${_lang_}}
.endfor
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.icc)
PREPEND_PATH+= ${_ICC_DIR}/bin
.endif
# icc supports __attribute__, but the GNU configure test uses a nested
# function, which icc does not support. #undef'ing __attribute__ has the
# unfortunate side-effect of breaking many of the Linux header files, which
# cannot be compiled properly without __attribute__. The test must be
# overridden so that __attribute__ is assumed supported by the compiler.
.if defined(GNU_CONFIGURE)
CONFIGURE_ENV+= ac_cv___attribute__=yes
.endif
override-tools: ${_ICC_CPP}
${_ICC_CPP}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'for o in "$$@"'; ${ECHO} 'do'; \
${ECHO} ' case "$$o"'; ${ECHO} ' in'; \
${ECHO} ' -undef) undef=1;;'; ${ECHO} ' esac'; \
${ECHO} 'done'; \
${ECHO} 'if [ -n "$$undef" ]'; ${ECHO} 'then'; \
${ECHO} 'exec ${ICCBASE}/bin/icc -E -Uunix "$$@"'; \
${ECHO} 'else'; \
${ECHO} 'exec ${ICCBASE}/bin/icc -E "$$@"'; \
${ECHO} 'fi' \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_ICC_VARS}
. if !target(${_ICC_${_var_}})
override-tools: ${_ICC_${_var_}}
${_ICC_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${ICCBASE}/bin/${.TARGET:T} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${ICCBASE}/bin/${.TARGET:T} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET} ${_alias_}; \
fi
. endfor
. endif
.endfor
.endif # COMPILER_ICC_MK

99
mk/compiler/ido.mk Normal file
View File

@@ -0,0 +1,99 @@
# $NetBSD: ido.mk,v 1.8 2009/06/02 22:32:49 joerg Exp $
#
# This is the compiler definition for the SGI IRIS Development Option
# cc (IRIX 5).
#
# User-settable variables:
#
# IDOBASE
# The base directory where the compiler is installed.
#
.if !defined(COMPILER_IDO_MK)
COMPILER_IDO_MK= defined
.include "../../mk/bsd.prefs.mk"
IDOBASE?= /usr
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.ido= # empty
_IDO_DIR= ${WRKDIR}/.ido
_IDO_VARS= # empty
.if exists(${IDOBASE}/bin/cc)
LANGUAGES.ido+= c
_IDO_VARS+= CC
_IDO_CC= ${_IDO_DIR}/bin/cc
_ALIASES.CC= cc
CCPATH= ${IDOBASE}/bin/cc
PKG_CC:= ${_IDO_CC}
.endif
.if exists(${IDOBASE}/lib/cpp)
_IDO_VARS+= CPP
_IDO_CPP= ${_IDO_DIR}/bin/cpp
_ALIASES.CPP= cpp
CPPPATH= ${IDOBASE}/lib/cpp
PKG_CPP:= ${_IDO_CPP}
.endif
_COMPILER_STRIP_VARS+= ${_IDO_VARS}
CC_VERSION?= ${LOWER_OPSYS} ido cc
# IDO linker option used to set the rpath.
_LINKER_RPATH_FLAG= -rpath
# IDO passes rpath directives to the linker using "-Wl,-rpath,".
_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG},
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.ido= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.ido+= ${LANGUAGES.ido:M${_lang_}}
.endfor
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.ido)
PREPEND_PATH+= ${_IDO_DIR}/bin
.endif
# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_IDO_VARS}
. if !target(${_IDO_${_var_}})
override-tools: ${_IDO_${_var_}}
${_IDO_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${${_var_}PATH} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${${_var_}PATH} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET} ${_alias_}; \
fi
. endfor
. endif
.endfor
# Force the use of f2c-f77 for compiling Fortran.
_IDO_USE_F2C= no
FCPATH= /nonexistent
.if !exists(${FCPATH})
_IDO_USE_F2C= yes
.endif
.if !empty(_IDO_USE_F2C:M[yY][eE][sS])
. include "../../mk/compiler/f2c.mk"
.endif
.endif # COMPILER_IDO_MK

View File

@@ -0,0 +1,47 @@
# $NetBSD: mipspro-ucode.mk,v 1.5 2011/05/08 10:37:54 cheusov Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
.if !defined(COMPILER_MIPSPRO_UCODE_MK)
COMPILER_MIPSPRO_UCODE_MK= defined
.include "../../mk/bsd.prefs.mk"
CC_VERSION?= MIPSpro Compilers: Version 4.x (ucode)
.include "../../mk/compiler/mipspro.mk"
.endif # COMPILER_MIPSPRO_UCODE_MK

131
mk/compiler/mipspro.mk Normal file
View File

@@ -0,0 +1,131 @@
# $NetBSD: mipspro.mk,v 1.42 2011/08/22 09:18:29 cheusov Exp $
#
# This is the compiler definition for the MIPSpro C compiler.
#
# User-settable variables:
#
# MIPSPROBASE
# The base directory where the compiler is installed.
#
.if !defined(COMPILER_MIPSPRO_MK)
COMPILER_MIPSPRO_MK= defined
.include "../../mk/bsd.prefs.mk"
MIPSPROBASE?= /usr
COMPILER_USE_SYMLINKS= no # PR pkg/42424
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.mipspro= # empty
_MIPSPRO_DIR= ${WRKDIR}/.mipspro
_MIPSPRO_VARS= # empty
.if exists(${MIPSPROBASE}/bin/cc)
LANGUAGES.mipspro+= c
_MIPSPRO_VARS+= CC
_MIPSPRO_CC= ${_MIPSPRO_DIR}/bin/cc
_ALIASES.CC= cc
CCPATH= ${MIPSPROBASE}/bin/cc
PKG_CC:= ${_MIPSPRO_CC}
.endif
.if exists(${MIPSPROBASE}/bin/CC)
LANGUAGES.mipspro+= c++
_MIPSPRO_VARS+= CXX
_MIPSPRO_CXX= ${_MIPSPRO_DIR}/bin/CC
_ALIASES.CXX= CC c++
CXXPATH= ${MIPSPROBASE}/bin/CC
PKG_CXX:= ${_MIPSPRO_CXX}
.endif
_COMPILER_STRIP_VARS+= ${_MIPSPRO_VARS}
.if exists(${CCPATH})
# MIPSpro Compilers: Version 7.3.1.2m
CC_VERSION_STRING!= ${CCPATH} -version 2>&1 || ${TRUE}
CC_VERSION!= ${CCPATH} -version 2>&1 | ${GREP} '^MIPSpro'
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= MIPSpro Compilers
.endif
# MIPSPro linker option used to set the rpath.
_LINKER_RPATH_FLAG= -rpath
# MIPSPro passes rpath directives to the linker using "-Wl,-rpath,".
_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG},
# MIPSPro supports compiling/linking objects for several ABIs: n32, o32,
# and 64 bit.
#
_COMPILER_ABI_FLAG.32= -n32 # ABI == "32" is an alias for ABI == "n32"
_COMPILER_ABI_FLAG.o32= # empty
_COMPILER_ABI_FLAG.n32= -n32
_COMPILER_ABI_FLAG.64= -64
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.mipspro= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.mipspro+= ${LANGUAGES.mipspro:M${_lang_}}
.endfor
.if !empty(USE_LANGUAGES:Mc99)
_WRAP_EXTRA_ARGS.CC+= -c99
.endif
# Normally, the #error directive only results in a warning (which is
# explicitly allowed in ISO C99), but we want it to be an error.
_WRAP_EXTRA_ARGS.CC+= -diag_error 1035
_WRAP_EXTRA_ARGS.CXX+= -diag_error 1035
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.mipspro)
PREPEND_PATH+= ${_MIPSPRO_DIR}/bin
.endif
# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_MIPSPRO_VARS}
. if !target(${_MIPSPRO_${_var_}})
override-tools: ${_MIPSPRO_${_var_}}
${_MIPSPRO_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${MIPSPROBASE}/bin/${.TARGET:T} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${MIPSPROBASE}/bin/${.TARGET:T} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET} ${_alias_}; \
fi
. endfor
. endif
.endfor
.if defined(ABI)
MABIFLAG= -${ABI:C/^32$/n&/}
CFLAGS+= ${MABIFLAG}
LDFLAGS+= ${MABIFLAG}
.endif
# Force the use of f2c-f77 for compiling Fortran.
_MIPSPRO_USE_F2C= no
FCPATH= /nonexistent
.if !exists(${FCPATH})
_MIPSPRO_USE_F2C= yes
.endif
.if !empty(_MIPSPRO_USE_F2C:M[yY][eE][sS])
. include "../../mk/compiler/f2c.mk"
.endif
.endif # COMPILER_MIPSPRO_MK

78
mk/compiler/pcc.mk Normal file
View File

@@ -0,0 +1,78 @@
# $NetBSD: pcc.mk,v 1.6 2013/05/09 23:37:26 riastradh Exp $
#
# This is the compiler definition for the PCC compiler.
#
# User-settable variables:
#
# PCCBASE
# The base directory where the compiler is installed.
#
.if !defined(COMPILER_PCC_MK)
COMPILER_PCC_MK= defined
# Add the dependency on pcc
# NOTE: not enabled by default as may be installed already
# TODO: check for this?
#TOOL_DEPENDS+= pcc-[0-9]*:../../lang/pcc
.include "../../mk/bsd.prefs.mk"
PCCBASE?= ${LOCALBASE}
# common definitions
_COMPILER_TYPE.c= CC
_COMPILER_TYPE.c++ = CXX
_COMPILER_TYPE.fortran= FC
# PCC-specific definitions
_COMPILER_LANGS= c c++ fortran77
_COMPILER_NAME.c= pcc
# TODO:
_COMPILER_NAME.c++ = CC
_COMPILER_NAME.fortran77= f77
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.pcc= # empty
.for l in ${_COMPILER_LANGS}
. for t in ${_COMPILER_TYPE.${l}}
. for n in ${_COMPILER_NAME.${l}}
. if exists(${PCCBASE}/bin/${n})
LANGUAGES.pcc+= ${l}
_COMPILER_STRIP_VARS+= ${t}
${t}PATH= ${PCCBASE}/bin/${n}
PKG_${t}:= ${PCCBASE}/bin/${n}
. endif
. endfor
. endfor
.endfor
# Turn on C99 support if required
#.if !empty(USE_LANGUAGES:Mc99)
#_WRAP_EXTRA_ARGS.CC+= -xc99
#.endif
_LINKER_RPATH_FLAG= -R
_COMPILER_RPATH_FLAG= -Wl,-R
.if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -v 2>&1 || ${TRUE}
CC_VERSION!= ${CCPATH} -v 2>&1 | ${GREP} '^pcc'
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= pcc
.endif
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.pcc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.pcc+= ${LANGUAGES.pcc:M${_lang_}}
.endfor
.endif # COMPILER_PCC_MK

109
mk/compiler/sunpro.mk Normal file
View File

@@ -0,0 +1,109 @@
# $NetBSD: sunpro.mk,v 1.48 2013/04/06 18:09:43 tez Exp $
#
# This is the compiler definition for the SUNWspro C compiler.
#
# User-settable variables:
#
# SUNWSPROBASE
# The base directory where the compiler is installed.
#
# Keywords: sun sunpro sunwspro
#
.if !defined(COMPILER_SUNPRO_MK)
COMPILER_SUNPRO_MK= defined
.include "../../mk/bsd.prefs.mk"
SUNWSPROBASE?= /opt/SUNWspro
.if !exists($SUNWSPROBASE)
SUNWSPROBASE!= /bin/ls -d /opt/solstudio*
.endif
# common definitions
# XXX: should be moved to compiler.mk.
_COMPILER_TYPE.c= CC
_COMPILER_TYPE.c++ = CXX
_COMPILER_TYPE.fortran= FC
# sunpro-specific definitions
_COMPILER_LANGS= c c++ fortran fortran77
_COMPILER_NAME.c= cc
_COMPILER_NAME.c++ = CC
_COMPILER_NAME.fortran= f77
_COMPILER_NAME.fortran77= f77
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.sunpro= # empty
# XXX: Should be moved to compiler.mk.
.for l in ${_COMPILER_LANGS}
. for t in ${_COMPILER_TYPE.${l}}
. for n in ${_COMPILER_NAME.${l}}
. if exists(${SUNWSPROBASE}/bin/${n})
LANGUAGES.sunpro+= ${l}
_COMPILER_STRIP_VARS+= ${t}
# XXX: What is the ${t}PATH variable used for? And why isn't it
# parameterized as usual? This makes searching for it very difficult.
# Same for PKG_${t}.
${t}PATH= ${SUNWSPROBASE}/bin/${n}
PKG_${t}:= ${SUNWSPROBASE}/bin/${n}
. endif
. endfor
. endfor
.endfor
# Turn on C99 support if required
# XXX: What if a package needs both -- a c89 and a c99 compiler?
#
# Solaris SunPro Compiler 11/12 fails on Solaris 8/9 with -xc99
# The header files supplied by the OS are not c99 aware, the
# manpage suggests the setting: -xc99=all,no_lib
# See PR 37200
.if !empty(USE_LANGUAGES:Mc99)
_WRAP_EXTRA_ARGS.CC+= -xc99
. if !empty(MACHINE_PLATFORM:MSunOS-5.[89]-*)
_WRAP_EXTRA_ARGS.CC+= -xc99=all,no_lib
. endif
.endif
# The Solaris linker uses "-R" for rpath directives.
# XXX: This shouldn't be here, but in platform/SunOS.mk.
_LINKER_RPATH_FLAG= -R
# SunPro passes rpath directives to the linker using "-R", however
# some packages require the "-Wl," prefix to recognize linker options.
# This is transformed by the compiler wrapper to "-R".
_COMPILER_RPATH_FLAG= -Wl,-R
# XXX: What about the versions of the other compilers? Fortran and C++?
# XXX: should be moved to compiler.mk.
.if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -V 2>&1 || ${TRUE}
CC_VERSION!= ${CCPATH} -V 2>&1 | ${GREP} '^cc'
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= cc: Sun C
.endif
# SunPro compiler must be passed certain flags to compile/link 64-bit code.
.if !empty(CC_VERSION:M5.9) || !empty(CC_VERSION:M5.1[0-9])
_COMPILER_ABI_FLAG.64= -m64
.elif ${MACHINE_ARCH} == "sparc"
_COMPILER_ABI_FLAG.64= -xtarget=ultra -xarch=v9
.else
_COMPILER_ABI_FLAG.64= -xarch=amd64
.endif
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
# XXX: should be moved to compiler.mk.
_LANGUAGES.sunpro= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.sunpro+= ${LANGUAGES.sunpro:M${_lang_}}
.endfor
.endif # COMPILER_SUNPRO_MK

177
mk/compiler/xlc.mk Normal file
View File

@@ -0,0 +1,177 @@
# $NetBSD: xlc.mk,v 1.26 2011/10/30 23:11:33 wiz Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Grant Beattie.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# This is the compiler definition for IBM's XL C/C++ compiler suite.
#
# User-settable variables:
#
# XLCBASE
# The base directory where the compiler is installed.
#
.if !defined(COMPILER_XLC_MK)
COMPILER_XLC_MK= defined
.include "../../mk/bsd.prefs.mk"
.if !defined(XLCBASE)
. if exists(/usr/vacpp/README)
XLCBASE= /usr/vacpp
. elif exists(/usr/vac/README) || exists(/usr/vac/README.C)
XLCBASE= /usr/vac
. elif exists(/opt/ibmcmp/vacpp/6.0/README)
XLCBASE= /opt/ibmcmp/vacpp/6.0
. else
PKG_FAIL_REASON+= "Cannot determine XLCBASE."
. endif
.endif
# LANGUAGES.<compiler> is the list of supported languages by the
# compiler.
#
LANGUAGES.xlc= # empty
_XLC_DIR= ${WRKDIR}/.xlc
_XLC_VARS= # empty
.if exists(${XLCBASE}/bin/xlc)
LANGUAGES.xlc+= c
_XLC_VARS+= CC
_XLC_CC= ${_XLC_DIR}/bin/xlc
_ALIASES.CC= cc xlc
_XLC_VARS+= CPP
_XLC_CPP= ${_XLC_DIR}/bin/cpp
PKG_CPP:= ${_XLC_CPP}
CCPATH= ${XLCBASE}/bin/xlc
PKG_CC:= ${_XLC_CC}
.endif
.if exists(${XLCBASE}/bin/xlc++)
LANGUAGES.xlc+= c++
_XLC_VARS+= CXX
_XLC_CXX= ${_XLC_DIR}/bin/xlc++
_ALIASES.CXX= c++ xlc++
CXXPATH= ${XLCBASE}/bin/xlc++
PKG_CXX:= ${_XLC_CXX}
.endif
.if exists(${XLCBASE}/bin/xlc_r)
_XLC_VARS+= CC_R
_XLC_CC_R= ${_XLC_DIR}/bin/xlc_r
_ALIASES.CC_R= cc_r xlc_r
CC_RPATH= ${XLCBASE}/bin/xlc_r
PKG_CC_R:= ${_XLC_CC_R}
CC_R?= cc_r
.endif
.if exists(${XLCBASE}/bin/xlc++_r)
_XLC_VARS+= CXX_R
_XLC_CXX_R= ${_XLC_DIR}/bin/xlc++_r
_ALIASES.CXX_R= c++_r xlc++_r
CXX_RPATH= ${XLCBASE}/bin/xlc++_r
PKG_CXX_R:= ${_XLC_CXX_R}
CXX_R?= c++_r
.endif
_COMPILER_STRIP_VARS+= ${_XLC_VARS}
_COMPILER_RPATH_FLAG= -Wl,-R
_LINKER_RPATH_FLAG= -R
.if exists(${CCPATH})
CC_VERSION_STRING!= ${CCPATH} -qversion 2>&1 | ${GREP} 'IBM XL C.*for' | ${SED} -e 's/^ *//' || ${TRUE}
CC_VERSION= ${CC_VERSION_STRING}
.else
CC_VERSION_STRING?= ${CC_VERSION}
CC_VERSION?= IBM XL C
.endif
# Most packages assume alloca is available without #pragma alloca, so
# make it the default.
CFLAGS+= -ma
# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
# ones requested by the package in USE_LANGUAGES.
#
_LANGUAGES.xlc= # empty
.for _lang_ in ${USE_LANGUAGES}
_LANGUAGES.xlc+= ${LANGUAGES.xlc:M${_lang_}}
.endfor
# Prepend the path to the compiler to the PATH.
.if !empty(_LANGUAGES.xlc)
PREPEND_PATH+= ${_XLC_DIR}/bin
.endif
override-tools: ${_XLC_CPP}
${_XLC_CPP}:
${RUN}${MKDIR} ${.TARGET:H}
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${XLCBASE}/bin/xlc -E "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
# Create compiler driver scripts in ${WRKDIR}.
.for _var_ in ${_XLC_VARS}
. if !target(${_XLC_${_var_}})
override-tools: ${_XLC_${_var_}}
${_XLC_${_var_}}:
${RUN}${MKDIR} ${.TARGET:H}
. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
${RUN}${RM} -f ${.TARGET}
${RUN}${LN} -s ${XLCBASE}/bin/${.TARGET:T} ${.TARGET}
. else
${RUN} \
(${ECHO} '#!${TOOLS_SHELL}'; \
${ECHO} 'exec ${XLCBASE}/bin/${.TARGET:T} "$$@"'; \
) > ${.TARGET}
${RUN}${CHMOD} +x ${.TARGET}
. endif
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
${RUN} \
if [ ! -x "${_alias_}" ]; then \
${LN} -f -s ${.TARGET} ${_alias_}; \
fi
. endfor
. endif
.endfor
# Force the use of f2c-f77 for compiling Fortran.
_XLC_USE_F2C= no
FCPATH= /nonexistent
.if !exists(${FCPATH})
_XLC_USE_F2C= yes
.endif
.if !empty(_XLC_USE_F2C:M[yY][eE][sS])
. include "../../mk/compiler/f2c.mk"
.endif
.endif # COMPILER_XLC_MK

View File

@@ -0,0 +1,27 @@
# $NetBSD: bsd.configure-vars.mk,v 1.4 2007/07/12 18:59:15 jlam Exp $
#
# CONFIGURE_DIRS is the list of directories in which to run the
# configure process. If the directories are relative paths,
# then they are assumed to be relative to ${WRKSRC}.
#
# SCRIPTS_ENV is the shell environment passed to xmkmf (used by
# the configure process).
#
CONFIGURE_DIRS?= ${WRKSRC}
SCRIPTS_ENV?= # empty
SCRIPTS_ENV+= ${ALL_ENV}
SCRIPTS_ENV+= _PKGSRCDIR=${_PKGSRCDIR}
SCRIPTS_ENV+= ${BATCH:DBATCH=yes}
SCRIPTS_ENV+= CURDIR=${.CURDIR}
SCRIPTS_ENV+= DEPENDS=${DEPENDS:Q}
SCRIPTS_ENV+= DISTDIR=${DISTDIR}
SCRIPTS_ENV+= FILESDIR=${FILESDIR}
SCRIPTS_ENV+= LOCALBASE=${LOCALBASE}
SCRIPTS_ENV+= PATCHDIR=${PATCHDIR}
SCRIPTS_ENV+= PKGSRCDIR=${PKGSRCDIR}
SCRIPTS_ENV+= SCRIPTDIR=${SCRIPTDIR}
SCRIPTS_ENV+= VIEWBASE=${VIEWBASE}
SCRIPTS_ENV+= WRKDIR=${WRKDIR}
SCRIPTS_ENV+= WRKSRC=${WRKSRC}
SCRIPTS_ENV+= X11BASE=${X11BASE}

View File

@@ -0,0 +1,40 @@
# $NetBSD: bsd.configure.mk,v 1.11 2008/01/04 01:46:26 rillig Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and provides all
# variables and targets related to configuring packages for building.
#
# The following are the "public" targets provided by this module:
#
# configure
#
# The following targets may be overridden in a package Makefile:
#
# pre-configure, do-configure, post-configure
#
_COOKIE.configure= ${WRKDIR}/.configure_done
######################################################################
### configure (PUBLIC)
######################################################################
### configure is a public target to configure the software for building.
###
.PHONY: configure
.if !defined(NO_CONFIGURE)
. include "configure.mk"
.elif !target(configure)
. if exists(${_COOKIE.configure})
configure:
@${DO_NADA}
. elif defined(_PKGSRC_BARRIER)
configure: wrapper _configure-cookie
. else
configure: barrier
. endif
.endif
# Creates the "configure" cookie file.
_configure-cookie: .PHONY
${RUN} [ ! -f ${_COOKIE.configure} ] # XXX: What's the purpose of this assertion?
${RUN} ${MKDIR} ${_COOKIE.configure:H}
${RUN} ${ECHO} ${PKGNAME} > ${_COOKIE.configure}

View File

@@ -0,0 +1,30 @@
# $NetBSD: cmake-rewrite.awk,v 1.2 2007/12/20 18:51:18 abs Exp $
#
# cleanup references to libraries in the buildlink tree in files
# written by cmake's export_library_dependencies() function
#
BEGIN { buildlink_dir = ARGV[1]; delete ARGV[1] }
{
match($0, "_LIB_DEPENDS \"")
if (RSTART == 0) {
print
} else {
printf "%s \"", $1
d=substr($0,RSTART+RLENGTH,length($0))
while ( d != "\")") {
match(d,"[^;]*")
dep=substr(d,RSTART,RLENGTH)
d=substr(d,RLENGTH+2,length(d))
if (dep ~ "^" buildlink_dir) {
"ls -l " dep | getline ls_out
close ("ls -l " dep)
match(ls_out,"-> ")
if (RSTART > 0) {
dep=substr(ls_out,RSTART+RLENGTH,length(ls_out))
}
}
printf "%s;",dep
}
print d
}
}

70
mk/configure/cmake.mk Normal file
View File

@@ -0,0 +1,70 @@
# $NetBSD: cmake.mk,v 1.9 2013/02/22 22:45:12 markd Exp $
#
# This file handles packages that use CMake as their primary build
# system. For more information about CMake, see http://www.cmake.org/.
#
# === Package-settable variables ===
#
# CMAKE_DEPENDENCIES_REWRITE
# A list of files (XXX: variable name) relative to WRKSRC in
# which, after configuring the package, buildlink3 dependencies
# are resolved to the real ones.
#
# CMAKE_MODULE_PATH_OVERRIDE
# A list of files relative to WRKSRC in which the CMAKE_MODULE_PATH
# variable is adjusted to include the path from the pkgsrc wrappers.
# The file ${WRKSRC}/CMakeLists.txt is always appended to this list.
#
_CMAKE_DIR= ${BUILDLINK_DIR}/cmake-Modules
CMAKE_ARGS+= -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX}
CMAKE_ARGS+= -DCMAKE_MODULE_PATH:PATH=${_CMAKE_DIR}
CMAKE_ARGS+= -DCMAKE_INSTALL_LIBDIR:PATH=lib
.if ${OPSYS} != "Darwin"
CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=TRUE
.else
CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=FALSE
CMAKE_ARGS+= -DCMAKE_INSTALL_NAME_DIR:PATH=${PREFIX}/lib
CMAKE_ARGS+= -DOPENAL_INCLUDE_DIR:PATH=/System/Library/Frameworks/OpenAL.framework/Headers
CMAKE_ARGS+= -DOPENGL_INCLUDE_DIR:PATH=/System/Library/Frameworks/OpenGL.framework/Headers
.endif
CMAKE_MODULE_PATH_OVERRIDE+= CMakeLists.txt
### configure-cmake-override modifies the cmake CMakeLists.txt file in
### ${WRKSRC} so that if CMAKE_MODULE_PATH is set we add our Module
### directory before any others.
###
SUBST_CLASSES+= cmake
SUBST_STAGE.cmake= do-configure-pre-hook
SUBST_MESSAGE.cmake= Fixing CMAKE_MODULE_PATH in CMakeLists.txt
SUBST_FILES.cmake= ${CMAKE_MODULE_PATH_OVERRIDE}
SUBST_SED.cmake= \
's|set *( *CMAKE_MODULE_PATH |set (CMAKE_MODULE_PATH "${_CMAKE_DIR}" |'
do-configure-pre-hook: __cmake-copy-module-tree
__cmake-copy-module-tree: .PHONY
${RUN} cd ${PKGSRCDIR}/mk; ${CP} -R cmake-Modules ${_CMAKE_DIR}
### The cmake function export_library_dependencies() writes out
### library dependency info to a file and this may contain buildlink
### paths.
### cmake-dependencies-rewrite modifies any such files, listed in
### ${CMAKE_DEPENDENCIES_REWRITE} (relative to ${WRKSRC}) to have the
### real dependencies
###
do-configure-post-hook: __cmake-dependencies-rewrite
__cmake-dependencies-rewrite: .PHONY
@${STEP_MSG} "Rewrite cmake Dependencies files"
.if defined(CMAKE_DEPENDENCIES_REWRITE) && !empty(CMAKE_DEPENDENCIES_REWRITE)
${RUN} \
cd ${WRKSRC}; \
for file in ${CMAKE_DEPENDENCIES_REWRITE}; do \
${TEST} -f "$$file" || continue; \
${AWK} -f ${PKGSRCDIR}/mk/configure/cmake-rewrite.awk ${BUILDLINK_DIR} $$file > $$file.override; \
${MV} -f $$file.override $$file; \
done
.endif

View File

@@ -0,0 +1,51 @@
# $NetBSD: config-override.mk,v 1.6 2008/02/07 21:36:13 rillig Exp $
######################################################################
### config-{guess,sub,rpath}-override (PRIVATE)
######################################################################
### config-{guess,sub,rpath}-override replace any existing config.guess,
### config.sub, and config-rpath under ${WRKSRC} with the specially-kept
### versions under pkgsrc/mk/gnu-config.
###
do-configure-pre-hook: config-guess-override
do-configure-pre-hook: config-sub-override
.if defined(CONFIG_RPATH_OVERRIDE)
do-configure-pre-hook: config-rpath-override
.endif
_OVERRIDE_VAR.guess= CONFIG_GUESS_OVERRIDE
_OVERRIDE_VAR.sub= CONFIG_SUB_OVERRIDE
_OVERRIDE_VAR.rpath= CONFIG_RPATH_OVERRIDE
OVERRIDE_DIRDEPTH.config-guess?= ${OVERRIDE_DIRDEPTH}
OVERRIDE_DIRDEPTH.config-sub?= ${OVERRIDE_DIRDEPTH}
OVERRIDE_DIRDEPTH.config-rpath?= ${OVERRIDE_DIRDEPTH}
.for _sub_ in guess sub rpath
_SCRIPT.config-${_sub_}-override= \
${RM} -f $$file; \
${LN} -fs ${PKGSRCDIR}/mk/gnu-config/config.${_sub_} $$file
.PHONY: config-${_sub_}-override
config-${_sub_}-override:
@${STEP_MSG} "Replacing config-${_sub_} with pkgsrc versions"
. if defined(${_OVERRIDE_VAR.${_sub_}}) && !empty(${_OVERRIDE_VAR.${_sub_}})
${RUN} \
cd ${WRKSRC}; \
for file in ${${_OVERRIDE_VAR.${_sub_}}}; do \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done
. else
${RUN} \
cd ${WRKSRC}; \
depth=0; pattern=config.${_sub_}; \
while [ $$depth -le ${OVERRIDE_DIRDEPTH.config-${_sub_}} ]; do \
for file in $$pattern; do \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done; \
depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
done
. endif
.endfor

Some files were not shown because too many files have changed in this diff Show More