Search
lxdream.org :: lxdream/acinclude.m4
lxdream 0.9.1
released Jun 29
Download Now
filename acinclude.m4
changeset 1212:d1117828f011
prev1211:eecdeb37934a
author nkeynes
date Thu Feb 23 20:16:37 2012 +1000 (7 years ago)
permissions -rw-r--r--
last change Merge emu sign-extension fix to top
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 save_CFLAGS="$CFLAGS"
     8 CFLAGS="-Werror $save_CFLAGS"
     9 AC_RUN_IFELSE([
    10   AC_LANG_SOURCE([[
    11 int __attribute__((regparm(3))) foo(int a, int b) { return a+b; }
    13 int main(int argc, char *argv[])
    14 {
    15    return foo( 1, 2 ) == 3 ? 0 : 1;
    16 }]])], [ 
    17    AC_MSG_RESULT([yes])
    18    $1 ], [ 
    19    AC_MSG_RESULT([no])
    20    $2 ], [
    21       AC_MSG_RESULT([no])
    22    $2 ])
    23 CFLAGS="$save_CFLAGS"
    24 ])
    26 # AC_CHECK_FORCEINLINE([if-ok],[if-notok])
    27 # Test if the compiler recognizes __attribute__((always_inline))
    28 # -----------------------
    29 AC_DEFUN([AC_CHECK_FORCEINLINE], [
    30 AC_MSG_CHECKING([support for force inlining]);
    31 AC_COMPILE_IFELSE([
    32   AC_LANG_SOURCE([[
    33 static int __attribute__((always_inline)) foo(int a, int b) { return a+b; }
    35 int main(int argc, char *argv[])
    36 {
    37    return foo( 1, 2 ) == 3 ? 0 : 1;
    38 }]])], [ 
    39    FORCEINLINE="__attribute__((always_inline))"
    40    AC_MSG_RESULT([$FORCEINLINE])
    41    $1 ], [ 
    42    FORCEINLINE=""
    43    AC_MSG_RESULT([no])
    44    $2 ])
    45 ])
    47 # AC_CHECK_FRAME_ADDRESS([if-ok],[if-notok])
    48 # Test if the compiler will let us modify the return address on the stack
    49 # via __builtin_frame_address()
    50 # -----------------------
    51 AC_DEFUN([AC_CHECK_FRAME_ADDRESS], [
    52 AC_MSG_CHECKING([if we have a working __builtin_frame_address()]);
    53 AC_RUN_IFELSE([
    54   AC_LANG_SOURCE([[
    55 void * __attribute__((noinline)) first_arg( void *x, void *y ) { return x; }
    56 int __attribute__((noinline)) foo( int arg, void *exc )
    57 {
    58     if( arg < 2 ) {
    59         *(((void * volatile *)__builtin_frame_address(0))+1) = exc;
    60     }
    61     return 0;
    62 }
    64 int main(int argc, char *argv[])
    65 {
    66    goto *first_arg(&&start, &&except);
    68 start:
    69    return foo( argc, &&except ) + 1;
    71 except:
    72    return 0;
    73 }]])], [ 
    74    AC_MSG_RESULT([yes])
    75    $1 ], [ 
    76    AC_MSG_RESULT([no])
    77    $2 ], [
    78    AC_MSG_RESULT([no])
    79    $2 ] )
    80 ])
    82 # AC_CC_VERSION([if-gcc], [if-icc],[if-other])
    83 # Check which C compiler we're using and branch accordingly, eg to set
    84 # different optimization flags. Currently recognizes gcc and icc
    85 # ---------------
    86 AC_DEFUN([AC_CC_VERSION], [
    87 _GCC_VERSION=`$CC --version | $SED -ne '/gcc/p'`
    88 _ICC_VERSION=`$CC --version | $SED -ne '/(ICC)/p'`
    89 AC_MSG_CHECKING([CC version])
    90 if test -n "$_ICC_VERSION"; then
    91    AC_MSG_RESULT([ICC])
    92    [ $2 ]
    93 elif test -n "$_GCC_VERSION"; then
    94    AC_MSG_RESULT([GCC])
    95    [ $1 ] 
    96 else 
    97    AC_MSG_RESULT([Unknown])
    98    [ $3 ]
    99 fi
   100 ]);
   102 # AC_OBJC_VERSION([if-gcc],[if-other], [if-none])
   103 # Check which objective C compiler we're using and branch accordingly.
   104 AC_DEFUN([AC_OBJC_VERSION], [
   105 AC_MSG_CHECKING([OBJC version])
   106 if test -n "$OBJC"; then
   107   _GOBJC_VERSION=`$OBJC --version | $SED -ne '/(GCC)/p'`
   108   if test -n "$_GOBJC_VERSION"; then
   109     AC_MSG_RESULT([GCC])
   110     [ $1 ]
   111   else 
   112     AC_MSG_RESULT([Unknown])
   113     [ $2 ]
   114   fi
   115 else
   116   AC_MSG_RESULT([None])
   117   [ $3 ]
   118 fi
   119 ]);
   121 # Check if the given C compiler flag is supported, and if so add it to CFLAGS
   122 AC_DEFUN([AC_CHECK_CFLAG], [
   123 AC_LANG_PUSH([C])
   124 AC_MSG_CHECKING([if $CC supports $1])
   125 save_CFLAGS="$CFLAGS"
   126 CFLAGS="$1 $CFLAGS"
   127 AC_COMPILE_IFELSE([
   128   AC_LANG_SOURCE([int main() { return 0; }])], [
   129    AC_MSG_RESULT([yes])
   130    $2 ], [ 
   131    CFLAGS="$save_CFLAGS"
   132    AC_MSG_RESULT([no])
   133    $3 ])
   134 AC_LANG_POP([C])
   135 ])
   137 # Check if the given OBJC compiler flag is supported, and if so add it to OBJCFLAGS
   138 AC_DEFUN([AC_CHECK_OBJCFLAG], [
   139 AC_LANG_PUSH([Objective C])
   140 AC_MSG_CHECKING([if $OBJC supports $1])
   141 save_OBJCFLAGS="$OBJCFLAGS"
   142 OBJCFLAGS="$1 $OBJCFLAGS"
   143 AC_COMPILE_IFELSE([
   144   AC_LANG_SOURCE([int main() { return 0; }])], [
   145    AC_MSG_RESULT([yes])
   146    $2 ], [ 
   147    OBJCFLAGS="$save_OBJCFLAGS"
   148    AC_MSG_RESULT([no])
   149    $3 ])
   150 AC_LANG_POP([Objective C])
   151 ])
   155 # AC_HAVE_OBJC([if-present],[if-not-present])
   156 # Check if we have a working Objective-C compiler
   157 AC_DEFUN([AC_HAVE_OBJC], [
   158 AC_PROG_OBJC
   159 AC_MSG_CHECKING([for a working Objective-C compiler])
   160 AC_LANG_PUSH([Objective C])dnl
   161 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@interface Foo @end]], [])],
   162    [AC_MSG_RESULT([yes])
   163     $1 ],
   164    [AC_MSG_RESULT([No])
   165     $2 ]);
   166 AC_LANG_POP([Objective C])
   167 ]);
.