File: acinclude.m4

package info (click to toggle)
abuse 2.00-12
  • links: PTS
  • area: main
  • in suites: slink
  • size: 12,708 kB
  • ctags: 15,389
  • sloc: ansic: 115,852; cpp: 6,792; lisp: 2,066; sh: 1,734; makefile: 1,601; asm: 264
file content (83 lines) | stat: -rw-r--r-- 2,305 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
dnl AB_CHECK_FLAG(FLAG, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AB_CHECK_FLAG,
[
AC_MSG_CHECKING([whether ifelse(AC_LANG, CPLUSPLUS, ${CXX}, ${CC}) supports the $1 flag])
ab_flag_var=`echo $1 | sed 'y%./+-%__p_%'`
AC_CACHE_VAL(ab_cv_flag_$ab_flag_var,
[
ifelse(AC_LANG, CPLUSPLUS, [
ab_save_flags="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $1"
], [
ab_save_flags="$CFLAGS"
CFLAGS="$CFLAGS $1"
])dnl
AC_TRY_COMPILE(,[int a;],
eval "ab_cv_flag_$ab_flag_var=yes", eval "ab_cv_flag_$ab_flag_var=no")
ifelse(AC_LANG, CPLUSPLUS, CXXFLAGS="$ab_save_flags", CFLAGS="$ab_save_flags")
])
if eval "test \"`echo '$ab_cv_flag_'$ab_flag_var`\" = yes"; then
  AC_MSG_RESULT(yes)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
ifelse([$3], , , [$3
])dnl
fi
])

dnl AB_ADD_FLAGS(FLAG...)
AC_DEFUN(AB_ADD_FLAGS,
[ab_flags=
for ab_flag in $1; do
AB_CHECK_FLAG([$ab_flag], [ab_flags="$ab_flags $ab_flag"])
ifelse(AC_LANG, CPLUSPLUS, [
ADDCXXFLAGS="$ab_flags"
AC_SUBST(ADDCXXFLAGS)
], [
ADDCFLAGS="$ab_flags"
AC_SUBST(ADDCFLAGS)
])dnl
done
])

AC_DEFUN(AB_C_BIGENDIAN,
[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
[ac_cv_c_bigendian=unknown
# See if we have a good endian.h.
AC_TRY_CPP([#include <endian.h>], [AC_TRY_COMPILE([#include <endian.h>], [
#if !__BYTE_ORDER || !__BIG_ENDIAN
  bogus endian macros
#endif], [AC_TRY_COMPILE([#include <endian.h>], [
#if __BYTE_ORDER != __BIG_ENDIAN
 not big endian
#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])])
if test $ac_cv_c_bigendian = unknown; then
# See if sys/param.h defines the BYTE_ORDER macro.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>], [
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
 bogus endian macros
#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>], [
#if BYTE_ORDER != BIG_ENDIAN
 not big endian
#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
fi
if test $ac_cv_c_bigendian = unknown; then
AC_TRY_RUN([main () {
  /* Are we little or big endian?  From Harbison&Steele.  */
  union
  {
    long l;
    char c[sizeof (long)];
  } u;
  u.l = 1;
  exit (u.c[sizeof (long) - 1] == 1);
}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
fi])
if test $ac_cv_c_bigendian = yes; then
  AC_DEFINE(WORDS_BIGENDIAN)
fi
])