-
Notifications
You must be signed in to change notification settings - Fork 0
/
acinclude.m4
90 lines (84 loc) · 3.2 KB
/
acinclude.m4
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
84
85
86
87
88
89
90
dnl acinclude.m4 are M4 macros used to generate aclocal.m4
dnl Copyright (C) 2002, 2003 Billy Biggs
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or (at
dnl your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
dnl AC_C_ATTRIBUTE_ALIGNED
dnl define ATTRIBUTE_ALIGNED_MAX to the maximum alignment if this is supported
AC_DEFUN([AC_C_ATTRIBUTE_ALIGNED],
[AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
[ac_cv_c_attribute_aligned],
[ac_cv_c_attribute_aligned=0
for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
AC_TRY_COMPILE([],
[static char c __attribute__ ((aligned($ac_cv_c_attr_align_try))) = 0; return c;],
[ac_cv_c_attribute_aligned=$ac_cv_c_attr_align_try])
done])
if test x"$ac_cv_c_attribute_aligned" != x"0"; then
AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
[$ac_cv_c_attribute_aligned],[maximum supported data alignment])
fi])
dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CC supports a given set of cflags
AC_DEFUN([AC_TRY_CFLAGS],
[AC_MSG_CHECKING([if $CC supports $1 flags])
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$1"
AC_TRY_COMPILE([],[],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no])
CFLAGS="$SAVE_CFLAGS"
AC_MSG_RESULT([$ac_cv_try_cflags_ok])
if test x"$ac_cv_try_cflags_ok" = x"yes"; then
ifelse([$2],[],[:],[$2])
else
ifelse([$3],[],[:],[$3])
fi])
dnl AC_CHECK_GENERATE_INTTYPES_H (INCLUDE-DIRECTORY)
dnl generate a default inttypes.h if the header file does not exist already
AC_DEFUN([AC_CHECK_GENERATE_INTTYPES],
[AC_CHECK_HEADER([inttypes.h],[],
[AC_COMPILE_CHECK_SIZEOF([char],[1])
AC_COMPILE_CHECK_SIZEOF([short],[2])
AC_COMPILE_CHECK_SIZEOF([int],[4])
AC_COMPILE_CHECK_SIZEOF([long long],[8])
cat >$1/inttypes.h << EOF
#ifndef _INTTYPES_H
#define _INTTYPES_H
/* default inttypes.h for people who do not have it on their system */
#if (!defined __int8_t_defined) && (!defined __BIT_TYPES_DEFINED__)
#define __int8_t_defined
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
#ifdef ARCH_X86
typedef signed long long int64_t;
#endif
#endif
#if (!defined _LINUX_TYPES_H)
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#ifdef ARCH_X86
typedef unsigned long long uint64_t;
#endif
#endif
#endif
EOF
])])
dnl AC_COMPILE_CHECK_SIZEOF (TYPE SUPPOSED-SIZE)
dnl abort if the given type does not have the supposed size
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
[AC_MSG_CHECKING(that size of $1 is $2)
AC_TRY_COMPILE([],[switch (0) case 0: case (sizeof ($1) == $2):;],[],
[AC_MSG_ERROR([can not build a default inttypes.h])])
AC_MSG_RESULT([yes])])