acinclude.m4.in 142 KB
Newer Older
Joachim Eibl's avatar
Joachim Eibl committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
##   -*- autoconf -*-

dnl    This file is part of the KDE libraries/packages
dnl    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
dnl              (C) 1997,98,99 Stephan Kulow (coolo@kde.org)

dnl    This file is free software; you can redistribute it and/or
dnl    modify it under the terms of the GNU Library General Public
dnl    License as published by the Free Software Foundation; either
dnl    version 2 of the License, or (at your option) any later version.

dnl    This library is distributed in the hope that it will be useful,
dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl    Library General Public License for more details.

dnl    You should have received a copy of the GNU Library General Public License
dnl    along with this library; see the file COPYING.LIB.  If not, write to
dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dnl    Boston, MA 02111-1307, USA.

dnl IMPORTANT NOTE:
dnl Please do not modify this file unless you expect your modifications to be
Joachim Eibl's avatar
Joachim Eibl committed
24
dnl carried into every other module in the repository. 
Joachim Eibl's avatar
Joachim Eibl committed
25 26 27 28 29 30 31
dnl
dnl Single-module modifications are best placed in configure.in for kdelibs
dnl and kdebase or configure.in.in if present.

# KDE_PATH_X_DIRECT
dnl Internal subroutine of AC_PATH_X.
dnl Set ac_x_includes and/or ac_x_libraries.
Joachim Eibl's avatar
Joachim Eibl committed
32
AC_DEFUN([KDE_PATH_X_DIRECT],
Joachim Eibl's avatar
Joachim Eibl committed
33 34 35 36
[
AC_REQUIRE([KDE_CHECK_LIB64])

if test "$ac_x_includes" = NO; then
Joachim Eibl's avatar
Joachim Eibl committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
  # Guess where to find include files, by looking for this one X11 .h file.
  test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h

  # First, try using that file with no special directory specified.
AC_TRY_CPP([#include <$x_direct_test_include>],
[# We can compile using X headers with no special include directory.
ac_x_includes=],
[# Look for the header file in a standard set of common directories.
# Check X11 before X11Rn because it is often a symlink to the current release.
  for ac_dir in               \
    /usr/X11/include          \
    /usr/X11R6/include        \
    /usr/X11R5/include        \
    /usr/X11R4/include        \
                              \
    /usr/include/X11          \
    /usr/include/X11R6        \
    /usr/include/X11R5        \
    /usr/include/X11R4        \
                              \
    /usr/local/X11/include    \
    /usr/local/X11R6/include  \
    /usr/local/X11R5/include  \
    /usr/local/X11R4/include  \
                              \
    /usr/local/include/X11    \
    /usr/local/include/X11R6  \
    /usr/local/include/X11R5  \
    /usr/local/include/X11R4  \
                              \
    /usr/X386/include         \
    /usr/x386/include         \
    /usr/XFree86/include/X11  \
                              \
    /usr/include              \
    /usr/local/include        \
    /usr/unsupported/include  \
    /usr/athena/include       \
    /usr/local/x11r5/include  \
    /usr/lpp/Xamples/include  \
                              \
    /usr/openwin/include      \
    /usr/openwin/share/include \
    ; \
  do
    if test -r "$ac_dir/$x_direct_test_include"; then
      ac_x_includes=$ac_dir
      break
    fi
  done])
fi # $ac_x_includes = NO

if test "$ac_x_libraries" = NO; then
  # Check for the libraries.

  test -z "$x_direct_test_library" && x_direct_test_library=Xt
  test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc

  # See if we find them without any special options.
  # Don't add to $LIBS permanently.
  ac_save_LIBS="$LIBS"
  LIBS="-l$x_direct_test_library $LIBS"
AC_TRY_LINK(, [${x_direct_test_function}()],
[LIBS="$ac_save_LIBS"
# We can link X programs with no special library path.
ac_x_libraries=],
[LIBS="$ac_save_LIBS"
# First see if replacing the include by lib works.
# Check X11 before X11Rn because it is often a symlink to the current release.
Joachim Eibl's avatar
Joachim Eibl committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
for ac_dir in `echo "$ac_x_includes" | sed s/include/lib${kdelibsuff}/` \
    /usr/X11/lib${kdelibsuff}           \
    /usr/X11R6/lib${kdelibsuff}         \
    /usr/X11R5/lib${kdelibsuff}         \
    /usr/X11R4/lib${kdelibsuff}         \
                                        \
    /usr/lib${kdelibsuff}/X11           \
    /usr/lib${kdelibsuff}/X11R6         \
    /usr/lib${kdelibsuff}/X11R5         \
    /usr/lib${kdelibsuff}/X11R4         \
                                        \
    /usr/local/X11/lib${kdelibsuff}     \
    /usr/local/X11R6/lib${kdelibsuff}   \
    /usr/local/X11R5/lib${kdelibsuff}   \
    /usr/local/X11R4/lib${kdelibsuff}   \
                                        \
    /usr/local/lib${kdelibsuff}/X11     \
    /usr/local/lib${kdelibsuff}/X11R6   \
    /usr/local/lib${kdelibsuff}/X11R5   \
    /usr/local/lib${kdelibsuff}/X11R4   \
                                        \
    /usr/X386/lib${kdelibsuff}          \
    /usr/x386/lib${kdelibsuff}          \
    /usr/XFree86/lib${kdelibsuff}/X11   \
                                        \
    /usr/lib${kdelibsuff}               \
    /usr/local/lib${kdelibsuff}         \
    /usr/unsupported/lib${kdelibsuff}   \
    /usr/athena/lib${kdelibsuff}        \
    /usr/local/x11r5/lib${kdelibsuff}   \
    /usr/lpp/Xamples/lib${kdelibsuff}   \
    /lib/usr/lib${kdelibsuff}/X11       \
                                        \
    /usr/openwin/lib${kdelibsuff}       \
    /usr/openwin/share/lib${kdelibsuff} \
Joachim Eibl's avatar
Joachim Eibl committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
    ; \
do
dnl Don't even attempt the hair of trying to link an X program!
  for ac_extension in a so sl; do
    if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
      ac_x_libraries=$ac_dir
      break 2
    fi
  done
done])
fi # $ac_x_libraries = NO
])


dnl ------------------------------------------------------------------------
dnl Find a file (or one of more files in a list of dirs)
dnl ------------------------------------------------------------------------
dnl
Joachim Eibl's avatar
Joachim Eibl committed
159
AC_DEFUN([AC_FIND_FILE],
Joachim Eibl's avatar
Joachim Eibl committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
[
$3=NO
for i in $2;
do
  for j in $1;
  do
    echo "configure: __oline__: $i/$j" >&AC_FD_CC
    if test -r "$i/$j"; then
      echo "taking that" >&AC_FD_CC
      $3=$i
      break 2
    fi
  done
done
])

dnl KDE_FIND_PATH(programm-name, variable-name, list of directories,
dnl	if-not-found, test-parameter)
Joachim Eibl's avatar
Joachim Eibl committed
178
AC_DEFUN([KDE_FIND_PATH],
Joachim Eibl's avatar
Joachim Eibl committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
[
   AC_MSG_CHECKING([for $1])
   if test -n "$$2"; then
        kde_cv_path="$$2";
   else
        kde_cache=`echo $1 | sed 'y%./+-%__p_%'`

        AC_CACHE_VAL(kde_cv_path_$kde_cache,
        [
        kde_cv_path="NONE"
	dirs="$3"
	kde_save_IFS=$IFS
	IFS=':'
	for dir in $PATH; do
	  dirs="$dirs $dir"
        done
	IFS=$kde_save_IFS

        for dir in $dirs; do
	  if test -x "$dir/$1"; then
	    if test -n "$5"
	    then
              evalstr="$dir/$1 $5 2>&1 "
	      if eval $evalstr; then
                kde_cv_path="$dir/$1"
                break
	      fi
            else
		kde_cv_path="$dir/$1"
                break
	    fi
          fi
        done

        eval "kde_cv_path_$kde_cache=$kde_cv_path"

        ])

      eval "kde_cv_path=\"`echo '$kde_cv_path_'$kde_cache`\""

   fi

   if test -z "$kde_cv_path" || test "$kde_cv_path" = NONE; then
      AC_MSG_RESULT(not found)
      $4
   else
      AC_MSG_RESULT($kde_cv_path)
      $2=$kde_cv_path

   fi
])

Joachim Eibl's avatar
Joachim Eibl committed
231
AC_DEFUN([KDE_MOC_ERROR_MESSAGE],
Joachim Eibl's avatar
Joachim Eibl committed
232 233 234 235 236 237 238 239 240 241 242
[
    AC_MSG_ERROR([No Qt meta object compiler (moc) found!
Please check whether you installed Qt correctly.
You need to have a running moc binary.
configure tried to run $ac_cv_path_moc and the test didn't
succeed. If configure shouldn't have tried this one, set
the environment variable MOC to the right one before running
configure.
])
])

Joachim Eibl's avatar
Joachim Eibl committed
243
AC_DEFUN([KDE_UIC_ERROR_MESSAGE],
Joachim Eibl's avatar
Joachim Eibl committed
244 245 246 247 248 249 250 251 252 253 254
[
    AC_MSG_WARN([No Qt ui compiler (uic) found!
Please check whether you installed Qt correctly.
You need to have a running uic binary.
configure tried to run $ac_cv_path_uic and the test didn't
succeed. If configure shouldn't have tried this one, set
the environment variable UIC to the right one before running
configure.
])
])

Joachim Eibl's avatar
Joachim Eibl committed
255

Joachim Eibl's avatar
Joachim Eibl committed
256
AC_DEFUN([KDE_CHECK_UIC_FLAG],
Joachim Eibl's avatar
Joachim Eibl committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
[
    AC_MSG_CHECKING([whether uic supports -$1 ])
    kde_cache=`echo $1 | sed 'y% .=/+-%____p_%'`
    AC_CACHE_VAL(kde_cv_prog_uic_$kde_cache,
    [
        cat >conftest.ui <<EOT
        <!DOCTYPE UI><UI version="3" stdsetdef="1"></UI>
EOT
        ac_uic_testrun="$UIC_PATH -$1 $2 conftest.ui >/dev/null"
        if AC_TRY_EVAL(ac_uic_testrun); then
            eval "kde_cv_prog_uic_$kde_cache=yes"
        else
            eval "kde_cv_prog_uic_$kde_cache=no"
        fi
        rm -f conftest*
    ])

    if eval "test \"`echo '$kde_cv_prog_uic_'$kde_cache`\" = yes"; then
        AC_MSG_RESULT([yes])
        :
        $3
    else
        AC_MSG_RESULT([no])
        :
        $4
    fi
])


Joachim Eibl's avatar
Joachim Eibl committed
286 287 288 289 290
dnl ------------------------------------------------------------------------
dnl Find the meta object compiler and the ui compiler in the PATH,
dnl in $QTDIR/bin, and some more usual places
dnl ------------------------------------------------------------------------
dnl
Joachim Eibl's avatar
Joachim Eibl committed
291
AC_DEFUN([AC_PATH_QT_MOC_UIC],
Joachim Eibl's avatar
Joachim Eibl committed
292
[
Joachim Eibl's avatar
Joachim Eibl committed
293
   AC_REQUIRE([KDE_CHECK_PERL])
Joachim Eibl's avatar
Joachim Eibl committed
294 295 296 297 298 299 300 301 302 303 304
   qt_bindirs=""
   for dir in $kde_qt_dirs; do
      qt_bindirs="$qt_bindirs $dir/bin $dir/src/moc"
   done
   qt_bindirs="$qt_bindirs /usr/bin /usr/X11R6/bin /usr/local/qt/bin"
   if test ! "$ac_qt_bindir" = "NO"; then
      qt_bindirs="$ac_qt_bindir $qt_bindirs"
   fi

   KDE_FIND_PATH(moc, MOC, [$qt_bindirs], [KDE_MOC_ERROR_MESSAGE])
   if test -z "$UIC_NOT_NEEDED"; then
Joachim Eibl's avatar
Joachim Eibl committed
305 306
     KDE_FIND_PATH(uic, UIC_PATH, [$qt_bindirs], [UIC_PATH=""])
     if test -z "$UIC_PATH" ; then
Joachim Eibl's avatar
Joachim Eibl committed
307 308
       KDE_UIC_ERROR_MESSAGE
       exit 1
Joachim Eibl's avatar
Joachim Eibl committed
309
     else
Joachim Eibl's avatar
Joachim Eibl committed
310
       UIC=$UIC_PATH
Joachim Eibl's avatar
Joachim Eibl committed
311 312 313 314 315 316 317 318 319 320 321

       if test $kde_qtver = 3; then
         KDE_CHECK_UIC_FLAG(L,[/nonexistent],ac_uic_supports_libpath=yes,ac_uic_supports_libpath=no)
         KDE_CHECK_UIC_FLAG(nounload,,ac_uic_supports_nounload=yes,ac_uic_supports_nounload=no)

         if test x$ac_uic_supports_libpath = xyes; then
             UIC="$UIC -L \$(kde_widgetdir)"
         fi
         if test x$ac_uic_supports_nounload = xyes; then
             UIC="$UIC -nounload"
         fi
Joachim Eibl's avatar
Joachim Eibl committed
322
       fi
Joachim Eibl's avatar
Joachim Eibl committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
     fi
   else
     UIC="echo uic not available: "
   fi

   AC_SUBST(MOC)
   AC_SUBST(UIC)

   UIC_TR="i18n"
   if test $kde_qtver = 3; then
     UIC_TR="tr2i18n"
   fi

   AC_SUBST(UIC_TR)
])

Joachim Eibl's avatar
Joachim Eibl committed
339
AC_DEFUN([KDE_1_CHECK_PATHS],
Joachim Eibl's avatar
Joachim Eibl committed
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
[
  KDE_1_CHECK_PATH_HEADERS

  KDE_TEST_RPATH=

  if test -n "$USE_RPATH"; then

     if test -n "$kde_libraries"; then
       KDE_TEST_RPATH="-R $kde_libraries"
     fi

     if test -n "$qt_libraries"; then
       KDE_TEST_RPATH="$KDE_TEST_RPATH -R $qt_libraries"
     fi

     if test -n "$x_libraries"; then
       KDE_TEST_RPATH="$KDE_TEST_RPATH -R $x_libraries"
     fi

     KDE_TEST_RPATH="$KDE_TEST_RPATH $KDE_EXTRA_RPATH"
  fi

AC_MSG_CHECKING([for KDE libraries installed])
ac_link='$LIBTOOL_SHELL --silent --mode=link ${CXX-g++} -o conftest $CXXFLAGS $all_includes $CPPFLAGS $LDFLAGS $all_libraries conftest.$ac_ext $LIBS -lkdecore $LIBQT $KDE_TEST_RPATH 1>&5'

if AC_TRY_EVAL(ac_link) && test -s conftest; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_ERROR([your system fails at linking a small KDE application!
Check, if your compiler is installed correctly and if you have used the
same compiler to compile Qt and kdelibs as you did use now.
For more details about this problem, look at the end of config.log.])
fi

if eval `KDEDIR= ./conftest 2>&5`; then
  kde_result=done
else
  kde_result=problems
fi

KDEDIR= ./conftest 2> /dev/null >&5 # make an echo for config.log
kde_have_all_paths=yes

KDE_SET_PATHS($kde_result)

])

Joachim Eibl's avatar
Joachim Eibl committed
387
AC_DEFUN([KDE_SET_PATHS],
Joachim Eibl's avatar
Joachim Eibl committed
388 389 390 391 392 393 394 395 396 397
[
  kde_cv_all_paths="kde_have_all_paths=\"yes\" \
	kde_htmldir=\"$kde_htmldir\" \
	kde_appsdir=\"$kde_appsdir\" \
	kde_icondir=\"$kde_icondir\" \
	kde_sounddir=\"$kde_sounddir\" \
	kde_datadir=\"$kde_datadir\" \
	kde_locale=\"$kde_locale\" \
	kde_cgidir=\"$kde_cgidir\" \
	kde_confdir=\"$kde_confdir\" \
Joachim Eibl's avatar
Joachim Eibl committed
398
	kde_kcfgdir=\"$kde_kcfgdir\" \
Joachim Eibl's avatar
Joachim Eibl committed
399 400 401 402 403 404 405 406
	kde_mimedir=\"$kde_mimedir\" \
	kde_toolbardir=\"$kde_toolbardir\" \
	kde_wallpaperdir=\"$kde_wallpaperdir\" \
	kde_templatesdir=\"$kde_templatesdir\" \
	kde_bindir=\"$kde_bindir\" \
	kde_servicesdir=\"$kde_servicesdir\" \
	kde_servicetypesdir=\"$kde_servicetypesdir\" \
	kde_moduledir=\"$kde_moduledir\" \
Joachim Eibl's avatar
Joachim Eibl committed
407
	kde_styledir=\"$kde_styledir\" \
Joachim Eibl's avatar
Joachim Eibl committed
408
	kde_widgetdir=\"$kde_widgetdir\" \
Joachim Eibl's avatar
Joachim Eibl committed
409
	xdg_appsdir=\"$xdg_appsdir\" \
Joachim Eibl's avatar
Joachim Eibl committed
410
	xdg_menudir=\"$xdg_menudir\" \
Joachim Eibl's avatar
Joachim Eibl committed
411
	xdg_directorydir=\"$xdg_directorydir\" \
Joachim Eibl's avatar
Joachim Eibl committed
412 413 414
	kde_result=$1"
])

Joachim Eibl's avatar
Joachim Eibl committed
415
AC_DEFUN([KDE_SET_DEFAULT_PATHS],
Joachim Eibl's avatar
Joachim Eibl committed
416 417 418 419
[
if test "$1" = "default"; then

  if test -z "$kde_htmldir"; then
Joachim Eibl's avatar
Joachim Eibl committed
420
    kde_htmldir='\${datadir}/doc/HTML'
Joachim Eibl's avatar
Joachim Eibl committed
421 422
  fi
  if test -z "$kde_appsdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
423
    kde_appsdir='\${datadir}/applnk'
Joachim Eibl's avatar
Joachim Eibl committed
424 425
  fi
  if test -z "$kde_icondir"; then
Joachim Eibl's avatar
Joachim Eibl committed
426
    kde_icondir='\${datadir}/icons'
Joachim Eibl's avatar
Joachim Eibl committed
427 428
  fi
  if test -z "$kde_sounddir"; then
Joachim Eibl's avatar
Joachim Eibl committed
429
    kde_sounddir='\${datadir}/sounds'
Joachim Eibl's avatar
Joachim Eibl committed
430 431
  fi
  if test -z "$kde_datadir"; then
Joachim Eibl's avatar
Joachim Eibl committed
432
    kde_datadir='\${datadir}/apps'
Joachim Eibl's avatar
Joachim Eibl committed
433 434
  fi
  if test -z "$kde_locale"; then
Joachim Eibl's avatar
Joachim Eibl committed
435
    kde_locale='\${datadir}/locale'
Joachim Eibl's avatar
Joachim Eibl committed
436 437 438 439 440
  fi
  if test -z "$kde_cgidir"; then
    kde_cgidir='\${exec_prefix}/cgi-bin'
  fi
  if test -z "$kde_confdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
441 442 443 444
    kde_confdir='\${datadir}/config'
  fi
  if test -z "$kde_kcfgdir"; then
    kde_kcfgdir='\${datadir}/config.kcfg'
Joachim Eibl's avatar
Joachim Eibl committed
445 446
  fi
  if test -z "$kde_mimedir"; then
Joachim Eibl's avatar
Joachim Eibl committed
447
    kde_mimedir='\${datadir}/mimelnk'
Joachim Eibl's avatar
Joachim Eibl committed
448 449
  fi
  if test -z "$kde_toolbardir"; then
Joachim Eibl's avatar
Joachim Eibl committed
450
    kde_toolbardir='\${datadir}/toolbar'
Joachim Eibl's avatar
Joachim Eibl committed
451 452
  fi
  if test -z "$kde_wallpaperdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
453
    kde_wallpaperdir='\${datadir}/wallpapers'
Joachim Eibl's avatar
Joachim Eibl committed
454 455
  fi
  if test -z "$kde_templatesdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
456
    kde_templatesdir='\${datadir}/templates'
Joachim Eibl's avatar
Joachim Eibl committed
457 458 459 460 461
  fi
  if test -z "$kde_bindir"; then
    kde_bindir='\${exec_prefix}/bin'
  fi
  if test -z "$kde_servicesdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
462
    kde_servicesdir='\${datadir}/services'
Joachim Eibl's avatar
Joachim Eibl committed
463 464
  fi
  if test -z "$kde_servicetypesdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
465
    kde_servicetypesdir='\${datadir}/servicetypes'
Joachim Eibl's avatar
Joachim Eibl committed
466 467 468
  fi
  if test -z "$kde_moduledir"; then
    if test "$kde_qtver" = "2"; then
Joachim Eibl's avatar
Joachim Eibl committed
469
      kde_moduledir='\${libdir}/kde2'
Joachim Eibl's avatar
Joachim Eibl committed
470
    else
Joachim Eibl's avatar
Joachim Eibl committed
471
      kde_moduledir='\${libdir}/kde3'
Joachim Eibl's avatar
Joachim Eibl committed
472 473 474
    fi
  fi
  if test -z "$kde_styledir"; then
Joachim Eibl's avatar
Joachim Eibl committed
475
    kde_styledir='\${libdir}/kde3/plugins/styles'
Joachim Eibl's avatar
Joachim Eibl committed
476 477
  fi
  if test -z "$kde_widgetdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
478 479 480
    kde_widgetdir='\${libdir}/kde3/plugins/designer'
  fi
  if test -z "$xdg_appsdir"; then
Joachim Eibl's avatar
Joachim Eibl committed
481 482 483 484
    xdg_appsdir='\${datadir}/applications/kde'
  fi
  if test -z "$xdg_menudir"; then
    xdg_menudir='\${sysconfdir}/xdg/menus'
Joachim Eibl's avatar
Joachim Eibl committed
485 486 487
  fi
  if test -z "$xdg_directorydir"; then
    xdg_directorydir='\${datadir}/desktop-directories'
Joachim Eibl's avatar
Joachim Eibl committed
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
  fi

  KDE_SET_PATHS(defaults)

else

  if test $kde_qtver = 1; then
     AC_MSG_RESULT([compiling])
     KDE_1_CHECK_PATHS
  else
     AC_MSG_ERROR([path checking not yet supported for KDE 2])
  fi

fi
])

Joachim Eibl's avatar
Joachim Eibl committed
504
AC_DEFUN([KDE_CHECK_PATHS_FOR_COMPLETENESS],
Joachim Eibl's avatar
Joachim Eibl committed
505 506 507 508
[ if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
   test -z "$kde_icondir" || test -z "$kde_sounddir" ||
   test -z "$kde_datadir" || test -z "$kde_locale"  ||
   test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
Joachim Eibl's avatar
Joachim Eibl committed
509
   test -z "$kde_kcfgdir" ||
Joachim Eibl's avatar
Joachim Eibl committed
510 511 512 513
   test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
   test -z "$kde_wallpaperdir" || test -z "$kde_templatesdir" ||
   test -z "$kde_bindir" || test -z "$kde_servicesdir" ||
   test -z "$kde_servicetypesdir" || test -z "$kde_moduledir" ||
Joachim Eibl's avatar
Joachim Eibl committed
514
   test -z "$kde_styledir" || test -z "kde_widgetdir" ||
Joachim Eibl's avatar
Joachim Eibl committed
515
   test -z "$xdg_appsdir" || test -z "$xdg_menudir" || test -z "$xdg_directorydir" ||
Joachim Eibl's avatar
Joachim Eibl committed
516 517 518 519 520
   test "x$kde_have_all_paths" != "xyes"; then
     kde_have_all_paths=no
  fi
])

Joachim Eibl's avatar
Joachim Eibl committed
521
AC_DEFUN([KDE_MISSING_PROG_ERROR],
Joachim Eibl's avatar
Joachim Eibl committed
522 523 524 525 526 527
[
    AC_MSG_ERROR([The important program $1 was not found!
Please check whether you installed KDE correctly.
])
])

Joachim Eibl's avatar
Joachim Eibl committed
528
AC_DEFUN([KDE_MISSING_ARTS_ERROR],
Joachim Eibl's avatar
Joachim Eibl committed
529 530
[
    AC_MSG_ERROR([The important program $1 was not found!
Joachim Eibl's avatar
Joachim Eibl committed
531 532
Please check whether you installed aRts correctly or use
--without-arts to compile without aRts support (this will remove functionality).
Joachim Eibl's avatar
Joachim Eibl committed
533 534 535
])
])

Joachim Eibl's avatar
Joachim Eibl committed
536
AC_DEFUN([KDE_SUBST_PROGRAMS],
Joachim Eibl's avatar
Joachim Eibl committed
537
[
Joachim Eibl's avatar
Joachim Eibl committed
538
    AC_ARG_WITH(arts,
Joachim Eibl's avatar
Joachim Eibl committed
539
        AC_HELP_STRING([--without-arts],[build without aRts [default=yes]]),
Joachim Eibl's avatar
Joachim Eibl committed
540 541 542 543
        [build_arts=$withval],
        [build_arts=yes]
    )
    AM_CONDITIONAL(include_ARTS, test "$build_arts" != "no")
Joachim Eibl's avatar
Joachim Eibl committed
544 545

        kde_default_bindirs="/usr/bin /usr/local/bin /opt/local/bin /usr/X11R6/bin /opt/kde/bin /opt/kde3/bin /usr/kde/bin /usr/local/kde/bin"
Joachim Eibl's avatar
Joachim Eibl committed
546
        test -n "$KDEDIR" && kde_default_bindirs="$KDEDIR/bin $kde_default_bindirs"
Joachim Eibl's avatar
Joachim Eibl committed
547 548 549 550 551 552 553 554 555 556 557
        if test -n "$KDEDIRS"; then
           kde_save_IFS=$IFS
           IFS=:
           for dir in $KDEDIRS; do
                kde_default_bindirs="$dir/bin $kde_default_bindirs "
           done
           IFS=$kde_save_IFS
        fi
        kde_default_bindirs="$exec_prefix/bin $prefix/bin $kde_default_bindirs"
        KDE_FIND_PATH(dcopidl, DCOPIDL, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(dcopidl)])
        KDE_FIND_PATH(dcopidl2cpp, DCOPIDL2CPP, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(dcopidl2cpp)])
Joachim Eibl's avatar
Joachim Eibl committed
558 559 560 561
        if test "$build_arts" != "no"; then
          KDE_FIND_PATH(mcopidl, MCOPIDL, [$kde_default_bindirs], [KDE_MISSING_ARTS_ERROR(mcopidl)])
          KDE_FIND_PATH(artsc-config, ARTSCCONFIG, [$kde_default_bindirs], [KDE_MISSING_ARTS_ERROR(artsc-config)])
        fi
Joachim Eibl's avatar
Joachim Eibl committed
562 563
        KDE_FIND_PATH(kde-config, KDECONFIG, [$kde_default_bindirs])
        KDE_FIND_PATH(meinproc, MEINPROC, [$kde_default_bindirs])
Joachim Eibl's avatar
Joachim Eibl committed
564

Joachim Eibl's avatar
Joachim Eibl committed
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
        kde32ornewer=1
        if test -n "$kde_qtver" && test "$kde_qtver" -lt 3; then
            kde32ornewer=
        else
            if test "$kde_qtver" = "3" && test "$kde_qtsubver" -le 1; then
                kde32ornewer=
            fi
        fi

        if test -n "$kde32ornewer"; then
            KDE_FIND_PATH(kconfig_compiler, KCONFIG_COMPILER, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(kconfig_compiler)])
            KDE_FIND_PATH(dcopidlng, DCOPIDLNG, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(dcopidlng)])
        fi
        KDE_FIND_PATH(xmllint, XMLLINT, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [XMLLINT=""])

