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 Tue Feb 24 11:47:41 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Set the source-type flags to -D__EXTENSIONS__ -U__STRICT_ANSI__ - this seems
to work correctly on all the platforms we care about at the moment.
Tweak the gcc-detection slightly (it was getting it wrong on some gcc builds)
file annotate diff log raw
nkeynes@923
     1
# AC_CHECK_FASTCALL([if-ok],[if-notok])
nkeynes@923
     2
# Test if the compiler recognizes __attribute__((regparm(3))) - we don't 
nkeynes@923
     3
# currently check if it actually works correctly, but probably should...
nkeynes@923
     4
# -----------------------
nkeynes@923
     5
AC_DEFUN([AC_CHECK_FASTCALL], [
nkeynes@923
     6
AC_MSG_CHECKING([support for fastcall calling conventions]);
nkeynes@923
     7
AC_RUN_IFELSE([
nkeynes@923
     8
  AC_LANG_SOURCE([[
nkeynes@923
     9
int __attribute__((regparm(3))) foo(int a, int b) { return a+b; }
nkeynes@923
    10
nkeynes@923
    11
int main(int argc, char *argv[])
nkeynes@923
    12
{
nkeynes@923
    13
   return foo( 1, 2 ) == 3 ? 0 : 1;
nkeynes@923
    14
}]])], [ 
nkeynes@923
    15
   AC_MSG_RESULT([yes])
nkeynes@923
    16
   $1 ], [ 
nkeynes@923
    17
   AC_MSG_RESULT([no])
nkeynes@923
    18
   $2 ])
nkeynes@923
    19
])
nkeynes@923
    20
nkeynes@927
    21
# AC_CHECK_FRAME_ADDRESS([if-ok],[if-notok])
nkeynes@927
    22
# Test if the compiler will let us modify the return address on the stack
nkeynes@927
    23
# via __builtin_frame_address()
nkeynes@927
    24
# -----------------------
nkeynes@927
    25
AC_DEFUN([AC_CHECK_FRAME_ADDRESS], [
nkeynes@927
    26
AC_MSG_CHECKING([if we have a working __builtin_frame_address()]);
nkeynes@927
    27
AC_RUN_IFELSE([
nkeynes@927
    28
  AC_LANG_SOURCE([[
nkeynes@927
    29
void * __attribute__((noinline)) first_arg( void *x, void *y ) { return x; }
nkeynes@927
    30
int __attribute__((noinline)) foo( int arg, void *exc )
nkeynes@927
    31
{
nkeynes@927
    32
    if( arg < 2 ) {
nkeynes@927
    33
        *(((void **)__builtin_frame_address(0))+1) = exc;
nkeynes@927
    34
    }
nkeynes@927
    35
    return 0;
nkeynes@927
    36
}
nkeynes@927
    37
nkeynes@927
    38
int main(int argc, char *argv[])
nkeynes@927
    39
{
nkeynes@927
    40
   goto *first_arg(&&start, &&except);
nkeynes@927
    41
   
nkeynes@927
    42
start:
nkeynes@927
    43
   return foo( argc, &&except ) + 1;
nkeynes@927
    44
nkeynes@927
    45
except:
nkeynes@927
    46
   return 0;
nkeynes@927
    47
}]])], [ 
nkeynes@927
    48
   AC_MSG_RESULT([yes])
nkeynes@927
    49
   $1 ], [ 
nkeynes@927
    50
   AC_MSG_RESULT([no])
nkeynes@927
    51
   $2 ])
nkeynes@927
    52
])
nkeynes@927
    53
nkeynes@964
    54
# AC_CC_VERSION([if-gcc], [if-icc],[if-other])
nkeynes@964
    55
# Check which C compiler we're using and branch accordingly, eg to set
nkeynes@964
    56
# different optimization flags. Currently recognizes gcc and icc
nkeynes@964
    57
# ---------------
nkeynes@964
    58
AC_DEFUN([AC_CC_VERSION], [
nkeynes@985
    59
_GCC_VERSION=`$CC --version | $SED -ne '/gcc/p'`
nkeynes@964
    60
_ICC_VERSION=`$CC --version | $SED -ne '/(ICC)/p'`
nkeynes@964
    61
AC_MSG_CHECKING([CC version])
nkeynes@985
    62
if test -n "$_ICC_VERSION"; then
nkeynes@985
    63
   AC_MSG_RESULT([ICC])
nkeynes@985
    64
   [ $2 ]
nkeynes@985
    65
elif test -n "$_GCC_VERSION"; then
nkeynes@964
    66
   AC_MSG_RESULT([GCC])
nkeynes@985
    67
   [ $1 ] 
nkeynes@964
    68
else 
nkeynes@964
    69
   AC_MSG_RESULT([Unknown])
nkeynes@964
    70
   [ $3 ]
nkeynes@964
    71
fi
nkeynes@964
    72
]);
nkeynes@927
    73
nkeynes@964
    74
# AC_OBJC_VERSION([if-gcc],[if-other], [if-none])
nkeynes@964
    75
# Check which objective C compiler we're using and branch accordingly.
nkeynes@964
    76
AC_DEFUN([AC_OBJC_VERSION], [
nkeynes@964
    77
AC_MSG_CHECKING([OBJC version])
nkeynes@964
    78
if test -n "$OBJC"; then
nkeynes@964
    79
  _GOBJC_VERSION=`$OBJC --version | $SED -ne '/(GCC)/p'`
nkeynes@964
    80
  if test -n "$_GOBJC_VERSION"; then
nkeynes@964
    81
    AC_MSG_RESULT([GCC])
nkeynes@964
    82
    [ $1 ]
nkeynes@964
    83
  else 
nkeynes@964
    84
    AC_MSG_RESULT([Unknown])
nkeynes@964
    85
    [ $2 ]
nkeynes@964
    86
  fi
nkeynes@964
    87
else
nkeynes@964
    88
  AC_MSG_RESULT([None])
nkeynes@964
    89
  [ $3 ]
nkeynes@964
    90
fi
nkeynes@964
    91
]);
nkeynes@977
    92
nkeynes@977
    93
# AC_HAVE_OBJC([if-present],[if-not-present])
nkeynes@977
    94
# Check if we have a working Objective-C compiler
nkeynes@977
    95
AC_DEFUN([AC_HAVE_OBJC], [
nkeynes@977
    96
AC_PROG_OBJC
nkeynes@977
    97
AC_MSG_CHECKING([for a working Objective-C compiler])
nkeynes@977
    98
AC_LANG_PUSH([Objective C])dnl
nkeynes@977
    99
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@interface Foo @end]], [])],
nkeynes@977
   100
   [AC_MSG_RESULT([yes])
nkeynes@977
   101
    $1 ],
nkeynes@977
   102
   [AC_MSG_RESULT([No])
nkeynes@977
   103
    $2 ]);
nkeynes@977
   104
AC_LANG_POP([Objective C])
nkeynes@977
   105
]);
.