autoconf
[Top][All Lists]
Advanced

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

Re: How to pass AC_ARG_ENABLE an argument


From: Eric Sunshine
Subject: Re: How to pass AC_ARG_ENABLE an argument
Date: Sun, 21 Dec 2003 04:22:14 -0500
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624

Dave Kirkby wrote:
What am I doing wrong here then?
AC_ARG_ENABLE([cpus],
   AC_HELP_STRING([--enable-CPUs=<N>], [use N CPUs in SMP mode
       (default is 4)]),
   AC_DEFINE([CPUS],$enable_cpus,[Enabled N CPUs in SMP mode]),
   AC_DEFINE([CPUS],4,[Enabled the default number of CPUs in SMP mode]))
configure --enable-cpus=12
Then my config.h shows:
#define CPUS $enable_cpus

Some notes:

(1) Use AC_DEFINE_UNQUOTED to get $enable_cpus to expand properly.

(2) You should handle the case when the user specifies --disable-cpus (or --enable-cpus=no).

(3) To avoid confusing users, your help message should reflect the actual option name (that is, --enable-cpus rather than --enable-CPUs).

(4) As a general rule, it is important to quote all arguments to all functions. For instance, you are using AC_HELP_STRING() and AC_DEFINE() as arguments to AC_ARG_ENABLE(), so those invocations should be quoted. For example: AC_ARG_ENABLE([cpus], [AC_HELP_STRING([--blah]...)], [AC_DEFINE([FOO]...)]).

Here is one possible implementation which will provide the output you desire, and which addresses the above issues.

AC_ARG_ENABLE([cpus],
    [AC_HELP_STRING([--enable-cpus=<N>],
        [use N CPUs in SMP mode (default is 4)])],
    [], [enable_cpus=4])
AS_IF([test $enable_cpus = no], [enable_cpus=1])
AC_DEFINE_UNQUOTED([CPUS],[$enable_cpus],[Enabled N CPUs in SMP mode])

-- ES





reply via email to

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