Joachim Eibl's avatar
Joachim Eibl committed
580 581 582 583 584 585 586 587 588 589 590 591
        if test -n "$MEINPROC" && test ! "$MEINPROC" = "compiled"; then  
 	    kde_sharedirs="/usr/share/kde /usr/local/share /usr/share /opt/kde3/share /opt/kde/share $prefix/share"
            test -n "$KDEDIR" && kde_sharedirs="$KDEDIR/share $kde_sharedirs"
            AC_FIND_FILE(apps/ksgmltools2/customization/kde-chunk.xsl, $kde_sharedirs, KDE_XSL_STYLESHEET)
	    if test "$KDE_XSL_STYLESHEET" = "NO"; then
		KDE_XSL_STYLESHEET=""
	    else
                KDE_XSL_STYLESHEET="$KDE_XSL_STYLESHEET/apps/ksgmltools2/customization/kde-chunk.xsl"
	    fi
        fi

        DCOP_DEPENDENCIES='$(DCOPIDL)'
Joachim Eibl's avatar
Joachim Eibl committed
592 593 594 595 596 597 598
        if test -n "$kde32ornewer"; then
            KCFG_DEPENDENCIES='$(KCONFIG_COMPILER)'
            DCOP_DEPENDENCIES='$(DCOPIDL) $(DCOPIDLNG)'
            AC_SUBST(KCONFIG_COMPILER)
            AC_SUBST(KCFG_DEPENDENCIES)
            AC_SUBST(DCOPIDLNG)
        fi
