Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.474
diff -u -r1.474 bsd.port.mk
--- bsd.port.mk 24 Nov 2003 01:08:41 -0000 1.474
+++ bsd.port.mk 12 Jan 2004 18:17:37 -0000
@@ -639,6 +639,11 @@
# makesum - Generate distinfo (only do this for your own ports!).
# clean - Remove ${WRKDIR} and other temporary files used for building.
# clean-depends - Do a "make clean" for all dependencies.
+# config - Configure options for this port (using ${DIALOG}).
+# Automatically run prior to extract, patch, configure, build,
+# install, and package.
+# showconfig - Display options config for this port
+# rmconfig - Remove the options config for this port
#
# Default sequence for "all" is: fetch checksum extract patch configure build
#
@@ -661,6 +666,20 @@
#
# Here are some variables used in various stages.
#
+# For options:
+# OPTIONS - List of what WITH_ options this port accept. The
+# format is
+# "" [on|off]
+# Example:
+# FLEXRESP "Flexible response to events" off
+# which tell that an option WITH_FLEXRESP exists for this port,
+# that by default it is not defined, and that the description to
+# show to a user in the config dialog is "Flexible response to
+# events". If you have more than one option, just chain them
+# into a single variable. NOTE: To make options work, you need
+# to include bsd.port.pre.mk before you start testing the
+# WITH_xyz variables.
+#
# For fetch:
#
# FETCH_CMD - Full path to ftp/http fetch command if not in $PATH
@@ -803,6 +822,8 @@
# PATCH_DEBUG - If set, print out more information about the patches as
# it attempts to apply them.
# PKG_DBDIR - Where package installation is recorded (default: /var/db/pkg)
+# PORT_DBDIR - Where port configuration options are recorded
+# (default: /var/db/ports)
# NO_PKG_REGISTER - Don't register a port installation as a package.
# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
# registration information in ${PKG_DBDIR}/${PKGNAME}.
@@ -849,6 +870,7 @@
CP?= /bin/cp
CUT?= /usr/bin/cut
DC?= /usr/bin/dc
+DIALOG?= /usr/bin/dialog
EGREP?= /usr/bin/egrep
EXPR?= /bin/expr
FALSE?= false # Shell builtin
@@ -955,6 +977,17 @@
USE_SUBMAKE= yes
.endif
+# where 'make config' records user configuration options
+PORT_DBDIR?= /var/db/ports
+
+OPTIONSFILE?=${PORT_DBDIR}/${PORTNAME}/options
+.if exists(${OPTIONSFILE})
+.include "${OPTIONSFILE}"
+.endif
+.if exists(${OPTIONSFILE}.local)
+.include "${OPTIONSFILE}.local"
+.endif
+
.if !defined(PORTNAME) || !defined(PORTVERSION) || defined(PKGNAME)
.BEGIN:
@${ECHO_CMD} "${PKGNAME}: You need to define PORTNAME and PORTVERSION instead of PKGNAME."
@@ -2739,6 +2772,18 @@
.endif
################################################################
+#
+# Do preliminary work to detect if we need to run the config
+# target or not.
+#
+################################################################
+.if (!defined(OPTIONS) || defined(CONFIG_DONE) || \
+ defined(PACKAGE_BUILDING) || defined(BATCH) || \
+ exists(${OPTIONSFILE}) || exists(${OPTIONSFILE}.local))
+_OPTIONS_OK=yes
+.endif
+
+################################################################
# The following are used to create easy dummy targets for
# disabling some bit of default target behavior you don't want.
# They still check to see if the target exists, and if so don't
@@ -2748,25 +2793,25 @@
################################################################
# Disable checksum
-.if defined(NO_CHECKSUM) && !target(checksum)
+.if defined(NO_CHECKSUM) && !target(checksum) && defined(_OPTIONS_OK)
checksum: fetch
@${DO_NADA}
.endif
# Disable build
-.if defined(NO_BUILD) && !target(build)
+.if defined(NO_BUILD) && !target(build) && defined(_OPTIONS_OK)
build: configure
@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
.endif
# Disable install
-.if defined(NO_INSTALL) && !target(install)
+.if defined(NO_INSTALL) && !target(install) && defined(_OPTIONS_OK)
install: build
@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
.endif
# Disable package
-.if defined(NO_PACKAGE) && !target(package)
+.if defined(NO_PACKAGE) && !target(package) && defined(_OPTIONS_OK)
package:
.if defined(IGNORE_SILENT)
@${DO_NADA}
@@ -3451,8 +3496,12 @@
.for target in extract patch configure build install package
-.if !target(${target})
+.if !target(${target}) && defined(_OPTIONS_OK)
${target}: ${${target:U}_COOKIE}
+.elif !target(${target})
+${target}: config
+ @cd ${.CURDIR} && ${MAKE} CONFIG_DONE=1 ${__softMAKEFLAGS} ${${target:U}_COOKIE}
+.elif target(${target}) && defined(IGNORE)
.endif
.if !exists(${${target:U}_COOKIE})
@@ -4627,6 +4676,88 @@
OSVERSION="${OSVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
PORTOBJFORMAT="${PORTOBJFORMAT:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
SYSTEMVERSION="${SYSTEMVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}"
+.endif
+
+.if !target(config)
+config:
+ @${MKDIR} ${WRKDIR}
+.if !defined(OPTIONS)
+ @${ECHO_MSG} "===> No options to configure"
+.else
+ @(${MKDIR} ${PORT_DBDIR}/${PORTNAME} 2> /dev/null) || \
+ (${ECHO_MSG} "===> Cannot create ${PORT_DBDIR}/${PORTNAME}, check permissions"; exit 1)
+ -@if [ -e ${OPTIONSFILE} ]; then \
+ . ${OPTIONSFILE}; \
+ fi; \
+ set ${OPTIONS} XXX; \
+ while [ $$# -gt 3 ]; do \
+ OPTIONSLIST="$${OPTIONSLIST} $$1"; \
+ defaultval=$$3; \
+ withvar=WITH_$$1; \
+ withoutvar=WITHOUT_$$1; \
+ withval=$$(eval echo $$\{$${withvar}\}); \
+ withoutval=$$(eval echo $$\{$${withoutvar}\}); \
+ echo $${withval}; \
+ if [ ! -z "$${withval}" ]; then \
+ val=on; \
+ elif [ ! -z "$${withoutval}" ]; then \
+ val=off; \
+ else \
+ val=$$3; \
+ fi; \
+ DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \
+ shift 3; \
+ done > /dev/null; \
+ TMPOPTIONSFILE=$$(mktemp -t portoptions); \
+ trap "rm -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
+ ${SH} -c "${DIALOG} --checklist \"Options for ${PORTNAME} ${PORTVERSION}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
+ status=$$?; \
+ if [ $${status} -ne 0 ] ; then \
+ ${RM} -f $${TMPOPTIONSFILE}; \
+ ${ECHO_MSG} "===> Options unchanged"; \
+ exit 0; \
+ fi; \
+ if [ ! -e ${TMPOPTIONSFILE} ]; then \
+ ${ECHO_MSG} "===> No user-specified options to save for ${PORTNAME}"; \
+ exit 0; \
+ fi; \
+ SELOPTIONS=$$(cat $${TMPOPTIONSFILE}); \
+ ${RM} -f $${TMPOPTIONSFILE}; \
+ ${ECHO_MSG} "# This file is auto-generated by 'make config'. No user-servicable parts" > ${OPTIONSFILE}; \
+ ${ECHO_MSG} "# inside!" >> ${OPTIONSFILE}; \
+ for i in $${OPTIONSLIST}; do \
+ ${ECHO_CMD} $${SELOPTIONS} | grep -qw $${i}; \
+ if [ $$? -eq 0 ]; then \
+ ${ECHO_CMD} WITH_$${i}=true >> ${OPTIONSFILE}; \
+ else \
+ ${ECHO_CMD} WITHOUT_$${i}=true >> ${OPTIONSFILE}; \
+ fi; \
+ done
+.endif
+.endif
+
+.if !target(showconfig)
+showconfig:
+.if exists(${OPTIONSFILE})
+ @${ECHO_MSG} "===> The following configuration options are set for ${PORTNAME}"; \
+ ${GREP} -v ^# ${OPTIONSFILE}
+.else
+ @${ECHO_MSG} "===> No configuration options are set for this port"
+.if defined(OPTIONS)
+ @${ECHO_MSG} " Use 'make config' to set default values"
+.endif
+.endif
+.endif
+
+.if !target(rmconfig)
+rmconfig:
+.if exists(${OPTIONSFILE})
+ -@${ECHO_MSG} "===> Removing user-configured options for ${PORTNAME}"; \
+ ${RM} -f ${OPTIONSFILE}; \
+ ${RMDIR} ${PORT_DBDIR}/${PORTNAME}
+.else
+ @${ECHO_MSG} "===> No user-specified options configured for ${PORTNAME}"
+.endif
.endif
.endif