Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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], [ |
| 4 | SAVE_CFLAGS=$CFLAGS |
| 5 | CFLAGS="-I$KINC -O2 -D__KERNEL__" |
| 6 | AC_TRY_COMPILE( [#include <linux/config.h>], |
| 7 | [ |
| 8 | #ifndef $1 |
| 9 | break_me_hard(\\\); |
| 10 | #endif |
| 11 | ],[$2],[$3],) |
| 12 | CFLAGS=$SAVE_CFLAGS |
| 13 | ]) |
| 14 | |
| 15 | dnl Handle the 2.4 module inside module/ |
| 16 | AC_DEFUN([AX_CONFIG_MODULE], |
| 17 | [ |
| 18 | if test ! -f $KINC/linux/autoconf.h; then |
| 19 | AC_MSG_ERROR([no suitably configured kernel include tree found]) |
| 20 | fi |
| 21 | |
| 22 | dnl --- Get Linux kernel version and compile parameters --- |
| 23 | |
| 24 | AC_SUBST(KVERS) |
| 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]) |
| 29 | case "$KVERS" in |
| 30 | 2.2.*|2.4.*) ;; |
| 31 | *) AC_MSG_ERROR([Unsupported kernel version]) |
| 32 | esac |
| 33 | |
| 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])) |
| 37 | |
| 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" |
| 42 | AC_MSG_RESULT([yes]) |
| 43 | else |
| 44 | AC_MSG_RESULT([no]) |
| 45 | fi |
| 46 | |
| 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" |
| 51 | AC_MSG_RESULT([yes]) |
| 52 | else |
| 53 | AC_MSG_RESULT([no]) |
| 54 | fi |
| 55 | |
| 56 | arch="unknown" |
| 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) |
| 60 | BUILD_HAMMER=no |
| 61 | if test "$x8664" -eq 1; then |
| 62 | arch="x86" |
| 63 | BUILD_HAMMER=yes |
| 64 | else |
| 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 | |
| 78 | fi |
| 79 | AC_SUBST(BUILD_HAMMER) |
| 80 | |
| 81 | test "$arch" = "unknown" && AC_MSG_ERROR(Unsupported architecture) |
| 82 | |
| 83 | dnl check to see if kernel verion appropriate for arch |
| 84 | AC_MSG_CHECKING(arch/kernel version combination) |
| 85 | case "$arch" in |
| 86 | ia64) |
| 87 | AX_KERNEL_VERSION(2, 4, 18, <, AC_MSG_RESULT([ok]), |
| 88 | AC_MSG_ERROR([unsupported arch/kernel])) ;; |
| 89 | *) AC_MSG_RESULT([ok]) |
| 90 | esac |
| 91 | |
| 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]) |
| 97 | |
| 98 | AC_SUBST(KINC) |
| 99 | |
| 100 | MODINSTALLDIR=/lib/modules/$KVERS |
| 101 | |
| 102 | OPROFILE_MODULE_ARCH=$arch |
| 103 | AC_SUBST(OPROFILE_MODULE_ARCH) |
| 104 | ] |
| 105 | ) |
| 106 | |
| 107 | dnl AX_MSG_RESULT_YN(a) |
| 108 | dnl results "yes" iff a==1, "no" else |
| 109 | AC_DEFUN([AX_MSG_RESULT_YN], [x=no |
| 110 | test "x$1" = "x1" && x=yes |
| 111 | AC_MSG_RESULT($x)]) |
| 112 | |
| 113 | dnl AX_MALLOC_ATTRIBUTE - see if gcc will take __attribute__((malloc)) |
| 114 | AC_DEFUN([AX_MALLOC_ATTRIBUTE], |
| 115 | [ |
| 116 | AC_MSG_CHECKING([whether malloc attribute is understood]) |
| 117 | SAVE_CFLAGS=$CFLAGS |
| 118 | CFLAGS="-Werror $CFLAGS" |
| 119 | AC_TRY_COMPILE(,[ |
| 120 | void monkey() __attribute__((malloc)); |
| 121 | ],AC_MSG_RESULT([yes]); AC_DEFINE(MALLOC_ATTRIBUTE_OK, 1, [whether malloc attribute is understood]), AC_MSG_RESULT([no])) |
| 122 | CFLAGS=$SAVE_CFLAGS |
| 123 | ] |
| 124 | ) |
| 125 | |
| 126 | dnl builtin_expect is used in module we can't add that in config.h |
| 127 | AC_DEFUN([AX_BUILTIN_EXPECT], |
| 128 | [ |
| 129 | AC_MSG_CHECKING([whether __builtin_expect is understood]) |
| 130 | SAVE_CFLAGS=$CFLAGS |
| 131 | CFLAGS="-Werror $CFLAGS" |
| 132 | AC_TRY_LINK(,[ |
| 133 | int i; |
| 134 | if (__builtin_expect(i, 0)) { } |
| 135 | ], |
| 136 | AC_MSG_RESULT([yes]); EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK", |
| 137 | AC_MSG_RESULT([no]);) |
| 138 | CFLAGS=$SAVE_CFLAGS |
| 139 | ] |
| 140 | ) |
| 141 | |
| 142 | dnl AX_EXTRA_DIRS - Let user specify extra dirs for include/libs |
| 143 | AC_DEFUN([AX_EXTRA_DIRS], |
| 144 | [ |
| 145 | AC_ARG_WITH(extra-includes, |
| 146 | [ --with-extra-includes=DIR add extra include paths], |
| 147 | use_extra_includes="$withval", |
| 148 | use_extra_includes=NO |
| 149 | ) |
| 150 | if 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" |
| 159 | fi |
| 160 | |
| 161 | AC_ARG_WITH(extra-libs, |
| 162 | [ --with-extra-libs=DIR add extra library paths], |
| 163 | use_extra_libs=$withval, |
| 164 | use_extra_libs=NO |
| 165 | ) |
| 166 | if 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" |
| 175 | fi |
| 176 | ] |
| 177 | ) |
| 178 | |
| 179 | dnl AX_POPT_CONST - check popt prototype |
| 180 | AC_DEFUN([AX_POPT_CONST], |
| 181 | [ |
| 182 | AC_MSG_CHECKING([popt prototype]) |
| 183 | SAVE_CXXFLAGS=$CXXFLAGS |
| 184 | CXXFLAGS="-Werror $CXXFLAGS" |
| 185 | AC_TRY_COMPILE([#include <popt.h>], |
| 186 | [ |
| 187 | int c; char **v; |
| 188 | poptGetContext(0, c, v, 0, 0); |
| 189 | ], |
| 190 | AC_MSG_RESULT([takes char **]);, |
| 191 | AC_MSG_RESULT([takes const char **]); AC_DEFINE(CONST_POPT, 1, [whether popt prototype takes a const char **])) |
| 192 | CXXFLAGS="$SAVE_CXXFLAGS" |
| 193 | ] |
| 194 | ) |
| 195 | |
| 196 | dnl AX_CHECK_SSTREAM - check if local sstream is needed to compile OK |
| 197 | AC_DEFUN([AX_CHECK_SSTREAM], |
| 198 | [ |
| 199 | AC_MSG_CHECKING([whether to use included sstream]) |
| 200 | AC_TRY_COMPILE([#include <sstream>], [], |
| 201 | AC_MSG_RESULT([no]);, |
| 202 | AC_MSG_RESULT([yes]); OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include") |
| 203 | ] |
| 204 | ) |
| 205 | |
| 206 | dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false) |
| 207 | dnl exec action-if-true if typedef_name is a typedef to type else exec |
| 208 | dnl action-if-false |
| 209 | dnl currently work only with type typedef'ed in stddef.h |
| 210 | AC_DEFUN([AX_CHECK_TYPEDEF], [ |
| 211 | dnl AC_LANG_PUSH(C) not in autoconf 2.13 |
| 212 | AC_LANG_SAVE |
| 213 | AC_LANG_C |
| 214 | SAVE_CFLAGS=$CFLAGS |
| 215 | CFLAGS="-Werror $CFLAGS" |
| 216 | |
| 217 | AC_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 | |
| 230 | CFLAGS=$SAVE_CFLAGS |
| 231 | AC_LANG_RESTORE |
| 232 | ]) |
| 233 | |
| 234 | |
| 235 | dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name) |
| 236 | dnl set var_name to the typedef name of $1 which must be in canditate_list |
| 237 | dnl else produce a fatal error |
| 238 | AC_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 | |
| 253 | dnl find a binary in the path |
| 254 | AC_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 | |
| 297 | dnl Find the uic compiler on the path or in qt_cv_dir |
| 298 | AC_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 | |
| 306 | dnl Find the right moc in path/qt_cv_dir |
| 307 | AC_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 | |
| 333 | dnl check a particular libname |
| 334 | AC_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 | |
| 353 | dnl check we can do a compile |
| 354 | AC_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 | |
| 385 | dnl get Qt version we're using |
| 386 | AC_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"%%%" |
| 399 | EOF |
| 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 | |
| 411 | dnl start here |
| 412 | AC_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 | |
| 471 | dnl AX_CXXFLAGS_OPTIONS(var-name, option) |
| 472 | dnl add option to var-name if $CXX support it. |
| 473 | AC_DEFUN([AX_CHECK_PRECOMPILED_HEADER], [ |
| 474 | AC_MSG_CHECKING([whether ${CXX} support precompiled header]) |
| 475 | AC_LANG_SAVE |
| 476 | AC_LANG_CPLUSPLUS |
| 477 | SAVE_CXXFLAGS=$CXXFLAGS |
| 478 | dnl we consider than if -Winvalid-pch is accepted pch will works ... |
| 479 | CXXFLAGS=-Winvalid-pch |
| 480 | dnl but we don't want -Winvalid-pch else compilation will fail due -Werror and |
| 481 | dnl the fact than some pch will be invalid for the given compilation option |
| 482 | AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} -include bits/stdc++.h", AC_MSG_RESULT([no])) |
| 483 | CXXFLAGS=$SAVE_CXXFLAGS |
| 484 | AC_LANG_RESTORE |
| 485 | ]) |
| 486 | |
| 487 | dnl AX_CHECK_DOCBOOK |
| 488 | AC_DEFUN([AX_CHECK_DOCBOOK], [ |
| 489 | # It's just rude to go over the net to build |
| 490 | XSLTPROC_FLAGS=--nonet |
| 491 | DOCBOOK_ROOT= |
| 492 | if 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 |
| 504 | else |
| 505 | XML_CATALOG=/etc/xml/catalog |
| 506 | CAT_ENTRY_START='<!--' |
| 507 | CAT_ENTRY_END='-->' |
| 508 | fi |
| 509 | |
| 510 | AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,) |
| 511 | XSLTPROC_WORKS=no |
| 512 | if 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> |
| 526 | END |
| 527 | if test "$?" = 0; then |
| 528 | XSLTPROC_WORKS=yes |
| 529 | fi |
| 530 | AC_MSG_RESULT($XSLTPROC_WORKS) |
| 531 | fi |
| 532 | AM_CONDITIONAL(have_xsltproc, test "$XSLTPROC_WORKS" = "yes") |
| 533 | |
| 534 | AC_SUBST(XML_CATALOG) |
| 535 | AC_SUBST(XSLTPROC_FLAGS) |
| 536 | AC_SUBST(DOCBOOK_ROOT) |
| 537 | AC_SUBST(CAT_ENTRY_START) |
| 538 | AC_SUBST(CAT_ENTRY_END) |
| 539 | ]) |
| 540 | |
| 541 | dnl AX_CFLAGS_OPTIONS(var-name, option) |
| 542 | dnl add option to var-name if $CC support it. |
| 543 | AC_DEFUN([AX_CFLAGS_OPTION], [ |
| 544 | AC_MSG_CHECKING([whether ${CC} $2 is understood]) |
| 545 | AC_LANG_SAVE |
| 546 | AC_LANG_C |
| 547 | SAVE_CFLAGS=$CFLAGS |
| 548 | CFLAGS=$2 |
| 549 | AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no])) |
| 550 | CFLAGS=$SAVE_CFLAGS |
| 551 | AC_LANG_RESTORE |
| 552 | ]) |
| 553 | |
| 554 | |
| 555 | dnl AX_CXXFLAGS_OPTIONS(var-name, option) |
| 556 | dnl add option to var-name if $CXX support it. |
| 557 | AC_DEFUN([AX_CXXFLAGS_OPTION], [ |
| 558 | AC_MSG_CHECKING([whether ${CXX} $2 is understood]) |
| 559 | AC_LANG_SAVE |
| 560 | AC_LANG_CPLUSPLUS |
| 561 | SAVE_CXXFLAGS=$CXXFLAGS |
| 562 | CXXFLAGS=$2 |
| 563 | AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no])) |
| 564 | CXXFLAGS=$SAVE_CXXFLAGS |
| 565 | AC_LANG_RESTORE |
| 566 | ]) |
| 567 | |
| 568 | dnl AX_COPY_IF_CHANGE(source, dest) |
| 569 | dnl copy source to dest if they don't compare equally or if dest doesn't exist |
| 570 | AC_DEFUN([AX_COPY_IF_CHANGE], [ |
| 571 | if 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 |
| 577 | else |
| 578 | cp -f $1 $2 |
| 579 | fi |
| 580 | ]) |
| 581 | |