Joachim Eibl's avatar
Joachim Eibl committed
599 600 601 602 603 604 605 606
        AC_SUBST(DCOPIDL)
        AC_SUBST(DCOPIDL2CPP)
        AC_SUBST(DCOP_DEPENDENCIES)
        AC_SUBST(MCOPIDL)
        AC_SUBST(ARTSCCONFIG)
        AC_SUBST(KDECONFIG)
	AC_SUBST(MEINPROC)
 	AC_SUBST(KDE_XSL_STYLESHEET)
Joachim Eibl's avatar
Joachim Eibl committed
607
	AC_SUBST(XMLLINT)
Joachim Eibl's avatar
Joachim Eibl committed
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625

        if test -x "$KDECONFIG"; then # it can be "compiled"
          kde_libs_prefix=`$KDECONFIG --prefix`
          if test -z "$kde_libs_prefix" || test ! -x "$kde_libs_prefix"; then
               AC_MSG_ERROR([$KDECONFIG --prefix outputed the non existant prefix '$kde_libs_prefix' for kdelibs.
                          This means it has been moved since you installed it.
                          This won't work. Please recompile kdelibs for the new prefix.
                          ])
           fi
           kde_libs_htmldir=`$KDECONFIG --install html --expandvars`
        else
           kde_libs_prefix='$(prefix)'
           kde_libs_htmldir='$(kde_htmldir)'
        fi
        AC_SUBST(kde_libs_prefix)
        AC_SUBST(kde_libs_htmldir)
])dnl

