1 dnl ===================================================================
2 dnl Macros for various checks
3 dnl ===================================================================
5 dnl TODO: Make EL_CONFIG* macros assume CONFIG_* defines so it is possible
6 dnl to write EL_CONFIG_DEPENDS(SCRIPTING, [GUILE LUA PERL], [...])
8 dnl EL_CONFIG(define, what)
9 AC_DEFUN([EL_CONFIG], [
12 AC_DEFINE($1, 1, [Define if you want: $2 support])])
14 dnl EL_LOG_CONFIG(define, description, value)
15 dnl The first parameter (define) will not be expanded by m4,
16 dnl and it must be a valid name for a shell variable.
17 AC_DEFUN([EL_LOG_CONFIG],
21 [msgdots2="`echo $about | sed 's/[0-9]/./g'`"]
22 [msgdots1="`echo $msgdots2 | sed 's/[a-z]/./g'`"]
23 [msgdots0="`echo $msgdots1 | sed 's/[A-Z]/./g'`"]
24 [msgdots="`echo $msgdots0 | sed 's/[-_ ()]/./g'`"]
25 DOTS="................................"
26 dots=`echo $DOTS | sed "s/$msgdots//"`
29 if test "$dots" = "$DOTS"; then
33 if test -z "$value"; then
37 echo "$about $dots $value" >> features.log
41 dnl EL_CONFIG_DEPENDS(define, CONFIG_* dependencies, what)
42 AC_DEFUN([EL_CONFIG_DEPENDS],
47 for dependency in $2; do
48 # Hope this is portable?!? --jonas
49 eval el_config_value=$`echo $dependency`
51 if test "$el_config_value" = yes; then
52 el_about_dep=$`echo ABOUT_$dependency`
53 eval depvalue=$el_about_dep
55 if test -z "$el_value"; then
58 el_value="$el_value, $depvalue"
64 if test "[$]$1" = yes; then
67 EL_LOG_CONFIG([$1], [$3], [$el_value])
70 dnl EL_ARG_ENABLE(define, name, conf-help, arg-help)
71 AC_DEFUN([EL_ARG_ENABLE],
73 AC_ARG_ENABLE($2, [$4],
75 if test "$enableval" != no; then enableval="yes"; fi
79 if test "x[$]$1" = xyes; then
84 EL_LOG_CONFIG([$1], [$3], [])
87 dnl EL_ARG_DEPEND(define, name, depend, conf-help, arg-help)
88 AC_DEFUN([EL_ARG_DEPEND],
90 AC_ARG_ENABLE($2, [$5],
92 if test "$enableval" != no; then enableval="yes"; fi
97 if test "x[$]$1" = xyes; then
98 # require all dependencies to be met
99 for dependency in $3; do
100 el_name=`echo "$dependency" | sed 's/:.*//'`;
101 el_arg=`echo "$dependency" | sed 's/.*://'`;
102 # Hope this is portable?!? --jonas
103 eval el_value=$`echo $el_name`;
105 if test "x$el_value" != "x$el_arg"; then
111 if test "[$]ENABLE_$1" = yes; then
119 EL_LOG_CONFIG([$1], [$4], [])
122 dnl EL_DEFINE(define, what)
123 AC_DEFUN([EL_DEFINE], [AC_DEFINE($1, 1, [Define if you have $2])])
125 dnl EL_CHECK_CODE(type, define, includes, code)
126 AC_DEFUN([EL_CHECK_CODE],
129 AC_MSG_CHECKING([for $1])
130 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],[EL_DEFINE($2, [$1])],[$2=no])
134 dnl EL_CHECK_TYPE(type, default)
135 AC_DEFUN([EL_CHECK_TYPE],
137 EL_CHECK_TYPE_LOCAL=yes;
138 AC_MSG_CHECKING([for $1])
139 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
140 #include <sys/types.h>
141 ]], [[int a = sizeof($1);]])],[EL_CHECK_TYPE_LOCAL=yes],[EL_CHECK_TYPE_LOCAL=no])
142 AC_MSG_RESULT([$]EL_CHECK_TYPE_LOCAL)
143 if test "x[$]EL_CHECK_TYPE_LOCAL" != "xyes"; then
144 AC_DEFINE($1, $2, [Define to $2 if <sys/types.h> doesn't define.])
148 dnl EL_CHECK_SYS_TYPE(type, define, includes)
149 AC_DEFUN([EL_CHECK_SYS_TYPE],
151 EL_CHECK_CODE([$1], [$2], [
152 #include <sys/types.h>
154 ], [int a = sizeof($1);])
157 dnl EL_CHECK_NET_TYPE(type, define, include)
158 AC_DEFUN([EL_CHECK_NET_TYPE],
160 EL_CHECK_SYS_TYPE([$1], [$2], [
161 #include<sys/socket.h>
166 dnl EL_CHECK_INT_TYPE(type, define)
167 AC_DEFUN([EL_CHECK_INT_TYPE],
169 EL_CHECK_SYS_TYPE([$1], [$2], [
173 #ifdef HAVE_INTTYPES_H
174 #include <inttypes.h>
180 dnl Save and restore the current build flags
182 AC_DEFUN([EL_SAVE_FLAGS],
185 CPPFLAGS_X="$CPPFLAGS";
186 LDFLAGS_X="$LDFLAGS";
190 AC_DEFUN([EL_RESTORE_FLAGS],
193 CPPFLAGS="$CPPFLAGS_X";
194 LDFLAGS="$LDFLAGS_X";