comparison configure.ac @ 3147:971e3c687f18

[xemacs-hg @ 2005-12-18 12:21:49 by malcolmp] Improvements to configure's complex option processing.
author malcolmp
date Sun, 18 Dec 2005 12:22:03 +0000
parents a05d78a1685f
children 71959ba52b08
comparison
equal deleted inserted replaced
3146:7c45a748ff54 3147:971e3c687f18
366 dnl 366 dnl
367 dnl Internal macro create the option's shell variable containing the default 367 dnl Internal macro create the option's shell variable containing the default
368 dnl value and to note the values in an option list. 368 dnl value and to note the values in an option list.
369 dnl 369 dnl
370 define([XE_EXPAND_COMPLEX_OPTION], 370 define([XE_EXPAND_COMPLEX_OPTION],
371 [with_[$1]_[$2]=[$3] 371 [_[$1]_[$2]_default=[$3]
372 enable_[$1]_[$2]=[$3]
373 m4_append([XE_COMPONENT_LIST],[$2],[ ])dnl 372 m4_append([XE_COMPONENT_LIST],[$2],[ ])dnl
374 dnl Separate with a ':' instead of a ',' (see <prefix>_default below) to avoid 373 dnl Separate with a ':' instead of a ',' (see <prefix>_default below) to avoid
375 dnl confusion with marco parameter lists. 374 dnl confusion with marco parameter lists.
376 m4_append([XE_COMPONENT_DEFAULT],[m4_if([$3],no,no)[$2]],[:])dnl 375 m4_append([XE_COMPONENT_DEFAULT],[m4_if([$3],no,no)[$2]],[:])dnl
377 ])dnl 376 ])dnl
396 dnl values. 395 dnl values.
397 dnl 396 dnl
398 define([XE_INIT_COMPLEX_OPTION], 397 define([XE_INIT_COMPLEX_OPTION],
399 [_[$1]_notfirst="" 398 [_[$1]_notfirst=""
400 dnl 399 dnl
401 XE_EXPAND_COMPLEX_OPTIONS($@) 400 XE_EXPAND_COMPLEX_OPTIONS($@)dnl
402 _[$1]_types="XE_COMPONENT_LIST" 401 _[$1]_types="XE_COMPONENT_LIST"
403 _[$1]_default="m4_translit(XE_COMPONENT_DEFAULT,[:],[,])" 402 _[$1]_default="m4_translit(XE_COMPONENT_DEFAULT,[:],[,])"
404 dnl Undefine these macros so that they can be reused by later complex 403 dnl Undefine these macros so that they can be reused by later complex
405 dnl options. 404 dnl options.
406 undefine([XE_COMPONENT_LIST]) 405 undefine([XE_COMPONENT_LIST])dnl
407 undefine([XE_COMPONENT_DEFAULT]) 406 undefine([XE_COMPONENT_DEFAULT])dnl
408 ])dnl 407 ])dnl
409 dnl 408 dnl
410 dnl XE_PARSE_COMPLEX_OPTION(prefix, cmdline-flag) 409 dnl XE_PARSE_COMPLEX_OPTION(prefix, cmdline-flag)
411 dnl --------------------------------------------- 410 dnl ---------------------------------------------
412 dnl 411 dnl
413 dnl Internal macro to parse the option values. If an undeclared option is 412 dnl Internal macro to parse the option values. If an undeclared option is
414 dnl found then an error is generated. Because something has been supplied on 413 dnl found then an error is generated. Because something has been supplied on
415 dnl the command line initialise all the complex options to 'no' rather than 414 dnl the command line initialise all the complex options to 'no' rather than
416 dnl the default. In thius way --enable-complex=foo will give the expected 415 dnl the default. In this way --enable-complex=foo will give the expected
417 dnl value (no) for bar. 416 dnl value (no) for bar.
418 dnl 417 dnl
418 dnl #### I think we should add a couple more features.
419 dnl First, at the end of XE_PARSE_COMPLEX_OPTION check for contradictory args,
420 dnl specifically if `all' is specified but the options are all individually
421 dnl disabled, or if `none' is specified but the options are all individually
422 dnl enabled, we should _warn_ about this situation.
423 dnl Second, we should provide an XE_VALIDATE_COMPLEX_OPTION macro to be used
424 dnl at the end of detection. If any feature is `yes' but we don't have it,
425 dnl then we should XE_DIE.
426 dnl
419 define([XE_PARSE_COMPLEX_OPTION], 427 define([XE_PARSE_COMPLEX_OPTION],
420 [for y in $_[$1]_types; do 428 [dnl Initialize variables for COMPLEX_OPTION [$1]. Leading underscore or
421 eval "with_[$1]_$y=no" 429 dnl single letter variables are internal to the XE_PARSE_COMPLEX_OPTION macro.
422 eval "enable_[$1]_$y=no" 430 _[$1]_all_default=""
431 _require_[$1]=""
432 dnl check first arg for default spec
433 case "$with_[$1]" in
434 n | no | non | none ) _[$1]_all_default=no ;;
435 n,* | no,* | non,* | none,* ) _[$1]_all_default=no ;;
436 a | al | all | both ) _[$1]_all_default=yes ;;
437 a,* | al,* | all,* | both,* ) _[$1]_all_default=yes ;;
438 y | yes ) _require_[$1]=yes ;;
439 esac
440 dnl if first arg was a default spec, trim it
441 if test -n "$_[$1]_all_default$_require_[$1]"; then
442 _with_[$1]_args=`echo $with_[$1] | sed -e 's/^[[a-z]]*\(,\(.*\)\)\{0,1\}$/\2/'`
443 else
444 _with_[$1]_args=$with_[$1]
445 fi
446 dnl set default for each type
447 for y in $_[$1]_types; do
448 if test -n "$_[$1]_all_default" ; then
449 eval "with_[$1]_${y}=$_[$1]_all_default"
450 else
451 eval "with_[$1]_$y=\$_[$1]_${y}_default"
452 fi
423 done 453 done
424 for x in `echo "$with_[$1]" | sed -e 's/,/ /g'` ; do 454 dnl parse the command line arg and set types found appropriately
425 _[$1]_all_default="" 455 for x in `echo "$_with_[$1]_args" | sed -e 's/,/ /g'` ; do
426 _[$1]_found="" 456 _[$1]_found=""
427 case "$x" in 457 for y in $_[$1]_types; do
428 n | no | non | none ) _[$1]_all_default=no ;; 458 if test "$x" = "$y"; then
429 a | al | all | both ) _[$1]_all_default=yes ;; 459 _[$1]_found=yes
430 esac 460 eval "with_[$1]_$y=yes"
431 461 elif test "$x" = "no$y"; then
432 if test -z "$_[$1]_all_default"; then 462 _[$1]_found=yes
433 for y in $_[$1]_types; do 463 eval "with_[$1]_$y=no"
434 dnl echo "testing x='$x' against y='$y'" 464 fi
435 if test "$x" = "$y"; then 465 done
436 dnl echo "$x" = "$y" 466 test -z "$_[$1]_found" && \
437 _[$1]_found=yes 467 USAGE_ERROR(["\
438 dnl echo eval `echo "[$1]_$y=yes"` 468 Invalid type list supplied. Valid types for the [$2] option are:
439 eval "with_[$1]_$y=yes" 469 $_[$1]_types.
440 eval "enable_[$1]_$y=yes" 470 A prefix of \"no\" (eg, \"notype\" for \"type\") turns a type off.
441 elif test "$x" = "no$y"; then 471 Types not explicitly specified or negated take their defaults.
442 dnl echo "$x" = "no$y" 472 The list of defaults is \"$_[$1]_default\". Prefixing \`all' or
443 _[$1]_found=yes 473 \`none' to the list sets all defaults to on and off respectively.
444 dnl echo eval `echo "[$1]_$y=no"` 474 \`yes' as the sole argument is equivalent to omitting the argument."])
445 eval "with_[$1]_$y=no"
446 eval "enable_[$1]_$y=no"
447 fi
448 done
449 test -z "$_[$1]_found" && _[$1]_bogus=yes
450 fi
451 if test "$_[$1]_bogus" = "yes" -o \
452 \( -n "$_[$1]_all_default" -a -n "$_[$1]_notfirst" \) ; then
453 USAGE_ERROR(["Valid values for the [$2] option are:
454 $_[$1]_types. With prefix \"no\", switch it off.
455 Defaults may be overridden with \`all' or \`none' first in the list.
456 Hardcoded default is: $_[$1]_default."])
457 elif test -n "$_[$1]_all_default" ; then
458 for y in $_[$1]_types; do
459 eval "with_[$1]_$y=$_[$1]_all_default"
460 eval "enable_[$1]_$y=$_[$1]_all_default"
461 done
462 fi
463 _[$1]_notfirst=yes
464 done 475 done
465 unset _[$1]_bogus _[$1]_found _[$1]_notfirst _[$1]_types 476 dnl copy values to enable_FEATURE_TYPE. Cleanup default vars.
466 unset _[$1]_default _[$1]_all_default x y 477 for y in $_[$1]_types; do
478 eval "enable_[$1]_$y=\$with_[$1]_$y"
479 unset _[$1]_${y}_default
480 done
481 dnl clean up
482 unset _[$1]_types _[$1]_default _[$1]_all_default _[$1]_use_defaults
483 unset _with_[$1]_args _[$1]_found x y _require_[$1]
467 ])dnl 484 ])dnl
468 dnl 485 dnl
469 dnl XE_COMPLEX_OPTION(option, yesno) 486 dnl XE_COMPLEX_OPTION(option, yesno)
470 dnl -------------------------------- 487 dnl --------------------------------
471 dnl 488 dnl
494 define([XE_COMPLEX_ARG], 511 define([XE_COMPLEX_ARG],
495 [XE_INIT_COMPLEX_OPTION(patsubst([$1], -, _), m4_shiftn(4, $@)) 512 [XE_INIT_COMPLEX_OPTION(patsubst([$1], -, _), m4_shiftn(4, $@))
496 XE_MERGED_ARG([$1],[$2], 513 XE_MERGED_ARG([$1],[$2],
497 [XE_PARSE_COMPLEX_OPTION(patsubst([$1], -, _), [--with-$1]) 514 [XE_PARSE_COMPLEX_OPTION(patsubst([$1], -, _), [--with-$1])
498 $3 515 $3
499 ],[$4])])dnl 516 ],[
517 # set default for each type
518 for y in $_[$1]_types; do
519 eval "with_[$1]_$y=\$_[$1]_${y}_default"
520 eval "enable_[$1]_$y=\$_[$1]_${y}_default"
521 unset _[$1]_${y}_default
522 done
523 $4])])dnl
500 dnl 524 dnl
501 dnl ------------------------------------------------------------------------- 525 dnl -------------------------------------------------------------------------
502 XE_APPEND(lib-src, MAKE_SUBDIR) 526 XE_APPEND(lib-src, MAKE_SUBDIR)
503 XE_APPEND(lib-src, INSTALL_ARCH_DEP_SUBDIR) 527 XE_APPEND(lib-src, INSTALL_ARCH_DEP_SUBDIR)
504 with_dragndrop_default="no" 528 with_dragndrop_default="no"