Joachim Eibl's avatar
Joachim Eibl committed
626
AC_DEFUN([AC_CREATE_KFSSTND],
Joachim Eibl's avatar
Joachim Eibl committed
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
[
AC_REQUIRE([AC_CHECK_RPATH])

AC_MSG_CHECKING([for KDE paths])
kde_result=""
kde_cached_paths=yes
AC_CACHE_VAL(kde_cv_all_paths,
[
  KDE_SET_DEFAULT_PATHS($1)
  kde_cached_paths=no
])
eval "$kde_cv_all_paths"
KDE_CHECK_PATHS_FOR_COMPLETENESS
if test "$kde_have_all_paths" = "no" && test "$kde_cached_paths" = "yes"; then
  # wrong values were cached, may be, we can set better ones
  kde_result=
  kde_htmldir= kde_appsdir= kde_icondir= kde_sounddir=
Joachim Eibl's avatar
Joachim Eibl committed
644
  kde_datadir= kde_locale=  kde_cgidir=  kde_confdir= kde_kcfgdir=
Joachim Eibl's avatar
Joachim Eibl committed
645 646 647 648 649
  kde_mimedir= kde_toolbardir= kde_wallpaperdir= kde_templatesdir=
  kde_bindir= kde_servicesdir= kde_servicetypesdir= kde_moduledir=
  kde_have_all_paths=
  kde_styledir=
  kde_widgetdir=
Joachim Eibl's avatar
Joachim Eibl committed
650
  xdg_appsdir = xdg_menudir= xdg_directorydir= 
Joachim Eibl's avatar
Joachim Eibl committed
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673
  KDE_SET_DEFAULT_PATHS($1)
  eval "$kde_cv_all_paths"
  KDE_CHECK_PATHS_FOR_COMPLETENESS
  kde_result="$kde_result (cache overridden)"
fi
if test "$kde_have_all_paths" = "no"; then
  AC_MSG_ERROR([configure could not run a little KDE program to test the environment.
Since it had compiled and linked before, it must be a strange problem on your system.
Look at config.log for details. If you are not able to fix this, look at
http://www.kde.org/faq/installation.html or any www.kde.org mirror.
(If you're using an egcs version on Linux, you may update binutils!)
])
else
  rm -f conftest*
  AC_MSG_RESULT($kde_result)
fi

bindir=$kde_bindir

KDE_SUBST_PROGRAMS

])

Joachim Eibl's avatar
Joachim Eibl committed
674
AC_DEFUN([AC_SUBST_KFSSTND],
Joachim Eibl's avatar
Joachim Eibl committed
675 676 677 678 679 680 681 682
[
AC_SUBST(kde_htmldir)
AC_SUBST(kde_appsdir)
AC_SUBST(kde_icondir)
AC_SUBST(kde_sounddir)
AC_SUBST(kde_datadir)
AC_SUBST(kde_locale)
AC_SUBST(kde_confdir)
Joachim Eibl's avatar
Joachim Eibl committed
683
AC_SUBST(kde_kcfgdir)
Joachim Eibl's avatar
Joachim Eibl committed
684 685 686
AC_SUBST(kde_mimedir)
AC_SUBST(kde_wallpaperdir)
AC_SUBST(kde_bindir)
Joachim Eibl's avatar
Joachim Eibl committed
687 688
dnl X Desktop Group standards
AC_SUBST(xdg_appsdir)
Joachim Eibl's avatar
Joachim Eibl committed
689
AC_SUBST(xdg_menudir)
Joachim Eibl's avatar
Joachim Eibl committed
690
AC_SUBST(xdg_directorydir)
Joachim Eibl's avatar
Joachim Eibl committed
691 692 693 694 695
dnl for KDE 2
AC_SUBST(kde_templatesdir)
AC_SUBST(kde_servicesdir)
AC_SUBST(kde_servicetypesdir)
AC_SUBST(kde_moduledir)
Joachim Eibl's avatar
Joachim Eibl committed
696
AC_SUBST(kdeinitdir, '$(kde_moduledir)')
Joachim Eibl's avatar
Joachim Eibl committed
697 698 699 700 701 702 703 704 705 706 707 708 709 710
AC_SUBST(kde_styledir)
AC_SUBST(kde_widgetdir)
if test "$kde_qtver" = 1; then
  kde_minidir="$kde_icondir/mini"
else
# for KDE 1 - this breaks KDE2 apps using minidir, but
# that's the plan ;-/
  kde_minidir="/dev/null"
fi
dnl AC_SUBST(kde_minidir)
dnl AC_SUBST(kde_cgidir)
dnl AC_SUBST(kde_toolbardir)
])

Joachim Eibl's avatar
Joachim Eibl committed
711
AC_DEFUN([KDE_MISC_TESTS],
Joachim Eibl's avatar
Joachim Eibl committed
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754
[
   dnl Checks for libraries.
   AC_CHECK_LIB(util, main, [LIBUTIL="-lutil"]) dnl for *BSD 
   AC_SUBST(LIBUTIL)
   AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"]) dnl for *BSD
   AC_SUBST(LIBCOMPAT)
   kde_have_crypt=
   AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"; kde_have_crypt=yes],
      AC_CHECK_LIB(c, crypt, [kde_have_crypt=yes], [
        AC_MSG_WARN([you have no crypt in either libcrypt or libc.
You should install libcrypt from another source or configure with PAM
support])
	kde_have_crypt=no
      ]))
   AC_SUBST(LIBCRYPT)
   if test $kde_have_crypt = yes; then
      AC_DEFINE_UNQUOTED(HAVE_CRYPT, 1, [Defines if your system has the crypt function])
   fi
   AC_CHECK_SOCKLEN_T
   AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
   if test $ac_cv_lib_dnet_dnet_ntoa = no; then
      AC_CHECK_LIB(dnet_stub, dnet_ntoa,
        [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
   fi
   AC_CHECK_FUNC(inet_ntoa)
   if test $ac_cv_func_inet_ntoa = no; then
     AC_CHECK_LIB(nsl, inet_ntoa, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
   fi
   AC_CHECK_FUNC(connect)
   if test $ac_cv_func_connect = no; then
      AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
        $X_EXTRA_LIBS)
   fi

   AC_CHECK_FUNC(remove)
   if test $ac_cv_func_remove = no; then
      AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
   fi

   # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
   AC_CHECK_FUNC(shmat, ,
     AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"))
   
Joachim Eibl's avatar
Joachim Eibl committed
755 756 757 758 759 760 761 762 763 764
   # more headers that need to be explicitly included on darwin
   AC_CHECK_HEADERS(sys/types.h stdint.h)

   # darwin requires a poll emulation library
   AC_CHECK_LIB(poll, poll, LIB_POLL="-lpoll")

   # CoreAudio framework
   AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [
     AC_DEFINE(HAVE_COREAUDIO, 1, [Define if you have the CoreAudio API])
     FRAMEWORK_COREAUDIO="-Xlinker -framework -Xlinker CoreAudio"
Joachim Eibl's avatar
Joachim Eibl committed
765 766
   ])

Joachim Eibl's avatar
Joachim Eibl committed
767 768 769
   AC_CHECK_RES_INIT
   AC_SUBST(LIB_POLL)
   AC_SUBST(FRAMEWORK_COREAUDIO)
Joachim Eibl's avatar
Joachim Eibl committed
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
   LIBSOCKET="$X_EXTRA_LIBS"
   AC_SUBST(LIBSOCKET)
   AC_SUBST(X_EXTRA_LIBS)
   AC_CHECK_LIB(ucb, killpg, [LIBUCB="-lucb"]) dnl for Solaris2.4
   AC_SUBST(LIBUCB)

   case $host in  dnl this *is* LynxOS specific
   *-*-lynxos* )
        AC_MSG_CHECKING([LynxOS header file wrappers])
        [CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"]
        AC_MSG_RESULT(disabled)
        AC_CHECK_LIB(bsd, gethostbyname, [LIBSOCKET="-lbsd"]) dnl for LynxOS
         ;;
    esac

   KDE_CHECK_TYPES
   KDE_CHECK_LIBDL
Joachim Eibl's avatar
Joachim Eibl committed
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838
   KDE_CHECK_STRLCPY

# darwin needs this to initialize the environment
AC_CHECK_HEADERS(crt_externs.h)
AC_CHECK_FUNC(_NSGetEnviron, [AC_DEFINE(HAVE_NSGETENVIRON, 1, [Define if your system needs _NSGetEnviron to set up the environment])])
 
AH_VERBATIM(_DARWIN_ENVIRON,
[
#if defined(HAVE_NSGETENVIRON) && defined(HAVE_CRT_EXTERNS_H)
# include <sys/time.h>
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#endif
])

AH_VERBATIM(_AIX_STRINGS_H_BZERO,
[
/*
 * AIX defines FD_SET in terms of bzero, but fails to include <strings.h>
 * that defines bzero.
 */

#if defined(_AIX)
#include <strings.h>
#endif
])

AC_CHECK_FUNCS([vsnprintf snprintf])

AH_VERBATIM(_TRU64,[
/*
 * On HP-UX, the declaration of vsnprintf() is needed every time !
 */

#if !defined(HAVE_VSNPRINTF) || defined(hpux)
#if __STDC__
#include <stdarg.h>
#include <stdlib.h>
#else
#include <varargs.h>
#endif
#ifdef __cplusplus
extern "C"
#endif
int vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
#ifdef __cplusplus
extern "C"
#endif
int snprintf(char *str, size_t n, char const *fmt, ...);
#endif
])

Joachim Eibl's avatar
Joachim Eibl committed
839 840 841 842 843 844 845
])

dnl ------------------------------------------------------------------------
dnl Find the header files and libraries for X-Windows. Extended the
dnl macro AC_PATH_X
dnl ------------------------------------------------------------------------
dnl
Joachim Eibl's avatar
Joachim Eibl committed
846
AC_DEFUN([K_PATH_X],
Joachim Eibl's avatar
Joachim Eibl committed
847 848
[
AC_REQUIRE([KDE_MISC_TESTS])dnl
Joachim Eibl's avatar
Joachim Eibl committed
849
AC_REQUIRE([KDE_CHECK_LIB64])
Joachim Eibl's avatar
Joachim Eibl committed
850 851 852

AC_ARG_ENABLE(
  embedded,
Joachim Eibl's avatar
Joachim Eibl committed
853
  AC_HELP_STRING([--enable-embedded],[link to Qt-embedded, don't use X]),
Joachim Eibl's avatar
Joachim Eibl committed
854 855 856 857 858 859
  kde_use_qt_emb=$enableval,
  kde_use_qt_emb=no
)

AC_ARG_ENABLE(
  qtopia,
Joachim Eibl's avatar
Joachim Eibl committed
860
  AC_HELP_STRING([--enable-qtopia],[link to Qt-embedded, link to the Qtopia Environment]),
Joachim Eibl's avatar
Joachim Eibl committed
861 862 863 864
  kde_use_qt_emb_palm=$enableval,
  kde_use_qt_emb_palm=no
)

Joachim Eibl's avatar
Joachim Eibl committed
865 866
AC_ARG_ENABLE(
  mac,
Joachim Eibl's avatar
Joachim Eibl committed
867
  AC_HELP_STRING([--enable-mac],[link to Qt/Mac (don't use X)]),
Joachim Eibl's avatar
Joachim Eibl committed
868 869 870 871 872
  kde_use_qt_mac=$enableval,
  kde_use_qt_mac=no
)

if test "$kde_use_qt_emb" = "no" && test "$kde_use_qt_mac" = "no"; then
Joachim Eibl's avatar
Joachim Eibl committed
873 874

AC_MSG_CHECKING(for X)
Joachim Eibl's avatar
Joachim Eibl committed
875

Joachim Eibl's avatar
Joachim Eibl committed
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
AC_CACHE_VAL(kde_cv_have_x,
[# One or both of the vars are not set, and there is no cached value.
if test "{$x_includes+set}" = set || test "$x_includes" = NONE; then
   kde_x_includes=NO
else
   kde_x_includes=$x_includes
fi
if test "{$x_libraries+set}" = set || test "$x_libraries" = NONE; then
   kde_x_libraries=NO
else
   kde_x_libraries=$x_libraries
fi

# below we use the standard autoconf calls
ac_x_libraries=$kde_x_libraries
ac_x_includes=$kde_x_includes

KDE_PATH_X_DIRECT
dnl AC_PATH_X_XMKMF picks /usr/lib as the path for the X libraries.
dnl Unfortunately, if compiling with the N32 ABI, this is not the correct
dnl location. The correct location is /usr/lib32 or an undefined value
dnl (the linker is smart enough to pick the correct default library).
dnl Things work just fine if you use just AC_PATH_X_DIRECT.
dnl Solaris has a similar problem. AC_PATH_X_XMKMF forces x_includes to
dnl /usr/openwin/include, which doesn't work. /usr/include does work, so
dnl x_includes should be left alone.
case "$host" in
mips-sgi-irix6*)
  ;;
*-*-solaris*)
  ;;
*)
  _AC_PATH_X_XMKMF
  if test -z "$ac_x_includes"; then
    ac_x_includes="."
  fi
  if test -z "$ac_x_libraries"; then
Joachim Eibl's avatar
Joachim Eibl committed
913
    ac_x_libraries="/usr/lib${kdelibsuff}"
Joachim Eibl's avatar
Joachim Eibl committed
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
  fi
esac
#from now on we use our own again

# when the user already gave --x-includes, we ignore
# what the standard autoconf macros told us.
if test "$kde_x_includes" = NO; then
  kde_x_includes=$ac_x_includes
fi

# for --x-libraries too
if test "$kde_x_libraries" = NO; then
  kde_x_libraries=$ac_x_libraries
fi

if test "$kde_x_includes" = NO; then
  AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
fi

if test "$kde_x_libraries" = NO; then
  AC_MSG_ERROR([Can't find X libraries. Please check your installation and add the correct paths!])
fi

# Record where we found X for the cache.
kde_cv_have_x="have_x=yes \
         kde_x_includes=$kde_x_includes kde_x_libraries=$kde_x_libraries"
])dnl

eval "$kde_cv_have_x"

if test "$have_x" != yes; then
  AC_MSG_RESULT($have_x)
  no_x=yes
else
  AC_MSG_RESULT([libraries $kde_x_libraries, headers $kde_x_includes])
fi

if test -z "$kde_x_includes" || test "x$kde_x_includes" = xNONE; then
  X_INCLUDES=""
  x_includes="."; dnl better than nothing :-
 else
  x_includes=$kde_x_includes
  X_INCLUDES="-I$x_includes"
fi

if test -z "$kde_x_libraries" || test "x$kde_x_libraries" = xNONE; then
  X_LDFLAGS=""
  x_libraries="/usr/lib"; dnl better than nothing :-
 else
  x_libraries=$kde_x_libraries
  X_LDFLAGS="-L$x_libraries"
fi
all_includes="$X_INCLUDES"
all_libraries="$X_LDFLAGS"

# Check for libraries that X11R6 Xt/Xaw programs need.
ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $X_LDFLAGS"
# SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
# check for ICE first), but we must link in the order -lSM -lICE or
# we get undefined symbols.  So assume we have SM if we have ICE.
# These have to be linked with before -lX11, unlike the other
# libraries we check for below, so use a different variable.
#  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
AC_CHECK_LIB(ICE, IceConnectionNumber,
  [LIBSM="-lSM -lICE"], , $X_EXTRA_LIBS)
LDFLAGS="$ac_save_LDFLAGS"

LIB_X11='-lX11 $(LIBSOCKET)'

AC_MSG_CHECKING(for libXext)
AC_CACHE_VAL(kde_cv_have_libXext,
[
kde_ldflags_safe="$LDFLAGS"
kde_libs_safe="$LIBS"

LDFLAGS="$LDFLAGS $X_LDFLAGS $USER_LDFLAGS"
LIBS="-lXext -lX11 $LIBSOCKET"

AC_TRY_LINK([
#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
#endif
],
[
printf("hello Xext\n");
],
kde_cv_have_libXext=yes,
kde_cv_have_libXext=no
Joachim Eibl's avatar
Joachim Eibl committed
1004
)
Joachim Eibl's avatar
Joachim Eibl committed
1005 1006 1007

LDFLAGS=$kde_ldflags_safe
LIBS=$kde_libs_safe
Joachim Eibl's avatar
Joachim Eibl committed
1008
])
Joachim Eibl's avatar
Joachim Eibl committed
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020

AC_MSG_RESULT($kde_cv_have_libXext)

if test "$kde_cv_have_libXext" = "no"; then
  AC_MSG_ERROR([We need a working libXext to proceed. Since configure
can't find it itself, we stop here assuming that make wouldn't find
them either.])
fi

LIB_XEXT="-lXext"
QTE_NORTTI=""

Joachim Eibl's avatar
Joachim Eibl committed
1021
elif test "$kde_use_qt_emb" = "yes"; then
Joachim Eibl's avatar
Joachim Eibl committed
1022
  dnl We're using QT Embedded
Joachim Eibl's avatar
Joachim Eibl committed
1023 1024
  CPPFLAGS=-DQWS
  CXXFLAGS="$CXXFLAGS -fno-rtti"
Joachim Eibl's avatar
Joachim Eibl committed
1025 1026 1027 1028
  QTE_NORTTI="-fno-rtti -DQWS"
  X_PRE_LIBS=""
  LIB_X11=""
  LIB_XEXT=""
Joachim Eibl's avatar
Joachim Eibl committed
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
  LIB_XRENDER=""
  LIBSM=""
  X_INCLUDES=""
  X_LDFLAGS=""
  x_includes=""
  x_libraries=""
elif test "$kde_use_qt_mac" = "yes"; then
  dnl We're using QT/Mac (I use QT_MAC so that qglobal.h doesn't *have* to
  dnl be included to get the information) --Sam
  CXXFLAGS="$CXXFLAGS -DQT_MAC -no-cpp-precomp"
  CFLAGS="$CFLAGS -DQT_MAC -no-cpp-precomp"
  X_PRE_LIBS=""
  LIB_X11=""
  LIB_XEXT=""
  LIB_XRENDER=""
Joachim Eibl's avatar
Joachim Eibl committed
1044 1045 1046 1047 1048 1049
  LIBSM=""
  X_INCLUDES=""
  X_LDFLAGS=""
  x_includes=""
  x_libraries=""
fi
Joachim Eibl's avatar
Joachim Eibl committed
1050 1051 1052 1053 1054 1055 1056 1057
AC_SUBST(X_PRE_LIBS)
AC_SUBST(LIB_X11)
AC_SUBST(LIB_XRENDER)
AC_SUBST(LIBSM)
AC_SUBST(X_INCLUDES)
AC_SUBST(X_LDFLAGS)
AC_SUBST(x_includes)
AC_SUBST(x_libraries)
Joachim Eibl's avatar
Joachim Eibl committed
1058 1059 1060 1061 1062
AC_SUBST(QTE_NORTTI)
AC_SUBST(LIB_XEXT)

])

Joachim Eibl's avatar
Joachim Eibl committed
1063
AC_DEFUN([KDE_PRINT_QT_PROGRAM],
Joachim Eibl's avatar
Joachim Eibl committed
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
[
AC_REQUIRE([KDE_USE_QT])
cat > conftest.$ac_ext <<EOF
#include "confdefs.h"
#include <qglobal.h>
#include <qapplication.h>
EOF
if test "$kde_qtver" = "2"; then
cat >> conftest.$ac_ext <<EOF
#include <qevent.h>
#include <qstring.h>
#include <qstyle.h>
EOF

if test $kde_qtsubver -gt 0; then
cat >> conftest.$ac_ext <<EOF
Joachim Eibl's avatar
Joachim Eibl committed
1080 1081 1082
#if QT_VERSION < 210
#error 1
#endif
Joachim Eibl's avatar
Joachim Eibl committed
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
EOF
fi
fi

if test "$kde_qtver" = "3"; then
cat >> conftest.$ac_ext <<EOF
#include <qcursor.h>
#include <qstylefactory.h>
#include <private/qucomextra_p.h>
EOF
fi

echo "#if ! ($kde_qt_verstring)" >> conftest.$ac_ext
cat >> conftest.$ac_ext <<EOF
#error 1
#endif

int main() {
EOF
if test "$kde_qtver" = "2"; then
cat >> conftest.$ac_ext <<EOF
    QStringList *t = new QStringList();
    Q_UNUSED(t);
EOF
if test $kde_qtsubver -gt 0; then
cat >> conftest.$ac_ext <<EOF
    QString s;
    s.setLatin1("Elvis is alive", 14);
EOF
fi
fi
if test "$kde_qtver" = "3"; then
cat >> conftest.$ac_ext <<EOF
    (void)QStyleFactory::create(QString::null);
    QCursor c(Qt::WhatsThisCursor);
EOF
fi
cat >> conftest.$ac_ext <<EOF
    return 0;
}
EOF
])

Joachim Eibl's avatar
Joachim Eibl committed
1126
AC_DEFUN([KDE_USE_QT],
Joachim Eibl's avatar
Joachim Eibl committed
1127 1128
[
if test -z "$1"; then
Joachim Eibl's avatar
Joachim Eibl committed
1129
  # Current default Qt version: 3.2
Joachim Eibl's avatar
Joachim Eibl committed
1130
  kde_qtver=3
Joachim Eibl's avatar
Joachim Eibl committed
1131
  kde_qtsubver=2
Joachim Eibl's avatar
Joachim Eibl committed
1132 1133
else
  kde_qtsubver=`echo "$1" | sed -e 's#[0-9][0-9]*\.\([0-9][0-9]*\).*#\1#'`
Joachim Eibl's avatar
Joachim Eibl committed
1134
  # following is the check if subversion isnt found in passed argument
Joachim Eibl's avatar
Joachim Eibl committed
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152
  if test "$kde_qtsubver" = "$1"; then
    kde_qtsubver=1
  fi
  kde_qtver=`echo "$1" | sed -e 's#^\([0-9][0-9]*\)\..*#\1#'`
  if test "$kde_qtver" = "1"; then
    kde_qtsubver=42
  fi
fi

if test -z "$2"; then
  if test "$kde_qtver" = "2"; then
    if test $kde_qtsubver -gt 0; then
      kde_qt_minversion=">= Qt 2.2.2"
    else
      kde_qt_minversion=">= Qt 2.0.2"
    fi
  fi
  if test "$kde_qtver" = "3"; then
Joachim Eibl's avatar
Joachim Eibl committed
1153
    if test $kde_qtsubver -gt 0; then
Joachim Eibl's avatar
Joachim Eibl committed
1154 1155 1156 1157 1158
	 if test $kde_qtsubver -gt 1; then
	    kde_qt_minversion=">= Qt 3.2"
	 else
            kde_qt_minversion=">= Qt 3.1 (20021021)"
         fi
Joachim Eibl's avatar
Joachim Eibl committed
1159 1160 1161
    else
      kde_qt_minversion=">= Qt 3.0"
    fi
Joachim Eibl's avatar
Joachim Eibl committed
1162 1163 1164 1165 1166
  fi
  if test "$kde_qtver" = "1"; then
    kde_qt_minversion=">= 1.42 and < 2.0"
  fi
else
Joachim Eibl's avatar
Joachim Eibl committed
1167
   kde_qt_minversion="$2"
Joachim Eibl's avatar
Joachim Eibl committed
1168 1169 1170 1171
fi

if test -z "$3"; then
   if test $kde_qtver = 3; then
Joachim Eibl's avatar
Joachim Eibl committed
1172
     if test $kde_qtsubver -gt 0; then
Joachim Eibl's avatar
Joachim Eibl committed
1173 1174 1175
       kde_qt_verstring="QT_VERSION >= 0x03@VER@00"
       qtsubver=`echo "00$kde_qtsubver" | sed -e 's,.*\(..\)$,\1,'`
       kde_qt_verstring=`echo $kde_qt_verstring | sed -e "s,@VER@,$qtsubver,"`
Joachim Eibl's avatar
Joachim Eibl committed
1176 1177 1178
     else
       kde_qt_verstring="QT_VERSION >= 300"
     fi
Joachim Eibl's avatar
Joachim Eibl committed
1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190
   fi
   if test $kde_qtver = 2; then
     if test $kde_qtsubver -gt 0; then
       kde_qt_verstring="QT_VERSION >= 222"
     else
       kde_qt_verstring="QT_VERSION >= 200"
     fi
   fi
   if test $kde_qtver = 1; then
    kde_qt_verstring="QT_VERSION >= 142 && QT_VERSION < 200"
   fi
else
Joachim Eibl's avatar
Joachim Eibl committed
1191
   kde_qt_verstring="$3"
Joachim Eibl's avatar
Joachim Eibl committed
1192 1193 1194
fi

if test $kde_qtver = 3; then
Joachim Eibl's avatar
Joachim Eibl committed
1195
  kde_qt_dirs="$QTDIR /usr/lib/qt3 /usr/lib/qt /usr/share/qt3"
Joachim Eibl's avatar
Joachim Eibl committed
1196 1197 1198 1199 1200 1201 1202 1203 1204
fi
if test $kde_qtver = 2; then
   kde_qt_dirs="$QTDIR /usr/lib/qt2 /usr/lib/qt"
fi
if test $kde_qtver = 1; then
   kde_qt_dirs="$QTDIR /usr/lib/qt"
fi
])

Joachim Eibl's avatar
Joachim Eibl committed
1205
AC_DEFUN([KDE_CHECK_QT_DIRECT],
Joachim Eibl's avatar
Joachim Eibl committed
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
[
AC_REQUIRE([KDE_USE_QT])
AC_MSG_CHECKING([if Qt compiles without flags])
AC_CACHE_VAL(kde_cv_qt_direct,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
ac_LIBRARY_PATH="$LIBRARY_PATH"
ac_cxxflags_safe="$CXXFLAGS"
ac_ldflags_safe="$LDFLAGS"
ac_libs_safe="$LIBS"

CXXFLAGS="$CXXFLAGS -I$qt_includes"
LDFLAGS="$LDFLAGS $X_LDFLAGS"
Joachim Eibl's avatar
Joachim Eibl committed
1221
if test "x$kde_use_qt_emb" != "xyes" && test "x$kde_use_qt_mac" != "xyes"; then
Joachim Eibl's avatar
Joachim Eibl committed
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267
LIBS="$LIBQT -lXext -lX11 $LIBSOCKET"
else
LIBS="$LIBQT $LIBSOCKET"
fi
LD_LIBRARY_PATH=
export LD_LIBRARY_PATH
LIBRARY_PATH=
export LIBRARY_PATH

KDE_PRINT_QT_PROGRAM

if AC_TRY_EVAL(ac_link) && test -s conftest; then
  kde_cv_qt_direct="yes"
else
  kde_cv_qt_direct="no"
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
fi

rm -f conftest*
CXXFLAGS="$ac_cxxflags_safe"
LDFLAGS="$ac_ldflags_safe"
LIBS="$ac_libs_safe"

LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
export LD_LIBRARY_PATH
LIBRARY_PATH="$ac_LIBRARY_PATH"
export LIBRARY_PATH
AC_LANG_RESTORE
])

if test "$kde_cv_qt_direct" = "yes"; then
  AC_MSG_RESULT(yes)
  $1
else
  AC_MSG_RESULT(no)
  $2
fi
])

dnl ------------------------------------------------------------------------
dnl Try to find the Qt headers and libraries.
dnl $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
dnl and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
dnl ------------------------------------------------------------------------
dnl
Joachim Eibl's avatar
Joachim Eibl committed
1268
AC_DEFUN([AC_PATH_QT_1_3],
Joachim Eibl's avatar
Joachim Eibl committed
1269 1270 1271
[
AC_REQUIRE([K_PATH_X])
AC_REQUIRE([KDE_USE_QT])
Joachim Eibl's avatar
Joachim Eibl committed
1272
AC_REQUIRE([KDE_CHECK_LIB64])
Joachim Eibl's avatar
Joachim Eibl committed
1273 1274 1275 1276 1277 1278 1279

dnl ------------------------------------------------------------------------
dnl Add configure flag to enable linking to MT version of Qt library.
dnl ------------------------------------------------------------------------

AC_ARG_ENABLE(
  mt,
Joachim Eibl's avatar
Joachim Eibl committed
1280
  AC_HELP_STRING([--disable-mt],[link to non-threaded Qt (deprecated)]),
Joachim Eibl's avatar
Joachim Eibl committed
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387
  kde_use_qt_mt=$enableval,
  [
    if test $kde_qtver = 3; then
      kde_use_qt_mt=yes
    else
      kde_use_qt_mt=no
    fi
  ]
)

USING_QT_MT=""

dnl ------------------------------------------------------------------------
dnl If we not get --disable-qt-mt then adjust some vars for the host.
dnl ------------------------------------------------------------------------

KDE_MT_LDFLAGS=
KDE_MT_LIBS=
if test "x$kde_use_qt_mt" = "xyes"; then
  KDE_CHECK_THREADING
  if test "x$kde_use_threading" = "xyes"; then
    CPPFLAGS="$USE_THREADS -DQT_THREAD_SUPPORT $CPPFLAGS"
    KDE_MT_LDFLAGS="$USE_THREADS"
    KDE_MT_LIBS="$LIBPTHREAD"
  else
    kde_use_qt_mt=no
  fi
fi
AC_SUBST(KDE_MT_LDFLAGS)
AC_SUBST(KDE_MT_LIBS)

kde_qt_was_given=yes

dnl ------------------------------------------------------------------------
dnl If we haven't been told how to link to Qt, we work it out for ourselves.
dnl ------------------------------------------------------------------------
if test -z "$LIBQT_GLOB"; then
  if test "x$kde_use_qt_emb" = "xyes"; then
    LIBQT_GLOB="libqte.*"
  else
    LIBQT_GLOB="libqt.*"
  fi
fi

if test -z "$LIBQT"; then
dnl ------------------------------------------------------------
dnl If we got --enable-embedded then adjust the Qt library name.
dnl ------------------------------------------------------------
  if test "x$kde_use_qt_emb" = "xyes"; then
    qtlib="qte"
  else
    qtlib="qt"
  fi

  kde_int_qt="-l$qtlib"
else
  kde_int_qt="$LIBQT"
  kde_lib_qt_set=yes
fi

if test -z "$LIBQPE"; then
dnl ------------------------------------------------------------
dnl If we got --enable-palmtop then add -lqpe to the link line
dnl ------------------------------------------------------------
  if test "x$kde_use_qt_emb" = "xyes"; then
    if test "x$kde_use_qt_emb_palm" = "xyes"; then
      LIB_QPE="-lqpe"
    else
      LIB_QPE=""
    fi
  else
    LIB_QPE=""
  fi
fi

dnl ------------------------------------------------------------------------
dnl If we got --enable-qt-mt then adjust the Qt library name for the host.
dnl ------------------------------------------------------------------------

if test "x$kde_use_qt_mt" = "xyes"; then
  if test -z "$LIBQT"; then
    LIBQT="-l$qtlib-mt"
    kde_int_qt="-l$qtlib-mt"
  else
    LIBQT="$qtlib-mt"
    kde_int_qt="$qtlib-mt"
  fi
  LIBQT_GLOB="lib$qtlib-mt.*"
  USING_QT_MT="using -mt"
else
  LIBQT="-l$qtlib"
fi

if test $kde_qtver != 1; then

  AC_REQUIRE([AC_FIND_PNG])
  AC_REQUIRE([AC_FIND_JPEG])
  LIBQT="$LIBQT $LIBPNG $LIBJPEG"
fi

if test $kde_qtver = 3; then
  AC_REQUIRE([KDE_CHECK_LIBDL])
  LIBQT="$LIBQT $LIBDL"
fi

AC_MSG_CHECKING([for Qt])

Joachim Eibl's avatar
Joachim Eibl committed
1388
if test "x$kde_use_qt_emb" != "xyes" && test "x$kde_use_qt_mac" != "xyes"; then
Joachim Eibl's avatar
Joachim Eibl committed
1389 1390 1391 1392 1393 1394
LIBQT="$LIBQT $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
fi
ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
qt_libraries=""
qt_includes=""
AC_ARG_WITH(qt-dir,
Joachim Eibl's avatar
Joachim Eibl committed
1395
    AC_HELP_STRING([--with-qt-dir=DIR],[where the root of Qt is installed ]),
Joachim Eibl's avatar
Joachim Eibl committed
1396
    [  ac_qt_includes="$withval"/include
Joachim Eibl's avatar
Joachim Eibl committed
1397
       ac_qt_libraries="$withval"/lib${kdelibsuff}
Joachim Eibl's avatar
Joachim Eibl committed
1398 1399 1400 1401
       ac_qt_bindir="$withval"/bin
    ])

AC_ARG_WITH(qt-includes,
Joachim Eibl's avatar
Joachim Eibl committed
1402
    AC_HELP_STRING([--with-qt-includes=DIR],[where the Qt includes are. ]),
Joachim Eibl's avatar
Joachim Eibl committed
1403 1404 1405 1406 1407 1408 1409
    [
       ac_qt_includes="$withval"
    ])

kde_qt_libs_given=no

AC_ARG_WITH(qt-libraries,
Joachim Eibl's avatar
Joachim Eibl committed
1410
    AC_HELP_STRING([--with-qt-libraries=DIR],[where the Qt library is installed.]),
Joachim Eibl's avatar
Joachim Eibl committed
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421
    [  ac_qt_libraries="$withval"
       kde_qt_libs_given=yes
    ])

AC_CACHE_VAL(ac_cv_have_qt,
[#try to guess Qt locations

qt_incdirs=""
for dir in $kde_qt_dirs; do
   qt_incdirs="$qt_incdirs $dir/include $dir"
done
Joachim Eibl's avatar
Joachim Eibl committed
1422
qt_incdirs="$QTINC $qt_incdirs /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/X11R6/include/qt2 /usr/include/qt3 $x_includes"
Joachim Eibl's avatar
Joachim Eibl committed
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
if test ! "$ac_qt_includes" = "NO"; then
   qt_incdirs="$ac_qt_includes $qt_incdirs"
fi

if test "$kde_qtver" != "1"; then
  kde_qt_header=qstyle.h
else
  kde_qt_header=qglobal.h
fi

AC_FIND_FILE($kde_qt_header, $qt_incdirs, qt_incdir)
ac_qt_includes="$qt_incdir"

qt_libdirs=""
for dir in $kde_qt_dirs; do
Joachim Eibl's avatar
Joachim Eibl committed
1438
   qt_libdirs="$qt_libdirs $dir/lib${kdelibsuff} $dir"
Joachim Eibl's avatar
Joachim Eibl committed
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451
done
qt_libdirs="$QTLIB $qt_libdirs /usr/X11R6/lib /usr/lib /usr/local/qt/lib $x_libraries"
if test ! "$ac_qt_libraries" = "NO"; then
  qt_libdir=$ac_qt_libraries
else
  qt_libdirs="$ac_qt_libraries $qt_libdirs"
  # if the Qt was given, the chance is too big that libqt.* doesn't exist
  qt_libdir=NONE
  for dir in $qt_libdirs; do
    try="ls -1 $dir/${LIBQT_GLOB}"
    if test -n "`$try 2> /dev/null`"; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
  done
fi
Joachim Eibl's avatar
Joachim Eibl committed
1452 1453 1454 1455 1456 1457
for a in $qt_libdir/lib`echo ${kde_int_qt} | sed 's,^-l,,'`_incremental.*; do
  if test -e "$a"; then
    LIBQT="$LIBQT ${kde_int_qt}_incremental"
    break
  fi
done
Joachim Eibl's avatar
Joachim Eibl committed
1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526

ac_qt_libraries="$qt_libdir"

AC_LANG_SAVE
AC_LANG_CPLUSPLUS

ac_cxxflags_safe="$CXXFLAGS"
ac_ldflags_safe="$LDFLAGS"
ac_libs_safe="$LIBS"

CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
LDFLAGS="$LDFLAGS -L$qt_libdir $all_libraries $USER_LDFLAGS $KDE_MT_LDFLAGS"
LIBS="$LIBS $LIBQT $KDE_MT_LIBS"

KDE_PRINT_QT_PROGRAM

if AC_TRY_EVAL(ac_link) && test -s conftest; then
  rm -f conftest*
else
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
  ac_qt_libraries="NO"
fi
rm -f conftest*
CXXFLAGS="$ac_cxxflags_safe"
LDFLAGS="$ac_ldflags_safe"
LIBS="$ac_libs_safe"

AC_LANG_RESTORE
if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
  ac_cv_have_qt="have_qt=no"
  ac_qt_notfound=""
  missing_qt_mt=""
  if test "$ac_qt_includes" = NO; then
    if test "$ac_qt_libraries" = NO; then
      ac_qt_notfound="(headers and libraries)";
    else
      ac_qt_notfound="(headers)";
    fi
  else
    if test "x$kde_use_qt_mt" = "xyes"; then
       missing_qt_mt="
Make sure that you have compiled Qt with thread support!"
       ac_qt_notfound="(library $qtlib-mt)";
    else
       ac_qt_notfound="(library $qtlib)";
    fi
  fi

  AC_MSG_ERROR([Qt ($kde_qt_minversion) $ac_qt_notfound not found. Please check your installation!
For more details about this problem, look at the end of config.log.$missing_qt_mt])
else
  have_qt="yes"
fi
])

eval "$ac_cv_have_qt"

if test "$have_qt" != yes; then
  AC_MSG_RESULT([$have_qt]);
else
  ac_cv_have_qt="have_qt=yes \
    ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
  AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes $USING_QT_MT])

  qt_libraries="$ac_qt_libraries"
  qt_includes="$ac_qt_includes"
fi

Joachim Eibl's avatar
Joachim Eibl committed
1527 1528
if test ! "$kde_qt_libs_given" = "yes" && test ! "$kde_qtver" = 3; then
     KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
Joachim Eibl's avatar
Joachim Eibl committed
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552
fi

AC_SUBST(qt_libraries)
AC_SUBST(qt_includes)

if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
 QT_INCLUDES=""
else
 QT_INCLUDES="-I$qt_includes"
 all_includes="$QT_INCLUDES $all_includes"
fi

if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
 QT_LDFLAGS=""
else
 QT_LDFLAGS="-L$qt_libraries"
 all_libraries="$all_libraries $QT_LDFLAGS"
fi
test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"

AC_SUBST(QT_INCLUDES)
AC_SUBST(QT_LDFLAGS)
AC_PATH_QT_MOC_UIC

Joachim Eibl's avatar
Joachim Eibl committed
1553 1554 1555 1556
KDE_CHECK_QT_JPEG

if test "x$kde_use_qt_emb" != "xyes" && test "x$kde_use_qt_mac" != "xyes"; then
LIB_QT="$kde_int_qt $LIBJPEG_QT "'$(LIBZ) $(LIBPNG) -lXext $(LIB_X11) $(LIBSM)'
Joachim Eibl's avatar
Joachim Eibl committed
1557
else
Joachim Eibl's avatar
Joachim Eibl committed
1558
LIB_QT="$kde_int_qt $LIBJPEG_QT "'$(LIBZ) $(LIBPNG)'
Joachim Eibl's avatar
Joachim Eibl committed
1559 1560
fi
test -z "$KDE_MT_LIBS" || LIB_QT="$LIB_QT $KDE_MT_LIBS"
Joachim Eibl's avatar
Joachim Eibl committed
1561 1562 1563 1564 1565 1566
for a in $qt_libdir/lib`echo ${kde_int_qt} | sed 's,^-l,,'`_incremental.*; do
  if test -e "$a"; then
     LIB_QT="$LIB_QT ${kde_int_qt}_incremental"
     break
  fi
done
Joachim Eibl's avatar
Joachim Eibl committed
1567 1568 1569 1570 1571 1572 1573

AC_SUBST(LIB_QT)
AC_SUBST(LIB_QPE)

AC_SUBST(kde_qtver)
])

Joachim Eibl's avatar
Joachim Eibl committed
1574
AC_DEFUN([AC_PATH_QT],
Joachim Eibl's avatar
Joachim Eibl committed
1575 1576 1577 1578
[
AC_PATH_QT_1_3
])

Joachim Eibl's avatar
Joachim Eibl committed
1579
AC_DEFUN([KDE_CHECK_UIC_PLUGINS],
Joachim Eibl's avatar
Joachim Eibl committed
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609
[
AC_REQUIRE([AC_PATH_QT_MOC_UIC])

if test x$ac_uic_supports_libpath = xyes; then

AC_MSG_CHECKING([if UIC has KDE plugins available])
AC_CACHE_VAL(kde_cv_uic_plugins,
[
cat > actest.ui << EOF
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>NewConnectionDialog</class>
<widget class="QDialog">
   <widget class="KLineEdit">
        <property name="name">
           <cstring>testInput</cstring>
        </property>
   </widget>
</widget>
</UI>
EOF
       


kde_cv_uic_plugins=no
kde_line="$UIC_PATH -L $kde_widgetdir"
if test x$ac_uic_supports_nounload = xyes; then
   kde_line="$kde_line -nounload"
fi
kde_line="$kde_line -impl actest.h actest.ui > actest.cpp"
if AC_TRY_EVAL(kde_line); then
Joachim Eibl's avatar
Joachim Eibl committed
1610 1611 1612
	# if you're trying to debug this check and think it's incorrect,
	# better check your installation. The check _is_ correct - your
	# installation is not.
Joachim Eibl's avatar
Joachim Eibl committed
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626
	if test -f actest.cpp && grep klineedit actest.cpp > /dev/null; then
		kde_cv_uic_plugins=yes
	fi
fi
rm -f actest.ui actest.cpp
])

AC_MSG_RESULT([$kde_cv_uic_plugins])
if test "$kde_cv_uic_plugins" != yes; then
	AC_MSG_ERROR([you need to install kdelibs first.])
fi
fi
])

Joachim Eibl's avatar
Joachim Eibl committed
1627
AC_DEFUN([KDE_CHECK_FINAL],
Joachim Eibl's avatar
Joachim Eibl committed
1628
[
Joachim Eibl's avatar
Joachim Eibl committed
1629 1630 1631
  AC_ARG_ENABLE(final,
	AC_HELP_STRING([--enable-final],
		       [build size optimized apps (experimental - needs lots of memory)]),
Joachim Eibl's avatar
Joachim Eibl committed
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642
	kde_use_final=$enableval, kde_use_final=no)

  if test "x$kde_use_final" = "xyes"; then
      KDE_USE_FINAL_TRUE=""
      KDE_USE_FINAL_FALSE="#"
   else
      KDE_USE_FINAL_TRUE="#"
      KDE_USE_FINAL_FALSE=""
  fi
  AC_SUBST(KDE_USE_FINAL_TRUE)
  AC_SUBST(KDE_USE_FINAL_FALSE)
Joachim Eibl's avatar
Joachim Eibl committed
1643
])
Joachim Eibl's avatar
Joachim Eibl committed
1644

Joachim Eibl's avatar
Joachim Eibl committed
1645
AC_DEFUN([KDE_CHECK_CLOSURE],
Joachim Eibl's avatar
Joachim Eibl committed
1646
[
Joachim Eibl's avatar
Joachim Eibl committed
1647 1648 1649
  AC_ARG_ENABLE(closure,
		AC_HELP_STRING([--enable-closure],[delay template instantiation]),
  	kde_use_closure=$enableval, kde_use_closure=no)
Joachim Eibl's avatar
Joachim Eibl committed
1650

Joachim Eibl's avatar
Joachim Eibl committed
1651
  KDE_NO_UNDEFINED=""
Joachim Eibl's avatar
Joachim Eibl committed
1652 1653 1654 1655 1656 1657 1658
  if test "x$kde_use_closure" = "xyes"; then
       KDE_USE_CLOSURE_TRUE=""
       KDE_USE_CLOSURE_FALSE="#"
#       CXXFLAGS="$CXXFLAGS $REPO"
  else
       KDE_USE_CLOSURE_TRUE="#"
       KDE_USE_CLOSURE_FALSE=""
Joachim Eibl's avatar
Joachim Eibl committed
1659 1660 1661 1662 1663
       KDE_NO_UNDEFINED=""
       case $host in 
         *-*-linux-gnu)
           KDE_CHECK_COMPILER_FLAG([Wl,--no-undefined],
                [KDE_CHECK_COMPILER_FLAG([Wl,--allow-shlib-undefined],
Joachim Eibl's avatar
Joachim Eibl committed
1664 1665 1666
		[KDE_NO_UNDEFINED="-Wl,--no-undefined -Wl,--allow-shlib-undefined"],
		[KDE_NO_UNDEFINED=""])],
	    [KDE_NO_UNDEFINED=""])
Joachim Eibl's avatar
Joachim Eibl committed
1667 1668
           ;;
       esac
Joachim Eibl's avatar
Joachim Eibl committed
1669 1670 1671
  fi
  AC_SUBST(KDE_USE_CLOSURE_TRUE)
  AC_SUBST(KDE_USE_CLOSURE_FALSE)
Joachim Eibl's avatar
Joachim Eibl committed
1672 1673 1674
  AC_SUBST(KDE_NO_UNDEFINED)
])

Joachim Eibl's avatar
Joachim Eibl committed
1675
AC_DEFUN([KDE_CHECK_NMCHECK],
Joachim Eibl's avatar
Joachim Eibl committed
1676
[
Joachim Eibl's avatar
Joachim Eibl committed
1677
  AC_ARG_ENABLE(nmcheck,AC_HELP_STRING([--enable-nmcheck],[enable automatic namespace cleanness check]),
Joachim Eibl's avatar
Joachim Eibl committed
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688
	kde_use_nmcheck=$enableval, kde_use_nmcheck=no)

  if test "$kde_use_nmcheck" = "yes"; then
      KDE_USE_NMCHECK_TRUE=""
      KDE_USE_NMCHECK_FALSE="#"
   else
      KDE_USE_NMCHECK_TRUE="#"
      KDE_USE_NMCHECK_FALSE=""
  fi
  AC_SUBST(KDE_USE_NMCHECK_TRUE)
  AC_SUBST(KDE_USE_NMCHECK_FALSE)
Joachim Eibl's avatar
Joachim Eibl committed
1689 1690
])

Joachim Eibl's avatar
Joachim Eibl committed
1691 1692 1693 1694 1695 1696 1697
AC_DEFUN([KDE_EXPAND_MAKEVAR], [
savex=$exec_prefix
test "x$exec_prefix" = xNONE && exec_prefix=$prefix
tmp=$$2
while $1=`eval echo "$tmp"`; test "x$$1" != "x$tmp"; do tmp=$$1; done
exec_prefix=$savex
])
Joachim Eibl's avatar
Joachim Eibl committed
1698

Joachim Eibl's avatar
Joachim Eibl committed
1699 1700 1701 1702 1703 1704
dnl ------------------------------------------------------------------------
dnl Now, the same with KDE
dnl $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
dnl and $(kde_includes) will be the kdehdrlocation (if needed)
dnl ------------------------------------------------------------------------
dnl
Joachim Eibl's avatar
Joachim Eibl committed
1705
AC_DEFUN([AC_BASE_PATH_KDE],
Joachim Eibl's avatar
Joachim Eibl committed
1706
[
Joachim Eibl's avatar
Joachim Eibl committed
1707
AC_REQUIRE([KDE_CHECK_STL])
Joachim Eibl's avatar
Joachim Eibl committed
1708
AC_REQUIRE([AC_PATH_QT])dnl
Joachim Eibl's avatar
Joachim Eibl committed
1709 1710
AC_REQUIRE([KDE_CHECK_LIB64])

Joachim Eibl's avatar
Joachim Eibl committed
1711 1712 1713 1714
AC_CHECK_RPATH
AC_MSG_CHECKING([for KDE])

if test "${prefix}" != NONE; then
Joachim Eibl's avatar
Joachim Eibl committed
1715 1716 1717 1718 1719 1720
  kde_includes=${includedir}
  KDE_EXPAND_MAKEVAR(ac_kde_includes, includedir)

  kde_libraries=${libdir}
  KDE_EXPAND_MAKEVAR(ac_kde_libraries, libdir)

Joachim Eibl's avatar
Joachim Eibl committed
1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752
else
  ac_kde_includes=
  ac_kde_libraries=
  kde_libraries=""
  kde_includes=""
fi

AC_CACHE_VAL(ac_cv_have_kde,
[#try to guess kde locations

if test "$kde_qtver" = 1; then
  kde_check_header="ksock.h"
  kde_check_lib="libkdecore.la"
else
  kde_check_header="ksharedptr.h"
  kde_check_lib="libkio.la"
fi

if test -z "$1"; then

kde_incdirs="/usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /usr/include /opt/kde3/include /opt/kde/include $x_includes $qt_includes"
test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include $KDEDIR/include/kde $KDEDIR $kde_incdirs"
kde_incdirs="$ac_kde_includes $kde_incdirs"
AC_FIND_FILE($kde_check_header, $kde_incdirs, kde_incdir)
ac_kde_includes="$kde_incdir"

if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/$kde_check_header"; then
  AC_MSG_ERROR([
in the prefix, you've chosen, are no KDE headers installed. This will fail.
So, check this please and use another prefix!])
fi

Joachim Eibl's avatar
Joachim Eibl committed
1753 1754 1755
kde_libdirs="/usr/lib/kde/lib${kdelibsuff} /usr/local/kde/lib${kdelibsuff} /usr/kde/lib${kdelibsuff} /usr/lib${kdelibsuff}/kde /usr/lib${kdelibsuff}/kde3 /usr/lib${kdelibsuff} /usr/X11R6/lib${kdelibsuff} /usr/local/lib${kdelibsuff} /opt/kde3/lib${kdelibsuff} /opt/kde/lib${kdelibsuff} /usr/X11R6/kde/lib${kdelibsuff}"
test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib${kdelibsuff} $KDEDIR $kde_libdirs"
kde_libdirs="$ac_kde_libraries $libdir $kde_libdirs"
Joachim Eibl's avatar
Joachim Eibl committed
1756 1757 1758
AC_FIND_FILE($kde_check_lib, $kde_libdirs, kde_libdir)
ac_kde_libraries="$kde_libdir"

Joachim Eibl's avatar
Joachim Eibl committed
1759 1760 1761 1762
kde_widgetdir=NO
dnl this might be somewhere else
AC_FIND_FILE("kde3/plugins/designer/kdewidgets.la", $kde_libdirs, kde_widgetdir)

Joachim Eibl's avatar
Joachim Eibl committed
1763 1764 1765 1766 1767 1768
if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/$kde_check_lib"; then
AC_MSG_ERROR([
in the prefix, you've chosen, are no KDE libraries installed. This will fail.
So, check this please and use another prefix!])
fi

Joachim Eibl's avatar
Joachim Eibl committed
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780
if test -n "$kde_widgetdir" && test ! -r "$kde_widgetdir/kde3/plugins/designer/kdewidgets.la"; then
AC_MSG_ERROR([
I can't find the designer plugins. These are required and should have been installed
by kdelibs])
fi

if test -n "$kde_widgetdir"; then
    kde_widgetdir="$kde_widgetdir/kde3/plugins/designer"
fi


if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO || test "$kde_widgetdir" = NO; then
Joachim Eibl's avatar
Joachim Eibl committed
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
  ac_cv_have_kde="have_kde=no"
else
  ac_cv_have_kde="have_kde=yes \
    ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
fi

else dnl test -z $1

  ac_cv_have_kde="have_kde=no"

fi
])dnl

eval "$ac_cv_have_kde"

if test "$have_kde" != "yes"; then
 if test "${prefix}" = NONE; then
  ac_kde_prefix="$ac_default_prefix"
 else
  ac_kde_prefix="$prefix"
 fi
 if test "$exec_prefix" = NONE; then
  ac_kde_exec_prefix="$ac_kde_prefix"
  AC_MSG_RESULT([will be installed in $ac_kde_prefix])
 else
  ac_kde_exec_prefix="$exec_prefix"
  AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
 fi

Joachim Eibl's avatar
Joachim Eibl committed
1810
 kde_libraries="${libdir}"
Joachim Eibl's avatar
Joachim Eibl committed
1811
 kde_includes="${includedir}"
Joachim Eibl's avatar
Joachim Eibl committed
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829

else
  ac_cv_have_kde="have_kde=yes \
    ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
  AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])

  kde_libraries="$ac_kde_libraries"
  kde_includes="$ac_kde_includes"
fi
AC_SUBST(kde_libraries)
AC_SUBST(kde_includes)

if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes"  || test "$kde_includes" = "/usr/include"; then
 KDE_INCLUDES=""
else
 KDE_INCLUDES="-I$kde_includes"
 all_includes="$KDE_INCLUDES $all_includes"
fi
Joachim Eibl's avatar
Joachim Eibl committed
1830 1831

KDE_DEFAULT_CXXFLAGS="-DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION"
Joachim Eibl's avatar
Joachim Eibl committed
1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847
 
KDE_LDFLAGS="-L$kde_libraries"
if test ! "$kde_libraries" = "$x_libraries" && test ! "$kde_libraries" = "$qt_libraries" ; then 
 all_libraries="$all_libraries $KDE_LDFLAGS"
fi

AC_SUBST(KDE_LDFLAGS)
AC_SUBST(KDE_INCLUDES)

AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])

