summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mk/bsd.options.mk36
-rw-r--r--regress/pkg-options/Makefile4
-rw-r--r--regress/pkg-options/files/legacy-opt.mk17
-rw-r--r--regress/pkg-options/files/legacy-opt.out1
4 files changed, 51 insertions, 7 deletions
diff --git a/mk/bsd.options.mk b/mk/bsd.options.mk
index 448fc67ac49..a07a6fbb734 100644
--- a/mk/bsd.options.mk
+++ b/mk/bsd.options.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.options.mk,v 1.25 2005/05/28 12:14:34 dillo Exp $
+# $NetBSD: bsd.options.mk,v 1.26 2005/05/31 11:05:31 dillo Exp $
#
# This Makefile fragment provides boilerplate code for standard naming
# conventions for handling per-package build options.
@@ -22,6 +22,11 @@
# This is a list of USE_VARIABLE:option pairs that
# map legacy /etc/mk.conf variables to their option
# counterparts.
+#
+# PKG_OPTIONS_LEGACY_OPTS
+# This is a list of old-option:new-option pairs that
+# map options that have been renamed to their new
+# counterparts.
#
#
# Optionally, the user may define the following variables in /etc/mk.conf:
@@ -48,10 +53,11 @@
#
# -------------8<-------------8<-------------8<-------------8<-------------
# PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
-# PKG_SUPPORTED_OPTIONS= foo ldap sasl
-# PKG_SUGGESTED_OPTIONS= foo
+# PKG_SUPPORTED_OPTIONS= wibble-foo ldap sasl
+# PKG_SUGGESTED_OPTIONS= wibble-foo
# PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
# PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_SASL2:sasl
+# PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
#
# .include "../../mk/bsd.options.mk"
#
@@ -60,7 +66,7 @@
# ###
# ### FOO support
# ###
-# .if !empty(PKG_OPTIONS:Mfoo)
+# .if !empty(PKG_OPTIONS:Mwibble-foo)
# CONFIGURE_ARGS+= --enable-foo
# .endif
@@ -112,6 +118,17 @@ _DEPRECATED_WARNING:=${_DEPRECATED_WARNING} "Deprecated variable "${_var_:Q}" us
.undef _opt_
.undef _popt_
+.for _m_ in ${PKG_OPTIONS_LEGACY_OPTS}
+_old_:= ${_m_:C/:.*//}
+_new_:= ${_m_:C/.*://}
+. if !empty(PKG_SUPPORTED_OPTIONS:M${_new_})
+_PKG_LEGACY_OPTMAP.${_old_}:=${_new_}
+_DEPRECATED_WARNING:=${_DEPRECATED_WARNING} "Deprecated option "${_old_:Q}" used, use option "${_new_:Q}" instead."
+. endif
+.endfor
+.undef _old_
+.undef _new_
+
#
# filter unsupported options from PKG_DEFAULT_OPTIONS
#
@@ -119,7 +136,8 @@ _OPTIONS_DEFAULT_SUPPORED:= #empty
.for _o_ in ${PKG_DEFAULT_OPTIONS}
_opt_:= ${_o_}
_popt_:= ${_opt_:C/^-//}
-.if !empty(PKG_SUPPORTED_OPTIONS:M${_popt_})
+.if !empty(PKG_SUPPORTED_OPTIONS:M${_popt_}) \
+ || defined(_PKG_LEGACY_OPTMAP.${_popt_})
_OPTIONS_DEFAULT_SUPPORTED:=${_OPTIONS_DEFAULT_SUPPORTED} ${_opt_}
.endif
.endfor
@@ -135,6 +153,14 @@ _OPTIONS_UNSUPPORTED:= #empty
${_OPTIONS_DEFAULT_SUPPORTED} ${${PKG_OPTIONS_VAR}}
_opt_:= ${_o_}
_popt_:= ${_o_:C/^-//} # positive option
+. if defined(_PKG_LEGACY_OPTMAP.${_popt_})
+_popt_:= ${_PKG_LEGACY_OPTMAP.${_popt_}}
+. if empty(_opt_:M-*)
+_opt_:= ${_popt_}
+. else
+_opt_:= -${_popt_}
+. endif
+. endif
. if empty(PKG_SUPPORTED_OPTIONS:M${_popt_})
_OPTIONS_UNSUPPORTED:=${_OPTIONS_UNSUPPORTED} ${_opt_}
. else
diff --git a/regress/pkg-options/Makefile b/regress/pkg-options/Makefile
index 539411f1702..127874567b8 100644
--- a/regress/pkg-options/Makefile
+++ b/regress/pkg-options/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2005/05/28 12:16:43 dillo Exp $
+# $NetBSD: Makefile,v 1.4 2005/05/31 11:05:31 dillo Exp $
#
DISTNAME= regress-pkg-options-1.0
@@ -8,7 +8,7 @@ DISTFILES= # empty
MAINTAINER= rillig@NetBSD.org
COMMENT= Test bsd.options.mk framework
-REGRESS_TESTS= all order simple unsupported
+REGRESS_TESTS= all legacy-opt order simple unsupported
do-test:
.for t in ${REGRESS_TESTS}
diff --git a/regress/pkg-options/files/legacy-opt.mk b/regress/pkg-options/files/legacy-opt.mk
new file mode 100644
index 00000000000..47c8c9218b7
--- /dev/null
+++ b/regress/pkg-options/files/legacy-opt.mk
@@ -0,0 +1,17 @@
+# $NetBSD: legacy-opt.mk,v 1.1 2005/05/31 11:05:31 dillo Exp $
+#
+# This file test a very simple options configuration.
+#
+
+MAKECONF= /dev/null
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.foo
+PKG_SUPPORTED_OPTIONS= new
+PKG_OPTIONS_LEGACY_OPTS+= old:new
+PKG_OPTIONS.foo= old
+
+.include "../../mk/bsd.options.mk"
+
+.PHONY: test
+test:
+ echo ${PKG_OPTIONS:M*:Q}
diff --git a/regress/pkg-options/files/legacy-opt.out b/regress/pkg-options/files/legacy-opt.out
new file mode 100644
index 00000000000..3e757656cf3
--- /dev/null
+++ b/regress/pkg-options/files/legacy-opt.out
@@ -0,0 +1 @@
+new