autoconf
[Top][All Lists]
Advanced

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

Re: iterating over arguments


From: Eric Blake
Subject: Re: iterating over arguments
Date: Fri, 11 Sep 2009 20:40:54 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 9/11/2009 11:34 AM:
> * Sam Steingold wrote on Fri, Sep 11, 2009 at 06:24:21PM CEST:
>> CL_CLISP_REQUIRE_FEATURE([ffi screen unicode])
>> and it will expand into something like
>>
>> AC_CACHE_CHECK([for FFI in CLISP], [cl_cv_clisp_ffi],
>>  [CLISP_SET(cl_cv_clisp_ffi,[[#+ffi "yes" #-ffi "no"]])])
>> test $cl_cv_clisp_ffi = no && AC_MSG_ERROR([FFI is missing in CLISP])
>> AC_CACHE_CHECK([for SCREEN in CLISP], [cl_cv_clisp_screen],
>>  [CLISP_SET(cl_cv_clisp_screen,[[#+screen "yes" #-screen "no"]])])
>> test $cl_cv_clisp_screen = no && AC_MSG_ERROR([SCREEN is missing in CLISP])
>> AC_CACHE_CHECK([for UNICODE in CLISP], [cl_cv_clisp_unicode],
>>  [CLISP_SET(cl_cv_clisp_unicode,[[#+unicode "yes" #-unicode "no"]])])
>> test $cl_cv_clisp_unicode = no && AC_MSG_ERROR([UNICODE is missing in CLISP])
> 
> again, completely untested, and probably overquoted in one or two spots:
> 
> AC_DEFUN([CL_CLISP_REQUIRE_FEATURE], [dnl
> m4_foreach_w([cl_feat], [$1],
> [m4_pushdef([CL_FEAT], [m4_toupper([cl_feat])])dnl
> AC_CACHE_CHECK([for CL_FEAT in CLISP], [cl_cv_clisp_][cl_feat],
>   [CLISP_SET([...])
> ])
> m4_popdef([CL_FEAT])
> ])
> ])

Try this (also untested, but less likely to be overquoted...):

AC_DEFUN([CL_CLISP_REQUIRE_FEATURE],
[m4_foreach_w([cl_feat], [$1],
[m4_pushdef([CL_FEAT], m4_toupper(cl_feat))dnl
AC_CACHE_CHECK([for CL_FEAT in CLISP], [cl_cv_clisp_]cl_feat,
  [CLISP_SET([cl_cv_clisp_]cl_feat,
    [[#+]]cl_feat[[ "yes" #-]]cl_feat[[ "no"]])])
test $cl_cv_clisp_]cl_feat[ = no && AC_MSG_ERROR(
  CL_FEAT[ is missing in CLISP])
m4_popdef([CL_FEAT])])])

This assumes that your arguments to CL_CLISP_REQUIRE_FEATURE won't cause
further macro expansion or quote removal; to be safer, you'd have to use
m4_defn([cl_feat]) rather than cl_feat in several places.  Also, if you
are requiring newer autoconf, it may be more efficient to use
m4_map_args_w rather than m4_foreach_w:

m4_define([_CL_CLISP_REQUIRE_FEATURE_1],
[_CL_CLISP_REQUIRE_FEATURE_2([$1], m4_toupper([$1]))])
m4_define([_CL_CLISP_REQUIRE_FEATURE_2],
[AC_CACHE_CHECK([for $2 in CLISP], [cl_cv_clisp_$1],
  [CLISP_SET([cl_cv_clisp_$1], [[#+$1 "yes" #-$1 "no"]])])
test $cl_cv_clisp_$1 = no && AC_MSG_ERROR([$2 is missing in CLISP])])
AC_DEFUN([CL_LISP_REQUIRE_FEATURE],
[m4_map_args_w([$1], [_CL_CLISP_REQUIRE_FEATURE_1(], [)], [
])

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqrCjYACgkQ84KuGfSFAYAyvQCglh/yL9dHoBSmxH9DMwCY4Nxr
Wh0AoIlcs5Y/TF+AsSqNlY2bWhjWVhQg
=KTiw
-----END PGP SIGNATURE-----




reply via email to

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