1dnl AX_KERNEL_OPTION(option, action-if-found, action-if-not-found) 2dnl see if autoconf.h defines the option 3AC_DEFUN([AX_KERNEL_OPTION], [ 4SAVE_CFLAGS=$CFLAGS 5CFLAGS="-I$KINC -O2 -D__KERNEL__" 6AC_TRY_COMPILE( [#include <linux/config.h>], 7[ 8#ifndef $1 9break_me_hard(\\\); 10#endif 11],[$2],[$3],) 12CFLAGS=$SAVE_CFLAGS 13]) 14 15dnl Handle the 2.4 module inside module/ 16AC_DEFUN([AX_CONFIG_MODULE], 17[ 18if test ! -f $KINC/linux/autoconf.h; then 19 AC_MSG_ERROR([no suitably configured kernel include tree found]) 20fi 21 22dnl --- Get Linux kernel version and compile parameters --- 23 24AC_SUBST(KVERS) 25AC_MSG_CHECKING([for kernel version]) 26dnl it's like this to handle mandrake's fubar version.h - bug #471448 27eval KVERS=`gcc -I$KINC -E -dM $KINC/linux/version.h | grep -w UTS_RELEASE | awk '{print $[]3}'` 28AC_MSG_RESULT([$KVERS]) 29case "$KVERS" in 302.2.*|2.4.*) ;; 31*) AC_MSG_ERROR([Unsupported kernel version]) 32esac 33 34dnl Check for the minimal kernel version supported 35AC_MSG_CHECKING([kernel version]) 36AX_KERNEL_VERSION(2, 2, 10, <=, AC_MSG_RESULT([ok]), AC_MSG_ERROR([check html documentation install section])) 37 38dnl linux/spinlock.h added at some point in past 39AC_MSG_CHECKING([for $KINC/linux/spinlock.h]) 40if test -f $KINC/linux/spinlock.h; then 41 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DHAVE_LINUX_SPINLOCK_HEADER" 42 AC_MSG_RESULT([yes]) 43else 44 AC_MSG_RESULT([no]) 45fi 46 47AC_MSG_CHECKING([for rtc_lock]) 48gcc -I$KINC -E $KINC/linux/mc146818rtc.h | grep rtc_lock >/dev/null 49if test "$?" -eq 0; then 50 EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DRTC_LOCK" 51 AC_MSG_RESULT([yes]) 52else 53 AC_MSG_RESULT([no]) 54fi 55 56arch="unknown" 57AC_MSG_CHECKING(for x86-64 architecture) 58AX_KERNEL_OPTION(CONFIG_X86_64, x8664=1, x8664=0) 59AX_MSG_RESULT_YN($x8664) 60BUILD_HAMMER=no 61if test "$x8664" -eq 1; then 62 arch="x86" 63 BUILD_HAMMER=yes 64else 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" 70 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" 76 fi 77 78fi 79AC_SUBST(BUILD_HAMMER) 80 81test "$arch" = "unknown" && AC_MSG_ERROR(Unsupported architecture) 82 83dnl check to see if kernel verion appropriate for arch 84AC_MSG_CHECKING(arch/kernel version combination) 85case "$arch" in 86ia64) 87 AX_KERNEL_VERSION(2, 4, 18, <, AC_MSG_RESULT([ok]), 88 AC_MSG_ERROR([unsupported arch/kernel])) ;; 89*) AC_MSG_RESULT([ok]) 90esac 91 92dnl for now we do not support PREEMPT patch 93AC_MSG_CHECKING([for preempt patch]) 94AX_KERNEL_OPTION(CONFIG_PREEMPT,preempt=1,preempt=0) 95AX_MSG_RESULT_YN([$preempt]) 96test "$preempt" = 0 || AC_MSG_ERROR([unsupported kernel configuration : CONFIG_PREEMPT]) 97 98AC_SUBST(KINC) 99 100MODINSTALLDIR=/lib/modules/$KVERS 101 102OPROFILE_MODULE_ARCH=$arch 103AC_SUBST(OPROFILE_MODULE_ARCH) 104] 105) 106 107dnl AX_MSG_RESULT_YN(a) 108dnl results "yes" iff a==1, "no" else 109AC_DEFUN([AX_MSG_RESULT_YN], [x=no 110test "x$1" = "x1" && x=yes 111AC_MSG_RESULT($x)]) 112 113dnl AX_MALLOC_ATTRIBUTE - see if gcc will take __attribute__((malloc)) 114AC_DEFUN([AX_MALLOC_ATTRIBUTE], 115[ 116AC_MSG_CHECKING([whether malloc attribute is understood]) 117SAVE_CFLAGS=$CFLAGS 118CFLAGS="-Werror $CFLAGS" 119AC_TRY_COMPILE(,[ 120void monkey() __attribute__((malloc)); 121],AC_MSG_RESULT([yes]); AC_DEFINE(MALLOC_ATTRIBUTE_OK, 1, [whether malloc attribute is understood]), AC_MSG_RESULT([no])) 122CFLAGS=$SAVE_CFLAGS 123] 124) 125 126dnl builtin_expect is used in module we can't add that in config.h 127AC_DEFUN([AX_BUILTIN_EXPECT], 128[ 129AC_MSG_CHECKING([whether __builtin_expect is understood]) 130SAVE_CFLAGS=$CFLAGS 131CFLAGS="-Werror $CFLAGS" 132AC_TRY_LINK(,[ 133int i; 134if (__builtin_expect(i, 0)) { } 135], 136AC_MSG_RESULT([yes]); EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK", 137AC_MSG_RESULT([no]);) 138CFLAGS=$SAVE_CFLAGS 139] 140) 141 142dnl AX_EXTRA_DIRS - Let user specify extra dirs for include/libs 143AC_DEFUN([AX_EXTRA_DIRS], 144[ 145AC_ARG_WITH(extra-includes, 146[ --with-extra-includes=DIR add extra include paths], 147 use_extra_includes="$withval", 148 use_extra_includes=NO 149) 150if test -n "$use_extra_includes" && \ 151 test "$use_extra_includes" != "NO"; then 152 ac_save_ifs=$IFS 153 IFS=':' 154 for dir in $use_extra_includes; do 155 extra_includes="$extra_includes -I$dir" 156 done 157 IFS=$ac_save_ifs 158 CPPFLAGS="$CPPFLAGS $extra_includes" 159fi 160 161AC_ARG_WITH(extra-libs, 162[ --with-extra-libs=DIR add extra library paths], 163 use_extra_libs=$withval, 164 use_extra_libs=NO 165) 166if test -n "$use_extra_libs" && \ 167 test "$use_extra_libs" != "NO"; then 168 ac_save_ifs=$IFS 169 IFS=':' 170 for dir in $use_extra_libs; do 171 extra_libraries="$extra_libraries -L$dir" 172 done 173 IFS=$ac_save_ifs 174 LDFLAGS="$LDFLAGS $extra_libraries" 175fi 176] 177) 178 179dnl AX_POPT_CONST - check popt prototype 180AC_DEFUN([AX_POPT_CONST], 181[ 182AC_MSG_CHECKING([popt prototype]) 183SAVE_CXXFLAGS=$CXXFLAGS 184CXXFLAGS="-Werror $CXXFLAGS" 185AC_TRY_COMPILE([#include <popt.h>], 186[ 187int c; char **v; 188poptGetContext(0, c, v, 0, 0); 189], 190AC_MSG_RESULT([takes char **]);, 191AC_MSG_RESULT([takes const char **]); AC_DEFINE(CONST_POPT, 1, [whether popt prototype takes a const char **])) 192CXXFLAGS="$SAVE_CXXFLAGS" 193] 194) 195 196dnl AX_CHECK_SSTREAM - check if local sstream is needed to compile OK 197AC_DEFUN([AX_CHECK_SSTREAM], 198[ 199AC_MSG_CHECKING([whether to use included sstream]) 200AC_TRY_COMPILE([#include <sstream>], [], 201AC_MSG_RESULT([no]);, 202AC_MSG_RESULT([yes]); OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include") 203] 204) 205 206dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false) 207dnl exec action-if-true if typedef_name is a typedef to type else exec 208dnl action-if-false 209dnl currently work only with type typedef'ed in stddef.h 210AC_DEFUN([AX_CHECK_TYPEDEF], [ 211dnl AC_LANG_PUSH(C) not in autoconf 2.13 212AC_LANG_SAVE 213AC_LANG_C 214SAVE_CFLAGS=$CFLAGS 215CFLAGS="-Werror $CFLAGS" 216 217AC_TRY_COMPILE( 218 [ 219 #include <stddef.h> 220 ], 221 [ 222 typedef void (*fct1)($1); 223 typedef void (*fct2)($2); 224 fct1 f1 = 0; 225 fct2 f2 = 0; 226 if (f1 == f2) {} 227 ], 228[$3],[$4]) 229 230CFLAGS=$SAVE_CFLAGS 231AC_LANG_RESTORE 232]) 233 234 235dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name) 236dnl set var_name to the typedef name of $1 which must be in canditate_list 237dnl else produce a fatal error 238AC_DEFUN([AX_TYPEDEFED_NAME], [ 239 AC_MSG_CHECKING([type of $1]) 240 for f in $2; do 241 AX_CHECK_TYPEDEF($1, $f, $3="$f", $3="") 242 if test -n "${$3}"; then 243 break 244 fi 245 done 246 if test -n "${$3}"; then 247 AC_MSG_RESULT([${$3}]) 248 else 249 AC_MSG_ERROR([not found]) 250 fi 251]) 252 253dnl find a binary in the path 254AC_DEFUN([QT_FIND_PATH], 255[ 256 AC_MSG_CHECKING([for $1]) 257 AC_CACHE_VAL(qt_cv_path_$1, 258 [ 259 qt_cv_path_$1="NONE" 260 if test -n "$$2"; then 261 qt_cv_path_$1="$$2"; 262 else 263 dirs="$3" 264 qt_save_IFS=$IFS 265 IFS=':' 266 for dir in $PATH; do 267 dirs="$dirs $dir" 268 done 269 IFS=$qt_save_IFS 270 271 for dir in $dirs; do 272 if test -x "$dir/$1"; then 273 if test -n "$5"; then 274 evalstr="$dir/$1 $5 2>&1 " 275 if eval $evalstr; then 276 qt_cv_path_$1="$dir/$1" 277 break 278 fi 279 else 280 qt_cv_path_$1="$dir/$1" 281 break 282 fi 283 fi 284 done 285 fi 286 ]) 287 288 if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then 289 AC_MSG_RESULT(not found) 290 $4 291 else 292 AC_MSG_RESULT($qt_cv_path_$1) 293 $2=$qt_cv_path_$1 294 fi 295]) 296 297dnl Find the uic compiler on the path or in qt_cv_dir 298AC_DEFUN([QT_FIND_UIC], 299[ 300 QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin) 301 if test -z "$ac_uic" -a "$FATAL" = 1; then 302 AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !]) 303 fi 304]) 305 306dnl Find the right moc in path/qt_cv_dir 307AC_DEFUN([QT_FIND_MOC], 308[ 309 QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin) 310 QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin) 311 312 if test -n "$ac_moc1" -a -n "$ac_moc2"; then 313 dnl found both. Prefer Qt3's if it exists else moc2 314 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null 315 if test "$?" = 0; then 316 ac_moc=$ac_moc1; 317 else 318 ac_moc=$ac_moc2; 319 fi 320 else 321 if test -n "$ac_moc1"; then 322 ac_moc=$ac_moc1; 323 else 324 ac_moc=$ac_moc2; 325 fi 326 fi 327 328 if test -z "$ac_moc" -a "$FATAL" = 1; then 329 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !]) 330 fi 331]) 332 333dnl check a particular libname 334AC_DEFUN([QT_TRY_LINK], 335[ 336 SAVE_LIBS="$LIBS" 337 LIBS="$LIBS $1" 338 AC_TRY_LINK([ 339 #include <qglobal.h> 340 #include <qstring.h> 341 ], 342 [ 343 QString s("mangle_failure"); 344 #if (QT_VERSION < 221) 345 break_me_(\\\); 346 #endif 347 ], 348 qt_cv_libname=$1, 349 ) 350 LIBS="$SAVE_LIBS" 351]) 352 353dnl check we can do a compile 354AC_DEFUN([QT_CHECK_COMPILE], 355[ 356 AC_MSG_CHECKING([for Qt library name]) 357 358 AC_CACHE_VAL(qt_cv_libname, 359 [ 360 AC_LANG_CPLUSPLUS 361 SAVE_CXXFLAGS=$CXXFLAGS 362 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS" 363 364 for libname in -lqt-mt -lqt3 -lqt2 -lqt; 365 do 366 QT_TRY_LINK($libname) 367 if test -n "$qt_cv_libname"; then 368 break; 369 fi 370 done 371 372 CXXFLAGS=$SAVE_CXXFLAGS 373 ]) 374 375 if test -z "$qt_cv_libname"; then 376 AC_MSG_RESULT([failed]) 377 if test "$FATAL" = 1 ; then 378 AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !]) 379 fi 380 else 381 AC_MSG_RESULT([$qt_cv_libname]) 382 fi 383]) 384 385dnl get Qt version we're using 386AC_DEFUN([QT_GET_VERSION], 387[ 388 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion, 389 [ 390 AC_LANG_CPLUSPLUS 391 SAVE_CPPFLAGS=$CPPFLAGS 392 CPPFLAGS="$CPPFLAGS $QT_INCLUDES" 393 394 cat > conftest.$ac_ext <<EOF 395#line __oline__ "configure" 396#include "confdefs.h" 397#include <qglobal.h> 398"%%%"QT_VERSION_STR"%%%" 399EOF 400 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \ 401 grep '^"%%%"' 2>/dev/null | \ 402 sed -e 's/"%%%"//g' -e 's/"//g'` 403 rm -f conftest.$ac_ext 404 CPPFLAGS=$SAVE_CPPFLAGS 405 ]) 406 407 QT_VERSION=$lyx_cv_qtversion 408 AC_SUBST(QT_VERSION) 409]) 410 411dnl start here 412AC_DEFUN([QT_DO_IT_ALL], 413[ 414 dnl Please leave this alone. I use this file in 415 dnl oprofile. 416 FATAL=0 417 418 AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ], 419 [ qt_cv_dir=`eval echo "$withval"/` ]) 420 421 AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ], 422 [ qt_cv_includes=`eval echo "$withval"` ]) 423 424 AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.], 425 [ qt_cv_libraries=`eval echo "$withval"` ]) 426 427 dnl pay attention to $QTDIR unless overridden 428 if test -z "$qt_cv_dir"; then 429 qt_cv_dir=$QTDIR 430 fi 431 432 dnl derive inc/lib if needed 433 if test -n "$qt_cv_dir"; then 434 if test -z "$qt_cv_includes"; then 435 qt_cv_includes=$qt_cv_dir/include 436 fi 437 if test -z "$qt_cv_libraries"; then 438 qt_cv_libraries=$qt_cv_dir/lib 439 fi 440 fi 441 442 dnl flags for compilation 443 QT_INCLUDES= 444 QT_LDFLAGS= 445 if test -n "$qt_cv_includes"; then 446 QT_INCLUDES="-I$qt_cv_includes" 447 fi 448 if test -n "$qt_cv_libraries"; then 449 QT_LDFLAGS="-L$qt_cv_libraries" 450 fi 451 AC_SUBST(QT_INCLUDES) 452 AC_SUBST(QT_LDFLAGS) 453 454 QT_FIND_MOC 455 MOC=$ac_moc 456 AC_SUBST(MOC) 457 QT_FIND_UIC 458 UIC=$ac_uic 459 AC_SUBST(UIC) 460 461 QT_CHECK_COMPILE 462 463 QT_LIB=$qt_cv_libname; 464 AC_SUBST(QT_LIB) 465 466 if test -n "$qt_cv_libname"; then 467 QT_GET_VERSION 468 fi 469]) 470 471dnl AX_CXXFLAGS_OPTIONS(var-name, option) 472dnl add option to var-name if $CXX support it. 473AC_DEFUN([AX_CHECK_PRECOMPILED_HEADER], [ 474AC_MSG_CHECKING([whether ${CXX} support precompiled header]) 475AC_LANG_SAVE 476AC_LANG_CPLUSPLUS 477SAVE_CXXFLAGS=$CXXFLAGS 478dnl we consider than if -Winvalid-pch is accepted pch will works ... 479CXXFLAGS=-Winvalid-pch 480dnl but we don't want -Winvalid-pch else compilation will fail due -Werror and 481dnl the fact than some pch will be invalid for the given compilation option 482AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} -include bits/stdc++.h", AC_MSG_RESULT([no])) 483CXXFLAGS=$SAVE_CXXFLAGS 484AC_LANG_RESTORE 485]) 486 487dnl AX_CHECK_DOCBOOK 488AC_DEFUN([AX_CHECK_DOCBOOK], [ 489# It's just rude to go over the net to build 490XSLTPROC_FLAGS=--nonet 491DOCBOOK_ROOT= 492if test ! -f /etc/xml/catalog; then 493 for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/; 494 do 495 if test -d "$i"; then 496 DOCBOOK_ROOT=$i 497 fi 498 done 499 500 # Last resort - try net 501 if test -z "$DOCBOOK_ROOT"; then 502 XSLTPROC_FLAGS= 503 fi 504else 505 XML_CATALOG=/etc/xml/catalog 506 CAT_ENTRY_START='<!--' 507 CAT_ENTRY_END='-->' 508fi 509 510AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,) 511XSLTPROC_WORKS=no 512if test -n "$XSLTPROC"; then 513 AC_MSG_CHECKING([whether xsltproc works]) 514 515 if test -n "$XML_CATALOG"; then 516 DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" 517 else 518 DB_FILE="$DOCBOOK_ROOT/docbook.xsl" 519 fi 520 521 $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END 522<?xml version="1.0" encoding='ISO-8859-1'?> 523<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> 524<book id="test"> 525</book> 526END 527 if test "$?" = 0; then 528 XSLTPROC_WORKS=yes 529 fi 530 AC_MSG_RESULT($XSLTPROC_WORKS) 531fi 532AM_CONDITIONAL(have_xsltproc, test "$XSLTPROC_WORKS" = "yes") 533 534AC_SUBST(XML_CATALOG) 535AC_SUBST(XSLTPROC_FLAGS) 536AC_SUBST(DOCBOOK_ROOT) 537AC_SUBST(CAT_ENTRY_START) 538AC_SUBST(CAT_ENTRY_END) 539]) 540 541dnl AX_CFLAGS_OPTIONS(var-name, option) 542dnl add option to var-name if $CC support it. 543AC_DEFUN([AX_CFLAGS_OPTION], [ 544AC_MSG_CHECKING([whether ${CC} $2 is understood]) 545AC_LANG_SAVE 546AC_LANG_C 547SAVE_CFLAGS=$CFLAGS 548CFLAGS=$2 549AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no])) 550CFLAGS=$SAVE_CFLAGS 551AC_LANG_RESTORE 552]) 553 554 555dnl AX_CXXFLAGS_OPTIONS(var-name, option) 556dnl add option to var-name if $CXX support it. 557AC_DEFUN([AX_CXXFLAGS_OPTION], [ 558AC_MSG_CHECKING([whether ${CXX} $2 is understood]) 559AC_LANG_SAVE 560AC_LANG_CPLUSPLUS 561SAVE_CXXFLAGS=$CXXFLAGS 562CXXFLAGS=$2 563AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no])) 564CXXFLAGS=$SAVE_CXXFLAGS 565AC_LANG_RESTORE 566]) 567 568dnl AX_COPY_IF_CHANGE(source, dest) 569dnl copy source to dest if they don't compare equally or if dest doesn't exist 570AC_DEFUN([AX_COPY_IF_CHANGE], [ 571if test -r $2; then 572 if cmp $1 $2 > /dev/null; then 573 echo $2 is unchanged 574 else 575 cp -f $1 $2 576 fi 577else 578 cp -f $1 $2 579fi 580]) 581 582