bsd.configure-vars.mk

# $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}

bsd.configure.mk

# $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}

cmake-rewrite.awk

# $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
}
}

cmake.mk

# $NetBSD: cmake.mk,v 1.6 2008/09/13 11:09:58 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_SKIP_RPATH:BOOL=TRUE

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

config-override.mk

# $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

configure.mk

# $NetBSD: configure.mk,v 1.23 2008/02/07 21:36:13 rillig Exp $
#
# = Package-settable variables =
#
# CONFIGURE_ENV is the shell environment that is exported to the
# configure script.
#
# CONFIG_SHELL is the shell that is used for interpreting the
# configure script.
#
# CONFIGURE_SCRIPT is the path to the script to run in order to
# configure the software for building. If the path is relative,
# then it is assumed to be relative to each directory listed in
# CONFIGURE_DIRS.
#
# CONFIGURE_ARGS is the list of arguments that is passed to the
# configure script.
#
# INSTALL_SH_OVERRIDE is a list of files relative to WRKSRC which
# should be overridden by the install-sh script from
# sysutils/install-sh. If not defined or set to "no", then
# no files are overridden.
#
# Possible values: no, defined, undefined.
#
# Default value: defined when GNU_CONFIGURE is defined, undefined
# otherwise.
#
# OVERRIDE_GNU_CONFIG_SCRIPTS
# Whether to override the GNU config.guess and config.sub scripts
# with the pkgsrc versions.
#
# Possible values: defined, undefined.
#
# Default value: defined when GNU_CONFIGURE is defined, undefined
# otherwise.
#
# Command-line variables:
#
# CONFIG_SHELL_FLAGS
# Set this to -x when you really need to see all commands that the
# configure script executes.
#
# Keywords: config.guess config.sub
#

_VARGROUPS+= configure
_USER_VARS.configure= CONFIG_SHELL_FLAGS
_PKG_VARS.configure= CONFIGURE_ENV CONFIG_SHELL CONFIGURE_SCRIPT \
CONFIGURE_ARGS OVERRIDE_GNU_CONFIG_SCRIPTS HAS_CONFIGURE \
GNU_CONFIGURE PKGCONFIG_OVERRIDE USE_PKGLOCALEDIR \
CMAKE_ARGS CMAKE_ARG_PATH

CONFIGURE_SCRIPT?= ./configure
CONFIGURE_ENV+= ${ALL_ENV}
CONFIGURE_ARGS?= # empty
CONFIG_SHELL?= ${SH}
CONFIG_SHELL_FLAGS?= # none
CMAKE_ARGS?= # empty
CMAKE_ARG_PATH?= .
_BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS CMAKE_ARGS

.if defined(GNU_CONFIGURE)
. include "gnu-configure.mk"
.endif
.if defined(OVERRIDE_GNU_CONFIG_SCRIPTS)
. include "config-override.mk"
.endif
.if defined(INSTALL_SH_OVERRIDE) && empty(INSTALL_SH_OVERRIDE:M[Nn][Oo])
. include "install-sh-override.mk"
.endif
.if defined(USE_LIBTOOL)
. include "libtool-override.mk"
.endif
.if defined(PKGCONFIG_OVERRIDE)
. include "pkg-config-override.mk"
.endif
.include "replace-interpreter.mk"
.if defined(USE_PKGLOCALEDIR)
. include "replace-localedir.mk"
.endif
.if defined(USE_CMAKE)
. include "cmake.mk"
.endif

######################################################################
### configure (PUBLIC)
######################################################################
### configure is a public target to configure the sources for building.
###
_CONFIGURE_TARGETS+= check-vulnerable
_CONFIGURE_TARGETS+= wrapper
_CONFIGURE_TARGETS+= acquire-configure-lock
_CONFIGURE_TARGETS+= ${_COOKIE.configure}
_CONFIGURE_TARGETS+= release-configure-lock

.PHONY: configure
.if !target(configure)
. if exists(${_COOKIE.configure})
configure:
@${DO_NADA}
. elif defined(_PKGSRC_BARRIER)
configure: ${_CONFIGURE_TARGETS}
. else
configure: barrier
. endif
.endif

