-
Notifications
You must be signed in to change notification settings - Fork 1
/
acinclude.m4
141 lines (124 loc) · 3.69 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
dnl =========================================================================
dnl acinclude.m4
dnl
dnl Author: Kai Poitschke <[email protected]>
dnl
dnl $Revision: 283 $
dnl
dnl Defines the macros:
dnl ACX_HPUX
dnl ACX_C_PRAGMA
dnl ACX_DEBUG
dnl ACX_PURIFY
dnl -------------------------------------------------------------------------
dnl ACX_HPUX
dnl Checks if this is an HP-UX system. In this case we define
dnl _HPUX_SOURCE.
dnl If CC is not set, we set it to c89 and CFLAGS to:
dnl +e +O3 +Oinline
dnl Sets the variable $HPUX to "yes" or "no" according to the
dnl result
AC_DEFUN([ACX_HPUX], [
AC_CACHE_CHECK([for HP-UX], acx_cv_hpux, [
AC_EGREP_CPP(yes,
[#ifdef __hpux
yes
#endif
], acx_cv_hpux=yes, acx_cv_hpux=no)
])
# set some hpux specific things
#
if test "$acx_cv_hpux" = "yes" ; then
CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
AC_DEFINE(_HPUX_SOURCE, [1], [Defined when this is HP-SUCKS])
#
# Try the hpux ansi compiler.
#
acx_save_cc=$CC
acx_save_cflags=$CFLAGS
# have to save it in HPUX_CC, because CC has an already cached value
AC_CHECK_PROG(HPUX_CC, c89, c89)
CC=$HPUX_CC
if test "$CC" = "c89" ; then
CFLAGS="+e +O3 +Oinline" # check for extended ansi mode
# AC_PROG_CC_WORKS
#
# restore previous settings if this didn't work
#
if test "$ac_prog_cc_works" = "no"; then
# lets use the one found by AC_PROG_CC
CC=$acx_save_cc
CFLAGS=$acx_save_cflags
fi
fi
fi
])dnl
dnl -------------------------------------------------------------------------
dnl ACX_C_PRAGMA(pragma, [foo], variable_name )
dnl Checks if it is valid to compile with this pragma and defines
dnl the variable. Note: You have to include this variable name
dnl into your acconfig.h!
dnl Specify the function name foo, if the pragma needs a function name
dnl
AC_DEFUN([ACX_C_PRAGMA], [
AC_MSG_CHECKING([Checking if compiler supports pragma $1])
AC_TRY_COMPILE([
#pragma $1 $2
static int foo(int x) {return x;}
], [
foo(0);
],
acx_cc_pragma=yes , acx_cc_pragma=no
)
AC_MSG_RESULT($acx_cc_pragma)
if test $acx_cc_pragma = "yes" ; then
AC_DEFINE($3)
fi
])
dnl -------------------------------------------------------------------------
dnl ACX_DEBUG(yes|no)
dnl Used to set some variables in case we want to debug or not
dnl if $1 is yes, we remove all [+-]O flags from CFLAGS and
dnl add -g if possible
dnl if $1 is no, we define the preprocessor consant NDEBUG in config.h
dnl The variable ACX_DEBUG_ENABLED is set to $1.
dnl
dnl
AC_DEFUN([ACX_DEBUG], [
AC_MSG_CHECKING(if debug is enabled)
if test "$1" = "yes" ; then
changequote(<<,>>)
CFLAGS=`echo $CFLAGS | sed 's/[+-]O[a-zA-Z0-9]* *//g'`
if test $ac_cv_prog_cc_g = "yes"; then
CFLAGS="$CFLAGS -g"
fi
changequote([,])
else
AC_DEFINE(NDEBUG, [1], [Defined when debugging and assertions are disabled])
fi
ACX_DEBUG_ENABLED=$1
AC_MSG_RESULT($ACX_DEBUG_ENABLED)
])
dnl -------------------------------------------------------------------------
dnl ACX_PURIFY(yes|no)
dnl If called with yes CCLD is substituted with
dnl purify -log-file=purify_%v_%p.log -messages=first -chain-length=12 \
dnl [-g++] $(PURIFY_OPTS) $(CC)
dnl
dnl The developer should specify his special settings in PURIFY_OPTS in
dnl Makefile.am
AC_DEFUN([ACX_PURIFY], [
AC_MSG_CHECKING(if linking with purify is enabled)
if test "$1" = "yes" ; then
acx_purify_opts="-log-file=purify_%v_%p.log -messages=first -chain-length=12"
if test "$CC" = "gcc" -o "$CC" = "g++" ; then
acx_purify_opts="$acx_purify_opts -g++"
fi
CCLD="purify $acx_purify_opts \$(PURIFY_OPTS) \$(CC)"
else
CCLD="\$(CC)"
fi
export CCLD
AC_SUBST(CCLD)
AC_MSG_RESULT($1)
])