Index: Mk/bsd.options.mk =================================================================== RCS file: Mk/bsd.options.mk diff -N Mk/bsd.options.mk --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Mk/bsd.options.mk 12 May 2012 04:02:19 -0000 @@ -0,0 +1,143 @@ +# Global options + +## +# Set all the options available for the ports, beginning with the +# global ones and ending with the ones decided by the maintainer. +# Options global to the entire ports tree + +OPTIONSFILE?= ${PORT_DBDIR}/${UNIQUENAME}/options + +#ALL_OPTIONS= DOCS \ +# NLS + +# Set the default values for the global options, as defined by portmgr +PORT_OPTIONS+= NLS \ + DOCS + +# Append options set by the port Makefile +.for opt in ${OPTIONS_DEFINE} +ALL_OPTIONS+= ${opt} +.endfor + +ALL_OPTIONS:= ${ALL_OPTIONS:O:u} + +# Remove global options the port maintainer doesn't want +.for opt in ${OPTIONS_EXCLUDE} +ALL_OPTIONS:= ${ALL_OPTIONS:N${opt}} +.endfor + +#XXX to kill when old option framework won't be used anymore +.if defined(OPTIONS) +. undef optname +. for O in ${OPTIONS:S|\#|\\\#|g} +opt:= ${O} +. if !defined(optname) +optname:= ${O} +ALL_OPTIONS+= ${O} +. elif !defined(optdesc) +optdesc:= ${opt} +${optname}_DESC:= ${opt} +. else +. if ${opt:L} == on +. if defined(PORT_OPTIONS) && defined(optname) +NO_OPTIONS+= ${optname} +NO_OPTIONS:= ${NO_OPTIONS:O:u} +. endif +. endif +. undef optname +. undef optdesc +. endif +. endfor +. if defined(NO_OPTIONS) +. for O in ${NO_OPTIONS} +PORT_OPTIONS:= ${PORT_OPTIONS:N${O}} +. endfor +. endif +. undef NO_OPTIONS +.endif +#XXX end of compatibility + +ALL_OPTIONS:= ${ALL_OPTIONS:O:u} + +## Now create the list of activated options +.if defined(OPTIONS_OVERRIDE) +# Special case $OPTIONS_OVERRIDE; if it is defined forget about anything done +# before +PORT_OPTIONS:= ${OPTIONS_OVERRIDE} +.else + +## Set default options defined by the port maintainer +. for opt in ${OPTIONS_DEFAULT} +PORT_OPTIONS+= ${opt} +. endfor +PORT_OPTIONS:= ${PORT_OPTIONS:O:u} + +## Set system-wide defined options (set by user in make.conf) +. for opt in ${OPTIONS_SET} +PORT_OPTIONS+= ${opt} +. endfor +PORT_OPTIONS:= ${PORT_OPTIONS:O:u} + +## Remove the options excluded system-wide (set by user in make.conf) +. for opt in ${OPTIONS_UNSET} +PORT_OPTIONS:= ${PORT_OPTIONS:N${opt}} +. endfor + +## Set the options specified per-port (set by user in make.conf) +. for opt in ${${UNIQUENAME:U}_SET} +PORT_OPTIONS+= ${opt} +. endfor +PORT_OPTIONS:= ${PORT_OPTIONS:O:u} + +## Unset the options excluded per-port (set by user in make.conf) +. for opt in ${${UNIQUENAME:U}_UNSET} +PORT_OPTIONS:= ${PORT_OPTIONS:N${opt}} +. endfor + +## options files (from dialog) +. if exists(${OPTIONSFILE}) && !make(rmconfig) +. include "${OPTIONSFILE}" +. endif +. if exists(${OPTIONSFILE}.local) +. include "${OPTIONSFILE}.local" +. endif + +# XXX(to be removed) +. if defined(OPTIONS) +. undef optname +. for O in ${OPTIONS:C/".*"//g} +. if defined(WITH_${O}) +PORT_OPTIONS+= ${O} +PORT_OPTIONS:= ${PORT_OPTIONS:O:u} +. endif +. if defined(WITHOUT_${O}) +PORT_OPTIONS:= ${PORT_OPTIONS:N${O}} +. endif +. endfor +. endif +# XXX(end to be removed) + +## Finish by using the options set by the port config dialog, if any +. for opt in ${OPTIONS_FILE_SET} +PORT_OPTIONS+= ${opt} +. endfor +PORT_OPTIONS:= ${PORT_OPTIONS:O:u} + +.for opt in ${OPTIONS_FILE_UNSET} +PORT_OPTIONS:= ${PORT_OPTIONS:N${opt}} +.endfor +.undef opt + +.endif + +## Now some compatibility +.if empty(PORT_OPTIONS:MDOCS) +NOPORTDOCS= yes +.endif + +.if empty(PORT_OPTIONS:MNLS) +WITHOUT_NLS= yes +.endif + + + Index: Mk/bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.708 diff -u -r1.708 bsd.port.mk --- Mk/bsd.port.mk 13 Mar 2012 08:14:45 -0000 1.708 +++ Mk/bsd.port.mk 12 May 2012 04:02:50 -0000 @@ -1254,46 +1254,6 @@ .else UNIQUENAME?= ${PKGNAMEPREFIX}${PORTNAME} .endif -OPTIONSFILE?= ${PORT_DBDIR}/${UNIQUENAME}/options -.if defined(OPTIONS) -# include OPTIONSFILE first if exists -. if exists(${OPTIONSFILE}) && !make(rmconfig) -. include "${OPTIONSFILE}" -. endif -. if exists(${OPTIONSFILE}.local) -. include "${OPTIONSFILE}.local" -. endif -WITHOUT:= -WITH:= -. if defined(OPTIONS) -REALOPTIONS=${OPTIONS:C/".*"//g} -. for O in ${REALOPTIONS} -RO:=${O} -. if ${RO:L} == off -WITHOUT:= ${WITHOUT} ${OPT} -. endif -. if ${RO:L} == on -WITH:= ${WITH} ${OPT} -. endif -OPT:=${RO} -. endfor -. endif -# define only if NO WITH/WITHOUT_${W} is defined -. for W in ${WITH} -. if !defined(WITH_${W}) && !defined(WITHOUT_${W}) -WITH_${W}:= true -. endif -. endfor -. for W in ${WITHOUT} -. if !defined(WITH_${W}) && !defined(WITHOUT_${W}) -WITHOUT_${W}:= true -. endif -. endfor -. undef WITH -. undef WITHOUT -. undef RO -. undef REALOPTIONS -.endif .endif @@ -1317,6 +1277,7 @@ STRIP= #none .endif +.include "${PORTSDIR}/Mk/bsd.options.mk" # Start of pre-makefile section. .if !defined(AFTERPORTMK) && !defined(INOPTIONSMK) @@ -4279,7 +4240,7 @@ _SANITY_SEQ= ${_CHROOT_SEQ} pre-everything check-makefile \ check-categories check-makevars check-desktop-entries \ check-depends identify-install-conflicts check-deprecated \ - check-vulnerable check-license buildanyway-message \ + check-vulnerable check-license check-config buildanyway-message \ options-message _PKG_DEP= check-sanity @@ -5959,9 +5920,108 @@ SYSTEMVERSION="${SYSTEMVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" .endif +.if !target(pre-check-config) +pre-check-config: +.for single in ${OPTIONS_SINGLE} +. for opt in ${OPTIONS_SINGLE_${single}} +. if empty(ALL_OPTIONS:M${single}) || !empty(PORT_OPTIONS:M${single}) +. if !empty(PORT_OPTIONS:M${opt}) +. if defined(OPTFOUND) +OPTIONS_WRONG_SINGLE+= ${single} +. else +OPTFOUND= true +. endif +. endif +. else +# if conditional and if the condition is unchecked, remove opt from the list of +# set options +PORT_OPTIONS:= ${PORT_OPTIONS:N${opt}} +OPTNOCHECK= true +. endif +. endfor +. if !defined(OPTFOUND) && !defined(OPTNOCHECK) +OPTIONS_WRONG_SINGLE+= ${single} +. endif +. undef OPTFOUND +. undef OPTNOCHECK +.endfor +.undef single + +.for multi in ${OPTIONS_MULTI} +. for opt in ${OPTIONS_MULTI_${multi}} +. if empty(ALL_OPTIONS:M${multi}) || !empty(PORT_OPTIONS:M${multi}) +. if !empty(PORT_OPTIONS:M${opt}) +OPTFOUND= true +. endif +. else +# if conditional and if the condition is unchecked, remove opt from the list of +# set options +PORT_OPTIONS:= ${PORT_OPTIONS:N${opt}} +OPTNOCHECK= true +. endif +. endfor +. if !defined(OPTFOUND) && !defined(OPTNOCHECK) +OPTIONS_WRONG_MULTI+= ${opt} +. endif +. undef OPTFOUND +. undef OPTNOCHECK +.endfor +.undef multi +.undef opt +.endif #pre-check-config + +.if !target(check-config) +check-config: pre-check-config +.for multi in ${OPTIONS_WRONG_MULTI} + @${ECHO_MSG} "====> You must check at least one option in the ${multi} multi" + @exit 1 +.endfor +.for single in ${OPTIONS_WRONG_SINGLE} + @${ECHO_MSG} "====> You must select one and only one option from the ${single} single" + @exit 1 +.endfor +.endif # check-config + +.if !target(pre-config) +pre-config: +_COMPLETE_OPTIONS_LIST:= ${ALL_OPTIONS} +.for opt in ${ALL_OPTIONS} +. if empty(PORT_OPTIONS:M${opt}) +DEFOPTIONS+= ${opt} "${${opt}_DESC:S|"||g}" off +. else +DEFOPTIONS+= ${opt} "${${opt}_DESC:S|"||g}" on +. endif +.endfor +.for multi in ${OPTIONS_MULTI} +. for opt in ${OPTIONS_MULTI_${multi}} +_COMPLETE_OPTIONS_LIST+= ${opt} +. if empty(PORT_OPTIONS:M${opt}) +DEFOPTIONS+= ${opt} "M(${multi}): ${${opt}_DESC}" off +. else +DEFOPTIONS+= ${opt} "M(${multi}): ${${opt}_DESC}" on +. endif +. endfor +.endfor +.for single in ${OPTIONS_SINGLE} +. for opt in ${OPTIONS_SINGLE_${single}} +_COMPLETE_OPTIONS_LIST+= ${opt} +. if empty(PORT_OPTIONS:M${opt}) +DEFOPTIONS+= ${opt} "S(${single}): ${${opt}_DESC}" off +. else +DEFOPTIONS+= ${opt} "S(${single}): ${${opt}_DESC}" on +. endif +. endfor +.endfor + +_COMPLETE_OPTIONS_LIST:= ${_COMPLETE_OPTIONS_LIST:u} +.undef multi +.undef single +.undef opt +.endif # pre-config + .if !target(config) -config: -.if !defined(OPTIONS) +config: pre-config +.if empty(ALL_OPTIONS) @${ECHO_MSG} "===> No options to configure" .else .if ${UID} != 0 && !defined(INSTALL_AS_USER) @@ -5973,56 +6033,34 @@ .else @(optionsdir=${OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \ ${MKDIR} $${optionsdir} 2> /dev/null) || \ - (${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1) + (${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1) .endif - -@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_CMD} $$\{$${withvar}\}); \ - withoutval=$$(eval ${ECHO_CMD} $$\{$${withoutvar}\}); \ - if [ ! -z "$${withval}" ]; then \ - val=on; \ - elif [ ! -z "$${withoutval}" ]; then \ - val=off; \ - else \ - val=$${defaultval}; \ - fi; \ - DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \ - shift 3; \ - done; \ TMPOPTIONSFILE=$$(mktemp -t portoptions); \ trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \ - ${SH} -c "${DIALOG} --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \ + ${SH} -c '${DIALOG} --checklist "Options for ${PKGNAME:C/-([^-]+)$/ \1/}" 21 70 15 ${DEFOPTIONS}' 2> $${TMPOPTIONSFILE}; \ status=$$?; \ - if [ $${status} -ne 0 ] ; then \ + echo $$status; \ + if [ $${status} -ne 0 ]; then \ ${RM} -f $${TMPOPTIONSFILE}; \ ${ECHO_MSG} "===> Options unchanged"; \ exit 0; \ fi; \ - if [ ! -e ${TMPOPTIONSFILE} ]; then \ + if [ ! -e $${TMPOPTIONSFILE} ]; then \ ${ECHO_MSG} "===> No user-specified options to save for ${PKGNAME}"; \ exit 0; \ fi; \ SELOPTIONS=$$(${CAT} $${TMPOPTIONSFILE}); \ - ${RM} -f $${TMPOPTIONSFILE}; \ TMPOPTIONSFILE=$$(mktemp -t portoptions); \ trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \ ${ECHO_CMD} "# This file is auto-generated by 'make config'." > $${TMPOPTIONSFILE}; \ - ${ECHO_CMD} "# No user-servicable parts inside!" >> $${TMPOPTIONSFILE}; \ ${ECHO_CMD} "# Options for ${PKGNAME}" >> $${TMPOPTIONSFILE}; \ ${ECHO_CMD} "_OPTIONS_READ=${PKGNAME}" >> $${TMPOPTIONSFILE}; \ - for i in $${OPTIONSLIST}; do \ - ${ECHO_CMD} $${SELOPTIONS} | ${GREP} -qw $${i}; \ - if [ $$? -eq 0 ]; then \ - ${ECHO_CMD} WITH_$${i}=true >> $${TMPOPTIONSFILE}; \ + ${ECHO_CMD} "_FILE_COMPLETE_OPTIONS_LIST=${_COMPLETE_OPTIONS_LIST}" >> $${TMPOPTIONSFILE}; \ + for i in ${_COMPLETE_OPTIONS_LIST}; do \ + if ${ECHO_CMD} $${SELOPTIONS} | ${GREP} -qw $${i}; then \ + ${ECHO_CMD} "OPTIONS_FILE_SET+=$${i}" >> $${TMPOPTIONSFILE}; \ else \ - ${ECHO_CMD} WITHOUT_$${i}=true >> $${TMPOPTIONSFILE}; \ + ${ECHO_CMD} "OPTIONS_FILE_UNSET+=$${i}" >> $${TMPOPTIONSFILE}; \ fi; \ done; \ if [ ${UID} != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \ @@ -6034,7 +6072,7 @@ fi; \ ${RM} -f $${TMPOPTIONSFILE} .endif -.endif +.endif # config .if !target(config-recursive) config-recursive: @@ -6042,68 +6080,69 @@ @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \ (cd $$dir; ${MAKE} config-conditional); \ done -.endif +.endif # config-recursive .if !target(config-conditional) -config-conditional: -.if defined(OPTIONS) -.if exists(${OPTIONSFILE}) -# scan saved options and invalidate them, if the set of options does not match - @. ${OPTIONSFILE}; \ - set ${OPTIONS} XXX; \ - while [ $$# -gt 3 ]; do \ - withvar=WITH_$$1; \ - withoutvar=WITHOUT_$$1; \ - withval=$$(eval ${ECHO_CMD} $$\{$${withvar}\}); \ - withoutval=$$(eval ${ECHO_CMD} $$\{$${withoutvar}\}); \ - if [ ! -z "$${withval}" ]; then \ - val=on; \ - elif [ ! -z "$${withoutval}" ]; then \ - val=off; \ - else \ - val=missing; \ - fi; \ - if [ "$${val}" = "missing" ]; then \ - OPTIONS_INVALID=yes; \ - fi; \ - shift 3; \ - done; \ - if [ "$${OPTIONS_INVALID}" = "yes" ]; then \ - cd ${.CURDIR} && ${MAKE} config; \ - fi; -.else +config-conditional: pre-config +.if defined(_COMPLETE_OPTIONS_LIST) && !defined(NO_DIALOG) +. if ${_COMPLETE_OPTIONS_LIST} != "${_FILE_COMPLETE_OPTIONS_LIST}" cd ${.CURDIR} && ${MAKE} config; +. endif .endif -.endif -.endif +.endif # config-conditional .if !target(showconfig) +.include "${PORTSDIR}/Mk/bsd.options.desc.mk" showconfig: -.if defined(OPTIONS) - @${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME}:" - -@if [ -e ${OPTIONSFILE} ]; then \ - . ${OPTIONSFILE}; \ - fi; \ - set -- ${OPTIONS} XXX; \ - while [ $$# -gt 3 ]; do \ - defaultval=$$3; \ - withvar=WITH_$$1; \ - withoutvar=WITHOUT_$$1; \ - withval=$$(eval ${ECHO_CMD} $$\{$${withvar}\}); \ - withoutval=$$(eval ${ECHO_CMD} $$\{$${withoutvar}\}); \ - if [ ! -z "$${withval}" ]; then \ - val=on; \ - elif [ ! -z "$${withoutval}" ]; then \ - val=off; \ - else \ - val="$${defaultval} (default)"; \ - fi; \ - ${ECHO_MSG} " $$1=$${val} \"$$2\""; \ - shift 3; \ - done + @${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME}": +.for opt in ${ALL_OPTIONS} +. if empty(PORT_OPTIONS:M${opt}) + @${ECHO_MSG} -n " ${opt}=off" +. else + @${ECHO_MSG} -n " ${opt}=on" +. endif +. if !empty(${opt}_DESC) + @${ECHO_MSG} -n ": "${${opt}_DESC} +. endif + @${ECHO_MSG} "" +.endfor +#multi and conditional multis +.for multi in ${OPTIONS_MULTI} + @${ECHO_MSG} "====> Options available for the multi ${multi}: you have to choose at least one of them" +. for opt in ${OPTIONS_MULTI_${multi}} +. if empty(PORT_OPTIONS:M${opt}) + @${ECHO_MSG} -n " ${opt}=off" +. else + @${ECHO_MSG} -n " ${opt}=on" +. endif +. if !empty(${opt}_DESC) + @${ECHO_MSG} ": "${${opt}_DESC} +. endif + @${ECHO_MSG} "" +. endfor +.endfor +#single and conditional singles + +.for single in ${OPTIONS_SINGLE} + @${ECHO_MSG} "====> Options available for the single ${single}: you have to select exactly one of them" +. for opt in ${OPTIONS_SINGLE_${single}} +. if empty(PORT_OPTIONS:M${opt}) + @${ECHO_MSG} -n " ${opt}=off" +. else + @${ECHO_MSG} -n " ${opt}=on" +. endif +. if !empty(${opt}_DESC) + @${ECHO_MSG} ": "${${opt}_DESC} +. endif + @${ECHO_MSG} "" +. endfor +.endfor + +.undef multi +.undef single +.undef opt @${ECHO_MSG} "===> Use 'make config' to modify these settings" -.endif -.endif +.endif # showconfig .if !target(showconfig-recursive) showconfig-recursive: @@ -6111,7 +6150,7 @@ @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \ (cd $$dir; ${MAKE} showconfig); \ done -.endif +.endif # showconfig-recursive .if !target(rmconfig) rmconfig: @@ -6125,12 +6164,12 @@ ${ECHO_MSG} "===> Returning to user credentials"; \ else \ ${RM} -f ${OPTIONSFILE}; \ - ${RMDIR} $${optionsdir}; \ + ${RMDIR} $${optionsdir} || return 0; \ fi .else @${ECHO_MSG} "===> No user-specified options configured for ${PKGNAME}" .endif -.endif +.endif # rmconfig .if !target(rmconfig-recursive) rmconfig-recursive: @@ -6138,7 +6177,44 @@ @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \ (cd $$dir; ${MAKE} rmconfig); \ done -.endif +.endif # rmconfig-recursive + +.if !target(pretty-print-config) +pretty-print-config: +.for opt in ${ALL_OPTIONS} +. if empty(PORT_OPTIONS:M${opt}) + @${ECHO_MSG} -n "-${opt} " +. else + @${ECHO_MSG} -n "+${opt} " +. endif +.endfor +.for multi in ${OPTIONS_MULTI} + @${ECHO_MSG} -n "${multi}[ " +. for opt in ${OPTIONS_MULTI_${multi}} +. if empty(PORT_OPTIONS:M${opt}) + @${ECHO_MSG} -n "-${opt} " +. else + @${ECHO_MSG} -n "+${opt} " +. endif +. endfor + @${ECHO_MSG} -n "] " +.endfor +.for single in ${OPTIONS_SINGLE} + @${ECHO_MSG} -n "${single}( " +. for opt in ${OPTIONS_SINGLE_${single}} +. if empty(PORT_OPTIONS:M${opt}) + @${ECHO_MSG} -n "-${opt} " +. else + @${ECHO_MSG} -n "+${opt} " +. endif +. endfor + @${ECHO_MSG} -n ") " +.endfor +.undef multi +.undef single +.undef opt + @${ECHO_MSG} "" +.endif # pretty-print-config desktop-categories: @categories=""; \ Index: Mk/bsd.options.desc.mk =================================================================== RCS file: Mk/bsd.options.desc.mk diff -N Mk/bsd.options.desc.mk --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Mk/bsd.options.desc.mk 12 May 2012 04:02:50 -0000 @@ -0,0 +1,2 @@ +DOCS_DESC?= Build and install the documentation +NLS_DESC?= Build and install the localisation data