.PHONY: acquire-configure-lock release-configure-lock
acquire-configure-lock: acquire-lock
release-configure-lock: release-lock

.if exists(${_COOKIE.configure})
${_COOKIE.configure}:
@${DO_NADA}
.else
${_COOKIE.configure}: real-configure
.endif

######################################################################
### real-configure (PRIVATE)
######################################################################
### real-configure is a helper target onto which one can hook all of the
### targets that do the actual configuration of the sources.
###
#
# Note: pre-configure-checks-hook comes after pre-configure to allow
# packages for fixing bad files with SUBST_STAGE.* = pre-configure.
#
_REAL_CONFIGURE_TARGETS+= configure-check-interactive
_REAL_CONFIGURE_TARGETS+= configure-message
_REAL_CONFIGURE_TARGETS+= configure-vars
_REAL_CONFIGURE_TARGETS+= pre-configure
_REAL_CONFIGURE_TARGETS+= do-configure-pre-hook
_REAL_CONFIGURE_TARGETS+= pre-configure-checks-hook
_REAL_CONFIGURE_TARGETS+= do-configure
_REAL_CONFIGURE_TARGETS+= do-configure-post-hook
_REAL_CONFIGURE_TARGETS+= post-configure
_REAL_CONFIGURE_TARGETS+= _configure-cookie
_REAL_CONFIGURE_TARGETS+= error-check

.PHONY: real-configure
real-configure: ${_REAL_CONFIGURE_TARGETS}

.PHONY: configure-message
configure-message:
@${PHASE_MSG} "Configuring for ${PKGNAME}"

######################################################################
### configure-check-interactive (PRIVATE)
######################################################################
### configure-check-interactive checks whether we must do an interactive
### configuration or not.
###
configure-check-interactive:
.if !empty(INTERACTIVE_STAGE:Mconfigure) && defined(BATCH)
@${ERROR_MSG} "The configure stage of this package requires user interaction"
@${ERROR_MSG} "Please configure manually with:"
@${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} configure\""
${RUN} ${FALSE}
.else
@${DO_NADA}
.endif

######################################################################
### do-configure-pre-hook (PRIVATE)
######################################################################
### do-configure-pre-hook is a helper target onto which one can hook
### all of the targets that should be run after pre-configure but before
### do-configure. These targets typically edit the files used by the
### do-configure target.
###
.PHONY: do-configure-pre-hook
do-configure-pre-hook:
@${DO_NADA}

######################################################################
### do-configure-post-hook (PRIVATE)
######################################################################
### do-configure-post-hook is a helper target onto which one can hook
### all of the targets that should be run after do-configure but before
### post-configure. These targets typically edit the files generated
### by the do-configure target that are used during the build phase.
###
.PHONY: do-configure-post-hook
do-configure-post-hook:
@${DO_NADA}

######################################################################
### do-configure-script (PRIVATE)
######################################################################
### do-configure-script runs the configure script to configure the
### software for building.
###
_CONFIGURE_SCRIPT_ENV+= INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP}
_CONFIGURE_SCRIPT_ENV+= INSTALL_PROGRAM=${INSTALL_PROGRAM:Q}
_CONFIGURE_SCRIPT_ENV+= INSTALL_SCRIPT=${INSTALL_SCRIPT:Q}
_CONFIGURE_SCRIPT_ENV+= INSTALL_DATA=${INSTALL_DATA:Q}
_CONFIGURE_SCRIPT_ENV+= INSTALL_GAME=${INSTALL_GAME:Q}
_CONFIGURE_SCRIPT_ENV+= INSTALL_GAME_DATA=${INSTALL_GAME_DATA:Q}
_CONFIGURE_SCRIPT_ENV+= ${CONFIGURE_ENV}

