| 1 |
dnl Copyright (c) 2002 Leon Bottou and Yann Le Cun. |
| 2 |
dnl Copyright (c) 2001 AT&T |
| 3 |
dnl |
| 4 |
dnl Most of these macros are derived from macros listed |
| 5 |
dnl at the GNU Autoconf Macro Archive |
| 6 |
dnl http://www.gnu.org/software/ac-archive/ |
| 7 |
dnl |
| 8 |
dnl This program is free software; you can redistribute it and/or modify |
| 9 |
dnl it under the terms of the GNU General Public License as published by |
| 10 |
dnl the Free Software Foundation; either version 2 of the License, or |
| 11 |
dnl (at your option) any later version. |
| 12 |
dnl |
| 13 |
dnl This program is distributed in the hope that it will be useful, |
| 14 |
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
dnl GNU General Public License for more details. |
| 17 |
dnl |
| 18 |
dnl You should have received a copy of the GNU General Public License |
| 19 |
dnl along with this program; if not, write to the Free Software |
| 20 |
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111 USA |
| 21 |
dnl |
| 22 |
|
| 23 |
dnl ------------------------------------------------------- |
| 24 |
dnl @synopsis AC_DEFINE_INSTALL_PATHS |
| 25 |
dnl Define various installation paths |
| 26 |
dnl ------------------------------------------------------- |
| 27 |
AC_DEFUN([AC_DEFINE_INSTALL_PATHS],[ |
| 28 |
save_prefix="${prefix}" |
| 29 |
save_exec_prefix="${exec_prefix}" |
| 30 |
test "x$prefix" = xNONE && prefix="$ac_default_prefix" |
| 31 |
test "x$exec_prefix" = xNONE && exec_prefix="$prefix" |
| 32 |
DIR_PREFIX="`eval echo \"$prefix\"`" |
| 33 |
AC_DEFINE_UNQUOTED(DIR_PREFIX,["${DIR_PREFIX}"], |
| 34 |
[directory "prefix"]) |
| 35 |
DIR_EXEC_PREFIX="`eval echo \"$exec_prefix\"`" |
| 36 |
DIR_EXEC_PREFIX="`eval echo \"$DIR_EXEC_PREFIX\"`" |
| 37 |
AC_DEFINE_UNQUOTED(DIR_EXEC_PREFIX,["${DIR_EXEC_PREFIX}"], |
| 38 |
[directory "exec_prefix"]) |
| 39 |
DIR_BINDIR="`eval echo \"$bindir\"`" |
| 40 |
DIR_BINDIR="`eval echo \"$DIR_BINDIR\"`" |
| 41 |
AC_DEFINE_UNQUOTED(DIR_BINDIR,["${DIR_BINDIR}"], |
| 42 |
[directory "bindir"]) |
| 43 |
DIR_LIBDIR="`eval echo \"$libdir\"`" |
| 44 |
DIR_LIBDIR="`eval echo \"$DIR_LIBDIR\"`" |
| 45 |
AC_DEFINE_UNQUOTED(DIR_LIBDIR,["${DIR_LIBDIR}"], |
| 46 |
[directory "libdir"]) |
| 47 |
DIR_DATADIR="`eval echo \"$datadir\"`" |
| 48 |
DIR_DATADIR="`eval echo \"$DIR_DATADIR\"`" |
| 49 |
AC_DEFINE_UNQUOTED(DIR_DATADIR,["${DIR_DATADIR}"], |
| 50 |
[directory "datadir"]) |
| 51 |
DIR_MANDIR="`eval echo \"$mandir\"`" |
| 52 |
DIR_MANDIR="`eval echo \"$DIR_MANDIR\"`" |
| 53 |
AC_DEFINE_UNQUOTED(DIR_MANDIR,["${DIR_MANDIR}"], |
| 54 |
[directory "mandir"]) |
| 55 |
prefix="${save_prefix}" |
| 56 |
exec_prefix="${save_exec_prefix}" |
| 57 |
]) |
| 58 |
|
| 59 |
dnl ------------------------------------------------------- |
| 60 |
dnl @synopsis AC_CHECK_CXX_OPT(OPTION, |
| 61 |
dnl ACTION-IF-OKAY,ACTION-IF-NOT-OKAY) |
| 62 |
dnl Check if compiler accepts option OPTION. |
| 63 |
dnl ------------------------------------------------------- |
| 64 |
AC_DEFUN(AC_CHECK_CXX_OPT,[ |
| 65 |
opt="$1" |
| 66 |
AC_MSG_CHECKING([if $CXX accepts $opt]) |
| 67 |
echo 'void f(){}' > conftest.cc |
| 68 |
if test -z "`${CXX} ${CXXFLAGS} ${OPTS} $opt -c conftest.cc 2>&1`"; then |
| 69 |
AC_MSG_RESULT(yes) |
| 70 |
rm conftest.* |
| 71 |
$2 |
| 72 |
else |
| 73 |
AC_MSG_RESULT(no) |
| 74 |
rm conftest.* |
| 75 |
$3 |
| 76 |
fi |
| 77 |
]) |
| 78 |
|
| 79 |
dnl ------------------------------------------------------- |
| 80 |
dnl @synopsis AC_CXX_OPTIMIZE |
| 81 |
dnl Setup option --enable-debug |
| 82 |
dnl Collects optimization/debug option in variable OPTS |
| 83 |
dnl Filter options from CFLAGS and CXXFLAGS |
| 84 |
dnl ------------------------------------------------------- |
| 85 |
AC_DEFUN(AC_CXX_OPTIMIZE,[ |
| 86 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 87 |
AC_ARG_ENABLE(debug, |
| 88 |
AC_HELP_STRING([--enable-debug], |
| 89 |
[Compile with debugging options (default: no)]), |
| 90 |
[ac_debug=$enableval],[ac_debug=no]) |
| 91 |
OPTS= |
| 92 |
AC_SUBST(OPTS) |
| 93 |
saved_CXXFLAGS="$CXXFLAGS" |
| 94 |
saved_CFLAGS="$CFLAGS" |
| 95 |
CXXFLAGS= |
| 96 |
CFLAGS= |
| 97 |
for opt in $saved_CXXFLAGS ; do |
| 98 |
case $opt in |
| 99 |
-g*) test $ac_debug != no && OPTS="$OPTS $opt" ;; |
| 100 |
-O*) ;; |
| 101 |
*) CXXFLAGS="$CXXFLAGS $opt" ;; |
| 102 |
esac |
| 103 |
done |
| 104 |
for opt in $saved_CFLAGS ; do |
| 105 |
case $opt in |
| 106 |
-O*|-g*) ;; |
| 107 |
*) CFLAGS="$CFLAGS $opt" ;; |
| 108 |
esac |
| 109 |
done |
| 110 |
if test x$ac_debug = xno ; then |
| 111 |
OPTS=-DNDEBUG |
| 112 |
AC_CHECK_CXX_OPT([-Wall],[OPTS="$OPTS -Wall"]) |
| 113 |
AC_CHECK_CXX_OPT([-O3],[OPTS="$OPTS -O3"], |
| 114 |
[ AC_CHECK_CXX_OPT([-O2], [OPTS="$OPTS -O2"] ) ] ) |
| 115 |
dnl This triggers compiler bugs with gcc-3.2.2: |
| 116 |
dnl AC_CHECK_CXX_OPT([-funroll-loops], [OPTS="$OPTS -funroll-loops"]) |
| 117 |
dnl QT3 has plenty of this: |
| 118 |
AC_CHECK_CXX_OPT([-Wno-non-virtual-dtor],[OPTS="$OPTS -Wno-non-virtual-dtor"]) |
| 119 |
cpu=`uname -m 2>/dev/null` |
| 120 |
test -z "$cpu" && cpu=${host_cpu} |
| 121 |
case "${host_cpu}" in |
| 122 |
i?86) |
| 123 |
opt="-mtune=${host_cpu}" |
| 124 |
AC_CHECK_CXX_OPT([$opt], [OPTS="$OPTS $opt"], |
| 125 |
[ opt="-mcpu=${host_cpu}" |
| 126 |
AC_CHECK_CXX_OPT([$opt], [OPTS="$OPTS $opt"]) ]) |
| 127 |
;; |
| 128 |
esac |
| 129 |
else |
| 130 |
AC_CHECK_CXX_OPT([-Wall],[OPTS="$OPTS -Wall"]) |
| 131 |
AC_CHECK_CXX_OPT([-Wno-non-virtual-dtor],[OPTS="$OPTS -Wno-non-virtual-dtor"]) |
| 132 |
fi |
| 133 |
case x"$ac_debug" in |
| 134 |
changequote(<<, >>)dnl |
| 135 |
x[0-9]) OPTS="$OPTS -DDEBUGLVL=$ac_debug" ;; |
| 136 |
xr*) OPTS="$OPTS -DRUNTIME_DEBUG_ONLY" ;; |
| 137 |
changequote([, ])dnl |
| 138 |
esac |
| 139 |
]) |
| 140 |
|
| 141 |
dnl ------------------------------------------------------- |
| 142 |
dnl @synopsis AC_CXX_INTEL_ATOMIC_BUILTINS |
| 143 |
dnl If the compiler supports intel atomic builtins. |
| 144 |
dnl define HAVE_INTEL_ATOMIC_BUILTINS |
| 145 |
dnl ------------------------------------------------------- |
| 146 |
AC_DEFUN([AC_CXX_INTEL_ATOMIC_BUILTINS], |
| 147 |
[AC_CACHE_CHECK(whether the compiler supports intel atomic builtins, |
| 148 |
ac_cv_cxx_intel_atomic_builtins, |
| 149 |
[AC_LANG_SAVE |
| 150 |
AC_LANG_CPLUSPLUS |
| 151 |
AC_TRY_LINK([static int volatile l;], |
| 152 |
[__sync_lock_test_and_set(&l,1); |
| 153 |
__sync_lock_release(&l); |
| 154 |
__sync_add_and_fetch(&l,1); |
| 155 |
__sync_bool_compare_and_swap(&l,&l,1); |
| 156 |
return 0;], |
| 157 |
ac_cv_cxx_intel_atomic_builtins=yes, ac_cv_cxx_intel_atomic_builtins=no) |
| 158 |
AC_LANG_RESTORE |
| 159 |
]) |
| 160 |
if test "$ac_cv_cxx_intel_atomic_builtins" = yes; then |
| 161 |
AC_DEFINE(HAVE_INTEL_ATOMIC_BUILTINS,1, |
| 162 |
[define if the compiler supports intel atomic builtins]) |
| 163 |
fi |
| 164 |
]) |
| 165 |
|
| 166 |
dnl ------------------------------------------------------- |
| 167 |
dnl @synopsis AC_CXX_MEMBER_TEMPLATES |
| 168 |
dnl If the compiler supports member templates, |
| 169 |
dnl define HAVE_MEMBER_TEMPLATES. |
| 170 |
dnl ------------------------------------------------------- |
| 171 |
AC_DEFUN([AC_CXX_MEMBER_TEMPLATES], |
| 172 |
[AC_CACHE_CHECK(whether the compiler supports member templates, |
| 173 |
ac_cv_cxx_member_templates, |
| 174 |
[AC_LANG_SAVE |
| 175 |
AC_LANG_CPLUSPLUS |
| 176 |
AC_TRY_COMPILE([ |
| 177 |
template<class T, int N> class A |
| 178 |
{ public: |
| 179 |
template<int N2> A<T,N> operator=(const A<T,N2>& z) { return A<T,N>(); } |
| 180 |
};],[A<double,4> x; A<double,7> y; x = y; return 0;], |
| 181 |
ac_cv_cxx_member_templates=yes, ac_cv_cxx_member_templates=no) |
| 182 |
AC_LANG_RESTORE |
| 183 |
]) |
| 184 |
if test "$ac_cv_cxx_member_templates" = yes; then |
| 185 |
AC_DEFINE(HAVE_MEMBER_TEMPLATES,1, |
| 186 |
[define if the compiler supports member templates]) |
| 187 |
fi |
| 188 |
]) |
| 189 |
|
| 190 |
|
| 191 |
dnl ------------------------------------------------------- |
| 192 |
dnl @synopsis AC_CXX_NAMESPACES |
| 193 |
dnl Define HAVE_NAMESPACES if the compiler supports |
| 194 |
dnl namespaces. |
| 195 |
dnl ------------------------------------------------------- |
| 196 |
AC_DEFUN([AC_CXX_NAMESPACES], |
| 197 |
[AC_CACHE_CHECK(whether the compiler implements namespaces, |
| 198 |
ac_cv_cxx_namespaces, |
| 199 |
[ AC_LANG_SAVE |
| 200 |
AC_LANG_CPLUSPLUS |
| 201 |
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], |
| 202 |
[using namespace Outer::Inner; return i;], |
| 203 |
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) |
| 204 |
AC_LANG_RESTORE |
| 205 |
]) |
| 206 |
if test "$ac_cv_cxx_namespaces" = yes && test "$ac_debug" = no; then |
| 207 |
AC_DEFINE(HAVE_NAMESPACES,1, |
| 208 |
[define if the compiler implements namespaces]) |
| 209 |
fi |
| 210 |
]) |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
dnl ------------------------------------------------------- |
| 215 |
dnl @synopsis AC_CXX_TYPENAME |
| 216 |
dnl Define HAVE_TYPENAME if the compiler recognizes |
| 217 |
dnl keyword typename. |
| 218 |
dnl ------------------------------------------------------- |
| 219 |
AC_DEFUN([AC_CXX_TYPENAME], |
| 220 |
[AC_CACHE_CHECK(whether the compiler recognizes typename, |
| 221 |
ac_cv_cxx_typename, |
| 222 |
[AC_LANG_SAVE |
| 223 |
AC_LANG_CPLUSPLUS |
| 224 |
AC_TRY_COMPILE([template<typename T>class X {public:X(){}};], |
| 225 |
[X<float> z; return 0;], |
| 226 |
ac_cv_cxx_typename=yes, ac_cv_cxx_typename=no) |
| 227 |
AC_LANG_RESTORE |
| 228 |
]) |
| 229 |
if test "$ac_cv_cxx_typename" = yes; then |
| 230 |
AC_DEFINE(HAVE_TYPENAME,1,[define if the compiler recognizes typename]) |
| 231 |
fi |
| 232 |
]) |
| 233 |
|
| 234 |
|
| 235 |
dnl ------------------------------------------------------- |
| 236 |
dnl @synopsis AC_CXX_STDINCLUDES |
| 237 |
dnl Define HAVE_STDINCLUDES if the compiler has the |
| 238 |
dnl new style include files (without the .h) |
| 239 |
dnl ------------------------------------------------------- |
| 240 |
AC_DEFUN([AC_CXX_STDINCLUDES], |
| 241 |
[AC_CACHE_CHECK(whether the compiler comes with standard includes, |
| 242 |
ac_cv_cxx_stdincludes, |
| 243 |
[AC_LANG_SAVE |
| 244 |
AC_LANG_CPLUSPLUS |
| 245 |
AC_TRY_COMPILE([#include <new> |
| 246 |
struct X { int a; X(int a):a(a){}; }; |
| 247 |
X* foo(void *x) { return new(x) X(2); } ],[], |
| 248 |
ac_cv_cxx_stdincludes=yes, ac_cv_cxx_stdincludes=no) |
| 249 |
AC_LANG_RESTORE |
| 250 |
]) |
| 251 |
if test "$ac_cv_cxx_stdincludes" = yes; then |
| 252 |
AC_DEFINE(HAVE_STDINCLUDES,1, |
| 253 |
[define if the compiler comes with standard includes]) |
| 254 |
fi |
| 255 |
]) |
| 256 |
|
| 257 |
|
| 258 |
dnl ------------------------------------------------------- |
| 259 |
dnl @synopsis AC_CXX_BOOL |
| 260 |
dnl If the compiler recognizes bool as a separate built-in type, |
| 261 |
dnl define HAVE_BOOL. Note that a typedef is not a separate |
| 262 |
dnl type since you cannot overload a function such that it |
| 263 |
dnl accepts either the basic type or the typedef. |
| 264 |
dnl ------------------------------------------------------- |
| 265 |
AC_DEFUN([AC_CXX_BOOL], |
| 266 |
[AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type, |
| 267 |
ac_cv_cxx_bool, |
| 268 |
[AC_LANG_SAVE |
| 269 |
AC_LANG_CPLUSPLUS |
| 270 |
AC_TRY_COMPILE([ |
| 271 |
int f(int x){return 1;} |
| 272 |
int f(char x){return 1;} |
| 273 |
int f(bool x){return 1;} |
| 274 |
],[bool b = true; return f(b);], |
| 275 |
ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no) |
| 276 |
AC_LANG_RESTORE |
| 277 |
]) |
| 278 |
if test "$ac_cv_cxx_bool" = yes; then |
| 279 |
AC_DEFINE(HAVE_BOOL,1,[define if bool is a built-in type]) |
| 280 |
fi |
| 281 |
]) |
| 282 |
|
| 283 |
dnl ------------------------------------------------------- |
| 284 |
dnl @synopsis AC_CXX_EXCEPTIONS |
| 285 |
dnl If the C++ compiler supports exceptions handling (try, |
| 286 |
dnl throw and catch), define HAVE_EXCEPTIONS. |
| 287 |
dnl ------------------------------------------------------- |
| 288 |
AC_DEFUN([AC_CXX_EXCEPTIONS], |
| 289 |
[AC_CACHE_CHECK(whether the compiler supports exceptions, |
| 290 |
ac_cv_cxx_exceptions, |
| 291 |
[AC_LANG_SAVE |
| 292 |
AC_LANG_CPLUSPLUS |
| 293 |
AC_TRY_COMPILE(,[try { throw 1; } catch (int i) { return i; }], |
| 294 |
ac_cv_cxx_exceptions=yes, ac_cv_cxx_exceptions=no) |
| 295 |
AC_LANG_RESTORE |
| 296 |
]) |
| 297 |
if test "$ac_cv_cxx_exceptions" = yes; then |
| 298 |
AC_DEFINE(HAVE_EXCEPTIONS,1,[define if the compiler supports exceptions]) |
| 299 |
fi |
| 300 |
]) |
| 301 |
|
| 302 |
|
| 303 |
dnl ------------------------------------------------------- |
| 304 |
dnl @synopsis AC_CXX_RPO |
| 305 |
dnl Defines option --enable-rpo and searches program RPO. |
| 306 |
dnl Set output variables CXXRPOFLAGS and RPO. |
| 307 |
dnl ------------------------------------------------------- |
| 308 |
AC_DEFUN([AC_CXX_RPO], |
| 309 |
[ CXXRPOFLAGS= |
| 310 |
RPO_YES='#' |
| 311 |
RPO_NO='' |
| 312 |
if test x$GXX = xyes ; then |
| 313 |
AC_ARG_ENABLE([rpo], |
| 314 |
AC_HELP_STRING([--enable-rpo], |
| 315 |
[Enable compilation with option -frepo]), |
| 316 |
[ac_rpo=$enableval], [ac_rpo=no] ) |
| 317 |
if test x$ac_rpo != xno ; then |
| 318 |
CXXRPOFLAGS='-frepo -fno-rtti' |
| 319 |
RPO_YES='' |
| 320 |
RPO_NO='#' |
| 321 |
fi |
| 322 |
fi |
| 323 |
AC_SUBST(CXXRPOFLAGS) |
| 324 |
AC_SUBST(RPO_YES) |
| 325 |
AC_SUBST(RPO_NO) |
| 326 |
]) |
| 327 |
|
| 328 |
|
| 329 |
dnl ------------------------------------------------------------------ |
| 330 |
dnl @synopsis AC_PATH_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 331 |
dnl This macro figures out how to build C programs using POSIX |
| 332 |
dnl threads. It sets the PTHREAD_LIBS output variable to the threads |
| 333 |
dnl library and linker flags, and the PTHREAD_CFLAGS output variable |
| 334 |
dnl to any special C compiler flags that are needed. (The user can also |
| 335 |
dnl force certain compiler flags/libs to be tested by setting these |
| 336 |
dnl environment variables.). |
| 337 |
dnl ------------------------------------------------------------------ |
| 338 |
AC_DEFUN([AC_PATH_PTHREAD], [ |
| 339 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 340 |
acx_pthread_ok=no |
| 341 |
# First, check if the POSIX threads header, pthread.h, is available. |
| 342 |
# If it isn't, don't bother looking for the threads libraries. |
| 343 |
AC_CHECK_HEADER(pthread.h, , acx_pthread_ok=noheader) |
| 344 |
# We must check for the threads library under a number of different |
| 345 |
# names; the ordering is very important because some systems |
| 346 |
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the |
| 347 |
# libraries is broken (non-POSIX). |
| 348 |
# First of all, check if the user has set any of the PTHREAD_LIBS, |
| 349 |
# etcetera environment variables, and if threads linking works. |
| 350 |
if test x${PTHREAD_LIBS+set} = xset || |
| 351 |
test x${PTHREAD_CFLAGS+set} = xset ; then |
| 352 |
save_CFLAGS="$CFLAGS" |
| 353 |
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 354 |
save_CXXFLAGS="$CXXFLAGS" |
| 355 |
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" |
| 356 |
save_LIBS="$LIBS" |
| 357 |
LIBS="$PTHREAD_LIBS $LIBS" |
| 358 |
AC_MSG_CHECKING([provided PTHREAD_LIBS/PTHREAD_CFLAGS.]) |
| 359 |
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) |
| 360 |
AC_MSG_RESULT($acx_pthread_ok) |
| 361 |
if test x"$acx_pthread_ok" = xno; then |
| 362 |
PTHREAD_LIBS="" |
| 363 |
PTHREAD_CFLAGS="" |
| 364 |
fi |
| 365 |
LIBS="$save_LIBS" |
| 366 |
CFLAGS="$save_CFLAGS" |
| 367 |
CXXFLAGS="$save_CXXFLAGS" |
| 368 |
fi |
| 369 |
# Create a list of thread flags to try. Items starting with a "-" are |
| 370 |
# C compiler flags, and other items are library names, except for "none" |
| 371 |
# which indicates that we try without any flags at all. Also, combinations |
| 372 |
# of items (for instance, both a compiler flag and a library name) can be |
| 373 |
# specified using a colon separator. |
| 374 |
acx_pthread_flags="pthreads none -Kthread -kthread lthread |
| 375 |
-pthread -pthreads -mt -mthreads pthread |
| 376 |
--thread-safe" |
| 377 |
# The ordering *is* (sometimes) important. |
| 378 |
# Some notes on the individual items follow: |
| 379 |
# pthreads: AIX (must check this before -lpthread) |
| 380 |
# none: in case threads are in libc; should be tried before -Kthread and |
| 381 |
# other compiler flags to prevent continual compiler warnings |
| 382 |
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) |
| 383 |
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) |
| 384 |
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) |
| 385 |
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) |
| 386 |
# -pthreads: Solaris/gcc |
| 387 |
# -mt: HP aCC (check before -mthreads) |
| 388 |
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it |
| 389 |
# doesn't hurt to check since this sometimes defines pthreads too; |
| 390 |
# also defines -D_REENTRANT) |
| 391 |
# -mthreads: Mingw32/gcc, Lynx/gcc |
| 392 |
# pthread: Linux, etcetera |
| 393 |
# --thread-safe: KAI C++ |
| 394 |
case "${host_cpu}-${host_os}" in |
| 395 |
*solaris*) |
| 396 |
# On Solaris (at least, for some versions), libc contains stubbed |
| 397 |
# (non-functional) versions of the pthreads routines, so link-based |
| 398 |
# tests will erroneously succeed. (We need to link with -pthread or |
| 399 |
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather |
| 400 |
# a function called by this macro, so we could check for that, but |
| 401 |
# who knows whether they'll stub that too in a future libc.) So, |
| 402 |
# we'll just look for -pthreads and -lpthread first: |
| 403 |
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" |
| 404 |
;; |
| 405 |
esac |
| 406 |
case "${host_os}-${GCC}" in |
| 407 |
*linux*-yes) |
| 408 |
# On Linux/GCC, libtool uses -nostdlib for linking, which cancel part |
| 409 |
# of the -pthread flag effect (libpthread is not automatically linked). |
| 410 |
# So we'll try to link with both -pthread and -lpthread first: |
| 411 |
acx_pthread_flags="-pthread:pthread $acx_pthread_flags" |
| 412 |
;; |
| 413 |
esac |
| 414 |
if test x"$acx_pthread_ok" = xno; then |
| 415 |
for flag in $acx_pthread_flags; do |
| 416 |
case $flag in |
| 417 |
none) |
| 418 |
AC_MSG_CHECKING([whether pthreads work without any flags]) |
| 419 |
;; |
| 420 |
*:*) |
| 421 |
PTHREAD_CFLAGS="" |
| 422 |
PTHREAD_LIBS="" |
| 423 |
message="whether pthreads work with" |
| 424 |
while test x"$flag" != x; do |
| 425 |
subflag=`echo $flag | cut -d: -f1` |
| 426 |
case $subflag in |
| 427 |
-*) |
| 428 |
PTHREAD_CFLAGS="$PTHREAD_CFLAGS $subflag" |
| 429 |
message="$message $subflag" |
| 430 |
;; |
| 431 |
*) |
| 432 |
PTHREAD_LIBS="$PTHREAD_LIBS -l$subflag" |
| 433 |
message="$message -l$subflag" |
| 434 |
;; |
| 435 |
esac |
| 436 |
flag=`echo $flag | cut -s -d: -f2-` |
| 437 |
done |
| 438 |
AC_MSG_CHECKING([$message]) |
| 439 |
;; |
| 440 |
-*) |
| 441 |
AC_MSG_CHECKING([whether pthreads work with $flag]) |
| 442 |
PTHREAD_CFLAGS="$flag" |
| 443 |
;; |
| 444 |
*) |
| 445 |
AC_MSG_CHECKING([for the pthreads library -l$flag]) |
| 446 |
PTHREAD_LIBS="-l$flag" |
| 447 |
;; |
| 448 |
esac |
| 449 |
save_LIBS="$LIBS" |
| 450 |
save_CFLAGS="$CFLAGS" |
| 451 |
save_CXXFLAGS="$CXXFLAGS" |
| 452 |
LIBS="$PTHREAD_LIBS $LIBS" |
| 453 |
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 454 |
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" |
| 455 |
# Check for various functions. We must include pthread.h, |
| 456 |
# since some functions may be macros. (On the Sequent, we |
| 457 |
# need a special flag -Kthread to make this header compile.) |
| 458 |
# We check for pthread_join because it is in -lpthread on IRIX |
| 459 |
# while pthread_create is in libc. We check for pthread_attr_init |
| 460 |
# due to DEC craziness with -lpthreads. We check for |
| 461 |
# pthread_cleanup_push because it is one of the few pthread |
| 462 |
# functions on Solaris that doesn't have a non-functional libc stub. |
| 463 |
# We try pthread_create on general principles. |
| 464 |
AC_TRY_LINK([#include <pthread.h>], |
| 465 |
[pthread_t th; pthread_join(th, 0); |
| 466 |
pthread_attr_init(0); pthread_cleanup_push(0, 0); |
| 467 |
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], |
| 468 |
[acx_pthread_ok=yes]) |
| 469 |
LIBS="$save_LIBS" |
| 470 |
CFLAGS="$save_CFLAGS" |
| 471 |
CXXFLAGS="$save_CXXFLAGS" |
| 472 |
AC_MSG_RESULT($acx_pthread_ok) |
| 473 |
if test "x$acx_pthread_ok" = xyes; then |
| 474 |
break; |
| 475 |
fi |
| 476 |
PTHREAD_LIBS="" |
| 477 |
PTHREAD_CFLAGS="" |
| 478 |
done |
| 479 |
fi |
| 480 |
# Various other checks: |
| 481 |
if test "x$acx_pthread_ok" = xyes; then |
| 482 |
save_LIBS="$LIBS" |
| 483 |
LIBS="$PTHREAD_LIBS $LIBS" |
| 484 |
save_CFLAGS="$CFLAGS" |
| 485 |
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 486 |
save_CXXFLAGS="$CXXFLAGS" |
| 487 |
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" |
| 488 |
AC_MSG_CHECKING([if more special flags are required for pthreads]) |
| 489 |
flag=no |
| 490 |
case "${host_cpu}-${host_os}" in |
| 491 |
*-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; |
| 492 |
*solaris* | alpha*-osf*) flag="-D_REENTRANT";; |
| 493 |
esac |
| 494 |
AC_MSG_RESULT(${flag}) |
| 495 |
if test "x$flag" != xno; then |
| 496 |
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" |
| 497 |
fi |
| 498 |
LIBS="$save_LIBS" |
| 499 |
CFLAGS="$save_CFLAGS" |
| 500 |
CXXFLAGS="$save_CXXFLAGS" |
| 501 |
fi |
| 502 |
AC_ARG_VAR(PTHREAD_LIBS, [Flags for linking pthread programs.]) |
| 503 |
AC_ARG_VAR(PTHREAD_CFLAGS, [Flags for compiling pthread programs.]) |
| 504 |
# execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: |
| 505 |
if test x"$acx_pthread_ok" = xyes; then |
| 506 |
AC_DEFINE(HAVE_PTHREAD,1,[Define if pthreads are available]) |
| 507 |
ifelse([$1],,:,[$1]) |
| 508 |
else |
| 509 |
ifelse([$2],,:,[$2]) |
| 510 |
fi |
| 511 |
]) |
| 512 |
|
| 513 |
|
| 514 |
dnl ------------------------------------------------------------------ |
| 515 |
dnl @synopsis AC_PATH_COTHREADS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 516 |
dnl Define HAVE_COTHREAD if cothreads can be used. |
| 517 |
dnl Define HAVE_COTHREAD_PATCH if cothread libgcc patch is available |
| 518 |
dnl ------------------------------------------------------------------ |
| 519 |
|
| 520 |
AC_DEFUN([AC_PATH_COTHREAD], [ |
| 521 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 522 |
acx_cothread=no |
| 523 |
if test x$GXX = xyes ; then |
| 524 |
AC_MSG_CHECKING([whether cothreads work with ${host_cpu}]) |
| 525 |
case ${host_cpu} in |
| 526 |
i?86|powerpc*|mips*|alpha*|hppa*) |
| 527 |
acx_cothread=yes |
| 528 |
;; |
| 529 |
esac |
| 530 |
AC_MSG_RESULT($acx_cothread) |
| 531 |
fi |
| 532 |
if test x$acx_cothread != xno ; then |
| 533 |
AC_MSG_CHECKING([whether libgcc contains the cothread patch]) |
| 534 |
AC_LANG_PUSH(C++) |
| 535 |
AC_TRY_LINK([extern "C" { void *(*__get_eh_context_ptr)(); |
| 536 |
void *__new_eh_context(void); }], |
| 537 |
[ __get_eh_context_ptr = &__new_eh_context;], |
| 538 |
[acx_cothread_patch=yes], [acx_cothread_patch=no]) |
| 539 |
AC_LANG_POP(C++) |
| 540 |
AC_MSG_RESULT($acx_cothread_patch) |
| 541 |
if test x$acx_cothread_patch = xno ; then |
| 542 |
AC_MSG_CHECKING([if the cothread patch is critical]) |
| 543 |
echo 'void foo() { throw "Hello"; }' > conftest.cc |
| 544 |
compile="$CXX $CXXFLAGS -c conftest.cc" |
| 545 |
check="nm conftest.o | grep sjthrow | cat > conftest.out" |
| 546 |
acx_cothread_patch=yes |
| 547 |
if AC_TRY_EVAL(compile) && AC_TRY_EVAL(check) ; then |
| 548 |
if test -z "`cat conftest.out`" ; then |
| 549 |
acx_cothread_patch=no |
| 550 |
fi |
| 551 |
fi |
| 552 |
AC_MSG_RESULT($acx_cothread_patch) |
| 553 |
rm conftest.* |
| 554 |
if test x$acx_cothread_patch = xyes ; then |
| 555 |
acx_cothread=no |
| 556 |
AC_MSG_WARN([Cothread cannot work without the patch]) |
| 557 |
else |
| 558 |
AC_MSG_WARN([Applying the patch is recommended anyway]) |
| 559 |
fi |
| 560 |
AC_MSG_WARN([See the INSTALL file for more information]) |
| 561 |
fi |
| 562 |
fi |
| 563 |
# Must do. |
| 564 |
if test x$acx_cothread = xyes ; then |
| 565 |
AC_DEFINE(HAVE_COTHREAD,1, |
| 566 |
[Define if cothreads are available.]) |
| 567 |
if test x$acx_cothread_patch = xyes ; then |
| 568 |
AC_DEFINE(HAVE_COTHREAD_PATCH,1, |
| 569 |
[Define if libgcc contains the cothread patch.]) |
| 570 |
fi |
| 571 |
ifelse([$1],,:,[$1]) |
| 572 |
else |
| 573 |
ifelse([$2],,:,[$2]) |
| 574 |
fi |
| 575 |
]) |
| 576 |
|
| 577 |
dnl ------------------------------------------------------------------ |
| 578 |
dnl @synopsis AC_PATH_THREADS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 579 |
dnl Process optional option --enable-threads |
| 580 |
dnl Check availability of pthreads or cothreads |
| 581 |
dnl using AC_PATH_PTHREAD and AC_PATH_COTHREAD. |
| 582 |
dnl Set output variable THREADS_LIBS and THREADS_CFLAGS |
| 583 |
dnl ------------------------------------------------------------------ |
| 584 |
|
| 585 |
AC_DEFUN([AC_PATH_THREADS], [ |
| 586 |
AC_ARG_ENABLE(threads, |
| 587 |
AC_HELP_STRING([--enable-threads], |
| 588 |
[select threading model (default is auto)]), |
| 589 |
ac_use_threads=$enableval, ac_use_threads=auto) |
| 590 |
ac_threads=no |
| 591 |
if test x$ac_use_threads != xno ; then |
| 592 |
if test x$ac_threads = xno ; then |
| 593 |
case x$ac_use_threads in |
| 594 |
x|xyes|xauto|xposix|xpthread) |
| 595 |
AC_PATH_PTHREAD( |
| 596 |
[ ac_threads=pthread |
| 597 |
ac_use_threads=pthread |
| 598 |
THREAD_LIBS="$PTHREAD_LIBS" |
| 599 |
THREAD_CFLAGS="$PTHREAD_CFLAGS -DTHREADMODEL=POSIXTHREADS" |
| 600 |
] ) |
| 601 |
;; |
| 602 |
esac |
| 603 |
fi |
| 604 |
if test x$ac_threads = xno ; then |
| 605 |
case x$ac_use_threads in |
| 606 |
x|xyes|xauto|xwin32|xwindows) |
| 607 |
AC_TRY_LINK([#include <windows.h>], |
| 608 |
[CreateThread(NULL,4096,NULL,NULL,0,NULL);], |
| 609 |
[ ac_threads=win32 |
| 610 |
ac_use_threads=win32 |
| 611 |
THREAD_LIBS="" |
| 612 |
THREAD_CFLAGS="-DTHREADMODEL=WINTHREADS" |
| 613 |
] ) |
| 614 |
;; |
| 615 |
esac |
| 616 |
fi |
| 617 |
if test x$ac_threads = xno ; then |
| 618 |
case x$ac_use_threads in |
| 619 |
x|xyes|xauto|xcothread) |
| 620 |
AC_PATH_COTHREAD( |
| 621 |
[ ac_threads=cothread |
| 622 |
THREAD_CFLAGS="-DTHREADMODEL=COTHREADS" |
| 623 |
] ) |
| 624 |
;; |
| 625 |
esac |
| 626 |
fi |
| 627 |
fi |
| 628 |
AC_SUBST(THREAD_LIBS) |
| 629 |
AC_SUBST(THREAD_CFLAGS) |
| 630 |
AC_SUBST(PTHREAD_LIBS) |
| 631 |
AC_SUBST(PTHREAD_CFLAGS) |
| 632 |
AC_MSG_CHECKING([threading model]) |
| 633 |
AC_MSG_RESULT($ac_threads) |
| 634 |
if test x$ac_threads = xwin32 ; then |
| 635 |
AC_CHECK_CXX_OPT([-mthreads], |
| 636 |
[THREAD_CFLAGS="-mthreads $THREAD_CFLAGS"]) |
| 637 |
fi |
| 638 |
if test $ac_threads != no ; then |
| 639 |
AC_MSG_RESULT([setting THREAD_CFLAGS=$THREAD_CFLAGS]) |
| 640 |
AC_MSG_RESULT([setting THREAD_LIBS=$THREAD_LIBS]) |
| 641 |
ifelse([$1],,:,[$1]) |
| 642 |
else |
| 643 |
ifelse([$2],,:,[$2]) |
| 644 |
fi |
| 645 |
]) |
| 646 |
|
| 647 |
dnl ------------------------------------------------------------------ |
| 648 |
dnl @synopsis AC_PATH_JPEG([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 649 |
dnl Process option --with-jpeg. |
| 650 |
dnl Search JPEG. Define HAVE_JPEG. |
| 651 |
dnl Set output variable JPEG_CFLAGS and JPEG_LIBS |
| 652 |
dnl ------------------------------------------------------------------ |
| 653 |
|
| 654 |
AC_DEFUN([AC_PATH_JPEG], |
| 655 |
[ |
| 656 |
AC_ARG_VAR(JPEG_LIBS) |
| 657 |
AC_ARG_VAR(JPEG_CFLAGS) |
| 658 |
ac_jpeg=no |
| 659 |
AC_ARG_WITH(jpeg, |
| 660 |
AC_HELP_STRING([--with-jpeg=DIR], |
| 661 |
[where the IJG jpeg library is located]), |
| 662 |
[ac_jpeg=$withval], [ac_jpeg=yes] ) |
| 663 |
# Process specification |
| 664 |
if test x$ac_jpeg = xyes ; then |
| 665 |
test x${JPEG_LIBS+set} != xset && JPEG_LIBS="-ljpeg" |
| 666 |
elif test x$ac_jpeg != xno ; then |
| 667 |
test x${JPEG_LIBS+set} != xset && JPEG_LIBS="-L$ac_jpeg/lib -ljpeg" |
| 668 |
test x${JPEG_CFLAGS+set} != xset && JPEG_CFLAGS="-I$ac_jpeg/include" |
| 669 |
fi |
| 670 |
# Try linking |
| 671 |
if test x$ac_jpeg != xno ; then |
| 672 |
AC_MSG_CHECKING([for jpeg library]) |
| 673 |
save_CFLAGS="$CFLAGS" |
| 674 |
save_CXXFLAGS="$CXXFLAGS" |
| 675 |
save_LIBS="$LIBS" |
| 676 |
CFLAGS="$CFLAGS $JPEG_CFLAGS" |
| 677 |
CXXFLAGS="$CXXFLAGS $JPEG_CFLAGS" |
| 678 |
LIBS="$LIBS $JPEG_LIBS" |
| 679 |
AC_TRY_LINK([ |
| 680 |
#ifdef __cplusplus |
| 681 |
extern "C" { |
| 682 |
#endif |
| 683 |
#include <stdio.h> |
| 684 |
#include <jpeglib.h> |
| 685 |
#ifdef __cplusplus |
| 686 |
} |
| 687 |
#endif ],[ |
| 688 |
jpeg_CreateDecompress(0,0,0);], |
| 689 |
[ac_jpeg=yes], [ac_jpeg=no] ) |
| 690 |
CFLAGS="$save_CFLAGS" |
| 691 |
CXXFLAGS="$save_CXXFLAGS" |
| 692 |
LIBS="$save_LIBS" |
| 693 |
AC_MSG_RESULT($ac_jpeg) |
| 694 |
fi |
| 695 |
# Finish |
| 696 |
if test x$ac_jpeg = xno; then |
| 697 |
JPEG_CFLAGS= ; JPEG_LIBS= |
| 698 |
ifelse([$2],,:,[$2]) |
| 699 |
else |
| 700 |
AC_DEFINE(HAVE_JPEG,1,[Define if you have the IJG JPEG library.]) |
| 701 |
AC_MSG_RESULT([setting JPEG_CFLAGS=$JPEG_CFLAGS]) |
| 702 |
AC_MSG_RESULT([setting JPEG_LIBS=$JPEG_LIBS]) |
| 703 |
ifelse([$1],,:,[$1]) |
| 704 |
fi |
| 705 |
]) |
| 706 |
|
| 707 |
dnl ------------------------------------------------------------------ |
| 708 |
dnl @synopsis AC_PATH_QT([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 709 |
dnl Process option --with-qt=DIR |
| 710 |
dnl Define HAVE_QT and set it to QT_VERSION |
| 711 |
dnl Set output variables MOC, UIC, QT_LIBS and QT_CFLAGS. |
| 712 |
dnl ------------------------------------------------------------------ |
| 713 |
|
| 714 |
AC_DEFUN([AC_PATH_QT], |
| 715 |
[ |
| 716 |
AC_REQUIRE([AC_PATH_X]) |
| 717 |
AC_REQUIRE([AC_PATH_XTRA]) |
| 718 |
if test ${no_x-no} != yes ; then |
| 719 |
X_LIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS" |
| 720 |
fi |
| 721 |
# Variables |
| 722 |
AC_ARG_VAR(QTDIR,[Location of the Qt package.]) |
| 723 |
AC_ARG_VAR(QT_CFLAGS,[Flags for compiling Qt programs.]) |
| 724 |
AC_ARG_VAR(QT_LIBS,[Flags for linking Qt programs.]) |
| 725 |
AC_ARG_VAR(MOC,[Location of the MOC program.]) |
| 726 |
AC_ARG_VAR(UIC,[Location of the UIC program.]) |
| 727 |
# Arguments |
| 728 |
AC_ARG_WITH(qt, |
| 729 |
AC_HELP_STRING([--with-qt=DIR], |
| 730 |
[where the Qt root is installed.]), |
| 731 |
[ test x$withval != xyes && QTDIR=$withval ]) |
| 732 |
test x$no_x = xyes && QTDIR=no |
| 733 |
# Check for the lib64 thing |
| 734 |
lib=`basename "$libdir"` |
| 735 |
case "$lib" in lib*) ;; *) lib="lib" ;; esac |
| 736 |
if test $lib = "lib" -o $lib = "lib64" ; then |
| 737 |
libs="$lib" ; else libs="$lib lib"; fi |
| 738 |
# Standard qt directory |
| 739 |
ac_has_qt=no |
| 740 |
if test x$QTDIR != xno ; then |
| 741 |
AC_MSG_CHECKING([for Qt root directory]) |
| 742 |
ac_has_qt=no |
| 743 |
ac_userdef_qt=no |
| 744 |
if test x${QT_CFLAGS+set} = xset || test x${QT_LIBS+set} = xset ; then |
| 745 |
ac_userdef_qt=yes |
| 746 |
ac_has_qt="user defined QT_CFLAGS and QT_LIBS" # no questions asked |
| 747 |
else |
| 748 |
ac_qt_dirs="/usr/local /usr/X11R6 /usr" |
| 749 |
for lib in $libs ; do |
| 750 |
for n in /usr/$lib/qt* ; do |
| 751 |
test -d $n && ac_qt_dirs="$n $ac_qt_dirs" ; |
| 752 |
done |
| 753 |
done |
| 754 |
if test -d "$QTDIR" ; then |
| 755 |
ac_qt_dirs="$QTDIR $ac_qt_dirs" |
| 756 |
fi |
| 757 |
for dir in $ac_qt_dirs ; do |
| 758 |
if test -r $dir/include/qwidget.h ; then |
| 759 |
ac_has_qt=$dir |
| 760 |
QTDIR=$dir |
| 761 |
break |
| 762 |
fi |
| 763 |
done |
| 764 |
fi |
| 765 |
# Unusual install |
| 766 |
if test "x$ac_has_qt" = xno ; then |
| 767 |
ac_qt_names="qt3 qt2 qt" |
| 768 |
ac_qt_dirs="/usr /usr/X11R6 /usr/local" |
| 769 |
case "$host" in |
| 770 |
*-darwin* | *-macos10*) |
| 771 |
if test -d /opt/local ; then |
| 772 |
ac_qt_dirs="/opt/local $ac_qt_dirs" |
| 773 |
elif test -d /sw ; then |
| 774 |
ac_qt_dirs="/sw $ac_qt_dirs" |
| 775 |
fi |
| 776 |
;; |
| 777 |
esac |
| 778 |
ac_qt_dirs="$QTDIR $prefix $ac_qt_dirs" |
| 779 |
for d in $ac_qt_dirs ; do |
| 780 |
for n in $ac_qt_names ; do |
| 781 |
if test -r $d/include/$n/qwidget.h ; then |
| 782 |
for lib in $libs ; do |
| 783 |
for l in lib$n.so lib$n-mt.so lib$n-mt.dylib lib$n.a lib$n-mt.a ; do |
| 784 |
if test -r $d/$lib/$l ; then |
| 785 |
QT_CFLAGS="-I$d/include/$n" |
| 786 |
QT_LIBS="-L$d/$lib -l$n" |
| 787 |
QTDIR=$d |
| 788 |
ac_has_qt="bsd-style Qt install" |
| 789 |
break 3 |
| 790 |
fi |
| 791 |
done |
| 792 |
for l in libqt.dll.a libqt-mt.dll.a libqt-mt.la libqt.a libqt-mt.a; do |
| 793 |
if test -r $d/$lib/$n/$lib/$l ; then |
| 794 |
QT_CFLAGS="-I$d/include/$n" |
| 795 |
QT_LIBS="-L$d/$lib/$n/$lib -lqt" |
| 796 |
QTDIR=$d/$lib/$n |
| 797 |
ac_has_qt="cygwin-style Qt install" |
| 798 |
break 3 |
| 799 |
fi |
| 800 |
done |
| 801 |
for l in libqt.so libqt-mt.so libqt-mt.dylib libqt.a libqt-mt.a; do |
| 802 |
if test -r $d/$lib/$l ; then |
| 803 |
QT_CFLAGS="-I$d/include/$n" |
| 804 |
QT_LIBS="-L$d/$lib -lqt" |
| 805 |
QTDIR=$d |
| 806 |
ac_has_qt="debian-style Qt install" |
| 807 |
break 3 |
| 808 |
fi |
| 809 |
done |
| 810 |
done |
| 811 |
fi |
| 812 |
done |
| 813 |
done |
| 814 |
fi |
| 815 |
# Print result |
| 816 |
AC_MSG_RESULT($ac_has_qt) |
| 817 |
fi |
| 818 |
# Programs |
| 819 |
if test "x$ac_has_qt" != xno ; then |
| 820 |
if test "x$ac_userdef_qt" != xyes ; then |
| 821 |
if test x${QT_CFLAGS+set} != xset ; then |
| 822 |
QT_CFLAGS="-I$QTDIR/include" |
| 823 |
fi |
| 824 |
if test x${QT_LIBS+set} != xset ; then |
| 825 |
if test -d $QTDIR/$lib ; then |
| 826 |
QT_LIBS="-L$QTDIR/$lib -lqt" |
| 827 |
else |
| 828 |
QT_LIBS="-L$QTDIR/lib -lqt" |
| 829 |
fi |
| 830 |
fi |
| 831 |
# KDE-3.0 styles require qt-mt even in non KDE applications. |
| 832 |
# Bero dixit. See kde bug #40823. |
| 833 |
qt_libdir= |
| 834 |
qt_libname= |
| 835 |
AC_MSG_CHECKING([for multithreaded Qt3 library]) |
| 836 |
for n in `echo $QT_LIBS` ; do case $n in |
| 837 |
-L*) qt_libdir=`echo "$n" | sed -e 's:^-L::'` ;; |
| 838 |
-l*) qt_libname=`echo "$n" | sed -e 's:^-l::'` ;; |
| 839 |
esac |
| 840 |
done |
| 841 |
ac_has_qt_mt=no |
| 842 |
for n in ${qt_libdir}/lib${qt_libname}-mt.so \ |
| 843 |
${qt_libdir}/lib${qt_libname}-mt.dylib \ |
| 844 |
${qt_libdir}/lib${qt_libname}-mt.dll.a; do |
| 845 |
if test -r $n ; then |
| 846 |
ac_has_qt_mt=yes |
| 847 |
fi |
| 848 |
done |
| 849 |
AC_MSG_RESULT($ac_has_qt_mt) |
| 850 |
if test $ac_has_qt_mt = yes ; then |
| 851 |
newqtlibs= |
| 852 |
for n in `echo $QT_LIBS` ; do |
| 853 |
test "$n" = "-l$qt_libname" && n="$n-mt" |
| 854 |
newqtlibs="$newqtlibs $n" |
| 855 |
done |
| 856 |
QT_LIBS="$newqtlibs" |
| 857 |
fi |
| 858 |
fi |
| 859 |
AC_PATH_PROGS(MOC, [moc moc3 moc2], [:], [$QTDIR/bin $PATH]) |
| 860 |
AC_PATH_PROGS(UIC, [uic uic3 uic2], [:], [$QTDIR/bin $PATH]) |
| 861 |
AC_PATH_PROGS(LUPDATE, [lupdate], [:], [$QTDIR/bin $PATH]) |
| 862 |
AC_PATH_PROGS(LRELEASE,[lrelease], [:], [$QTDIR/bin $PATH]) |
| 863 |
if test -x "$MOC" ; then : ; else |
| 864 |
AC_MSG_WARN([Cannot locate the Qt Meta-Object compiler.]) |
| 865 |
ac_has_qt=no |
| 866 |
QTDIR=no |
| 867 |
fi |
| 868 |
fi |
| 869 |
# Execute |
| 870 |
if test "x$ac_has_qt" != xno ; then |
| 871 |
AC_MSG_CHECKING([if a small Qt program runs]) |
| 872 |
AC_LANG_PUSH(C++) |
| 873 |
save_CXXFLAGS="$CXXFLAGS" |
| 874 |
save_LIBS="$LIBS" |
| 875 |
CXXFLAGS="$CXXFLAGS $CFLAGS $THREAD_CFLAGS $QT_CFLAGS $X_CFLAGS" |
| 876 |
LIBS="$THREAD_LIBS $QT_LIBS $X_LIBS $LIBS" |
| 877 |
AC_TRY_RUN([ |
| 878 |
#include <qfile.h> |
| 879 |
#include <qtextstream.h> |
| 880 |
#include <qglobal.h> |
| 881 |
int main() { |
| 882 |
QFile qf("confout"); if (!qf.open(IO_WriteOnly)) return 1; |
| 883 |
QTextStream ts(&qf); ts << QT_VERSION; return 0; |
| 884 |
}],[okay=yes],[okay=no; QTDIR=no]) |
| 885 |
CXXFLAGS="$save_CXXFLAGS" |
| 886 |
LIBS="$save_LIBS" |
| 887 |
AC_LANG_POP(C++) |
| 888 |
AC_MSG_RESULT($okay) |
| 889 |
if test "x$okay" = xno ; then |
| 890 |
ac_has_qt=no |
| 891 |
fi |
| 892 |
fi |
| 893 |
# Version |
| 894 |
if test "x$ac_has_qt" != xno ; then |
| 895 |
AC_MSG_CHECKING([Qt version]) |
| 896 |
qt_version=`cat < confout` |
| 897 |
AC_MSG_RESULT($qt_version) |
| 898 |
AC_DEFINE_UNQUOTED(HAVE_QT,$qt_version, |
| 899 |
[Define to Qt version if available]) |
| 900 |
rm confout 2>/dev/null |
| 901 |
fi |
| 902 |
# Execute |
| 903 |
if test "x$ac_has_qt" = xno ; then |
| 904 |
QT_CFLAGS= ; QT_LIBS= ; QTDIR= ; MOC=moc ; |
| 905 |
ifelse([$2],,:,[$2]) |
| 906 |
else |
| 907 |
AC_MSG_RESULT([setting QT_CFLAGS=$QT_CFLAGS]) |
| 908 |
AC_MSG_RESULT([setting QT_LIBS=$QT_LIBS]) |
| 909 |
ifelse([$1],,:,[$1]) |
| 910 |
fi |
| 911 |
]) |
| 912 |
|
| 913 |
|
| 914 |
dnl ------------------------------------------------------------------ |
| 915 |
dnl @synopsis AC_PATH_TIFF([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 916 |
dnl Process option --with-tiff |
| 917 |
dnl Search LIBTIFF. Define HAVE_TIFF. |
| 918 |
dnl Set output variable TIFF_CFLAGS and TIFF_LIBS |
| 919 |
dnl ------------------------------------------------------------------ |
| 920 |
|
| 921 |
AC_DEFUN([AC_PATH_TIFF], |
| 922 |
[ |
| 923 |
AC_ARG_VAR(TIFF_LIBS) |
| 924 |
AC_ARG_VAR(TIFF_CFLAGS) |
| 925 |
ac_tiff=no |
| 926 |
AC_ARG_WITH(tiff, |
| 927 |
AC_HELP_STRING([--with-tiff=DIR], |
| 928 |
[where libtiff is located]), |
| 929 |
[ac_tiff=$withval], [ac_tiff=yes] ) |
| 930 |
# Process specification |
| 931 |
if test x$ac_tiff = xyes ; then |
| 932 |
test x${TIFF_LIBS+set} != xset && TIFF_LIBS="-ltiff" |
| 933 |
elif test x$ac_tiff != xno ; then |
| 934 |
test x${TIFF_LIBS+set} != xset && TIFF_LIBS="-L$ac_tiff/lib -ltiff" |
| 935 |
test x${TIFF_CFLAGS+set} != xset && TIFF_CFLAGS="-I$ac_tiff/include" |
| 936 |
fi |
| 937 |
# Try linking |
| 938 |
if test x$ac_tiff != xno ; then |
| 939 |
AC_MSG_CHECKING([for the libtiff library]) |
| 940 |
save_CFLAGS="$CFLAGS" |
| 941 |
save_CXXFLAGS="$CXXFLAGS" |
| 942 |
save_LIBS="$LIBS" |
| 943 |
CFLAGS="$CFLAGS $TIFF_CFLAGS" |
| 944 |
CXXFLAGS="$CXXFLAGS $TIFF_CFLAGS" |
| 945 |
LIBS="$LIBS $TIFF_LIBS" |
| 946 |
AC_TRY_LINK([ |
| 947 |
#ifdef __cplusplus |
| 948 |
extern "C" { |
| 949 |
#endif |
| 950 |
#include <stdio.h> |
| 951 |
#include <tiffio.h> |
| 952 |
#ifdef __cplusplus |
| 953 |
} |
| 954 |
#endif ],[ |
| 955 |
TIFFOpen(0,0);], |
| 956 |
[ac_tiff=yes], [ac_tiff=no] ) |
| 957 |
CFLAGS="$save_CFLAGS" |
| 958 |
CXXFLAGS="$save_CXXFLAGS" |
| 959 |
LIBS="$save_LIBS" |
| 960 |
AC_MSG_RESULT($ac_tiff) |
| 961 |
fi |
| 962 |
# Finish |
| 963 |
if test x$ac_tiff = xno; then |
| 964 |
TIFF_CFLAGS= ; TIFF_LIBS= |
| 965 |
ifelse([$2],,:,[$2]) |
| 966 |
else |
| 967 |
AC_DEFINE(HAVE_TIFF,1,[Define if you have libtiff.]) |
| 968 |
AC_MSG_RESULT([setting TIFF_CFLAGS=$TIFF_CFLAGS]) |
| 969 |
AC_MSG_RESULT([setting TIFF_LIBS=$TIFF_LIBS]) |
| 970 |
ifelse([$1],,:,[$1]) |
| 971 |
fi |
| 972 |
]) |
| 973 |
|
| 974 |
|
| 975 |
dnl ------------------------------------------------------------------ |
| 976 |
dnl @synopsis AC_PROG_PKG_CONFIG([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
| 977 |
dnl Sets output variables PKG_CONFIG |
| 978 |
dnl ------------------------------------------------------------------ |
| 979 |
|
| 980 |
|
| 981 |
AC_DEFUN([AC_PROG_PKG_CONFIG], |
| 982 |
[ |
| 983 |
AC_ARG_VAR(PKG_CONFIG,[Location of the pkg-config program.]) |
| 984 |
AC_ARG_VAR(PKG_CONFIG_PATH, [Path for pkg-config descriptors.]) |
| 985 |
AC_PATH_PROG(PKG_CONFIG, pkg-config) |
| 986 |
if test -z "$PKG_CONFIG" ; then |
| 987 |
ifelse([$2],,:,[$2]) |
| 988 |
else |
| 989 |
ifelse([$1],,:,[$1]) |
| 990 |
fi |
| 991 |
]) |
| 992 |
|
| 993 |
|
| 994 |
dnl ------------------------------------------------------------------ |
| 995 |
dnl @synopsis AC_PATH_GLIB([action-if-found],[action-if-notfound]) |
| 996 |
dnl Search for glib. Defines HAVE_GLIB. |
| 997 |
dnl Sets output variables GLIB_CFLAGS and GLIB_LIBS |
| 998 |
dnl ------------------------------------------------------------------ |
| 999 |
|
| 1000 |
AC_DEFUN([AC_PATH_GLIB], |
| 1001 |
[ |
| 1002 |
AC_REQUIRE([AC_PROG_PKG_CONFIG]) |
| 1003 |
AC_ARG_VAR(GLIB_LIBS, [Libraries for glib-2.0]) |
| 1004 |
AC_ARG_VAR(GLIB_CFLAGS, [Compilation flags for glib-2.0]) |
| 1005 |
AC_MSG_CHECKING([for glib]) |
| 1006 |
if test -x "$PKG_CONFIG" ; then |
| 1007 |
if $PKG_CONFIG glib-2.0 ; then |
| 1008 |
ac_glib=yes |
| 1009 |
AC_MSG_RESULT([found]) |
| 1010 |
GLIB_LIBS=`$PKG_CONFIG --libs glib-2.0` |
| 1011 |
AC_MSG_RESULT([setting GLIB_LIBS=$GLIB_LIBS]) |
| 1012 |
GLIB_CFLAGS=`$PKG_CONFIG --cflags glib-2.0` |
| 1013 |
AC_MSG_RESULT([setting GLIB_CFLAGS=$GLIB_CFLAGS]) |
| 1014 |
AC_DEFINE(HAVE_GLIB,1,[Define if you have glib-2.0.]) |
| 1015 |
ifelse([$1],,:,[$1]) |
| 1016 |
else |
| 1017 |
AC_MSG_RESULT([not found by pkg-config]) |
| 1018 |
ac_glib=no |
| 1019 |
ifelse([$2],,:,[$2]) |
| 1020 |
fi |
| 1021 |
else |
| 1022 |
AC_MSG_RESULT([no pkg-config]) |
| 1023 |
ac_glib=no |
| 1024 |
ifelse([$2],,:,[$2]) |
| 1025 |
fi |
| 1026 |
]) |
| 1027 |
|
| 1028 |
|
| 1029 |
|