summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2006-07-05 06:09:15 +0000
committerjlam <jlam>2006-07-05 06:09:15 +0000
commitfb2264d773c37f606d8a4684e0599019bafbcdf7 (patch)
tree5cda57cdca85b18146d681fc321900e0b05b7666 /mk
parent7a214e80a1d117a1dc986293ccb493d6eb35032e (diff)
downloadpkgsrc-fb2264d773c37f606d8a4684e0599019bafbcdf7.tar.gz
Refactor configure, build, test and wrapper phases out of bsd.pkg.mk
and into their own directories. Also do some cleanups with build/_build and pkginstall -- we get rid of _build and simply run pkginstall as part of the "build" target. Introduce a new mechanism to handle varying directory depths under ${WRKSRC} in which we find files to override, e.g. configure, config.*, libtool, etc. OVERRIDE_DIRDEPTH is a package-settable variable that specifies how far under ${WRKSRC} the various targets should look, and it defaults to "2". We preserve the meaning of the various *_OVERRIDE variables, so if they are defined, then their values supersede the OVERRIDE_DIRDEPTH mechanism. devel/tla will need to specially set OVERRIDE_DIRDEPTH to 3 (see log for revision 1.1857 for bsd.pkg.mk -- to be done in a separate commit.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk591
-rw-r--r--mk/build/bsd.build-vars.mk47
-rw-r--r--mk/build/bsd.build.mk43
-rw-r--r--mk/build/build.mk119
-rw-r--r--mk/build/test.mk123
-rw-r--r--mk/configure/bsd.configure-vars.mk27
-rw-r--r--mk/configure/bsd.configure.mk39
-rw-r--r--mk/configure/config-override.mk51
-rw-r--r--mk/configure/configure.mk216
-rw-r--r--mk/configure/gnu-configure.mk100
-rw-r--r--mk/configure/libtool-override.mk83
-rw-r--r--mk/configure/pkg-config-override.mk33
-rw-r--r--mk/configure/replace-interpreter.mk48
-rw-r--r--mk/configure/replace-localedir.mk45
-rw-r--r--mk/pkginstall/bsd.pkginstall.mk3
-rw-r--r--mk/wrapper/bsd.wrapper.mk67
16 files changed, 1050 insertions, 585 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index f3fc5ed5e80..279e60a35f0 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1857 2006/06/18 09:40:25 rillig Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1858 2006/07/05 06:09:15 jlam Exp $
#
# This file is in the public domain.
#
@@ -26,6 +26,8 @@
.include "${PKGSRCDIR}/mk/fetch/bsd.fetch-vars.mk"
.include "${PKGSRCDIR}/mk/extract/bsd.extract-vars.mk"
.include "${PKGSRCDIR}/mk/patch/bsd.patch-vars.mk"
+.include "${PKGSRCDIR}/mk/configure/bsd.configure-vars.mk"
+.include "${PKGSRCDIR}/mk/build/bsd.build-vars.mk"
.include "${PKGSRCDIR}/mk/install/bsd.install-vars.mk"
.include "${PKGSRCDIR}/mk/bsd.pkg.error.mk"
@@ -99,18 +101,13 @@ PKGNAME_NOREV= ${PKGNAME}
##### Others
BUILD_DEPENDS?= # empty
-BUILD_TARGET?= all
COMMENT?= (no description)
-CONFIGURE_DIRS?= ${WRKSRC}
-CONFIGURE_SCRIPT?= ./configure
DEPENDS?= # empty
DESCR_SRC?= ${PKGDIR}/DESCR
DIGEST_ALGORITHMS?= SHA1 RMD160
DISTINFO_FILE?= ${PKGDIR}/distinfo
INTERACTIVE_STAGE?= none
MAINTAINER?= pkgsrc-users@NetBSD.org
-MAKE_FLAGS?= # empty
-MAKEFILE?= Makefile
PATCH_DIGEST_ALGORITHM?=SHA1
PKGWILDCARD?= ${PKGBASE}-[0-9]*
SVR4_PKGNAME?= ${PKGNAME}
@@ -239,40 +236,6 @@ ALL_ENV+= LINKER_RPATH_FLAG=${LINKER_RPATH_FLAG:Q}
ALL_ENV+= PATH=${PATH:Q}:${LOCALBASE}/bin:${X11BASE}/bin
ALL_ENV+= PREFIX=${PREFIX}
-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}
-
-# Constants to provide a consistent environment for packages using
-# BSD-style Makefiles.
-MAKE_ENV+= MAKECONF=${PKGMAKECONF:U/dev/null}
-MAKE_ENV+= OBJECT_FMT=${OBJECT_FMT:Q}
-MAKE_ENV+= ${USETOOLS:DUSETOOLS=${USETOOLS:Q}}
-
-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}
-
-CONFIGURE_ENV+= ${ALL_ENV}
-
# Store the result in the +BUILD_INFO file so we can query for the build
# options using "pkg_info -Q PKG_OPTIONS <pkg>".
#
@@ -295,22 +258,6 @@ _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_}};@}
-# If GNU_CONFIGURE is defined, then pass LIBS to the GNU configure script.
-# also pass in a CONFIG_SHELL to avoid picking up bash
-.if defined(GNU_CONFIGURE)
-CONFIG_SHELL?= ${SH}
-CONFIGURE_ENV+= CONFIG_SHELL=${CONFIG_SHELL:Q}
-CONFIGURE_ENV+= LIBS=${LIBS:M*:Q}
-CONFIGURE_ENV+= install_sh=${INSTALL:Q}
-. if (defined(USE_LIBTOOL) || !empty(PKGDIR:M*/libtool-base)) && defined(_OPSYS_MAX_CMDLEN_CMD)
-CONFIGURE_ENV+= lt_cv_sys_max_cmd_len=${_OPSYS_MAX_CMDLEN_CMD:sh}
-. endif
-.endif
-
-_WRAPPER_COOKIE= ${WRKDIR}/.wrapper_done
-_CONFIGURE_COOKIE= ${WRKDIR}/.configure_done
-_BUILD_COOKIE= ${WRKDIR}/.build_done
-_TEST_COOKIE= ${WRKDIR}/.test_done
_INTERACTIVE_COOKIE= ${.CURDIR}/.interactive_stage
_NULL_COOKIE= ${WRKDIR}/.null
@@ -395,6 +342,13 @@ _PKGSRC_BUILD_TARGETS= build test
_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
+
# The user can override the NO_PACKAGE by specifying this from
# the make command line
.if defined(FORCE_PACKAGE)
@@ -447,59 +401,6 @@ ERROR_CAT?= ${SED} -e "s|^|ERROR: |" 1>&2
# do something.
DO_NADA?= ${TRUE}
-.if defined(GNU_CONFIGURE)
-HAS_CONFIGURE= yes
-
-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])
-CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM:Q}
-. endif
-
-# Support for alternative info directories in packages is very sketchy.
-# For now, if we configure a package to install entirely into a
-# subdirectory of ${PREFIX}, then root the info directory directly under
-# that subdirectory.
-#
-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
-
-CONFIGURE_HAS_MANDIR?= yes
-GNU_CONFIGURE_MANDIR?= ${GNU_CONFIGURE_PREFIX}/${PKGMANDIR}
-. if !empty(CONFIGURE_HAS_MANDIR:M[yY][eE][sS])
-CONFIGURE_ARGS+= --mandir=${GNU_CONFIGURE_MANDIR:Q}
-. endif
-
-#
-# By default, override GNU configure scripts so that the generated
-# config.status scripts never do anything on "recheck".
-#
-CONFIGURE_SCRIPTS_OVERRIDE?= \
- configure */configure */*/configure
-.endif
-
-.if defined(GNU_CONFIGURE) || defined(OVERRIDE_GNU_CONFIG_SCRIPTS)
-#
-# By default, override config.guess and config.sub for GNU configure
-# packages. pkgsrc's updated versions of these scripts allows GNU
-# configure to recognise NetBSD ports such as shark.
-#
-CONFIG_GUESS_OVERRIDE?= \
- config.guess */config.guess */*/config.guess */*/*/config.guess
-CONFIG_SUB_OVERRIDE?= \
- config.sub */config.sub */*/config.sub */*/*/config.sub
-CONFIG_RPATH_OVERRIDE?= # set by platform file as needed
-.endif
-
#
# Config file related settings - see doc/pkgsrc.txt
#
@@ -608,11 +509,6 @@ _PATH_CMD= \
PATH= ${_PATH_CMD:sh} # DOES NOT use :=, to defer evaluation
.endif
-# Add these bits to the environment use when invoking the sub-make
-# processes for build-related phases.
-#
-BUILD_ENV+= PATH=${PATH:Q}
-
.MAIN: all
################################################################
@@ -731,7 +627,6 @@ do-check-pkg-fail-reason: do-check-pkg-fail-or-skip-reason
BUILD_DEFS+= PKGPATH
BUILD_DEFS+= OPSYS OS_VERSION MACHINE_ARCH MACHINE_GNU_ARCH
BUILD_DEFS+= CPPFLAGS CFLAGS FFLAGS LDFLAGS
-BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS
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
@@ -761,27 +656,6 @@ checksum: fetch
@${DO_NADA}
.endif
-# Disable wrapper
-.PHONY: wrapper
-.if defined(NO_BUILD) && !target(wrapper)
-wrapper: patch
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_WRAPPER_COOKIE}
-.endif
-
-# Disable configure
-.PHONY: configure
-.if defined(NO_CONFIGURE) && !target(configure)
-configure: wrapper
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_CONFIGURE_COOKIE}
-.endif
-
-# Disable build
-.PHONY: _build
-.if defined(NO_BUILD)
-_build: configure
- ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${_BUILD_COOKIE}
-.endif
-
################################################################
# More standard targets start here.
#
@@ -880,297 +754,6 @@ makedirs: ${.CURDIR}/${WRKDIR_BASENAME}
fi
.endif
-
-# Configure
-
-# _CONFIGURE_PREREQ is a list of targets to run after pre-configure but before
-# do-configure. These targets typically edit the files used by the
-# do-configure target. The targets are run as dependencies of
-# pre-configure-override.
-#
-# _CONFIGURE_POSTREQ is a list of targets to 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.
-
-.if defined(USE_PKGLOCALEDIR)
-_PKGLOCALEDIR= ${PREFIX}/${PKGLOCALEDIR}/locale
-REPLACE_LOCALEDIR_PATTERNS?= # empty
-_REPLACE_LOCALEDIR_PATTERNS= ${REPLACE_LOCALEDIR_PATTERNS}
-. if defined(HAS_CONFIGURE) || defined(GNU_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}
-
-_CONFIGURE_PREREQ+= subst-pkglocaledir
-. if empty(USE_PKGLOCALEDIR:M[nN][oO])
-SUBST_CLASSES+= pkglocaledir
-. endif
-SUBST_MESSAGE.pkglocaledir= Fixing locale directory references.
-SUBST_FILES.pkglocaledir= ${_REPLACE_LOCALEDIR}
-SUBST_SED.pkglocaledir= \
- -e 's|^\(localedir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
- -e 's|^\(gnulocaledir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
- -e 's|\(-DLOCALEDIR[ ]*=\)[^ ]*\(\.\*\)|\1"\\"${_PKGLOCALEDIR}\\""\2|'
-.endif
-
-.if defined(REPLACE_PERL)
-REPLACE_INTERPRETER+= perl
-REPLACE.perl.old= .*/bin/perl
-REPLACE.perl.new= ${PERL5}
-REPLACE_FILES.perl= ${REPLACE_PERL}
-.endif
-
-.if defined(REPLACE_INTERPRETER)
-
-# After 2006Q2, all instances of _REPLACE.* and _REPLACE_FILES.* should
-# have been replaced with REPLACE.* and REPLACE_FILES.*. This code is
-# then no longer needed.
-. for _lang_ in ${REPLACE_INTERPRETER}
-REPLACE.${_lang_}.old?= ${_REPLACE.${_lang_}.old}
-REPLACE.${_lang_}.new?= ${_REPLACE.${_lang_}.new}
-REPLACE_FILES.${_lang_}?= ${_REPLACE_FILES.${_lang_}}
-. endfor
-
-_CONFIGURE_PREREQ+= replace-interpreter
-.PHONY: replace-interpreter
-replace-interpreter:
-. for lang in ${REPLACE_INTERPRETER}
-. for pattern in ${REPLACE_FILES.${lang}}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- cd ${WRKSRC}; \
- for f in ${pattern}; do \
- if [ -f $${f} ]; then \
- ${SED} -e '1s|^#!${REPLACE.${lang}.old}|#!${REPLACE.${lang}.new}|' \
- $${f} > $${f}.new; \
- if [ -x $${f} ]; then \
- ${CHMOD} a+x $${f}.new; \
- fi; \
- ${MV} -f $${f}.new $${f}; \
- else \
- ${ECHO_MSG} "[bsd.pkg.mk:replace-interpreter] WARNING: Skipping non-existent file \"$$f\"." 1>&2; \
- fi; \
- done
-. endfor
-. endfor
-.endif
-
-.if defined(USE_LIBTOOL) && defined(LTCONFIG_OVERRIDE)
-_CONFIGURE_PREREQ+= do-ltconfig-override
-.PHONY: do-ltconfig-override
-do-ltconfig-override:
-. for ltconfig in ${LTCONFIG_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -f ${ltconfig} ]; then \
- ${RM} -f ${ltconfig}; \
- ${ECHO} "${RM} -f libtool; ${LN} -s ${_LIBTOOL} libtool" \
- > ${ltconfig}; \
- ${CHMOD} +x ${ltconfig}; \
- fi
-. endfor
-.endif
-
-_CONFIGURE_PREREQ+= do-config-star-override
-.PHONY: do-config-star-override
-do-config-star-override:
-.if defined(GNU_CONFIGURE) || defined(OVERRIDE_GNU_CONFIG_SCRIPTS)
-. if !empty(CONFIG_GUESS_OVERRIDE)
-. for _pattern_ in ${CONFIG_GUESS_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC}; \
- for file in ${_pattern_}; do \
- if [ -f "$$file" ]; then \
- ${RM} -f $$file; \
- ${LN} -s ${PKGSRCDIR}/mk/gnu-config/config.guess \
- $$file; \
- fi; \
- done
-. endfor
-. endif
-. if !empty(CONFIG_SUB_OVERRIDE)
-. for _pattern_ in ${CONFIG_SUB_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC}; \
- for file in ${_pattern_}; do \
- if [ -f "$$file" ]; then \
- ${RM} -f $$file; \
- ${LN} -s ${PKGSRCDIR}/mk/gnu-config/config.sub \
- $$file; \
- fi; \
- done
-. endfor
-. endif
-. if !empty(CONFIG_RPATH_OVERRIDE)
-. for _pattern_ in ${CONFIG_RPATH_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC}; \
- for file in ${_pattern_}; do \
- if [ -f "$$file" ]; then \
- ${RM} -f $$file; \
- ${LN} -s ${PKGSRCDIR}/mk/gnu-config/config.rpath \
- $$file; \
- fi; \
- done
-. endfor
-. endif
-.endif
-
-.if defined(CONFIGURE_SCRIPTS_OVERRIDE)
-_CONFIGURE_PREREQ+= do-configure-scripts-override
-.PHONY: do-configure-scripts-override
-do-configure-scripts-override:
-. for _pattern_ in ${CONFIGURE_SCRIPTS_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC}; \
- for file in ${_pattern_}; do \
- if ${TEST} -f "$$file"; then \
- ${AWK} '/ *-recheck *\| *--recheck.*\)/ { \
- print; \
- print " # Avoid regenerating for rechecks on pkgsrc"; \
- print " exit 0"; \
- next; \
- } \
- { print }' $$file > $$file.override && \
- ${CHMOD} +x $$file.override && \
- ${MV} -f $$file.override $$file; \
- fi; \
- done
-. endfor
-.endif
-
-PKGCONFIG_OVERRIDE_SED= \
- '/^Libs:.*[ ]/s|-L\([ ]*[^ ]*\)|${COMPILER_RPATH_FLAG}\1 -L\1|g'
-PKGCONFIG_OVERRIDE_STAGE?= pre-configure
-
-.if defined(PKGCONFIG_OVERRIDE) && !empty(PKGCONFIG_OVERRIDE)
-. if ${PKGCONFIG_OVERRIDE_STAGE} == "pre-configure"
-_CONFIGURE_PREREQ+= subst-pkgconfig
-. elif ${PKGCONFIG_OVERRIDE_STAGE} == "post-configure"
-_CONFIGURE_POSTREQ+= subst-pkgconfig
-. else
-SUBST_STAGE.pkgconfig= ${PKGCONFIG_OVERRIDE_STAGE}
-. endif
-SUBST_CLASSES+= pkgconfig
-SUBST_MESSAGE.pkgconfig= Adding rpaths to pkgconfig files.
-SUBST_FILES.pkgconfig= ${PKGCONFIG_OVERRIDE:S/^${WRKSRC}\///}
-SUBST_SED.pkgconfig= ${PKGCONFIG_OVERRIDE_SED}
-.endif
-
-# By adding this target, it makes sure the above PREREQ's work.
-.PHONY: pre-configure-override
-pre-configure-override: ${_CONFIGURE_PREREQ}
- @${DO_NADA}
-
-.PHONY: do-configure
-.if !target(do-configure)
-do-configure:
-. if defined(HAS_CONFIGURE)
-. for _dir_ in ${CONFIGURE_DIRS}
- ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
- cd ${WRKSRC} && cd ${_dir_} && \
- ${SETENV} \
- AWK=${TOOLS_AWK:Q} \
- INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP} \
- ac_given_INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP} \
- INSTALL_DATA=${INSTALL_DATA:Q} \
- INSTALL_PROGRAM=${INSTALL_PROGRAM:Q} \
- INSTALL_GAME=${INSTALL_GAME:Q} \
- INSTALL_GAME_DATA=${INSTALL_GAME_DATA:Q} \
- INSTALL_SCRIPT=${INSTALL_SCRIPT:Q} \
- ${CONFIGURE_ENV} ${CONFIG_SHELL} \
- ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
-. endfor
-. endif
-. if defined(USE_IMAKE)
-. for _dir_ in ${CONFIGURE_DIRS}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- cd ${WRKSRC}; cd ${_dir_}; \
- ${SETENV} ${SCRIPTS_ENV} XPROJECTROOT=${X11BASE} ${XMKMF}
-. endfor
-. endif
-.endif
-
-.if defined(USE_LIBTOOL) && \
- (defined(LIBTOOL_OVERRIDE) || defined(SHLIBTOOL_OVERRIDE))
-_CONFIGURE_POSTREQ+= do-libtool-override
-.PHONY: do-libtool-override
-do-libtool-override:
-. if defined(LIBTOOL_OVERRIDE)
-. for _pattern_ in ${LIBTOOL_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC}; \
- for file in ${_pattern_}; do \
- if [ -f "$$file" ]; then \
- ${RM} -f $$file; \
- (${ECHO} '#!${CONFIG_SHELL}'; \
- ${ECHO} 'exec ${_LIBTOOL} "$$@"'; \
- ) > $$file; \
- ${CHMOD} +x $$file; \
- fi; \
- done
-. endfor
-. endif
-. if defined(SHLIBTOOL_OVERRIDE)
-. for _pattern_ in ${SHLIBTOOL_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC}; \
- for file in ${_pattern_}; do \
- if [ -f "$$file" ]; then \
- ${RM} -f $$file; \
- (${ECHO} '#!${CONFIG_SHELL}'; \
- ${ECHO} 'exec ${_SHLIBTOOL} "$$@"'; \
- ) > $$file; \
- ${CHMOD} +x $$file; \
- fi; \
- done
-. endfor
-. endif
-.endif
-
-.PHONY: post-configure
-post-configure: ${_CONFIGURE_POSTREQ}
-
-# Build
-
-BUILD_DIRS?= ${CONFIGURE_DIRS}
-BUILD_MAKE_FLAGS?= ${MAKE_FLAGS}
-
-.PHONY: do-build
-.if !target(do-build)
-do-build:
-. for _dir_ in ${BUILD_DIRS}
- ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
- cd ${WRKSRC} && cd ${_dir_} && \
- ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
- -f ${MAKEFILE} ${BUILD_TARGET}
-. endfor
-.endif
-
-#Test
-
-TEST_DIRS?= ${BUILD_DIRS}
-TEST_ENV+= ${MAKE_ENV}
-TEST_MAKE_FLAGS?= ${MAKE_FLAGS}
-
-.PHONY: do-test
-.if !target(do-test)
-do-test:
-. if defined(TEST_TARGET) && !empty(TEST_TARGET)
-. for _dir_ in ${TEST_DIRS}
- ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
- cd ${WRKSRC} && cd ${_dir_} && \
- ${SETENV} ${TEST_ENV} ${MAKE_PROGRAM} ${TEST_MAKE_FLAGS} \
- -f ${MAKEFILE} ${TEST_TARGET}
-. endfor
-. else
- @${DO_NADA}
-. endif
-.endif
-
.include "${PKGSRCDIR}/mk/flavor/bsd.flavor.mk"
# Dependencies
@@ -1191,6 +774,12 @@ do-test:
# Patch
.include "${PKGSRCDIR}/mk/patch/bsd.patch.mk"
+# Configure
+.include "${PKGSRCDIR}/mk/configure/bsd.configure.mk"
+
+# Build
+.include "${PKGSRCDIR}/mk/build/bsd.build.mk"
+
# Install
.include "${PKGSRCDIR}/mk/install/bsd.install.mk"
@@ -1199,16 +788,6 @@ do-test:
.include "${PKGSRCDIR}/mk/bsd.pkg.update.mk"
-.PHONY: acquire-wrapper-lock acquire-configure-lock acquire-build-lock
-acquire-wrapper-lock: acquire-lock
-acquire-configure-lock: acquire-lock
-acquire-build-lock: acquire-lock
-
-.PHONY: release-wrapper-lock release-configure-lock release-build-lock
-release-wrapper-lock: release-lock
-release-configure-lock: release-lock
-release-build-lock: release-lock
-
################################################################
# Skeleton targets start here
#
@@ -1218,128 +797,6 @@ release-build-lock: release-lock
# call the necessary targets/scripts.
################################################################
-.PHONY: wrapper
-.if !target(wrapper)
-wrapper: patch acquire-wrapper-lock ${_WRAPPER_COOKIE} release-wrapper-lock
-.endif
-
-.PHONY: configure
-.if !target(configure)
-configure: wrapper acquire-configure-lock ${_CONFIGURE_COOKIE} release-configure-lock
-.endif
-
-.PHONY: _build
-.if !target(_build)
-_build: configure acquire-build-lock ${_BUILD_COOKIE} release-build-lock
-.endif
-
-.PHONY: build
-.if !target(build)
-build: pkginstall
-.endif
-
-.PHONY: test
-.if !target(test)
-test: build ${_TEST_COOKIE}
-.endif
-
-${_WRAPPER_COOKIE}:
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-wrapper PKG_PHASE=wrapper
-
-PKG_ERROR_CLASSES+= configure
-PKG_ERROR_MSG.configure= \
- "" \
- "There was an error during the \`\`configure'' phase." \
- "Please investigate the following for more information:"
-.if defined(GNU_CONFIGURE)
-PKG_ERROR_MSG.configure+= \
- " * config.log" \
- " * ${WRKLOG}" \
- ""
-.else
-PKG_ERROR_MSG.configure+= \
- " * log of the build" \
- " * ${WRKLOG}" \
- ""
-.endif
-.if defined(BROKEN_IN)
-PKG_ERROR_MSG.configure+= \
- " * This package is broken in ${BROKEN_IN}." \
- " * It may be removed in the next branch unless fixed."
-.endif
-${_CONFIGURE_COOKIE}:
-.if !empty(INTERACTIVE_STAGE:Mconfigure) && defined(BATCH)
- @${ERROR_MSG} "The configuration stage of this package requires user interaction"
- @${ERROR_MSG} "Please configure manually with \"cd ${PKGDIR} && ${MAKE} configure\""
- @${TOUCH} ${_INTERACTIVE_COOKIE}
- @${FALSE}
-.else
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure || ${PKG_ERROR_HANDLER.configure}
-.endif
-
-PKG_ERROR_CLASSES+= build
-PKG_ERROR_MSG.build= \
- "" \
- "There was an error during the \`\`build'' phase." \
- "Please investigate the following for more information:" \
- " * log of the build" \
- " * ${WRKLOG}" \
- ""
-.if defined(BROKEN_IN)
-PKG_ERROR_MSG.build+= \
- " * This package is broken in ${BROKEN_IN}." \
- " * It may be removed in the next branch unless fixed."
-.endif
-${_BUILD_COOKIE}:
-.if !empty(INTERACTIVE_STAGE:Mbuild) && defined(BATCH)
- @${ERROR_MSG} "The build stage of this package requires user interaction"
- @${ERROR_MSG} "Please build manually with \"cd ${PKGDIR} && ${MAKE} build\""
- @${TOUCH} ${_INTERACTIVE_COOKIE}
- @${FALSE}
-.else
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build || ${PKG_ERROR_HANDLER.build}
-.endif
-
-${_TEST_COOKIE}:
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=test
-
-.PHONY: wrapper-message
-.PHONY: configure-message build-message test-message
-wrapper-message:
- @${PHASE_MSG} "Creating toolchain wrappers for ${PKGNAME}"
-configure-message:
- @${PHASE_MSG} "Configuring for ${PKGNAME}"
-build-message:
- @${PHASE_MSG} "Building for ${PKGNAME}"
-test-message:
- @${PHASE_MSG} "Testing for ${PKGNAME}"
-
-.PHONY: wrapper-cookie
-.PHONY: configure-cookie build-cookie test-cookie
-wrapper-cookie:
- ${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${_WRAPPER_COOKIE}
-configure-cookie:
- ${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${_CONFIGURE_COOKIE}
-build-cookie:
- ${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${_BUILD_COOKIE}
-test-cookie:
- ${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${_TEST_COOKIE}
-
-.ORDER: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie
-.ORDER: configure-message configure-vars pre-configure pre-configure-override do-configure post-configure configure-cookie
-.ORDER: build-message build-vars pre-build do-build post-build build-cookie
-.ORDER: test-message pre-test do-test post-test test-cookie
-
-# Please note that the order of the following targets is important, and
-# should not be modified (.ORDER is not recognised by make(1) in a serial
-# make i.e. without -j n)
-.PHONY: real-wrapper
-.PHONY: real-configure real-build real-test
-real-wrapper: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie error-check
-real-configure: configure-message configure-vars pre-configure pre-configure-override do-configure post-configure configure-cookie error-check
-real-build: build-message build-vars pre-build do-build post-build build-cookie error-check
-real-test: test-message pre-test do-test post-test test-cookie error-check
-
# 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}".
@@ -1370,22 +827,6 @@ su-target: .USE
${STEP_MSG} "Dropping \`\`${ROOT_USER}'' privileges."; \
fi
-# Empty pre-* and post-* targets
-
-.for name in wrapper configure build test
-
-. if !target(pre-${name})
-pre-${name}:
- @${DO_NADA}
-. endif
-
-. if !target(post-${name})
-post-${name}:
- @${DO_NADA}
-. endif
-
-.endfor
-
################################################################
# Some more targets supplied for users' convenience
################################################################
diff --git a/mk/build/bsd.build-vars.mk b/mk/build/bsd.build-vars.mk
new file mode 100644
index 00000000000..5b70338890b
--- /dev/null
+++ b/mk/build/bsd.build-vars.mk
@@ -0,0 +1,47 @@
+# $NetBSD: bsd.build-vars.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+#
+# 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_PROGRAM is the path to the make executable that is run to
+# process the source makefiles. This is always overridden by
+# the tools framework in pkgsrc/mk/tools/make.mk, but we provide
+# a default here for documentation purposes.
+#
+# 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.
+#
+# MAKEFILE 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.
+#
+BUILD_DIRS?= ${CONFIGURE_DIRS}
+MAKE_PROGRAM?= ${MAKE}
+MAKE_ENV?= # empty
+MAKE_FLAGS?= # empty
+MAKEFILE?= 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}
+
+# 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.
+#
+BUILD_ENV+= PATH=${PATH:Q}
diff --git a/mk/build/bsd.build.mk b/mk/build/bsd.build.mk
new file mode 100644
index 00000000000..8b1e0aaf444
--- /dev/null
+++ b/mk/build/bsd.build.mk
@@ -0,0 +1,43 @@
+# $NetBSD: bsd.build.mk,v 1.1 2006/07/05 06:09:15 jlam 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
+#
+
+_BUILD_COOKIE= ${WRKDIR}/.build_done
+_TEST_COOKIE= ${WRKDIR}/.test_done
+
+######################################################################
+### build (PUBLIC)
+######################################################################
+### build is a public target to build the sources for the package.
+###
+.PHONY: build
+.if defined(NO_BUILD)
+. if !target(build)
+build: configure build-cookie
+. endif
+.else
+. include "${PKGSRCDIR}/mk/build/build.mk"
+.endif
+
+.include "${PKGSRCDIR}/mk/build/test.mk"
+
+######################################################################
+### build-cookie (PRIVATE)
+######################################################################
+### build-cookie creates the "build" cookie file.
+###
+.PHONY: build-cookie
+build-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_BUILD_COOKIE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_BUILD_COOKIE}
diff --git a/mk/build/build.mk b/mk/build/build.mk
new file mode 100644
index 00000000000..db9ad7dfce8
--- /dev/null
+++ b/mk/build/build.mk
@@ -0,0 +1,119 @@
+# $NetBSD: build.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+#
+# BUILD_MAKE_FLAGS is the list of arguments that is passed to the make
+# process.
+#
+# BUILD_TARGET is the target from ${MAKEFILE} that should be invoked
+# to build the sources.
+#
+BUILD_MAKE_FLAGS?= ${MAKE_FLAGS}
+BUILD_TARGET?= all
+
+######################################################################
+### build (PUBLIC)
+######################################################################
+### build is a public target to build the sources from the package.
+###
+_BUILD_TARGETS+= configure
+_BUILD_TARGETS+= acquire-build-lock
+_BUILD_TARGETS+= ${_BUILD_COOKIE}
+_BUILD_TARGETS+= release-build-lock
+_BUILD_TARGETS+= pkginstall
+
+.PHONY: build
+.if !target(build)
+build: ${_BUILD_TARGETS}
+.endif
+
+.PHONY: acquire-build-lock release-build-lock
+acquire-build-lock: acquire-lock
+release-build-lock: release-lock
+
+.if !exists(${_BUILD_COOKIE})
+${_BUILD_COOKIE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build || ${PKG_ERROR_HANDLER.build}
+.else
+${_BUILD_COOKIE}:
+ @${DO_NADA}
+.endif
+
+PKG_ERROR_CLASSES+= build
+PKG_ERROR_MSG.build= \
+ "" \
+ "There was an error during the \`\`build'' phase." \
+ "Please investigate the following for more information:" \
+ " * log of the build" \
+ " * ${WRKLOG}" \
+ ""
+.if defined(BROKEN_IN)
+PKG_ERROR_MSG.build+= \
+ " * This package is broken in ${BROKEN_IN}." \
+ " * It may be removed in the next branch unless fixed."
+.endif
+
+######################################################################
+### 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
+_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\""
+ @${TOUCH} ${_INTERACTIVE_COOKIE}
+ @${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}
+ ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && cd ${_dir_} && \
+ ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
+ -f ${MAKEFILE} ${BUILD_TARGET}
+. endfor
+.endif
+
+.if !target(pre-build)
+pre-build:
+ @${DO_NADA}
+.endif
+
+.if !target(post-build)
+post-build:
+ @${DO_NADA}
+.endif
diff --git a/mk/build/test.mk b/mk/build/test.mk
new file mode 100644
index 00000000000..6e242cf5f97
--- /dev/null
+++ b/mk/build/test.mk
@@ -0,0 +1,123 @@
+# $NetBSD: test.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+#
+# TEST_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}.
+#
+# 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.
+#
+TEST_DIRS?= ${BUILD_DIRS}
+TEST_ENV+= ${MAKE_ENV}
+TEST_MAKE_FLAGS?= ${MAKE_FLAGS}
+
+######################################################################
+### test (PUBLIC)
+######################################################################
+### build is a public target to build the sources from the package.
+###
+_TEST_TARGETS+= build
+_TEST_TARGETS+= acquire-test-lock
+_TEST_TARGETS+= ${_TEST_COOKIE}
+_TEST_TARGETS+= release-test-lock
+
+.PHONY: test
+.if !target(test)
+test: ${_TEST_TARGETS}
+.endif
+
+.PHONY: acquire-test-lock release-test-lock
+acquire-test-lock: acquire-lock
+release-test-lock: release-lock
+
+.if !exists(${_TEST_COOKIE})
+${_TEST_COOKIE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=build
+.else
+${_TEST_COOKIE}:
+ @${DO_NADA}
+.endif
+
+######################################################################
+### 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\""
+ @${TOUCH} ${_INTERACTIVE_COOKIE}
+ @${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}
+ ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && cd ${_dir_} && \
+ ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${TEST_MAKE_FLAGS} \
+ -f ${MAKEFILE} ${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:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_TEST_COOKIE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_TEST_COOKIE}
diff --git a/mk/configure/bsd.configure-vars.mk b/mk/configure/bsd.configure-vars.mk
new file mode 100644
index 00000000000..e857ea1b37f
--- /dev/null
+++ b/mk/configure/bsd.configure-vars.mk
@@ -0,0 +1,27 @@
+# $NetBSD: bsd.configure-vars.mk,v 1.1 2006/07/05 06:09: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 scripts invoked
+# by pkgsrc, including 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}
diff --git a/mk/configure/bsd.configure.mk b/mk/configure/bsd.configure.mk
new file mode 100644
index 00000000000..e90efd600d8
--- /dev/null
+++ b/mk/configure/bsd.configure.mk
@@ -0,0 +1,39 @@
+# $NetBSD: bsd.configure.mk,v 1.1 2006/07/05 06:09:15 jlam 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
+#
+
+_CONFIGURE_COOKIE= ${WRKDIR}/.configure_done
+
+######################################################################
+### configure (PUBLIC)
+######################################################################
+### configure is a public target to configure the software for building.
+###
+.PHONY: configure
+.if defined(NO_CONFIGURE)
+. if !target(configure)
+configure: patch configure-cookie
+. endif
+.else
+. include "${PKGSRCDIR}/mk/configure/configure.mk"
+.endif
+
+######################################################################
+### configure-cookie (PRIVATE)
+######################################################################
+### configure-cookie creates the "configure" cookie file.
+###
+.PHONY: configure-cookie
+configure-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_CONFIGURE_COOKIE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_CONFIGURE_COOKIE}
diff --git a/mk/configure/config-override.mk b/mk/configure/config-override.mk
new file mode 100644
index 00000000000..bfa1d22755d
--- /dev/null
+++ b/mk/configure/config-override.mk
@@ -0,0 +1,51 @@
+# $NetBSD: config-override.mk,v 1.1 2006/07/05 06:09:15 jlam 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-guess-override
+.if defined(CONFIG_RPATH_OVERRIDE)
+do-configure-pre-hook: config-guess-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-* with pkgsrc versions"
+. if defined(${_OVERRIDE_VAR.${_sub_}}) && !empty(${_OVERRIDE_VAR.${_sub_}})
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ for file in ${${_OVERRIDE_VAR.${_sub_}}}; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done
+. else
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ depth=0; pattern=config.${_sub_}; \
+ while ${TEST} $$depth -le ${OVERRIDE_DIRDEPTH.config-${_sub_}}; do \
+ for file in $$pattern; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done; \
+ depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
+ done
+. endif
+.endfor
diff --git a/mk/configure/configure.mk b/mk/configure/configure.mk
new file mode 100644
index 00000000000..fe504e2bba4
--- /dev/null
+++ b/mk/configure/configure.mk
@@ -0,0 +1,216 @@
+# $NetBSD: configure.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+#
+# 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_ENV is the shell environment that is exported to the
+# configure script.
+#
+# CONFIGURE_ARGS is the list of arguments that is passed to the
+# configure script.
+#
+CONFIGURE_SCRIPT?= ./configure
+CONFIGURE_ENV+= ${ALL_ENV}
+CONFIGURE_ARGS?= # empty
+BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS
+
+.if defined(GNU_CONFIGURE)
+. include "${PKGSRCDIR}/mk/configure/gnu-configure.mk"
+.endif
+.if defined(OVERRIDE_GNU_CONFIG_SCRIPTS)
+. include "${PKGSRCDIR}/mk/configure/config-override.mk"
+.endif
+.if defined(USE_LIBTOOL)
+. include "${PKGSRCDIR}/mk/configure/libtool-override.mk"
+.endif
+.if defined(PKGCONFIG_OVERRIDE)
+. include "${PKGSRCDIR}/mk/configure/pkg-config-override.mk"
+.endif
+.if defined(REPLACE_INTERPRETER) || defined(REPLACE_PERL)
+. include "${PKGSRCDIR}/mk/configure/replace-interpreter.mk"
+.endif
+.if defined(USE_PKGLOCALEDIR)
+. include "${PKGSRCDIR}/mk/configure/replace-localedir.mk"
+.endif
+
+######################################################################
+### configure (PUBLIC)
+######################################################################
+### configure is a public target to configure the sources for building.
+###
+_CONFIGURE_TARGETS+= wrapper
+_CONFIGURE_TARGETS+= acquire-configure-lock
+_CONFIGURE_TARGETS+= ${_CONFIGURE_COOKIE}
+_CONFIGURE_TARGETS+= release-configure-lock
+
+.PHONY: configure
+.if !target(configure)
+configure: ${_CONFIGURE_TARGETS}
+.endif
+
+.PHONY: acquire-configure-lock release-configure-lock
+acquire-configure-lock: acquire-lock
+release-configure-lock: release-lock
+
+.if !exists(${_CONFIGURE_COOKIE})
+${_CONFIGURE_COOKIE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-configure PKG_PHASE=configure || ${PKG_ERROR_HANDLER.configure}
+.else
+${_CONFIGURE_COOKIE}:
+ @${DO_NADA}
+.endif
+
+PKG_ERROR_CLASSES+= configure
+PKG_ERROR_MSG.configure= \
+ "" \
+ "There was an error during the \`\`configure'' phase." \
+ "Please investigate the following for more information:"
+.if defined(GNU_CONFIGURE)
+PKG_ERROR_MSG.configure+= \
+ " * config.log" \
+ " * ${WRKLOG}" \
+ ""
+.else
+PKG_ERROR_MSG.configure+= \
+ " * log of the build" \
+ " * ${WRKLOG}" \
+ ""
+.endif
+.if defined(BROKEN_IN)
+PKG_ERROR_MSG.configure+= \
+ " * This package is broken in ${BROKEN_IN}." \
+ " * It may be removed in the next branch unless fixed."
+.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.
+###
+_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+= 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\""
+ @${TOUCH} ${_INTERACTIVE_COOKIE}
+ @${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}
+ ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && cd ${_dir_} && \
+ ${SETENV} ${_CONFIGURE_SCRIPT_ENV} \
+ ${CONFIG_SHELL} ${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}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ cd ${WRKSRC} && cd ${_dir_} && \
+ ${SETENV} ${_CONFIGURE_IMAKE_ENV} ${XMKMF}
+.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}
+
+.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
diff --git a/mk/configure/gnu-configure.mk b/mk/configure/gnu-configure.mk
new file mode 100644
index 00000000000..bcf15bc5c1a
--- /dev/null
+++ b/mk/configure/gnu-configure.mk
@@ -0,0 +1,100 @@
+# $NetBSD: gnu-configure.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+
+HAS_CONFIGURE= defined
+OVERRIDE_GNU_CONFIG_SCRIPTS= defined
+
+CONFIG_SHELL?= ${SH}
+CONFIGURE_ENV+= CONFIG_SHELL=${CONFIG_SHELL:Q}
+CONFIGURE_ENV+= LIBS=${LIBS:M*:Q}
+CONFIGURE_ENV+= install_sh=${INSTALL: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])
+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
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ for file in ${CONFIGURE_SCRIPTS_OVERRIDE}; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done
+.else
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ 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
diff --git a/mk/configure/libtool-override.mk b/mk/configure/libtool-override.mk
new file mode 100644
index 00000000000..36b79685da2
--- /dev/null
+++ b/mk/configure/libtool-override.mk
@@ -0,0 +1,83 @@
+# $NetBSD: libtool-override.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+
+######################################################################
+### {ltconfig,libtool,shlibtool}-override (PRIVATE)
+######################################################################
+### {ltconfig,libtool,shlibtool}-override replace any existing ltconfig
+### and libtool under ${WRKSRC} with the versions installed by pkgsrc.
+###
+.if defined(LTCONFIG_OVERRIDE)
+do-configure-pre-hook: ltconfig-override
+.endif
+do-configure-post-hook: libtool-override
+.if defined(SHLIBTOOL_OVERRIDE)
+do-configure-post-hook: shlibtool-override
+.endif
+
+OVERRIDE_DIRDEPTH.ltconfig?= ${OVERRIDE_DIRDEPTH}
+OVERRIDE_DIRDEPTH.libtool?= ${OVERRIDE_DIRDEPTH}
+OVERRIDE_DIRDEPTH.shlibtool?= ${OVERRIDE_DIRDEPTH}
+
+_SCRIPT.ltconfig-override= \
+ ${RM} -f $$file; \
+ ${ECHO} "${RM} -f libtool; ${LN} -s ${_LIBTOOL} libtool" > $$file; \
+ ${CHMOD} +x $$file
+
+.PHONY: ltconfig-override
+ltconfig-override:
+.if defined(LTCONFIG_OVERRIDE) && !empty(LTCONFIG_OVERRIDE)
+ @${STEP_MSG} "Modifying ltconfig scripts to use pkgsrc libtool"
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ for file in ${LTCONFIG_OVERRIDE}; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done
+.else
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ depth=0; pattern=ltconfig; \
+ while ${TEST} $$depth -le ${OVERRIDE_DIRDEPTH.ltconfig}; do \
+ for file in $$pattern; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done; \
+ depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
+ done
+.endif
+
+_OVERRIDE_VAR.libtool= LIBTOOL_OVERRIDE
+_OVERRIDE_VAR.shlibtool= SHLIBTOOL_OVERRIDE
+_OVERRIDE_PATH.libtool= ${_LIBTOOL}
+_OVERRIDE_PATH.shlibtool= ${_SHLIBTOOL}
+
+.for _script_ in libtool shlibtool
+_SCRIPT.${_script_}-override= \
+ ${ECHO} "\#!"${TOOLS_SH:Q} > $$file; \
+ ${ECHO} "exec" ${_OVERRIDE_PATH.${_script_}:Q} '"$$@"' >> $$file; \
+ ${CHMOD} +x $$file
+
+.PHONY: ${_script_}-override
+${_script_}-override:
+. if defined(${_OVERRIDE_VAR.${_script_}}) && \
+ !empty(${_OVERRIDE_VAR.${_script_}})
+ @${STEP_MSG} "Replacing libtool scripts with pkgsrc ${_script_}"
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ for file in ${${_OVERRIDE_VAR.${_script_}}}; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done
+. else
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ depth=0; pattern=libtool; \
+ while ${TEST} $$depth -le ${OVERRIDE_DIRDEPTH.${_script_}}; do \
+ for file in $$pattern; do \
+ ${TEST} -f "$$file" || continue; \
+ ${_SCRIPT.${.TARGET}}; \
+ done; \
+ depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern"; \
+ done
+. endif
+.endfor
diff --git a/mk/configure/pkg-config-override.mk b/mk/configure/pkg-config-override.mk
new file mode 100644
index 00000000000..d493068a33d
--- /dev/null
+++ b/mk/configure/pkg-config-override.mk
@@ -0,0 +1,33 @@
+# $NetBSD: pkg-config-override.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+
+######################################################################
+### pkg-config-override (PRIVATE)
+######################################################################
+### pkg-config-override inserts the compiler's "rpath" flag into
+### pkg-config data files so that ``pkg-config --ldflags <module>'' 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[nN][oO])
+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
diff --git a/mk/configure/replace-interpreter.mk b/mk/configure/replace-interpreter.mk
new file mode 100644
index 00000000000..a82d1cc3cf2
--- /dev/null
+++ b/mk/configure/replace-interpreter.mk
@@ -0,0 +1,48 @@
+# $NetBSD: replace-interpreter.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $
+
+######################################################################
+### 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
+
+.if defined(REPLACE_PERL)
+REPLACE_INTERPRETER+= perl
+REPLACE.perl.old= .*/bin/perl
+REPLACE.perl.new= ${PERL5}
+REPLACE_FILES.perl= ${REPLACE_PERL}
+.endif
+
+# XXX After 2006Q2, all instances of _REPLACE.* and _REPLACE_FILES.* should
+# XXX have been replaced with REPLACE.* and REPLACE_FILES.*. This code is
+# XXX then no longer needed.
+# XXX
+.for _lang_ in ${REPLACE_INTERPRETER}
+REPLACE.${_lang_}.old?= ${_REPLACE.${_lang_}.old}
+REPLACE.${_lang_}.new?= ${_REPLACE.${_lang_}.new}
+REPLACE_FILES.${_lang_}?= ${_REPLACE_FILES.${_lang_}}
+.endfor
+
+.PHONY: replace-interpreter
+replace-interpreter:
+.for _lang_ in ${REPLACE_INTERPRETER}
+ @${STEP_MSG} "Replacing interpreter paths in scripts"
+. for _pattern_ in ${REPLACE_FILES.${_lang_}}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ cd ${WRKSRC}; \
+ for file in ${_pattern_}; do \
+ if ${TEST} ! -f "$$file"; then \
+ ${WARNING_MSG} "[replace-interpreter.mk] Skipping non-existent file \"$$file\"."; \
+ continue; \
+ fi; \
+ ${SED} -e '1s|^#!${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|' \
+ $$file > $$file.new; \
+ if ${TEST} -x $$file; then \
+ ${CHMOD} a+x $$file.new; \
+ fi; \
+ ${MV} -f $$file.new $$file; \
+ done
+. endfor
+.endfor
diff --git a/mk/configure/replace-localedir.mk b/mk/configure/replace-localedir.mk
new file mode 100644
index 00000000000..e045025541a
--- /dev/null
+++ b/mk/configure/replace-localedir.mk
@@ -0,0 +1,45 @@
+# $NetBSD: replace-localedir.mk,v 1.1 2006/07/05 06:09:15 jlam 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|^\(gnulocaledir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
+ -e 's|\(-DLOCALEDIR[ ]*=\)[^ ]*\(\.\*\)|\1"\\"${_PKGLOCALEDIR}\\""\2|'
diff --git a/mk/pkginstall/bsd.pkginstall.mk b/mk/pkginstall/bsd.pkginstall.mk
index 973a022e570..41aea55a31a 100644
--- a/mk/pkginstall/bsd.pkginstall.mk
+++ b/mk/pkginstall/bsd.pkginstall.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.11 2006/06/15 22:13:59 jlam Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.12 2006/07/05 06:09:15 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -966,7 +966,6 @@ install-rcd-${_script_}: ${RCD_SCRIPT_WRK.${_script_}}
_PKGINSTALL_COOKIE= ${WRKDIR}/.pkginstall_done
-_PKGINSTALL_TARGETS+= _build
_PKGINSTALL_TARGETS+= acquire-pkginstall-lock
_PKGINSTALL_TARGETS+= ${_PKGINSTALL_COOKIE}
_PKGINSTALL_TARGETS+= release-pkginstall-lock
diff --git a/mk/wrapper/bsd.wrapper.mk b/mk/wrapper/bsd.wrapper.mk
index c70d393ca2f..cf76bc799ef 100644
--- a/mk/wrapper/bsd.wrapper.mk
+++ b/mk/wrapper/bsd.wrapper.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.wrapper.mk,v 1.42 2006/07/05 04:32:10 jlam Exp $
+# $NetBSD: bsd.wrapper.mk,v 1.43 2006/07/05 06:09:15 jlam Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -45,7 +45,7 @@ ECHO_WRAPPER_MSG?= ${ECHO}
ECHO_WRAPPER_MSG?= ${TRUE}
.endif
-.PHONY: do-wrapper
+.PHONY: generate-wrappers
.include "../../mk/buildlink3/bsd.buildlink3.mk"
@@ -192,7 +192,7 @@ _WRAP_UNTRANSFORM_SEDFILE?= ${WRAPPER_TMPDIR}/untransform.sed
# Generate the transformation sedfiles if we need them.
.if !empty(_WRAP_TRANSFORM_CMDS)
-do-wrapper: ${_WRAP_TRANSFORM_SEDFILE} ${_WRAP_UNTRANSFORM_SEDFILE}
+generate-wrappers: ${_WRAP_TRANSFORM_SEDFILE} ${_WRAP_UNTRANSFORM_SEDFILE}
_WRAP_TRANSFORM_SED+= -f ${_WRAP_TRANSFORM_SEDFILE}
_UNWRAP_SED= -f ${_WRAP_UNTRANSFORM_SEDFILE}
.endif
@@ -377,7 +377,7 @@ _WRAP_COOKIE.${_wrappee_}= ${WRAPPER_DIR}/.wrapper_${_wrappee_}_done
.for _wrappee_ in ${_WRAPPEES_UNIQUE}
PKG_${_wrappee_}?= ${${_wrappee_}}
-do-wrapper: ${_WRAP_COOKIE.${_wrappee_}}
+generate-wrappers: ${_WRAP_COOKIE.${_wrappee_}}
${_WRAP_COOKIE.${_wrappee_}}: \
${_WRAPPER_SH.${_wrappee_}} \
${_WRAP_ARG_PP.${_wrappee_}} \
@@ -417,7 +417,7 @@ ${_WRAP_COOKIE.${_wrappee_}}: \
IFS="$$save_IFS"; \
if ${TEST} ! -x "$$wrappee"; then \
gen_wrapper=no; \
- ${ECHO_WRAPPER_MSG} "Warning: unable to create ${_wrappee_} wrapper script: \`$$wrappee'"; \
+ ${ECHO_WRAPPER_MSG} "Warning: unable to generate ${_wrappee_} wrapper script: \`$$wrappee'"; \
fi; \
;; \
esac; \
@@ -436,7 +436,7 @@ ${_WRAP_COOKIE.${_wrappee_}}: \
. for _alias_ in ${_WRAP_ALIASES.${_wrappee_}:S/^/${WRAPPER_BINDIR}\//}
. if !target(${_alias_})
-do-wrapper: ${_alias_}
+generate-wrappers: ${_alias_}
${_alias_}: ${_WRAP_COOKIE.${_wrappee_}}
${_PKG_SILENT}${_PKG_DEBUG} \
wrapper="${WRAPPER_${_wrappee_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}"; \
@@ -449,7 +449,7 @@ ${_alias_}: ${_WRAP_COOKIE.${_wrappee_}}
.endfor # _WRAPPEES_UNIQUE
.for _target_ in ${WRAPPER_TARGETS}
-do-wrapper: ${_target_}
+generate-wrappers: ${_target_}
.endfor
${WRAPPER_TMPDIR}/transform-solaris-gcc: \
@@ -769,7 +769,58 @@ SUBST_POSTCMD.unwrap= ${DO_NADA}
### END: after "wrapper" phase
###
+######################################################################
+######################################################################
+######################################################################
+
+_WRAPPER_COOKIE= ${WRKDIR}/.wrapper_done
+
+.PHONY: wrapper
+.if !target(wrapper)
+. if defined(NO_BUILD)
+wrapper: patch wrapper-cookie
+. else
+wrapper: patch acquire-wrapper-lock ${_WRAPPER_COOKIE} release-wrapper-lock
+. endif
+.endif
+
+.PHONY: acquire-wrapper-lock release-wrapper-lock
+acquire-wrapper-lock: acquire-lock
+release-wrapper-lock: release-lock
+
+.if !exists(${_WRAPPER_COOKIE})
+${_WRAPPER_COOKIE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-wrapper PKG_PHASE=wrapper
+.else
+${_WRAPPER_COOKIE}:
+ @${DO_NADA}
+.endif
+
+.PHONY: real-wrapper
+real-wrapper: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie error-check
+
+.PHONY: wrapper-message
+wrapper-message:
+ @${PHASE_MSG} "Creating toolchain wrappers for ${PKGNAME}"
+
+.PHONY: pre-wrapper do-wrapper post-wrapper
+
.if !target(do-wrapper)
-do-wrapper:
+do-wrapper: generate-wrappers
+ @${DO_NADA}
+.endif
+
+.if !target(pre-wrapper)
+pre-wrapper:
@${DO_NADA}
.endif
+
+.if !target(post-wrapper)
+post-wrapper:
+ @${DO_NADA}
+.endif
+
+.PHONY: wrapper-cookie
+wrapper-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_WRAPPER_COOKIE:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_WRAPPER_COOKIE}