.PHONY: do-configure-script
do-configure-script:
.for _dir_ in ${CONFIGURE_DIRS}
${RUN}${_ULIMIT_CMD} \
cd ${WRKSRC} && cd ${_dir_} && \
${SETENV} ${_CONFIGURE_SCRIPT_ENV} \
${CONFIG_SHELL} ${CONFIG_SHELL_FLAGS} \
${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
.endfor

######################################################################
### do-configure-imake (PRIVATE)
######################################################################
### do-configure-imake runs xmkmf and imake to configure the software
### for building.
###
_CONFIGURE_IMAKE_ENV+= XPROJECTROOT=${X11BASE:Q}
_CONFIGURE_IMAKE_ENV+= ${SCRIPTS_ENV}

.PHONY: do-configure-imake
do-configure-imake:
.for _dir_ in ${CONFIGURE_DIRS}
${RUN} \
cd ${WRKSRC} && cd ${_dir_} && \
${SETENV} ${_CONFIGURE_IMAKE_ENV} ${XMKMF}
.endfor

######################################################################
### do-configure-cmake (PRIVATE)
######################################################################
### do-configure-cmake runs cmake to configure the software for
### building.
###
_CONFIGURE_CMAKE_ENV+= BUILDLINK_DIR=${BUILDLINK_DIR}
_CONFIGURE_CMAKE_ENV+= ${CONFIGURE_ENV}


.PHONY: do-configure-cmake
do-configure-cmake:
.for _dir_ in ${CONFIGURE_DIRS}
${RUN}${_ULIMIT_CMD} \
cd ${WRKSRC} && cd ${_dir_} && \
${SETENV} ${_CONFIGURE_CMAKE_ENV} \
cmake ${CMAKE_ARGS} ${CMAKE_ARG_PATH}
.endfor

######################################################################
### pre-configure, do-configure, post-configure (PUBLIC, override)
######################################################################
### {pre,do,post}-configure are the heart of the package-customizable
### configure targets, and may be overridden within a package Makefile.
###
.PHONY: pre-configure do-configure post-configure

_DO_CONFIGURE_TARGETS+= ${HAS_CONFIGURE:D do-configure-script}
_DO_CONFIGURE_TARGETS+= ${USE_IMAKE:D do-configure-imake}
_DO_CONFIGURE_TARGETS+= ${USE_CMAKE:D do-configure-cmake}

.if !target(do-configure)
do-configure: ${_DO_CONFIGURE_TARGETS}
@${DO_NADA}
.endif

.if !target(pre-configure)
pre-configure:
@${DO_NADA}
.endif

.if !target(post-configure)
post-configure:
@${DO_NADA}
.endif

# configure-help:
# Runs ${CONFIGURE_SCRIPT} --help. It is mainly intended for
# package developers so they can quickly see the options of the
# configure script.
#
configure-help:
.for d in ${CONFIGURE_DIRS}
${RUN} cd ${WRKSRC} && cd ${d} && ${SETENV} ${_CONFIGURE_SCRIPT_ENV} ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} --help
.endfor

gnu-configure.mk

# $NetBSD: gnu-configure.mk,v 1.9 2009/09/12 00:52:45 joerg Exp $

_VARGROUPS+= gnu-configure
_USER_VARS.gnu-configure= # none
_PKG_VARS.gnu-configure= GNU_CONFIGURE GNU_CONFIGURE_PREFIX \
GNU_CONFIGURE_INFODIR GNU_CONFIGURE_MANDIR \
CONFIGURE_HAS_MANDIR CONFIGURE_HAS_INFODIR \
OVERRIDE_DIRDEPTH.configure \
USE_GNU_CONFIGURE_HOST

HAS_CONFIGURE= defined
OVERRIDE_GNU_CONFIG_SCRIPTS= defined
INSTALL_SH_OVERRIDE?= # empty

CONFIGURE_ENV+= CONFIG_SHELL=${CONFIG_SHELL:Q}
CONFIGURE_ENV+= LIBS=${LIBS:M*:Q}
CONFIGURE_ENV+= ac_given_INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP}

.if (defined(USE_LIBTOOL) || !empty(PKGPATH:Mdevel/libtool-base)) && \
defined(_OPSYS_MAX_CMDLEN_CMD)
CONFIGURE_ENV+= lt_cv_sys_max_cmd_len=${_OPSYS_MAX_CMDLEN_CMD:sh}
.endif

GNU_CONFIGURE_PREFIX?= ${PREFIX}
CONFIGURE_ARGS+= --prefix=${GNU_CONFIGURE_PREFIX:Q}

