cvsimport
[beagle.git] / acinclude.m4
blob3f946b52d5be31fcaec7bcd83881756a92b351fd
1 dnl Add compile warnings
3 AC_DEFUN([IDT_COMPILE_WARNINGS],[
4    if test -f $srcdir/autogen.sh; then
5         default_compile_warnings="error"
6     else
7         default_compile_warnings="no"
8     fi
10     AC_ARG_WITH(compile-warnings,
11                 AS_HELP_STRING([--with-compile-warnings=@<:@no/yes/error@:>@],
12                                [Compiler warnings]),
13                 [enable_compile_warnings="$withval"],
14                 [enable_compile_warnings="$default_compile_warnings"])
16     warnCFLAGS=
17     if test "x$GCC" != xyes; then
18         enable_compile_warnings=no
19     fi
21     warning_flags=
22     realsave_CFLAGS="$CFLAGS"
24     case "$enable_compile_warnings" in
25     no)
26         warning_flags=
27         ;;
28     yes)
29         warning_flags="-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations"
30         ;;
31     maximum|error)
32         warning_flags="-Wall -Wunused -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
33         CFLAGS="$warning_flags $CFLAGS"
34         for option in -Wno-sign-compare; do
35                 SAVE_CFLAGS="$CFLAGS"
36                 CFLAGS="$CFLAGS $option"
37                 AC_MSG_CHECKING([whether gcc understands $option])
38                 AC_TRY_COMPILE([], [],
39                         has_option=yes,
40                         has_option=no,)
41                 CFLAGS="$SAVE_CFLAGS"
42                 AC_MSG_RESULT($has_option)
43                 if test $has_option = yes; then
44                   warning_flags="$warning_flags $option"
45                 fi
46                 unset has_option
47                 unset SAVE_CFLAGS
48         done
49         unset option
50         if test "$enable_compile_warnings" = "error" ; then
51             warning_flags="$warning_flags -Werror"
52         fi
53         ;;
54     *)
55         AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
56         ;;
57     esac
58     CFLAGS="$realsave_CFLAGS"
59     AC_MSG_CHECKING(what warning flags to pass to the C compiler)
60     AC_MSG_RESULT($warning_flags)
62     WARN_CFLAGS="$warning_flags"
63     AC_SUBST(WARN_CFLAGS)
67 dnl -*- mode: autoconf -*-
69 # serial 1
71 dnl Usage:
72 dnl   GTK_DOC_CHECK([minimum-gtk-doc-version])
73 AC_DEFUN([GTK_DOC_CHECK],
75   AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
76   AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
77   dnl for overriding the documentation installation directory
78   AC_ARG_WITH(html-dir,
79     AC_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),,
80     [with_html_dir='${datadir}/gtk-doc/html'])
81   HTML_DIR="$with_html_dir"
82   AC_SUBST(HTML_DIR)
84   dnl enable/disable documentation building
85   AC_ARG_ENABLE(gtk-doc,
86     AC_HELP_STRING([--enable-gtk-doc],
87                    [use gtk-doc to build documentation [default=no]]),,
88     enable_gtk_doc=no)
90   have_gtk_doc=no
91   if test x$enable_gtk_doc = xyes; then
92     if test -z "$PKG_CONFIG"; then
93       AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
94     fi
95     if test "$PKG_CONFIG" != "no" && $PKG_CONFIG --exists gtk-doc; then
96       have_gtk_doc=yes
97     fi
99   dnl do we want to do a version check?
100 ifelse([$1],[],,
101     [gtk_doc_min_version=$1
102     if test "$have_gtk_doc" = yes; then
103       AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version])
104       if $PKG_CONFIG --atleast-version $gtk_doc_min_version gtk-doc; then
105         AC_MSG_RESULT(yes)
106       else
107         AC_MSG_RESULT(no)
108         have_gtk_doc=no
109       fi
110     fi
112     if test "$have_gtk_doc" != yes; then
113       enable_gtk_doc=no
114     fi
115   fi
117   AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
118   AM_CONDITIONAL(GTK_DOC_USE_LIBTOOL, test -n "$LIBTOOL")
121 ## this one is commonly used with AM_PATH_PYTHONDIR ...
122 dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
123 dnl Check if a module containing a given symbol is visible to python.
124 AC_DEFUN(AM_CHECK_PYMOD,
125 [AC_REQUIRE([AM_PATH_PYTHON])
126 py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
127 AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
128 AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
129 ifelse([$2],[], [prog="
130 import sys
131 try:
132         import $1
133 except ImportError:
134         sys.exit(1)
135 except:
136         sys.exit(0)
137 sys.exit(0)"], [prog="
138 import $1
139 $1.$2"])
140 if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
141   then
142     eval "py_cv_mod_$py_mod_var=yes"
143   else
144     eval "py_cv_mod_$py_mod_var=no"
145   fi
147 py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
148 if test "x$py_val" != xno; then
149   AC_MSG_RESULT(yes)
150   ifelse([$3], [],, [$3
151 ])dnl
152 else
153   AC_MSG_RESULT(no)
154   ifelse([$4], [],, [$4
155 ])dnl
159 dnl a macro to check for ability to create python extensions
160 dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
161 dnl function also defines PYTHON_INCLUDES
162 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
163 [AC_REQUIRE([AM_PATH_PYTHON])
164 AC_MSG_CHECKING(for headers required to compile python extensions)
165 dnl deduce PYTHON_INCLUDES
166 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
167 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
168 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
169 if test "$py_prefix" != "$py_exec_prefix"; then
170   PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
172 AC_SUBST(PYTHON_INCLUDES)
173 dnl check if the headers exist:
174 save_CPPFLAGS="$CPPFLAGS"
175 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
176 AC_TRY_CPP([#include <Python.h>],dnl
177 [AC_MSG_RESULT(found)
178 $1],dnl
179 [AC_MSG_RESULT(not found)
180 $2])
181 CPPFLAGS="$save_CPPFLAGS"