[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Trying to be fancy with feature testing
From: |
NightStrike |
Subject: |
Trying to be fancy with feature testing |
Date: |
Sat, 6 Mar 2010 12:23:38 -0500 |
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)?
- Trying to be fancy with feature testing,
NightStrike <=