Search
lxdream.org :: lxdream/acinclude.m4
lxdream 0.9.1
released Jun 29
Download Now
filename acinclude.m4
changeset 985:52e64faac752
prev977:8514fb4bc101
next1147:e04e4af64626
author nkeynes
date Fri Jun 26 05:47:04 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Refactor path operations into lxpaths.[ch]
view annotate diff log raw
     1 # AC_CHECK_FASTCALL([if-ok],[if-notok])
     2 # Test if the compiler recognizes __attribute__((regparm(3))) - we don't 
     3 # currently check if it actually works correctly, but probably should...
     4 # -----------------------
     5 AC_DEFUN([AC_CHECK_FASTCALL], [
     6 AC_MSG_CHECKING([support for fastcall calling conventions]);
     7 AC_RUN_IFELSE([
     8   AC_LANG_SOURCE([[
     9 int __attribute__((regparm(3))) foo(int a, int b) { return a+b; }
    11 int main(int argc, char *argv[])
    12 {
    13    return foo( 1, 2 ) == 3 ? 0 : 1;
    14 }]])], [ 
    15    AC_MSG_RESULT([yes])
    16    $1 ], [ 
    17    AC_MSG_RESULT([no])
    18    $2 ])
    19 ])
    21 # AC_CHECK_FRAME_ADDRESS([if-ok],[if-notok])
    22 # Test if the compiler will let us modify the return address on the stack
    23 # via __builtin_frame_address()
    24 # -----------------------
    25 AC_DEFUN([AC_CHECK_FRAME_ADDRESS], [
    26 AC_MSG_CHECKING([if we have a working __builtin_frame_address()]);
    27 AC_RUN_IFELSE([
    28   AC_LANG_SOURCE([[
    29 void * __attribute__((noinline)) first_arg( void *x, void *y ) { return x; }
    30 int __attribute__((noinline)) foo( int arg, void *exc )
    31 {
    32     if( arg < 2 ) {
    33         *(((void **)__builtin_frame_address(0))+1) = exc;
    34     }
    35     return 0;
    36 }
    38 int main(int argc, char *argv[])
    39 {
    40    goto *first_arg(&&start, &&except);
    42 start:
    43    return foo( argc, &&except ) + 1;
    45 except:
    46    return 0;
    47 }]])], [ 
    48    AC_MSG_RESULT([yes])
    49    $1 ], [ 
    50    AC_MSG_RESULT([no])
    51    $2 ])
    52 ])
    54 # AC_CC_VERSION([if-gcc], [if-icc],[if-other])
    55 # Check which C compiler we're using and branch accordingly, eg to set
    56 # different optimization flags. Currently recognizes gcc and icc
    57 # ---------------
    58 AC_DEFUN([AC_CC_VERSION], [
    59 _GCC_VERSION=`$CC --version | $SED -ne '/gcc/p'`
    60 _ICC_VERSION=`$CC --version | $SED -ne '/(ICC)/p'`
    61 AC_MSG_CHECKING([CC version])
    62 if test -n "$_ICC_VERSION"; then
    63    AC_MSG_RESULT([ICC])
    64    [ $2 ]
    65 elif test -n "$_GCC_VERSION"; then
    66    AC_MSG_RESULT([GCC])
    67    [ $1 ] 
    68 else 
    69    AC_MSG_RESULT([Unknown])
    70    [ $3 ]
    71 fi
    72 ]);
    74 # AC_OBJC_VERSION([if-gcc],[if-other], [if-none])
    75 # Check which objective C compiler we're using and branch accordingly.
    76 AC_DEFUN([AC_OBJC_VERSION], [
    77 AC_MSG_CHECKING([OBJC version])
    78 if test -n "$OBJC"; then
    79   _GOBJC_VERSION=`$OBJC --version | $SED -ne '/(GCC)/p'`
    80   if test -n "$_GOBJC_VERSION"; then
    81     AC_MSG_RESULT([GCC])
    82     [ $1 ]
    83   else 
    84     AC_MSG_RESULT([Unknown])
    85     [ $2 ]
    86   fi
    87 else
    88   AC_MSG_RESULT([None])
    89   [ $3 ]
    90 fi
    91 ]);
    93 # AC_HAVE_OBJC([if-present],[if-not-present])
    94 # Check if we have a working Objective-C compiler
    95 AC_DEFUN([AC_HAVE_OBJC], [
    96 AC_PROG_OBJC
    97 AC_MSG_CHECKING([for a working Objective-C compiler])
    98 AC_LANG_PUSH([Objective C])dnl
    99 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@interface Foo @end]], [])],
   100    [AC_MSG_RESULT([yes])
   101     $1 ],
   102    [AC_MSG_RESULT([No])
   103     $2 ]);
   104 AC_LANG_POP([Objective C])
   105 ]);
.