USE_GNU_CONFIGURE_HOST?= yes
.if !empty(USE_GNU_CONFIGURE_HOST:M[yY][eE][sS])
. if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
CONFIGURE_ARGS+= --build=${NATIVE_MACHINE_GNU_PLATFORM:Q}
. else
CONFIGURE_ARGS+= --build=${MACHINE_GNU_PLATFORM:Q}
. endif
CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM:Q}
.endif

# PKGINFODIR is the subdirectory of ${PREFIX} into which the info
# files are installed unless the software was configured with an
# installation prefix other than ${PREFIX}.
#
CONFIGURE_HAS_INFODIR?= yes
.if ${GNU_CONFIGURE_PREFIX} == ${PREFIX}
GNU_CONFIGURE_INFODIR?= ${GNU_CONFIGURE_PREFIX}/${PKGINFODIR}
.else
GNU_CONFIGURE_INFODIR?= ${GNU_CONFIGURE_PREFIX}/info
.endif
.if defined(INFO_FILES) && !empty(CONFIGURE_HAS_INFODIR:M[yY][eE][sS])
CONFIGURE_ARGS+= --infodir=${GNU_CONFIGURE_INFODIR:Q}
.endif

# PKGMANDIR is the subdirectory of ${PREFIX} into which the man and
# catman pages are installed unless the software was configured with
# an installation prefix other than ${PREFIX}.
#
CONFIGURE_HAS_MANDIR?= yes
.if ${GNU_CONFIGURE_PREFIX} == ${PREFIX}
GNU_CONFIGURE_MANDIR?= ${GNU_CONFIGURE_PREFIX}/${PKGMANDIR}
.else
GNU_CONFIGURE_MANDIR?= ${GNU_CONFIGURE_PREFIX}/man
.endif
.if !empty(CONFIGURE_HAS_MANDIR:M[yY][eE][sS])
CONFIGURE_ARGS+= --mandir=${GNU_CONFIGURE_MANDIR:Q}
.endif

######################################################################
### configure-scripts-override (PRIVATE)
######################################################################
### configure-scripts-override modifies the GNU configure scripts in
### ${WRKSRC} so that the generated config.status scripts never do
### anything on "--recheck". This is important in pkgsrc because we
### only ever want to run the configure checks during the configure
### phase, and "recheck" is often run during the build and install
### phases.
###
do-configure-pre-hook: configure-scripts-override

_SCRIPT.configure-scripts-override= \
${AWK} '/ *-recheck *\| *--recheck.*\)/ { \
print; \
print " : Avoid regenerating within pkgsrc"; \
print " exit 0"; \
next; \
} \
{ print }' $$file > $$file.override; \
${CHMOD} +x $$file.override; \
${MV} -f $$file.override $$file

OVERRIDE_DIRDEPTH.configure?= ${OVERRIDE_DIRDEPTH}

.PHONY: configure-scripts-override
configure-scripts-override:
@${STEP_MSG} "Modifying GNU configure scripts to avoid --recheck"
.if defined(CONFIGURE_SCRIPTS_OVERRIDE) && !empty(CONFIGURE_SCRIPTS_OVERRIDE)
@echo HERE
${RUN} \
cd ${WRKSRC}; \
for file in ${CONFIGURE_SCRIPTS_OVERRIDE}; do \
${TEST} -f "$$file" || continue; \
${_SCRIPT.${.TARGET}}; \
done
.else
${RUN} \
cd ${WRKSRC}; \
depth=0; pattern=${CONFIGURE_SCRIPT:T}; \
while ${TEST} $$depth -le ${OVERRIDE_DIRDEPTH.configure}; do \
for file in $$pattern; do \
${TEST} -f "$$file" || continue; \
${_SCRIPT.${.TARGET}}; \
done; \
depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
done
.endif

install-sh-override.mk

# $NetBSD: install-sh-override.mk,v 1.2 2008/02/07 21:36:13 rillig Exp $

######################################################################
### install-sh-override (PRIVATE)
######################################################################
### install-sh-override replace any existing install-sh under
### ${WRKSRC} with the version from sysutils/install-sh, which works
### on all pkgsrc platforms, in particular Interix.
###
do-configure-pre-hook: install-sh-override

OVERRIDE_DIRDEPTH.install-sh?= ${OVERRIDE_DIRDEPTH}

_SCRIPT.install-sh-override= \
${RM} -f $$file; \
${SED} -e "s|@DEFAULT_INSTALL_MODE@|${PKGDIRMODE}|g" \
${PKGSRCDIR}/sysutils/install-sh/files/install-sh.in \
> $$file; \
${CHMOD} +x $$file

.PHONY: install-sh-override
install-sh-override:
@${STEP_MSG} "Replacing install-sh with pkgsrc version"
.if defined(INSTALL_SH_OVERRIDE) && !empty(INSTALL_SH_OVERRIDE)
${RUN} \
cd ${WRKSRC}; \
set -- dummy ${INSTALL_SH_OVERRIDE}; shift; \
while [ $$# -gt 0 ]; do \
file="$$1"; shift; \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done
.else
${RUN} \
cd ${WRKSRC}; \
depth=0; pattern=install-sh; \
while [ $$depth -le ${OVERRIDE_DIRDEPTH.install-sh} ]; do \
for file in $$pattern; do \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done; \
depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
done
.endif

libtool-override.mk

# $NetBSD: libtool-override.mk,v 1.10 2008/02/07 21:36:13 rillig Exp $

######################################################################
### {libtool,shlibtool}-override (PRIVATE)
######################################################################
### {libtool,shlibtool}-override replace any existing libtool under
### ${WRKSRC} with the version installed by pkgsrc.
###
do-configure-post-hook: libtool-override
.if defined(SHLIBTOOL_OVERRIDE)
do-configure-post-hook: shlibtool-override
.endif

OVERRIDE_DIRDEPTH.libtool?= ${OVERRIDE_DIRDEPTH}
OVERRIDE_DIRDEPTH.shlibtool?= ${OVERRIDE_DIRDEPTH}

_OVERRIDE_PATH.libtool= ${_LIBTOOL}
_OVERRIDE_PATH.shlibtool= ${_SHLIBTOOL}

.for _script_ in libtool shlibtool
_SCRIPT.${_script_}-override= \
${RM} -f $$file; \
${ECHO} "\#!"${TOOLS_SH:Q} > $$file; \
${ECHO} "exec" ${_OVERRIDE_PATH.${_script_}:Q} '"$$@"' >> $$file; \
${CHMOD} +x $$file
.endfor

.PHONY: libtool-override
libtool-override:
@${STEP_MSG} "Modifying libtool scripts to use pkgsrc libtool"
.if defined(LIBTOOL_OVERRIDE)
${RUN} \
cd ${WRKSRC}; \
set -- dummy ${LIBTOOL_OVERRIDE}; shift; \
while [ $$# -gt 0 ]; do \
file="$$1"; shift; \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done
.else
${RUN} \
cd ${WRKSRC}; \
depth=0; pattern=libtool; \
while [ $$depth -le ${OVERRIDE_DIRDEPTH.libtool} ]; do \
for file in $$pattern; do \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done; \
depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
done
.endif

.PHONY: shlibtool-override
shlibtool-override:
@${STEP_MSG} "Modifying libtool scripts to use pkgsrc shlibtool"
.if defined(SHLIBTOOL_OVERRIDE) && !empty(SHLIBTOOL_OVERRIDE)
${RUN} \
cd ${WRKSRC}; \
set -- dummy ${SHLIBTOOL_OVERRIDE}; shift; \
while [ $$# -gt 0 ]; do \
file="$$1"; shift; \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done
.else
${RUN} \
cd ${WRKSRC}; \
depth=0; pattern=libtool; \
while [ $$depth -le ${OVERRIDE_DIRDEPTH.shlibtool} ]; do \
for file in $$pattern; do \
[ -f "$$file" ] || [ -h "$$file" ] || continue; \
${_SCRIPT.${.TARGET}}; \
done; \
depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
done
.endif

pkg-config-override.mk

# $NetBSD: pkg-config-override.mk,v 1.3 2007/07/25 18:07:34 rillig Exp $

# Package-settable variables:
#
# PKGCONFIG_OVERRIDE
# The list of pkg-config files relative to WRKSRC in which the
# compiler flags need to be adjusted.
#
# PKGCONFIG_OVERRIDE_STAGE
# The stage in which the pkg-config files will be adjusted. By
# default, this is pre-configure.
#

######################################################################
### pkg-config-override (PRIVATE)
######################################################################
### pkg-config-override inserts the compiler's "rpath" flag into
### pkg-config data files so that ``pkg-config --ldflags '' will
### return the full set of compiler flags needed to find libraries at
### run-time.
###
.PHONY: pkg-config-override
pkg-config-override:
@${DO_NADA}

.if defined(_USE_RPATH) && !empty(_USE_RPATH:M[yY][eE][sS])
pkg-config-override: subst-pkgconfig

PKGCONFIG_OVERRIDE_SED= \
'/^Libs:.*[ ]/s|-L\([ ]*[^ ]*\)|${COMPILER_RPATH_FLAG}\1 -L\1|g'
PKGCONFIG_OVERRIDE_STAGE?= pre-configure

SUBST_CLASSES+= pkgconfig
. if ${PKGCONFIG_OVERRIDE_STAGE} == "pre-configure"
SUBST_STAGE.pkgconfig= do-configure-pre-hook
. elif ${PKGCONFIG_OVERRIDE_STAGE} == "post-configure"
SUBST_STAGE.pkgconfig= do-configure-post-hook
. else
SUBST_STAGE.pkgconfig= ${PKGCONFIG_OVERRIDE_STAGE}
. endif
SUBST_MESSAGE.pkgconfig= Adding run-time search paths to pkg-config files.
SUBST_FILES.pkgconfig= ${PKGCONFIG_OVERRIDE:S/^${WRKSRC}\///}
SUBST_SED.pkgconfig= ${PKGCONFIG_OVERRIDE_SED}
.endif

replace-interpreter.mk

# $NetBSD: replace-interpreter.mk,v 1.9 2008/02/07 21:36:13 rillig Exp $

# This file provides common templates for replacing #! interpreters
# in script files.
#
# The following variables may be set by a package:
#
# REPLACE_AWK
# REPLACE_BASH
# REPLACE_KSH
# REPLACE_PERL
# REPLACE_PYTHON
# REPLACE_SH
# Lists of files relative to WRKSRC in which the #! interpreter
# should be replaced by the pkgsrc one. If any directories
# appear in the lists, they are silenty skipped, assuming that
# they result from shell globbing expressions.
#
# Use REPLACE_SH for shell programs that don't need any
# special features from bash, and REPLACE_BASH for the
# others.
#
# Note that in all the above cases, you have to add the needed
# tools manually to USE_TOOLS, since there is no way to detect
# automatically whether a tool should be a build-time or a
# run-time dependency.
#
# Packages may also add their own interpreter replacements, which should
# just look like the examples below. For the REPLACE_INTERPRETER
# variable, all identifiers starting with "sys-" are reserved for the
# pkgsrc infrastructure. All others may be used freely.
#
# Keywords: replace_interpreter interpreter interp

######################################################################
### replace-interpreter (PRIVATE)
######################################################################
### replace-interpreter replaces paths to interpreters in scripts with
### the paths to the pkgsrc-managed interpreters.
###
do-configure-pre-hook: replace-interpreter

REPLACE_INTERPRETER?= # none
REPLACE_AWK?= # none
REPLACE_BASH?= # none
REPLACE_KSH?= # none
REPLACE_PERL?= # none
REPLACE_SH?= # none

.if !empty(REPLACE_AWK:M*)
REPLACE_INTERPRETER+= sys-AWK
REPLACE.sys-AWK.old= .*awk
REPLACE.sys-AWK.new= ${AWK}
REPLACE_FILES.sys-AWK= ${REPLACE_AWK}
.endif

.if !empty(REPLACE_BASH:M*)
REPLACE_INTERPRETER+= sys-bash
REPLACE.sys-bash.old= .*sh
REPLACE.sys-bash.new= ${BASH}
REPLACE_FILES.sys-bash= ${REPLACE_BASH}
.endif

.if !empty(REPLACE_KSH:M*)
REPLACE_INTERPRETER+= sys-ksh
REPLACE.sys-ksh.old= [^[:space:]]*sh
REPLACE.sys-ksh.new= ${TOOLS_PATH.ksh}
REPLACE_FILES.sys-ksh= ${REPLACE_KSH}
.endif

.if !empty(REPLACE_PERL:M*)
REPLACE_INTERPRETER+= sys-Perl
REPLACE.sys-Perl.old= .*perl[^[:space:]]*
REPLACE.sys-Perl.new= ${PERL5}
REPLACE_FILES.sys-Perl= ${REPLACE_PERL}
.endif

.if !empty(REPLACE_SH:M*)
REPLACE_INTERPRETER+= sys-sh
REPLACE.sys-sh.old= [^[:space:]]*sh
REPLACE.sys-sh.new= ${SH}
REPLACE_FILES.sys-sh= ${REPLACE_SH}
.endif

.PHONY: replace-interpreter
replace-interpreter:
.for _lang_ in ${REPLACE_INTERPRETER}
. if defined(REPLACE_FILES.${_lang_}) && !empty(REPLACE_FILES.${_lang_}:M*)
@${STEP_MSG} "Replacing ${_lang_:S/^sys-//} interpreter in "${REPLACE_FILES.${_lang_}:M*:Q}"."
${RUN} set -u; \
cd ${WRKSRC}; \
for f in ${REPLACE_FILES.${_lang_}}; do \
if [ -f "$${f}" ]; then \
${SED} -e '1s|^#![[:space:]]*${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \
< "$${f}" > "$${f}.new"; \
if [ -x "$${f}" ]; then \
${CHMOD} a+x "$${f}.new"; \
fi; \
${MV} -f "$${f}.new" "$${f}"; \
elif [ -d "$$f" ]; then \
${SHCOMMENT} "Ignore it, most probably comes from shell globs"; \
else \
${WARNING_MSG} "[replace-interpreter] Skipping non-existent file \"$$f\"."; \
fi; \
done
. else
@${WARNING_MSG} "[replace-interpreter] Empty list of files for ${_lang_}."
. endif
.endfor

replace-localedir.mk

# $NetBSD: replace-localedir.mk,v 1.2 2006/08/03 16:49:48 salo Exp $

######################################################################
### replace-localedir (PRIVATE)
######################################################################
### replace-localedir replaces the path to the locale directory in
### various Makefiles with the one chosen by pkgsrc (PKGLOCALEDIR).
###
.PHONY: replace-localedir
replace-localedir:
@${DO_NADA}

replace-localedir: subst-pkglocaledir

_PKGLOCALEDIR= ${PREFIX}/${PKGLOCALEDIR}/locale

REPLACE_LOCALEDIR_PATTERNS?= # empty
_REPLACE_LOCALEDIR_PATTERNS= ${REPLACE_LOCALEDIR_PATTERNS}
.if defined(HAS_CONFIGURE)
_REPLACE_LOCALEDIR_PATTERNS+= [Mm]akefile.in*
.else
_REPLACE_LOCALEDIR_PATTERNS+= [Mm]akefile*
.endif
_REPLACE_LOCALEDIR_PATTERNS_FIND_cmd= \
cd ${WRKSRC} && \
${ECHO} "__dummy-entry__" && \
${FIND} . \( ${_REPLACE_LOCALEDIR_PATTERNS:C/.*/-o -name "&"/g:S/-o//1} \) -print | \
${SED} -e 's|^\./||' | \
${SORT} -u

REPLACE_LOCALEDIR?= # empty
_REPLACE_LOCALEDIR= \
${REPLACE_LOCALEDIR} \
${_REPLACE_LOCALEDIR_PATTERNS_FIND_cmd:sh:N__dummy-entry__:N*.orig}

.if empty(USE_PKGLOCALEDIR:M[nN][oO])
SUBST_CLASSES+= pkglocaledir
.endif
SUBST_STAGE.pkglocaledir= do-configure-pre-hook
SUBST_MESSAGE.pkglocaledir= Fixing locale directory references.
SUBST_FILES.pkglocaledir= ${_REPLACE_LOCALEDIR}
SUBST_SED.pkglocaledir= \
-e 's|^\(localedir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
-e 's|^\(itlocaledir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
-e 's|^\(gnulocaledir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
-e 's|\(-DLOCALEDIR[ ]*=\)[^ ]*\(\.\*\)|\1"\\"${_PKGLOCALEDIR}\\""\2|'