Trying to be fancy with feature testing

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

 



It comes up often that we want to test to see whether a feature of GCC
works.  For instance, we want to see if -m64 is a valid gcc option to
know if we should build the 64-bit libraries by default.  Other things
include checking for unicode support, and the -municode option.  To do
this, we usually do something like the following:

_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS option"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM.......
CFLAGS="$_save_CFLAGS"

I was trying to improve upon that using AS_VAR_COPY for the
save/restore, but I can't figure out how to handle variables
containing spaces.  So I then decided to make my own macro that would
be something like:
MACRO([variable to save],[option to add],[code to test])

I came up with this:
AC_DEFUN([MW64_VAR_PUSHPOP],[
  AS_VAR_PUSHDEF([savevar],[_save_$1])
  AS_VAR_SET([savevar],["$$1"])
  AS_VAR_APPEND([savevar],[" $2"])
  $3
  AS_VAR_SET([$1],["$savevar"])
  AS_VAR_POPDEF([savevar])])

The output seems ok (although I have a stray "])" coming from
somewhere, and I can't find it.)  Does my methodology seem at all
decent?  Is there an easier/better way to handle all that quoting for
variables with a lot of spaces (as CFLAGS and company usually
contain)?


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux