autoconf
[Top][All Lists]
Advanced

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

Re: Idiom for setting defines


From: Russ Allbery
Subject: Re: Idiom for setting defines
Date: Thu, 17 Jul 2003 13:18:54 -0700
User-agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Common Lisp, linux)

Bill Moseley <address@hidden> writes:

> For example, is there a better (or more compact) way to write:

> AC_ARG_ENABLE([memdebug],
>         AC_HELP_STRING([--enable-memdebug], [debug memory),
>         ,
>         enableval=no)

> if test "$enableval" != "no"; then
>         AC_MSG_NOTICE([MEM_DEBUG enabled])
>         AC_DEFINE(MEM_DEBUG,1,[debug memory])
> fi

I generally do something like:

AC_MSG_CHECKING([if memory debugging is requested])
AC_ARG_ENABLE([memdebug],
    AC_HELP_STRING([--enable-memdebug], [Enable memory debugging]),
    ,
    enableval=no)
AC_MSG_RESULT($enableval)
if test x"$enableval" != xno ; then
    AC_DEFINE([MEM_DEBUG], 1, [Define to 1 to enable memory debugging])
fi

Since you have a lot of those, I'd parameterize the whole thing and turn
it into a macro.  It would probably need to take five arguments (the name
of the enable string, the variable to set, the checking output, the help
string, and the string for config.h), which is sort of annoying, but it
might still be more compact.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>





reply via email to

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