1 dnl AX_KERNEL_OPTION(option, action-if-found, action-if-not-found)
2 dnl see if autoconf.h defines the option
3 AC_DEFUN([AX_KERNEL_OPTION], [
5 CFLAGS="-I$KINC -O2 -D__KERNEL__"
6 AC_TRY_COMPILE( [#include <linux/config.h>],
15 dnl Handle the 2.4 module inside module/
16 AC_DEFUN([AX_CONFIG_MODULE],
18 if test ! -f $KINC/linux/autoconf.h; then
19 AC_MSG_ERROR([no suitably configured kernel include tree found])
22 dnl --- Get Linux kernel version and compile parameters ---
25 AC_MSG_CHECKING([for kernel version])
26 dnl it's like this to handle mandrake's fubar version.h - bug #471448
27 eval KVERS=`gcc -I$KINC -E -dM $KINC/linux/version.h | grep -w UTS_RELEASE | awk '{print $[]3}'`
28 AC_MSG_RESULT([$KVERS])
31 *) AC_MSG_ERROR([Unsupported kernel version])
34 dnl Check for the minimal kernel version supported
35 AC_MSG_CHECKING([kernel version])
36 AX_KERNEL_VERSION(2, 2, 10, <=, AC_MSG_RESULT([ok]), AC_MSG_ERROR([check html documentation install section]))
38 dnl linux/spinlock.h added at some point in past
39 AC_MSG_CHECKING([for $KINC/linux/spinlock.h])
40 if test -f $KINC/linux/spinlock.h; then
41 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DHAVE_LINUX_SPINLOCK_HEADER"
47 AC_MSG_CHECKING([for rtc_lock])
48 gcc -I$KINC -E $KINC/linux/mc146818rtc.h | grep rtc_lock >/dev/null
49 if test "$?" -eq 0; then
50 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DRTC_LOCK"
57 AC_MSG_CHECKING(for x86-64 architecture)
58 AX_KERNEL_OPTION(CONFIG_X86_64, x8664=1, x8664=0)
59 AX_MSG_RESULT_YN($x8664)
61 if test "$x8664" -eq 1; then
65 AC_MSG_CHECKING(for x86 architecture)
66 AX_KERNEL_OPTION(CONFIG_X86, x86=1, x86=0)
67 AX_KERNEL_OPTION(CONFIG_X86_WP_WORKS_OK, x86=1, x86=$x86)
68 AX_MSG_RESULT_YN($x86)
69 test "$x86" = 1 && arch="x86"
71 if test "$arch" = "unknown"; then
72 AC_MSG_CHECKING(for ia64 architecture)
73 AX_KERNEL_OPTION(CONFIG_IA64, ia64=1, ia64=0)
74 AX_MSG_RESULT_YN($ia64)
75 test "$ia64" = 1 && arch="ia64"
79 AC_SUBST(BUILD_HAMMER)
81 test "$arch" = "unknown" && AC_MSG_ERROR(Unsupported architecture)
83 dnl check to see if kernel verion appropriate for arch
84 AC_MSG_CHECKING(arch/kernel version combination)
87 AX_KERNEL_VERSION(2, 4, 18, <, AC_MSG_RESULT([ok]),
88 AC_MSG_ERROR([unsupported arch/kernel])) ;;
89 *) AC_MSG_RESULT([ok])
92 dnl for now we do not support PREEMPT patch
93 AC_MSG_CHECKING([for preempt patch])
94 AX_KERNEL_OPTION(CONFIG_PREEMPT,preempt=1,preempt=0)
95 AX_MSG_RESULT_YN([$preempt])
96 test "$preempt" = 0 || AC_MSG_ERROR([unsupported kernel configuration : CONFIG_PREEMPT])
100 MODINSTALLDIR=/lib/modules/$KVERS
102 OPROFILE_MODULE_ARCH=$arch
103 AC_SUBST(OPROFILE_MODULE_ARCH)
107 dnl AX_KERNEL_VERSION(major, minor, level, comparison, action-if-true, action-if-false)
108 AC_DEFUN([AX_KERNEL_VERSION], [
110 CFLAGS="-I$KINC -D__KERNEL__ -Werror"
113 #include <linux/version.h>
114 #include <linux/config.h>
117 #if LINUX_VERSION_CODE $4 KERNEL_VERSION($1, $2, $3)
126 dnl AX_MSG_RESULT_YN(a)
127 dnl results "yes" iff a==1, "no" else
128 AC_DEFUN([AX_MSG_RESULT_YN], [x=no
129 test "x$1" = "x1" && x=yes
132 dnl AX_MALLOC_ATTRIBUTE - see if gcc will take __attribute__((malloc))
133 AC_DEFUN([AX_MALLOC_ATTRIBUTE],
135 AC_MSG_CHECKING([whether malloc attribute is understood])
137 CFLAGS="-Werror $CFLAGS"
139 void monkey() __attribute__((malloc));
140 ],AC_MSG_RESULT([yes]); AC_DEFINE(MALLOC_ATTRIBUTE_OK, 1, [whether malloc attribute is understood]), AC_MSG_RESULT([no]))
145 dnl builtin_expect is used in module we can't add that in config.h
146 AC_DEFUN([AX_BUILTIN_EXPECT],
148 AC_MSG_CHECKING([whether __builtin_expect is understood])
150 CFLAGS="-Werror $CFLAGS"
153 if (__builtin_expect(i, 0)) { }
155 AC_MSG_RESULT([yes]); EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK",
156 AC_MSG_RESULT([no]);)
161 dnl AX_EXTRA_DIRS - Let user specify extra dirs for include/libs
162 AC_DEFUN([AX_EXTRA_DIRS],
164 AC_ARG_WITH(extra-includes,
165 [ --with-extra-includes=DIR add extra include paths],
166 use_extra_includes="$withval",
167 use_extra_includes=NO
169 if test -n "$use_extra_includes" && \
170 test "$use_extra_includes" != "NO"; then
173 for dir in $use_extra_includes; do
174 extra_includes="$extra_includes -I$dir"
177 CPPFLAGS="$CPPFLAGS $extra_includes"
180 AC_ARG_WITH(extra-libs,
181 [ --with-extra-libs=DIR add extra library paths],
182 use_extra_libs=$withval,
185 if test -n "$use_extra_libs" && \
186 test "$use_extra_libs" != "NO"; then
189 for dir in $use_extra_libs; do
190 extra_libraries="$extra_libraries -L$dir"
193 LDFLAGS="$LDFLAGS $extra_libraries"
198 dnl AX_POPT_CONST - check popt prototype
199 AC_DEFUN([AX_POPT_CONST],
201 AC_MSG_CHECKING([popt prototype])
202 SAVE_CXXFLAGS=$CXXFLAGS
203 CXXFLAGS="-Werror $CXXFLAGS"
204 AC_TRY_COMPILE([#include <popt.h>],
207 poptGetContext(0, c, v, 0, 0);
209 AC_MSG_RESULT([takes char **]);,
210 AC_MSG_RESULT([takes const char **]); AC_DEFINE(CONST_POPT, 1, [whether popt prototype takes a const char **]))
211 CXXFLAGS="$SAVE_CXXFLAGS"
215 dnl AX_CHECK_SSTREAM - check if local sstream is needed to compile OK
216 AC_DEFUN([AX_CHECK_SSTREAM],
218 AC_MSG_CHECKING([whether to use included sstream])
219 AC_TRY_COMPILE([#include <sstream>], [],
220 AC_MSG_RESULT([no]);,
221 AC_MSG_RESULT([yes]); OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include")
225 dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false)
226 dnl exec action-if-true if typedef_name is a typedef to type else exec
228 dnl currently work only with type typedef'ed in stddef.h
229 AC_DEFUN([AX_CHECK_TYPEDEF], [
230 dnl AC_LANG_PUSH(C) not in autoconf 2.13
234 CFLAGS="-Werror $CFLAGS"
241 typedef void (*fct1)($1);
242 typedef void (*fct2)($2);
254 dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name)
255 dnl set var_name to the typedef name of $1 which must be in canditate_list
256 dnl else produce a fatal error
257 AC_DEFUN([AX_TYPEDEFED_NAME], [
258 AC_MSG_CHECKING([type of $1])
260 AX_CHECK_TYPEDEF($1, $f, $3="$f", $3="")
261 if test -n "${$3}"; then
265 if test -n "${$3}"; then
266 AC_MSG_RESULT([${$3}])
268 AC_MSG_ERROR([not found])
272 dnl find a binary in the path
273 AC_DEFUN([QT_FIND_PATH],
275 AC_MSG_CHECKING([for $1])
276 AC_CACHE_VAL(qt_cv_path_$1,
279 if test -n "$$2"; then
291 if test -x "$dir/$1"; then
292 if test -n "$5"; then
293 evalstr="$dir/$1 $5 2>&1 "
294 if eval $evalstr; then
295 qt_cv_path_$1="$dir/$1"
299 qt_cv_path_$1="$dir/$1"
307 if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then
308 AC_MSG_RESULT(not found)
311 AC_MSG_RESULT($qt_cv_path_$1)
316 dnl Find the uic compiler on the path or in qt_cv_dir
317 AC_DEFUN([QT_FIND_UIC],
319 QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin)
320 if test -z "$ac_uic" -a "$FATAL" = 1; then
321 AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !])
325 dnl Find the right moc in path/qt_cv_dir
326 AC_DEFUN([QT_FIND_MOC],
328 QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
329 QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
331 if test -n "$ac_moc1" -a -n "$ac_moc2"; then
332 dnl found both. Prefer Qt3's if it exists else moc2
333 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null
334 if test "$?" = 0; then
340 if test -n "$ac_moc1"; then
347 if test -z "$ac_moc" -a "$FATAL" = 1; then
348 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !])
352 dnl check a particular libname
353 AC_DEFUN([QT_TRY_LINK],
362 QString s("mangle_failure");
363 #if (QT_VERSION < 221)
372 dnl check we can do a compile
373 AC_DEFUN([QT_CHECK_COMPILE],
375 AC_MSG_CHECKING([for Qt library name])
377 AC_CACHE_VAL(qt_cv_libname,
380 SAVE_CXXFLAGS=$CXXFLAGS
381 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
383 for libname in -lqt-mt -lqt3 -lqt2 -lqt;
385 QT_TRY_LINK($libname)
386 if test -n "$qt_cv_libname"; then
391 CXXFLAGS=$SAVE_CXXFLAGS
394 if test -z "$qt_cv_libname"; then
395 AC_MSG_RESULT([failed])
396 if test "$FATAL" = 1 ; then
397 AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !])
400 AC_MSG_RESULT([$qt_cv_libname])
404 dnl get Qt version we're using
405 AC_DEFUN([QT_GET_VERSION],
407 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
410 SAVE_CPPFLAGS=$CPPFLAGS
411 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
413 cat > conftest.$ac_ext <<EOF
414 #line __oline__ "configure"
415 #include "confdefs.h"
417 "%%%"QT_VERSION_STR"%%%"
419 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
420 grep '^"%%%"' 2>/dev/null | \
421 sed -e 's/"%%%"//g' -e 's/"//g'`
422 rm -f conftest.$ac_ext
423 CPPFLAGS=$SAVE_CPPFLAGS
426 QT_VERSION=$lyx_cv_qtversion
431 AC_DEFUN([QT_DO_IT_ALL],
433 dnl Please leave this alone. I use this file in
437 AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ],
438 [ qt_cv_dir=`eval echo "$withval"/` ])
440 AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ],
441 [ qt_cv_includes=`eval echo "$withval"` ])
443 AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.],
444 [ qt_cv_libraries=`eval echo "$withval"` ])
446 dnl pay attention to $QTDIR unless overridden
447 if test -z "$qt_cv_dir"; then
451 dnl derive inc/lib if needed
452 if test -n "$qt_cv_dir"; then
453 if test -z "$qt_cv_includes"; then
454 qt_cv_includes=$qt_cv_dir/include
456 if test -z "$qt_cv_libraries"; then
457 qt_cv_libraries=$qt_cv_dir/lib
461 dnl flags for compilation
464 if test -n "$qt_cv_includes"; then
465 QT_INCLUDES="-I$qt_cv_includes"
467 if test -n "$qt_cv_libraries"; then
468 QT_LDFLAGS="-L$qt_cv_libraries"
470 AC_SUBST(QT_INCLUDES)
482 QT_LIB=$qt_cv_libname;
485 if test -n "$qt_cv_libname"; then
490 dnl AX_CXXFLAGS_OPTIONS(var-name, option)
491 dnl add option to var-name if $CXX support it.
492 AC_DEFUN([AX_CHECK_PRECOMPILED_HEADER], [
493 AC_MSG_CHECKING([whether ${CXX} support precompiled header])
496 SAVE_CXXFLAGS=$CXXFLAGS
497 dnl we consider than if -Winvalid-pch is accepted pch will works ...
498 CXXFLAGS=-Winvalid-pch
499 dnl but we don't want -Winvalid-pch else compilation will fail due -Werror and
500 dnl the fact than some pch will be invalid for the given compilation option
501 AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} -include bits/stdc++.h", AC_MSG_RESULT([no]))
502 CXXFLAGS=$SAVE_CXXFLAGS
507 AC_DEFUN([AX_CHECK_DOCBOOK], [
508 # It's just rude to go over the net to build
509 XSLTPROC_FLAGS=--nonet
511 if test ! -f /etc/xml/catalog; then
512 for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/;
514 if test -d "$i"; then
519 # Last resort - try net
520 if test -z "$DOCBOOK_ROOT"; then
524 XML_CATALOG=/etc/xml/catalog
525 CAT_ENTRY_START='<!--'
529 AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,)
531 if test -n "$XSLTPROC"; then
532 AC_MSG_CHECKING([whether xsltproc works])
534 if test -n "$XML_CATALOG"; then
535 DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"
537 DB_FILE="$DOCBOOK_ROOT/docbook.xsl"
540 $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END
541 <?xml version="1.0" encoding='ISO-8859-1'?>
542 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
546 if test "$?" = 0; then
549 AC_MSG_RESULT($XSLTPROC_WORKS)
551 AM_CONDITIONAL(have_xsltproc, test "$XSLTPROC_WORKS" = "yes")
553 AC_SUBST(XML_CATALOG)
554 AC_SUBST(XSLTPROC_FLAGS)
555 AC_SUBST(DOCBOOK_ROOT)
556 AC_SUBST(CAT_ENTRY_START)
557 AC_SUBST(CAT_ENTRY_END)
560 dnl AX_CFLAGS_OPTIONS(var-name, option)
561 dnl add option to var-name if $CC support it.
562 AC_DEFUN([AX_CFLAGS_OPTION], [
563 AC_MSG_CHECKING([whether ${CC} $2 is understood])
568 AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no]))
574 dnl AX_CXXFLAGS_OPTIONS(var-name, option)
575 dnl add option to var-name if $CXX support it.
576 AC_DEFUN([AX_CXXFLAGS_OPTION], [
577 AC_MSG_CHECKING([whether ${CXX} $2 is understood])
580 SAVE_CXXFLAGS=$CXXFLAGS
582 AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no]))
583 CXXFLAGS=$SAVE_CXXFLAGS
587 dnl AX_COPY_IF_CHANGE(source, dest)
588 dnl copy source to dest if they don't compare equally or if dest doesn't exist
589 AC_DEFUN([AX_COPY_IF_CHANGE], [
591 if cmp $1 $2 > /dev/null; then