all_libraries="$all_libraries $USER_LDFLAGS"
all_includes="$all_includes $USER_INCLUDES"
AC_SUBST(all_includes)
AC_SUBST(all_libraries)

Joachim Eibl's avatar
Joachim Eibl committed
1848 1849 1850 1851 1852 1853
if test -z "$1"; then
KDE_CHECK_UIC_PLUGINS
fi

ac_kde_libraries="$kde_libdir"

Joachim Eibl's avatar
Joachim Eibl committed
1854
AC_SUBST(AUTODIRS)
Joachim Eibl's avatar
Joachim Eibl committed
1855 1856


Joachim Eibl's avatar
Joachim Eibl committed
1857 1858
])

Joachim Eibl's avatar
Joachim Eibl committed
1859
AC_DEFUN([KDE_CHECK_EXTRA_LIBS],
Joachim Eibl's avatar
Joachim Eibl committed
1860 1861
[
AC_MSG_CHECKING(for extra includes)
Joachim Eibl's avatar
Joachim Eibl committed
1862
AC_ARG_WITH(extra-includes,AC_HELP_STRING([--with-extra-includes=DIR],[adds non standard include paths]),
Joachim Eibl's avatar
Joachim Eibl committed
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886
  kde_use_extra_includes="$withval",
  kde_use_extra_includes=NONE
)
kde_extra_includes=
if test -n "$kde_use_extra_includes" && \
   test "$kde_use_extra_includes" != "NONE"; then

   ac_save_ifs=$IFS
   IFS=':'
   for dir in $kde_use_extra_includes; do
     kde_extra_includes="$kde_extra_includes $dir"
     USER_INCLUDES="$USER_INCLUDES -I$dir"
   done
   IFS=$ac_save_ifs
   kde_use_extra_includes="added"
else
   kde_use_extra_includes="no"
fi
AC_SUBST(USER_INCLUDES)

AC_MSG_RESULT($kde_use_extra_includes)

kde_extra_libs=
AC_MSG_CHECKING(for extra libs)
Joachim Eibl's avatar
Joachim Eibl committed
1887
AC_ARG_WITH(extra-libs,AC_HELP_STRING([--with-extra-libs=DIR],[adds non standard library paths]),
Joachim Eibl's avatar
Joachim Eibl committed
1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912
  kde_use_extra_libs=$withval,
  kde_use_extra_libs=NONE
)
if test -n "$kde_use_extra_libs" && \
   test "$kde_use_extra_libs" != "NONE"; then

   ac_save_ifs=$IFS
   IFS=':'
   for dir in $kde_use_extra_libs; do
     kde_extra_libs="$kde_extra_libs $dir"
     KDE_EXTRA_RPATH="$KDE_EXTRA_RPATH -R $dir"
     USER_LDFLAGS="$USER_LDFLAGS -L$dir"
   done
   IFS=$ac_save_ifs
   kde_use_extra_libs="added"
else
   kde_use_extra_libs="no"
fi

AC_SUBST(USER_LDFLAGS)

AC_MSG_RESULT($kde_use_extra_libs)

])

