* assuan.h (assuan_error_t, assuan_context_t): New aliases.
[pinentry.git] / m4 / qt.m4
1 ##   -*- autoconf -*-
2
3
4 dnl    This file is part of the KDE libraries/packages
5 dnl    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
6 dnl              (C) 1997,98,99 Stephan Kulow (coolo@kde.org)
7 dnl              (C) 2002 g10 Code GmbH
8 dnl              Modified for PINENTRY by Marcus Brinkmann.
9 dnl
10 dnl    This file is free software; you can redistribute it and/or
11 dnl    modify it under the terms of the GNU Library General Public
12 dnl    License as published by the Free Software Foundation; either
13 dnl    version 2 of the License, or (at your option) any later version.
14
15 dnl    This library is distributed in the hope that it will be useful,
16 dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 dnl    Library General Public License for more details.
19
20 dnl    You should have received a copy of the GNU Library General Public License
21 dnl    along with this library; see the file COPYING.LIB.  If not, write to
22 dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 dnl    Boston, MA 02111-1307, USA.
24
25 dnl ------------------------------------------------------------------------
26 dnl Find a file (or one of more files in a list of dirs)
27 dnl ------------------------------------------------------------------------
28 dnl
29 AC_DEFUN([QT_FIND_FILE],
30 [
31 $3=NO
32 for i in $2;
33 do
34   for j in $1;
35   do
36     echo "configure: __oline__: $i/$j" >&AS_MESSAGE_LOG_FD
37     if test -r "$i/$j"; then
38       echo "taking that" >&AS_MESSAGE_LOG_FD
39       $3=$i
40       break 2
41     fi
42   done
43 done
44 ])
45
46 dnl ------------------------------------------------------------------------
47 dnl Find the meta object compiler in the PATH,
48 dnl in $QTDIR/bin, and some more usual places
49 dnl ------------------------------------------------------------------------
50 dnl
51 AC_DEFUN([QT_PATH_MOC],
52 [
53    qt_bindirs=""
54    for dir in $qt_dirs; do
55       qt_bindirs="$qt_bindirs:$dir/bin:$dir/src/moc"
56    done
57    qt_bindirs="$qt_bindirs:/usr/bin:/usr/X11R6/bin:/usr/local/qt/bin"
58    if test ! "$ac_qt_bindir" = "NO"; then
59       qt_bindirs="$ac_qt_bindir:$qt_bindirs"
60    fi
61
62    AC_PATH_PROG(MOC, moc, no, [$qt_bindirs])
63    if test "$MOC" = no; then
64     #AC_MSG_ERROR([No Qt meta object compiler (moc) found!
65     #Please check whether you installed Qt correctly.
66     #You need to have a running moc binary.
67     #configure tried to run $ac_cv_path_moc and the test didn't
68     #succeed. If configure shouldn't have tried this one, set
69     #the environment variable MOC to the right one before running
70     #configure.
71     #])
72     have_moc="no"
73    else
74     have_moc="yes"
75     AC_SUBST(MOC)
76    fi
77 ])
78
79
80 dnl ------------------------------------------------------------------------
81 dnl Find the header files and libraries for the X Window System.
82 dnl Extended the macro AC_PATH_XTRA.
83 dnl ------------------------------------------------------------------------
84 dnl
85 AC_DEFUN([QT_PATH_X],
86 [
87 AC_ARG_ENABLE(
88   embedded,
89   [  --enable-embedded       link to Qt-embedded, don't use X],
90   qt_use_emb=$enableval,
91   qt_use_emb=no
92 )
93
94 AC_ARG_ENABLE(
95   palmtop,
96   [  --enable-palmtop       link to Qt-embedded, don't use X, link to the Qt Palmtop Environment],
97   qt_use_emb_palm=$enableval,
98   qt_use_emb_palm=no
99 )
100
101 if test "$qt_use_emb" = "no"; then
102   AC_PATH_X
103   AC_PATH_XTRA
104   if test "$no_x" = yes; then
105     AC_MSG_ERROR([Can't find X. Please check your installation and add the correct paths!])
106   fi
107   QT_CXXFLAGS="$X_CFLAGS"
108   QT_LDFLAGS="$X_LIBS"
109   QT_LIBS="$X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS"
110   QTE_NORTTI=""
111 else
112   dnl We're using QT Embedded
113   QT_CXXFLAGS="-fno-rtti -DQWS"
114   QT_LDFLAGS="-DQWS"
115   QT_LIBS=""
116   QTE_NORTTI="-fno-rtti -DQWS"
117 fi
118 AC_SUBST(QT_CXXFLAGS)
119 AC_SUBST(QT_LDFLAGS)
120 AC_SUBST(QT_LIBS)
121 AC_SUBST(QTE_NORTTI)
122 ])
123
124 AC_DEFUN([QT_PRINT_PROGRAM],
125 [
126 AC_REQUIRE([QT_CHECK_VERSION])
127 cat > conftest.$ac_ext <<EOF
128 #include "confdefs.h"
129 #include <qglobal.h>
130 #include <qapplication.h>
131 EOF
132 if test "$qt_ver" = "2"; then
133 cat >> conftest.$ac_ext <<EOF
134 #include <qevent.h>
135 #include <qstring.h>
136 #include <qstyle.h>
137 EOF
138
139 if test $qt_subver -gt 0; then
140 cat >> conftest.$ac_ext <<EOF
141 #include <qiconview.h>
142 EOF
143 fi
144 fi
145
146 if test "$qt_ver" = "3"; then
147 cat >> conftest.$ac_ext <<EOF
148 #include <qcursor.h>
149 #include <qstylefactory.h>
150 #include <private/qucomextra_p.h>
151 EOF
152 fi
153
154 echo "#if ! ($qt_verstring)" >> conftest.$ac_ext
155 cat >> conftest.$ac_ext <<EOF
156 #error 1
157 #endif
158
159 int main() {
160 EOF
161 if test "$qt_ver" = "2"; then
162 cat >> conftest.$ac_ext <<EOF
163     QStringList *t = new QStringList();
164     Q_UNUSED(t);
165 EOF
166 if test $qt_subver -gt 0; then
167 cat >> conftest.$ac_ext <<EOF
168     QIconView iv(0);
169     iv.setWordWrapIconText(false);
170     QString s;
171     s.setLatin1("Elvis is alive", 14);
172 EOF
173 fi
174 fi
175 if test "$qt_ver" = "3"; then
176 cat >> conftest.$ac_ext <<EOF
177     (void)QStyleFactory::create(QString::null);
178     QCursor c(Qt::WhatsThisCursor);
179 EOF
180 fi
181 cat >> conftest.$ac_ext <<EOF
182     return 0;
183 }
184 EOF
185 ])
186
187
188 AC_DEFUN([QT_CHECK_VERSION],
189 [
190 if test -z "$1"; then
191   qt_ver=3
192   qt_subver=1
193 else
194   qt_subver=`echo "$1" | sed -e 's#[0-9][0-9]*\.\([0-9][0-9]*\).*#\1#'`
195   # following is the check if subversion isnĀ“t found in passed argument
196   if test "$qt_subver" = "$1"; then
197     qt_subver=1
198   fi
199   qt_ver=`echo "$1" | sed -e 's#^\([0-9][0-9]*\)\..*#\1#'`
200   if test "$qt_ver" = "1"; then
201     qt_subver=42
202   fi
203 fi
204
205 if test -z "$2"; then
206   if test "$qt_ver" = "2"; then
207     if test $qt_subver -gt 0; then
208       qt_minversion=">= Qt 2.2.2"
209     else
210       qt_minversion=">= Qt 2.0.2"
211     fi
212   fi
213   if test "$qt_ver" = "3"; then
214     qt_minversion=">= Qt 3.0.1"
215   fi
216   if test "$qt_ver" = "1"; then
217     qt_minversion=">= 1.42 and < 2.0"
218   fi
219 else
220    qt_minversion=$2
221 fi
222
223 if test -z "$3"; then
224    if test $qt_ver = 3; then
225      qt_verstring="QT_VERSION >= 301"
226    fi
227    if test $qt_ver = 2; then
228      if test $qt_subver -gt 0; then
229        qt_verstring="QT_VERSION >= 222"
230      else
231        qt_verstring="QT_VERSION >= 200"
232      fi
233    fi
234    if test $qt_ver = 1; then
235     qt_verstring="QT_VERSION >= 142 && QT_VERSION < 200"
236    fi
237 else
238    qt_verstring=$3
239 fi
240
241 if test $qt_ver = 3; then
242   qt_dirs="$QTDIR /usr/lib/qt3 /usr/lib/qt"
243 fi
244 if test $qt_ver = 2; then
245   qt_dirs="$QTDIR /usr/lib/qt2 /usr/lib/qt"
246 fi
247 if test $qt_ver = 1; then
248   qt_dirs="$QTDIR /usr/lib/qt"
249 fi
250 ])
251
252
253 dnl ------------------------------------------------------------------------
254 dnl Try to find the Qt headers and libraries.
255 dnl $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
256 dnl and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
257 dnl ------------------------------------------------------------------------
258 dnl
259 AC_DEFUN([QT_PATH_1_3],
260 [
261 AC_REQUIRE([QT_PATH_X])
262 AC_REQUIRE([QT_CHECK_VERSION])
263
264 dnl ------------------------------------------------------------------------
265 dnl Add configure flag to enable linking to MT version of Qt library.
266 dnl ------------------------------------------------------------------------
267
268 AC_ARG_ENABLE(
269   mt,
270   [  --disable-mt            link to non-threaded Qt (deprecated)],
271   qt_use_mt=$enableval,
272   [
273     if test $qt_ver = 3; then
274       qt_use_mt=yes
275     else
276       qt_use_mt=no
277     fi
278   ]
279 )
280
281 USING_QT_MT=""
282
283 dnl ------------------------------------------------------------------------
284 dnl If we not get --disable-qt-mt then adjust some vars for the host.
285 dnl ------------------------------------------------------------------------
286
287 QT_MT_LDFLAGS=
288 QT_MT_LIBS=
289 if test "x$qt_use_mt" = "xyes"; then
290   QT_CHECK_THREADING
291   if test "x$qt_use_threading" = "xyes"; then
292     QT_CXXFLAGS="$USE_THREADS -DQT_THREAD_SUPPORT $QT_CXXFLAGS"
293     QT_MT_LDFLAGS="$USE_THREADS"
294     QT_MT_LIBS="$LIBPTHREAD"
295   else
296     qt_use_mt=no
297   fi
298 fi
299 AC_SUBST(QT_MT_LDFLAGS)
300 AC_SUBST(QT_MT_LIBS)
301
302 dnl ------------------------------------------------------------------------
303 dnl If we haven't been told how to link to Qt, we work it out for ourselves.
304 dnl ------------------------------------------------------------------------
305 if test -z "$LIBQT_GLOB"; then
306   if test "x$qt_use_emb" = "xyes"; then
307     LIBQT_GLOB="libqte.*"
308   else
309     LIBQT_GLOB="libqt.*"
310   fi
311 fi
312
313 if test -z "$LIBQT"; then
314 dnl ------------------------------------------------------------
315 dnl If we got --enable-embedded then adjust the Qt library name.
316 dnl ------------------------------------------------------------
317   if test "x$qt_use_emb" = "xyes"; then
318     qtlib="qte"
319   else
320     qtlib="qt"
321   fi
322 fi
323
324 if test -z "$LIBQPE"; then
325 dnl ------------------------------------------------------------
326 dnl If we got --enable-palmtop then add -lqpe to the link line
327 dnl ------------------------------------------------------------
328   if test "x$qt_use_emb" = "xyes"; then
329     if test "x$qt_use_emb_palm" = "xyes"; then
330       LIB_QPE="-lqpe"
331     else
332       LIB_QPE=""
333     fi
334   else
335     LIB_QPE=""
336   fi
337 fi
338
339 dnl ------------------------------------------------------------------------
340 dnl If we got --enable-qt-mt then adjust the Qt library name for the host.
341 dnl ------------------------------------------------------------------------
342
343 if test "x$qt_use_mt" = "xyes"; then
344   if test -z "$LIBQT"; then
345     LIBQT="-l$qtlib-mt"
346   else
347     LIBQT="$qtlib-mt"
348   fi
349   LIBQT_GLOB="lib$qtlib-mt.*"
350   USING_QT_MT="using -mt"
351 else
352   LIBQT="-l$qtlib"
353 fi
354
355 AC_MSG_CHECKING([for Qt])
356
357 QT_LIBS="$LIBQT $QT_LIBS"
358 test -z "$QT_MT_LIBS" || QT_LIBS="$QT_LIBS $QT_MT_LIBS"
359
360 ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
361 qt_libraries=""
362 qt_includes=""
363 AC_ARG_WITH(qt-dir,
364     [  --with-qt-dir=DIR       where the root of Qt is installed ],
365     [  ac_qt_includes="$withval"/include
366        ac_qt_libraries="$withval"/lib
367        ac_qt_bindir="$withval"/bin
368     ])
369
370 AC_ARG_WITH(qt-includes,
371     [  --with-qt-includes=DIR  where the Qt includes are. ],
372     [
373        ac_qt_includes="$withval"
374     ])
375
376 kde_qt_libs_given=no
377
378 AC_ARG_WITH(qt-libraries,
379     [  --with-qt-libraries=DIR where the Qt library is installed.],
380     [  ac_qt_libraries="$withval"
381        kde_qt_libs_given=yes
382     ])
383
384 AC_CACHE_VAL(ac_cv_have_qt,
385 [#try to guess Qt locations
386
387 qt_incdirs=""
388 for dir in $qt_dirs; do
389    qt_incdirs="$qt_incdirs $dir/include $dir"
390 done
391 qt_incdirs="$QTINC $qt_incdirs /usr/local/qt/include  /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/X11R6/include/qt2 /usr/include/qt3 $x_includes"
392 if test ! "$ac_qt_includes" = "NO"; then
393    qt_incdirs="$ac_qt_includes $qt_incdirs"
394 fi
395
396 if test "$qt_ver" != "1"; then
397   kde_qt_header=qstyle.h
398 else
399   kde_qt_header=qglobal.h
400 fi
401
402 QT_FIND_FILE($kde_qt_header, $qt_incdirs, qt_incdir)
403 ac_qt_includes="$qt_incdir"
404
405 qt_libdirs=""
406 for dir in $qt_dirs; do
407    qt_libdirs="$qt_libdirs $dir/lib $dir"
408 done
409 qt_libdirs="$QTLIB $qt_libdirs /usr/X11R6/lib /usr/lib /usr/local/qt/lib $x_libraries"
410 if test ! "$ac_qt_libraries" = "NO"; then
411   qt_libdir=$ac_qt_libraries
412 else
413   qt_libdirs="$ac_qt_libraries $qt_libdirs"
414   # if the Qt was given, the chance is too big that libqt.* doesn't exist
415   qt_libdir=NONE
416   for dir in $qt_libdirs; do
417     try="ls -1 $dir/${LIBQT_GLOB}"
418     if test -n "`$try 2> /dev/null`"; then qt_libdir=$dir; break; else echo "tried $dir" >&AS_MESSAGE_LOG_FD; fi
419   done
420 fi
421
422 ac_qt_libraries="$qt_libdir"
423
424 AC_LANG_PUSH(C++)
425
426 ac_cxxflags_safe="$CXXFLAGS"
427 ac_ldflags_safe="$LDFLAGS"
428 ac_libs_safe="$LIBS"
429
430 CXXFLAGS="$CXXFLAGS -I$qt_incdir $QT_CXXFLAGS"
431 LDFLAGS="$LDFLAGS -L$qt_libdir $QT_LDFLAGS"
432 LIBS="$LIBS $QT_LIBS"
433
434 QT_PRINT_PROGRAM
435
436 if AC_TRY_EVAL(ac_link) && test -s conftest; then
437   rm -f conftest*
438 else
439   echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
440   cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
441   ac_qt_libraries="NO"
442 fi
443 rm -f conftest*
444 CXXFLAGS="$ac_cxxflags_safe"
445 LDFLAGS="$ac_ldflags_safe"
446 LIBS="$ac_libs_safe"
447
448 AC_LANG_POP(C++)
449 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
450   ac_cv_have_qt="have_qt=no"
451   ac_qt_notfound=""
452   missing_qt_mt=""
453   if test "$ac_qt_includes" = NO; then
454     if test "$ac_qt_libraries" = NO; then
455       ac_qt_notfound="(headers and libraries)";
456     else
457       ac_qt_notfound="(headers)";
458     fi
459   else
460     if test "x$qt_use_mt" = "xyes"; then
461        missing_qt_mt="
462 Make sure that you have compiled Qt with thread support!"
463        ac_qt_notfound="(library $qtlib-mt)";
464     else
465        ac_qt_notfound="(library $qtlib)";
466     fi
467   fi
468
469   #AC_MSG_ERROR([Qt ($qt_minversion) $ac_qt_notfound not found. Please check your installation!
470   #For more details about this problem, look at the end of config.log.$missing_qt_mt])
471   have_qt="no"
472 else
473   have_qt="yes"
474 fi
475 ])
476
477 eval "$ac_cv_have_qt"
478
479 if test "$have_qt" != yes; then
480   AC_MSG_RESULT([$have_qt]);
481 else
482   ac_cv_have_qt="have_qt=yes \
483     ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
484   AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes $USING_QT_MT])
485
486   qt_libraries="$ac_qt_libraries"
487   qt_includes="$ac_qt_includes"
488 fi
489
490 AC_SUBST(qt_libraries)
491 AC_SUBST(qt_includes)
492
493 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
494  QT_INCLUDES=""
495 else
496  QT_INCLUDES="-I$qt_includes"
497 fi
498
499 if test "$qt_libraries" != "$x_libraries" && test -n "$qt_libraries"; then
500  QT_LDFLAGS="$QT_LDFLAGS -L$qt_libraries"
501 fi
502 test -z "$QT_MT_LDFLAGS" || QT_LDFLAGS="$QT_LDFLAGS $QT_MT_LDFLAGS"
503
504 AC_SUBST(QT_INCLUDES)
505 QT_PATH_MOC
506
507
508 AC_SUBST(LIB_QPE)
509 ])
510
511 AC_DEFUN([QT_PATH],
512 [
513 QT_PATH_1_3
514 QT_CHECK_RPATH
515 ])
516
517
518 AC_DEFUN([QT_CHECK_COMPILER_FLAG],
519 [
520 AC_MSG_CHECKING(whether $CXX supports -$1)
521 kde_cache=`echo $1 | sed 'y% .=/+-%____p_%'`
522 AC_CACHE_VAL(kde_cv_prog_cxx_$kde_cache,
523 [
524   AC_LANG_PUSH(C++)
525   save_CXXFLAGS="$CXXFLAGS"
526   CXXFLAGS="$CXXFLAGS -$1"
527   AC_TRY_LINK([],[ return 0; ], [eval "kde_cv_prog_cxx_$kde_cache=yes"], [])
528   CXXFLAGS="$save_CXXFLAGS"
529   AC_LANG_POP(C++)
530 ])
531 if eval "test \"`echo '$kde_cv_prog_cxx_'$kde_cache`\" = yes"; then
532  AC_MSG_RESULT(yes)
533  :
534  $2
535 else
536  AC_MSG_RESULT(no)
537  :
538  $3
539 fi
540 ])
541
542 dnl QT_REMOVE_FORBIDDEN removes forbidden arguments from variables
543 dnl use: QT_REMOVE_FORBIDDEN(CC, [-forbid -bad-option whatever])
544 dnl it's all white-space separated
545 AC_DEFUN([QT_REMOVE_FORBIDDEN],
546 [ __val=$$1
547   __forbid=" $2 "
548   if test -n "$__val"; then
549     __new=""
550     ac_save_IFS=$IFS
551     IFS="       "
552     for i in $__val; do
553       case "$__forbid" in
554         *" $i "*) AC_MSG_WARN([found forbidden $i in $1, removing it]) ;;
555         *) # Careful to not add spaces, where there were none, because otherwise
556            # libtool gets confused, if we change e.g. CXX
557            if test -z "$__new" ; then __new=$i ; else __new="$__new $i" ; fi ;;
558       esac
559     done
560     IFS=$ac_save_IFS
561     $1=$__new
562   fi
563 ])
564
565 dnl QT_VALIDIFY_CXXFLAGS checks for forbidden flags the user may have given
566 AC_DEFUN([QT_VALIDIFY_CXXFLAGS],
567 [dnl
568 if test "x$qt_use_emb" != "xyes"; then
569  QT_REMOVE_FORBIDDEN(CXX, [-fno-rtti -rpath])
570  QT_REMOVE_FORBIDDEN(CXXFLAGS, [-fno-rtti -rpath])
571 else
572  QT_REMOVE_FORBIDDEN(CXX, [-rpath])
573  QT_REMOVE_FORBIDDEN(CXXFLAGS, [-rpath])
574 fi
575 ])
576
577 AC_DEFUN([QT_CHECK_COMPILERS],
578 [
579   AC_PROG_CXX
580
581   QT_CHECK_COMPILER_FLAG(fexceptions,[QT_CXXFLAGS="$QT_CXXFLAGS -fexceptions"])
582
583   case "$host" in
584       *-*-irix*)  test "$GXX" = yes && QT_CXXFLAGS="-D_LANGUAGE_C_PLUS_PLUS -D__LANGUAGE_C_PLUS_PLUS $QT_CXXFLAGS" ;;
585       *-*-sysv4.2uw*) QT_CXXFLAGS="-D_UNIXWARE $QT_CXXFLAGS";;
586       *-*-sysv5uw7*) QT_CXXFLAGS="-D_UNIXWARE7 $QT_CXXFLAGS";;
587       *-*-solaris*) 
588         if test "$GXX" = yes; then
589           libstdcpp=`$CXX -print-file-name=libstdc++.so`
590           if test ! -f $libstdcpp; then
591              AC_MSG_ERROR([You've compiled gcc without --enable-shared. This doesn't work with the Qt pinentry. Please recompile gcc with --enable-shared to receive a libstdc++.so])
592           fi
593         fi
594         ;;
595   esac
596
597   QT_VALIDIFY_CXXFLAGS
598
599   AC_PROG_CXXCPP
600 ])
601
602 AC_DEFUN([QT_CHECK_RPATH],
603 [
604 AC_MSG_CHECKING(for rpath)
605 AC_ARG_ENABLE(rpath,
606       [  --disable-rpath         do not use the rpath feature of ld],
607       USE_RPATH=$enableval, USE_RPATH=yes)
608
609 if test -z "$QT_RPATH" && test "$USE_RPATH" = "yes"; then
610
611   QT_RPATH=""
612   if test -n "$qt_libraries"; then
613     QT_RPATH="$QT_RPATH -Wl,--rpath -Wl,\$(qt_libraries)"
614   fi
615   dnl $x_libraries is set to /usr/lib in case
616   if test -n "$X_LIBS"; then
617     QT_RPATH="$QT_RPATH -Wl,--rpath -Wl,\$(x_libraries)"
618   fi
619 fi
620 AC_SUBST(x_libraries)
621 AC_SUBST(QT_RPATH)
622 AC_MSG_RESULT($USE_RPATH)
623 ])
624
625
626 AC_DEFUN([QT_CHECK_LIBPTHREAD],
627 [
628 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"] )
629 AC_SUBST(LIBPTHREAD)
630 ])
631
632 AC_DEFUN([QT_CHECK_PTHREAD_OPTION],
633 [
634     AC_ARG_ENABLE(kernel-threads, [  --enable-kernel-threads Enable the use of the LinuxThreads port on FreeBSD/i386 only.],
635         kde_use_kernthreads=$enableval, kde_use_kernthreads=no)
636
637     if test "$kde_use_kernthreads" = "yes"; then
638       ac_save_CXXFLAGS="$CXXFLAGS"
639       ac_save_CFLAGS="$CXXFLAGS"
640       CXXFLAGS="-I/usr/local/include/pthread/linuxthreads $CXXFLAGS"
641       CFLAGS="-I/usr/local/include/pthread/linuxthreads $CFLAGS"
642       AC_CHECK_HEADERS(pthread/linuxthreads/pthread.h)
643       CXXFLAGS="$ac_save_CXXFLAGS"
644       CFLAGS="$ac_save_CFLAGS"
645       if test "$ac_cv_header_pthread_linuxthreads_pthread_h" = "no"; then
646         kde_use_kernthreads=no
647       else
648         dnl Add proper -I and -l statements
649         AC_CHECK_LIB(lthread, pthread_join, [LIBPTHREAD="-llthread -llgcc_r"]) dnl for FreeBSD
650         if test "x$LIBPTHREAD" = "x"; then
651           kde_use_kernthreads=no
652         else
653           USE_THREADS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
654         fi
655       fi
656     else 
657       USE_THREADS=""
658       if test -z "$LIBPTHREAD"; then
659         QT_CHECK_COMPILER_FLAG(pthread, [USE_THREADS="-pthread"] )
660       fi
661     fi
662
663     case $host_os in
664         solaris*)
665                 QT_CHECK_COMPILER_FLAG(mt, [USE_THREADS="-mt"])
666                 QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DSVR4"
667                 ;;
668         freebsd*)
669                 QT_CXXFLAGS="$QT_CXXFLAGS -D_THREAD_SAFE"
670                 ;;
671         aix*)
672                 QT_CXXFLAGS="$QT_CXXFLAGS -D_THREAD_SAFE"
673                 LIBPTHREAD="$LIBPTHREAD -lc_r"
674                 ;;
675         linux*) QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT"
676                 if test "$CXX" = "KCC"; then
677                   QT_CXXFLAGS="$QT_CXXFLAGS --thread_safe"
678                 fi
679                 ;;
680         *)
681                 ;;
682     esac
683     AC_SUBST(USE_THREADS)
684     AC_SUBST(LIBPTHREAD)
685 ])
686
687 AC_DEFUN([QT_CHECK_THREADING],
688 [
689   AC_REQUIRE([QT_CHECK_LIBPTHREAD])
690   AC_REQUIRE([QT_CHECK_PTHREAD_OPTION])
691   dnl default is yes if libpthread is found and no if no libpthread is available
692   if test -z "$LIBPTHREAD"; then
693     if test -z "$USE_THREADS"; then
694       kde_check_threading_default=no
695     else
696       kde_check_threading_default=yes
697     fi
698   else
699     kde_check_threading_default=yes
700   fi
701   AC_ARG_ENABLE(threading, [  --disable-threading     disables threading even if libpthread found ],
702    qt_use_threading=$enableval, qt_use_threading=$kde_check_threading_default)
703   if test "x$qt_use_threading" = "xyes"; then
704     AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if you have a working libpthread (will enable threaded code)])
705   fi
706 ])