On 06/07/2012 07:59 AM, Adam Mercer wrote: > Hi > > I'm trying to add a check to my configure.ac to determine if clang is > being used, I have the following: > > CLANG_CC= > if test "$GCC" = yes; then > if test "`$CC -v 2>&1 | grep -c 'clang version'`" != "0"; then > CLANG_CC=1 > fi > fi > > And I'm trying to use AS_IF instead, I've been reading to > documentation[1], and have come up with the following: > > AS_IF([test "$GCC" = yes],[ ^ Unmatched [. > [AS_IF([test "`$CC -v 2>&1 | grep -c 'clang_version'`" != "0"],[CLANG_CC=1])], > [CLANG_CC=]) What you are doing should work, once you fix the typo; this is what I see in a resulting configure file after pasting in a corrected version of your attempt: if test "$GCC" = yes; then : if test "`$CC -v 2>&1 | grep -c 'clang_version'`" != "0"; then : CLANG_CC=1 fi else CLANG_CC= fi Yeah, the formatting is not as pretty as what you started with, but when was generated configure ever formatted nicely? You will also notice that you had a logic change - your original code left CLANG_CC explicitly set to the empty string in all but the double-success case, but your AS_IF attempt leaves CLANG_CC undefined rather than explicitly empty on the success/failure path. > > but it doesn't seem to be working, whereas the version using if does. > Therefore I must be incorrectly constructing the nested use of AS_IF. > Can anyone spot what I'm doing wrong? Or know of a better way to check > if clang is being used? Libvirt uses: AC_CACHE_CHECK([whether this build is done by a static analysis tool], [lv_cv_static_analysis], [ lv_cv_static_analysis=no if test -n "${CCC_ANALYZER_ANALYSIS+set}" || \ test -n "$COVERITY_BUILD_COMMAND$COVERITY_LD_PRELOAD"; then lv_cv_static_analysis=yes fi ]) -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf