guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

abstractions on AC_ARG_ENABLE and AC_ARG_WITH


From: Thien-Thi Nguyen
Subject: abstractions on AC_ARG_ENABLE and AC_ARG_WITH
Date: Fri, 30 Aug 2002 05:13:42 -0700

please find appended below four macros from (upcoming) guile-1.4.1.81
acinclude.m4 that provide some useful abstractions on AC_ARG_ENABLE and
AC_ARG_WITH.  sample usage:

  GUILE_DEFAULT_ENABLED(arrays,[array and uniform array support],[
    AC_LIBOBJ([ramap])
    AC_LIBOBJ([unif])
    AC_DEFINE(HAVE_ARRAYS, 1,
      [Define this if you want support for arrays and uniform arrays.])
    ])

this does the right thing with these invocations:

  configure
  configure --enable-arrays
  configure --enable-arrays=y
  configure --enable-arrays=yes
  configure --enable-arrays=no
  configure --disable-arrays

tested w/ autoconf 2.53 (and automake 1.6.1 and 1.6.3, which is where
aclocal comes from).  email me privately if you want the ad-hoc test
framework (two files).  check out autoconf info node "Redefined M4
Macros" for `m4_if' and friends.  also recommended is the autoconf
mailing list archives -- quite interesting!

(m4 style flames to /dev/null. :-)

thi


_______________________________________________________________________
(excerpt from file with:
## Copyright (C) 2002 Free Software Foundation, Inc.
)

## Abstractions on AC_ARG_ENABLE and AC_ARG_WITH
##
## The AC_ARG_ENABLE and AC_ARG_WITH macros help distinguish between
## given (seen) and not-given (unseen) args to configure.  We use them
## to provide distinction between enabled/with and disabled/without,
## which is conceptually a better fit (aka easier to work with).  The
## macros are all structured to accept args:
##
##   $1 -- feature
##   $2 -- 2nd arg to AC_HELP_STRING, a noun phrase
##   $3 -- enable (or "with") action                    [optional]
##   $4 -- disable (or "without") action                [optional]
##
## The upshot is that changing one's mind about the default of a feature
## (whether it is enabled or disabled (or "with" or "without")) means
## you only have to change the macro name at the call site instead of
## having to reorder args, etc, as would be required by using the raw
## AC_* macros.
##
## Perhaps these four can be contributed to Autoconf someday.
##

## GUILE_DEFAULT_ENABLED(FEATURE,NP,[ENABLE = true],[DISABLE = true])
## ------------------------------------------------------------------
AC_DEFUN([GUILE_DEFAULT_ENABLED],[
  AC_ARG_ENABLE([$1],AC_HELP_STRING([--disable-$1],[disable $2]),[
    if test $enableval != no ; then
      m4_if([$3],[],[true],[$3])
    m4_if([$4],[],[],[else $4])
    fi
  ],[
    m4_if([$3],[],[true],[$3])
  ])
])

## GUILE_DEFAULT_DISABLED(FEATURE,NP,[ENABLE = true],[DISABLE = true])
## -------------------------------------------------------------------
AC_DEFUN([GUILE_DEFAULT_DISABLED],[
  AC_ARG_ENABLE([$1],AC_HELP_STRING([--enable-$1],[enable $2]),[
    if test $enableval != no ; then
      m4_if([$3],[],[true],[$3])
    m4_if([$4],[],[],[else $4])
    fi
  ],[
    m4_if([$4],[],[true],[$4])
  ])
])

## GUILE_DEFAULT_WITH(FEATURE,NP,[WITH = true],[WITHOUT = true])
## -------------------------------------------------------------
AC_DEFUN([GUILE_DEFAULT_WITH],[
  AC_ARG_WITH([$1],AC_HELP_STRING([--without-$1],[do not use $2]),[
    if test $withval != no ; then
      m4_if([$3],[],[true],[$3])
    m4_if([$4],[],[],[else $4])
    fi
  ],[
    m4_if([$3],[],[true],[$3])
  ])
])

## GUILE_DEFAULT_WITHOUT(FEATURE,NP,[WITH = true],[WITHOUT = true])
## ----------------------------------------------------------------
AC_DEFUN([GUILE_DEFAULT_WITHOUT],[
  AC_ARG_WITH([$1],AC_HELP_STRING([--with-$1],[use $2]),[
    if test $withval != no ; then
      m4_if([$3],[],[true],[$3])
    m4_if([$4],[],[],[else $4])
    fi
  ],[
    m4_if([$4],[],[true],[$4])
  ])
])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]