source: abuse/tags/pd/imlib/acinclude.m4 @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
File size: 2.3 KB
Line 
1dnl AB_CHECK_FLAG(FLAG, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
2AC_DEFUN(AB_CHECK_FLAG,
3[
4AC_MSG_CHECKING([whether ifelse(AC_LANG, CPLUSPLUS, ${CXX}, ${CC}) supports the $1 flag])
5ab_flag_var=`echo $1 | sed 'y%./+-%__p_%'`
6AC_CACHE_VAL(ab_cv_flag_$ab_flag_var,
7[
8ifelse(AC_LANG, CPLUSPLUS, [
9ab_save_flags="$CXXFLAGS"
10CXXFLAGS="$CXXFLAGS $1"
11], [
12ab_save_flags="$CFLAGS"
13CFLAGS="$CFLAGS $1"
14])dnl
15AC_TRY_COMPILE(,[int a;],
16eval "ab_cv_flag_$ab_flag_var=yes", eval "ab_cv_flag_$ab_flag_var=no")
17ifelse(AC_LANG, CPLUSPLUS, CXXFLAGS="$ab_save_flags", CFLAGS="$ab_save_flags")
18])
19if eval "test \"`echo '$ab_cv_flag_'$ab_flag_var`\" = yes"; then
20  AC_MSG_RESULT(yes)
21  ifelse([$2], , :, [$2])
22else
23  AC_MSG_RESULT(no)
24ifelse([$3], , , [$3
25])dnl
26fi
27])
28
29dnl AB_ADD_FLAGS(FLAG...)
30AC_DEFUN(AB_ADD_FLAGS,
31[ab_flags=
32for ab_flag in $1; do
33AB_CHECK_FLAG([$ab_flag], [ab_flags="$ab_flags $ab_flag"])
34ifelse(AC_LANG, CPLUSPLUS, [
35ADDCXXFLAGS="$ab_flags"
36AC_SUBST(ADDCXXFLAGS)
37], [
38ADDCFLAGS="$ab_flags"
39AC_SUBST(ADDCFLAGS)
40])dnl
41done
42])
43
44AC_DEFUN(AB_C_BIGENDIAN,
45[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
46[ac_cv_c_bigendian=unknown
47# See if we have a good endian.h.
48AC_TRY_CPP([#include <endian.h>], [AC_TRY_COMPILE([#include <endian.h>], [
49#if !__BYTE_ORDER || !__BIG_ENDIAN
50  bogus endian macros
51#endif], [AC_TRY_COMPILE([#include <endian.h>], [
52#if __BYTE_ORDER != __BIG_ENDIAN
53 not big endian
54#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])])
55if test $ac_cv_c_bigendian = unknown; then
56# See if sys/param.h defines the BYTE_ORDER macro.
57AC_TRY_COMPILE([#include <sys/types.h>
58#include <sys/param.h>], [
59#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
60 bogus endian macros
61#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
62AC_TRY_COMPILE([#include <sys/types.h>
63#include <sys/param.h>], [
64#if BYTE_ORDER != BIG_ENDIAN
65 not big endian
66#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
67fi
68if test $ac_cv_c_bigendian = unknown; then
69AC_TRY_RUN([main () {
70  /* Are we little or big endian?  From Harbison&Steele.  */
71  union
72  {
73    long l;
74    char c[sizeof (long)];
75  } u;
76  u.l = 1;
77  exit (u.c[sizeof (long) - 1] == 1);
78}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
79fi])
80if test $ac_cv_c_bigendian = yes; then
81  AC_DEFINE(WORDS_BIGENDIAN)
82fi
83])
Note: See TracBrowser for help on using the repository browser.