Joachim Eibl's avatar
Joachim Eibl committed
1913
AC_DEFUN([KDE_1_CHECK_PATH_HEADERS],
Joachim Eibl's avatar
Joachim Eibl committed
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945
[
    AC_MSG_CHECKING([for KDE headers installed])
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS
cat > conftest.$ac_ext <<EOF
#ifdef STDC_HEADERS
# include <stdlib.h>
#endif
#include <stdio.h>
#include "confdefs.h"
#include <kapp.h>

int main() {
    printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
    printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
    printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
    printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
    printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
    printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
    printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
    printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
    printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
    printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
    printf("kde_wallpaperdir=\\"%s\\"\n",
	KApplication::kde_wallpaperdir().data());
    printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
    printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
    printf("kde_servicesdir=\\"/tmp/dummy\\"\n");
    printf("kde_servicetypesdir=\\"/tmp/dummy\\"\n");
    printf("kde_moduledir=\\"/tmp/dummy\\"\n");
    printf("kde_styledir=\\"/tmp/dummy\\"\n");
    printf("kde_widgetdir=\\"/tmp/dummy\\"\n");
Joachim Eibl's avatar
Joachim Eibl committed
1946
    printf("xdg_appsdir=\\"/tmp/dummy\\"\n");
Joachim Eibl's avatar
Joachim Eibl committed
1947
    printf("xdg_menudir=\\"/tmp/dummy\\"\n");
Joachim Eibl's avatar
Joachim Eibl committed
1948
    printf("xdg_directorydir=\\"/tmp/dummy\\"\n");
Joachim Eibl's avatar
Joachim Eibl committed
1949
    printf("kde_kcfgdir=\\"/tmp/dummy\\"\n");
Joachim Eibl's avatar
Joachim Eibl committed
1950 1951 1952 1953
    return 0;
    }
EOF

Joachim Eibl's avatar
Joachim Eibl committed
1954 1955
 ac_save_CPPFLAGS=$CPPFLAGS
 CPPFLAGS="$all_includes $CPPFLAGS"
Joachim Eibl's avatar
Joachim Eibl committed
1956 1957 1958 1959 1960 1961 1962
 if AC_TRY_EVAL(ac_compile); then
   AC_MSG_RESULT(yes)
 else
   AC_MSG_ERROR([your system is not able to compile a small KDE application!
Check, if you installed the KDE header files correctly.
For more details about this problem, look at the end of config.log.])
  fi
Joachim Eibl's avatar
Joachim Eibl committed
1963
  CPPFLAGS=$ac_save_CPPFLAGS
Joachim Eibl's avatar
Joachim Eibl committed
1964 1965 1966 1967

  AC_LANG_RESTORE
])

Joachim Eibl's avatar
Joachim Eibl committed
1968
AC_DEFUN([KDE_CHECK_KDEQTADDON],
Joachim Eibl's avatar
Joachim Eibl committed
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
[
AC_MSG_CHECKING(for kde-qt-addon)
AC_CACHE_VAL(kde_cv_have_kdeqtaddon,
[
 kde_ldflags_safe="$LDFLAGS"
 kde_libs_safe="$LIBS"
 kde_cxxflags_safe="$CXXFLAGS"

 LIBS="-lkde-qt-addon $LIBQT $LIBS"
 CXXFLAGS="$CXXFLAGS -I$prefix/include -I$prefix/include/kde $all_includes"
 LDFLAGS="$LDFLAGS $all_libraries $USER_LDFLAGS"

 AC_TRY_LINK([
   #include <qdom.h>
 ],
 [
   QDomDocument doc;
 ],
  kde_cv_have_kdeqtaddon=yes,
  kde_cv_have_kdeqtaddon=no
 )

 LDFLAGS=$kde_ldflags_safe
 LIBS=$kde_libs_safe
Joachim Eibl's avatar
Joachim Eibl committed
1993
 CXXFLAGS=$kde_cxxflags_safe
Joachim Eibl's avatar
Joachim Eibl committed
1994 1995 1996 1997 1998 1999 2000 2001 2002 2003
])

AC_MSG_RESULT($kde_cv_have_kdeqtaddon)

if test "$kde_cv_have_kdeqtaddon" = "no"; then
  AC_MSG_ERROR([Can't find libkde-qt-addon. You need to install it first.
It is a separate package (and CVS module) named kde-qt-addon.])
fi
])

Joachim Eibl's avatar
Joachim Eibl committed
2004
AC_DEFUN([KDE_CREATE_LIBS_ALIASES],
Joachim Eibl's avatar
Joachim Eibl committed
2005 2006 2007 2008 2009 2010
[
   AC_REQUIRE([KDE_MISC_TESTS])
   AC_REQUIRE([KDE_CHECK_LIBDL])
   AC_REQUIRE([K_PATH_X])

if test $kde_qtver = 3; then
Joachim Eibl's avatar
Joachim Eibl committed
2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
   AC_SUBST(LIB_KDECORE, "-lkdecore")
   AC_SUBST(LIB_KDEUI, "-lkdeui")
   AC_SUBST(LIB_KIO, "-lkio")
   AC_SUBST(LIB_SMB, "-lsmb")
   AC_SUBST(LIB_KAB, "-lkab")
   AC_SUBST(LIB_KABC, "-lkabc")
   AC_SUBST(LIB_KHTML, "-lkhtml")
   AC_SUBST(LIB_KSPELL, "-lkspell")
   AC_SUBST(LIB_KPARTS, "-lkparts")
   AC_SUBST(LIB_KDEPRINT, "-lkdeprint")
Joachim Eibl's avatar
Joachim Eibl committed
2021 2022
   AC_SUBST(LIB_KUTILS, "-lkutils")
   AC_SUBST(LIB_KDEPIM, "-lkdepim")
Joachim Eibl's avatar
Joachim Eibl committed
2023
# these are for backward compatibility
Joachim Eibl's avatar
Joachim Eibl committed
2024 2025
   AC_SUBST(LIB_KSYCOCA, "-lkio")
   AC_SUBST(LIB_KFILE, "-lkio")
Joachim Eibl's avatar
Joachim Eibl committed
2026
elif test $kde_qtver = 2; then
Joachim Eibl's avatar
Joachim Eibl committed
2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
   AC_SUBST(LIB_KDECORE, "-lkdecore")
   AC_SUBST(LIB_KDEUI, "-lkdeui")
   AC_SUBST(LIB_KIO, "-lkio")
   AC_SUBST(LIB_KSYCOCA, "-lksycoca")
   AC_SUBST(LIB_SMB, "-lsmb")
   AC_SUBST(LIB_KFILE, "-lkfile")
   AC_SUBST(LIB_KAB, "-lkab")
   AC_SUBST(LIB_KHTML, "-lkhtml")
   AC_SUBST(LIB_KSPELL, "-lkspell")
   AC_SUBST(LIB_KPARTS, "-lkparts")
   AC_SUBST(LIB_KDEPRINT, "-lkdeprint")
Joachim Eibl's avatar
Joachim Eibl committed
2038
else
Joachim Eibl's avatar
Joachim Eibl committed
2039 2040 2041 2042 2043
   AC_SUBST(LIB_KDECORE, "-lkdecore -lXext $(LIB_QT)")
   AC_SUBST(LIB_KDEUI, "-lkdeui $(LIB_KDECORE)")
   AC_SUBST(LIB_KFM, "-lkfm $(LIB_KDECORE)")
   AC_SUBST(LIB_KFILE, "-lkfile $(LIB_KFM) $(LIB_KDEUI)")
   AC_SUBST(LIB_KAB, "-lkab $(LIB_KIMGIO) $(LIB_KDECORE)")
Joachim Eibl's avatar
Joachim Eibl committed
2044 2045 2046
fi
])

Joachim Eibl's avatar
Joachim Eibl committed
2047
AC_DEFUN([AC_PATH_KDE],
Joachim Eibl's avatar
Joachim Eibl committed
2048 2049
[
  AC_BASE_PATH_KDE
Joachim Eibl's avatar
Joachim Eibl committed
2050
  AC_ARG_ENABLE(path-check,AC_HELP_STRING([--disable-path-check],[don't try to find out, where to install]),
Joachim Eibl's avatar
Joachim Eibl committed
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070
  [
  if test "$enableval" = "no";
    then ac_use_path_checking="default"
    else ac_use_path_checking=""
  fi
  ],
  [
  if test "$kde_qtver" = 1;
    then ac_use_path_checking=""
    else ac_use_path_checking="default"
  fi
  ]
  )

  AC_CREATE_KFSSTND($ac_use_path_checking)

  AC_SUBST_KFSSTND
  KDE_CREATE_LIBS_ALIASES
])

Joachim Eibl's avatar
Joachim Eibl committed
2071
dnl KDE_CHECK_FUNC_EXT(<func>, [headers], [sample-use], [C prototype], [autoheader define], [call if found])
Joachim Eibl's avatar
Joachim Eibl committed
2072
AC_DEFUN([KDE_CHECK_FUNC_EXT],
Joachim Eibl's avatar
Joachim Eibl committed
2073
[
Joachim Eibl's avatar
Joachim Eibl committed
2074 2075
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(kde_cv_func_$1,
Joachim Eibl's avatar
Joachim Eibl committed
2076 2077 2078 2079 2080 2081
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
save_CXXFLAGS="$CXXFLAGS"
kde_safe_LIBS="$LIBS"
LIBS="$LIBS $X_EXTRA_LIBS"
Joachim Eibl's avatar
Joachim Eibl committed
2082
if test "$GXX" = "yes"; then
Joachim Eibl's avatar
Joachim Eibl committed
2083 2084 2085
CXXFLAGS="$CXXFLAGS -pedantic-errors"
fi
AC_TRY_COMPILE([
Joachim Eibl's avatar
Joachim Eibl committed
2086
$2
Joachim Eibl's avatar
Joachim Eibl committed
2087 2088
],
[
Joachim Eibl's avatar
Joachim Eibl committed
2089
$3
Joachim Eibl's avatar
Joachim Eibl committed
2090
],
Joachim Eibl's avatar
Joachim Eibl committed
2091 2092
kde_cv_func_$1=yes,
kde_cv_func_$1=no)
Joachim Eibl's avatar
Joachim Eibl committed
2093
CXXFLAGS="$save_CXXFLAGS"
Joachim Eibl's avatar
Joachim Eibl committed
2094
LIBS="$kde_safe_LIBS"
Joachim Eibl's avatar
Joachim Eibl committed
2095 2096 2097
AC_LANG_RESTORE
])

Joachim Eibl's avatar
Joachim Eibl committed
2098 2099 2100 2101
AC_MSG_RESULT($kde_cv_func_$1)

AC_MSG_CHECKING([if $1 needs custom prototype])
AC_CACHE_VAL(kde_cv_proto_$1,
Joachim Eibl's avatar
Joachim Eibl committed
2102
[
Joachim Eibl's avatar
Joachim Eibl committed
2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117
if test "x$kde_cv_func_$1" = xyes; then
  kde_cv_proto_$1=no
else
  case "$1" in
	setenv|unsetenv|usleep|random|srandom|seteuid|mkstemps|mkstemp|revoke|vsnprintf|strlcpy|strlcat)
		kde_cv_proto_$1="yes - in libkdefakes"
		;;
	*)
		kde_cv_proto_$1=unknown
		;;
  esac
fi

if test "x$kde_cv_proto_$1" = xunknown; then

Joachim Eibl's avatar
Joachim Eibl committed
2118 2119 2120 2121 2122
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
  kde_safe_libs=$LIBS
  LIBS="$LIBS $X_EXTRA_LIBS"
  AC_TRY_LINK([
Joachim Eibl's avatar
Joachim Eibl committed
2123
$2
Joachim Eibl's avatar
Joachim Eibl committed
2124

Joachim Eibl's avatar
Joachim Eibl committed
2125
extern "C" $4;
Joachim Eibl's avatar
Joachim Eibl committed
2126 2127
],
[
Joachim Eibl's avatar
Joachim Eibl committed
2128
$3
Joachim Eibl's avatar
Joachim Eibl committed
2129
],
Joachim Eibl's avatar
Joachim Eibl committed
2130 2131 2132 2133
[ kde_cv_func_$1=yes
  kde_cv_proto_$1=yes ],
  [kde_cv_proto_$1="$1 unavailable"]
)
Joachim Eibl's avatar
Joachim Eibl committed
2134 2135
LIBS=$kde_safe_libs
AC_LANG_RESTORE
Joachim Eibl's avatar
Joachim Eibl committed
2136
fi
Joachim Eibl's avatar
Joachim Eibl committed
2137
])
Joachim Eibl's avatar
Joachim Eibl committed
2138
AC_MSG_RESULT($kde_cv_proto_$1)
Joachim Eibl's avatar
Joachim Eibl committed
2139

Joachim Eibl's avatar
Joachim Eibl committed
2140 2141 2142
if test "x$kde_cv_func_$1" = xyes; then
  AC_DEFINE(HAVE_$5, 1, [Define if you have $1])
  $6
Joachim Eibl's avatar
Joachim Eibl committed
2143
fi
Joachim Eibl's avatar
Joachim Eibl committed
2144 2145 2146
if test "x$kde_cv_proto_$1" = xno; then
  AC_DEFINE(HAVE_$5_PROTO, 1,
  [Define if you have the $1 prototype])
Joachim Eibl's avatar
Joachim Eibl committed
2147 2148
fi

Joachim Eibl's avatar
Joachim Eibl committed
2149 2150 2151 2152
AH_VERBATIM([_HAVE_$5_PROTO],
[
#if !defined(HAVE_$5_PROTO)
#ifdef __cplusplus
Joachim Eibl's avatar
Joachim Eibl committed
2153
extern "C" {
Joachim Eibl's avatar
Joachim Eibl committed
2154 2155
#endif
$4;
Joachim Eibl's avatar
Joachim Eibl committed
2156 2157 2158
#ifdef __cplusplus
}
#endif
Joachim Eibl's avatar
Joachim Eibl committed
2159 2160
#endif
])
Joachim Eibl's avatar
Joachim Eibl committed
2161 2162
])

Joachim Eibl's avatar
Joachim Eibl committed
2163
AC_DEFUN([AC_CHECK_SETENV],
Joachim Eibl's avatar
Joachim Eibl committed
2164
[
Joachim Eibl's avatar
Joachim Eibl committed
2165 2166 2167 2168 2169 2170 2171
	KDE_CHECK_FUNC_EXT(setenv, [
#include <stdlib.h>
], 
		[setenv("VAR", "VALUE", 1);],
	        [int setenv (const char *, const char *, int)],
		[SETENV])
])
Joachim Eibl's avatar
Joachim Eibl committed
2172

Joachim Eibl's avatar
Joachim Eibl committed
2173
AC_DEFUN([AC_CHECK_UNSETENV],
Joachim Eibl's avatar
Joachim Eibl committed
2174
[
Joachim Eibl's avatar
Joachim Eibl committed
2175 2176 2177 2178 2179 2180 2181 2182
	KDE_CHECK_FUNC_EXT(unsetenv, [
#include <stdlib.h>
], 
		[unsetenv("VAR");],
	        [void unsetenv (const char *)],
		[UNSETENV])
])

Joachim Eibl's avatar
Joachim Eibl committed
2183
AC_DEFUN([AC_CHECK_GETDOMAINNAME],
Joachim Eibl's avatar
Joachim Eibl committed
2184 2185
[
	KDE_CHECK_FUNC_EXT(getdomainname, [
Joachim Eibl's avatar
Joachim Eibl committed
2186 2187
#include <stdlib.h>
#include <unistd.h>
Joachim Eibl's avatar
Joachim Eibl committed
2188
#include <netdb.h>
Joachim Eibl's avatar
Joachim Eibl committed
2189 2190 2191 2192 2193
], 
		[
char buffer[200];
getdomainname(buffer, 200);
], 	
Joachim Eibl's avatar
Joachim Eibl committed
2194