]> git.lyx.org Git - lyx.git/blob - acinclude.m4
FILMagain changes (will need some work)
[lyx.git] / acinclude.m4
1 dnl Some useful functions for LyXs configure.in                 -*- sh -*-
2 dnl Author: Jean-Marc Lasgouttes (Jean-Marc.Lasgouttes@inria.fr)
3 dnl         Lars Gullik Bjønnes (larsbj@lyx.org)
4
5
6 dnl Usage LYX_GET_VERSION   Sets "lyx_version" to the version of LyX being 
7 dnl   built, displays it and sets variable "lyx_devel" to yes or no depending 
8 dnl   whether the version is a development release or not. 
9 AC_DEFUN(LYX_GET_VERSION,[
10 changequote(, ) dnl
11 VERSION=`grep '#define *LYX_VERSION' $1 |
12               sed -e 's/^.*"\(.*\)"$/\1/' 2>/dev/null`
13 echo "configuring LyX version $VERSION"
14 if echo "$VERSION" | grep 'cvs' >/dev/null ; then
15   lyx_devel_version=yes
16   echo "WARNING: This is a development version. Expect bugs."
17 else
18   lyx_devel_version=no
19 fi
20 if echo "$VERSION" | grep 'pre' > /dev/null ; then
21     lyx_prerelease=yes
22     echo "WARNING: This is a prerelease. Be careful and backup your documents."
23 else
24     lyx_prerelease=no
25 fi
26 changequote([, ]) dnl
27 PACKAGE=lyx${program_suffix}
28 AC_SUBST(lyx_devel_version)
29 if test $lyx_devel_version = yes ; then 
30   AC_DEFINE(DEVEL_VERSION, 1, Define if you are building a development version of LyX)
31 fi])
32
33 dnl Usage: LYX_ERROR(message)  Displays the warning "message" and sets the
34 dnl flag lyx_error to yes.
35 AC_DEFUN(LYX_ERROR,[
36 lyx_error_txt="$lyx_error_txt
37 ** $1
38 "
39 lyx_error=yes])
40
41
42 dnl Usage: LYX_WARNING(message)  Displays the warning "message" and sets the
43 dnl flag lyx_warning to yes.
44 AC_DEFUN(LYX_WARNING,[
45 lyx_warning_txt="$lyx_warning_txt
46 == $1
47 "
48 lyx_warning=yes])
49
50
51 dnl Usage: LYX_LIB_ERROR(file,library)  Displays an error message indication 
52 dnl  that 'file' cannot be found because 'lib' may be uncorrectly installed.
53 AC_DEFUN(LYX_LIB_ERROR,[
54 LYX_ERROR([Cannot find $1. Please check that the $2 library
55    is correctly installed on your system.])])
56
57
58 dnl Usage: LYX_CHECK_ERRORS  Displays a warning message if a LYX_ERROR
59 dnl   has occured previously. 
60 AC_DEFUN(LYX_CHECK_ERRORS,[
61 if test x$lyx_error = xyes; then
62 cat <<EOF
63 **** The following problems have been detected by configure. 
64 **** Please check the messages below before running 'make'.
65 **** (see the section 'Problems' in the INSTALL file)
66 $lyx_error_txt
67 $lyx_warning_txt
68 deleting cache $cache_file
69 EOF
70   rm -f $cache_file
71 else
72
73 if test x$lyx_warning = xyes; then
74 cat <<EOF
75 === The following minor problems have been detected by configure. 
76 === Please check the messages below before running 'make'.
77 === (see the section 'Problems' in the INSTALL file)
78 $lyx_warning_txt
79 EOF
80 fi
81 cat <<EOF
82 Configuration of LyX was successful.  
83 Type 'make' to compile the program, 
84 and then 'make install' to install it.
85 EOF
86 fi])
87
88
89 dnl LYX_SEARCH_PROG(VARIABLE-NAME,PROGRAMS-LIST,ACTION-IF-FOUND)
90 dnl             
91 define(LYX_SEARCH_PROG,[dnl
92 for ac_prog in $2 ; do
93 # Extract the first word of "$ac_prog", so it can be a program name with args.
94   set dummy $ac_prog ; ac_word=$[2]
95   if test -z "[$]$1"; then
96     IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS=":"
97     for ac_dir in $PATH; do
98       test -z "$ac_dir" && ac_dir=.
99       if test -f [$ac_dir/$ac_word]; then
100         $1="$ac_prog"
101         break
102       fi
103     done
104     IFS="$ac_save_ifs"
105   fi
106
107   if test -n "[$]$1"; then
108     ac_result=yes
109   else
110     ac_result=no
111   fi
112   ifelse($3,,,[$3])
113   test -n "[$]$1" && break
114 done
115 ])dnl
116
117
118 AC_DEFUN(LYX_PROG_CXX_WORKS,
119 [AC_LANG_SAVE
120 AC_LANG_CPLUSPLUS
121 AC_TRY_COMPILER([class foo { int bar; }; int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
122 AC_LANG_RESTORE
123 if test $ac_cv_prog_cxx_works = no; then
124   CXX=
125 fi
126 cross_compiling=$ac_cv_prog_cxx_cross
127 ])
128
129
130 AC_DEFUN(LYX_PROG_CXX,
131 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
132 AC_MSG_CHECKING([for a working C++ compiler])
133 LYX_SEARCH_PROG(CXX, $CCC g++ gcc c++ CC cxx xlC cc++, LYX_PROG_CXX_WORKS)
134
135 if test -z "$CXX" ; then
136   AC_ERROR([Unable to find a working C++ compiler])
137 fi
138
139 AC_SUBST(CXX)
140 AC_MSG_RESULT($CXX)
141
142 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
143 AC_MSG_RESULT($cross_compiling)
144
145 AC_PROG_CXX_GNU
146
147 dnl We might want to get or shut warnings.
148 AC_ARG_WITH(warnings,
149   [  --with-warnings         tell the compiler to display more warnings],,
150   [ if test $lyx_devel_version = yes -o $lyx_prerelease = yes && test $ac_cv_prog_gxx = yes ; then
151         with_warnings=yes;
152     else
153         with_warnings=no;
154     fi;])
155 if test x$with_warnings = xyes ; then
156   lyx_flags="$lyx_flags warnings"
157   AC_DEFINE(WITH_WARNINGS, 1,
158   [Define this if you want to see the warning directives put here and
159    there by the developpers to get attention])
160 fi
161
162 # optimize less for development versions
163 if test $lyx_devel_version = yes -o $lyx_prerelease = yes ; then
164   lyx_opt="-O"
165 else
166   lyx_opt="-O2"
167 fi
168
169 # set the debug flags correctly.
170 if test $ac_cv_prog_gxx = yes; then
171   GXX=yes
172 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
173 dnl plays around with CXXFLAGS (such as to build both debugging and
174 dnl normal versions of a library), tasteless as that idea is.
175   ac_test_CXXFLAGS="${CXXFLAGS+set}"
176   ac_save_CXXFLAGS="$CXXFLAGS"
177   CXXFLAGS=
178 dnl Check the version of g++
179   gxx_version=`${CXX} --version`
180   
181   AC_PROG_CXX_G
182   if test "$ac_test_CXXFLAGS" = set; then
183     CXXFLAGS="$ac_save_CXXFLAGS"
184   elif test $ac_cv_prog_cxx_g = yes; then
185     case $gxx_version in
186       2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
187       2.95.*)  CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
188       2.96*)   CXXFLAGS="-g $lyx_opt -fhonor-std";;
189       *2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
190       *)       CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
191     esac
192   else
193     CXXFLAGS="$lyx_opt"
194   fi
195   if test x$with_warnings = xyes ; then
196     case $gxx_version in
197         2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
198         2.96*)  CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
199         *)      CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
200     esac
201     if test $lyx_devel_version = yes ; then
202         case $gxx_version in
203             2.95.*) ;;
204             2.96*) ;;
205             *2.91*) ;;
206             *) CXXFLAGS="$CXXFLAGS -pedantic";;
207         esac
208     fi
209   fi
210 else
211   GXX=
212   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
213 fi
214 ])dnl
215
216
217 dnl Usage: LYX_CXX_RTTI : checks whether the C++ compiler
218 dnl   supports RTTI
219 AC_DEFUN(LYX_CXX_RTTI,[
220 ### Check whether the compiler supports runtime type information
221 AC_CACHE_CHECK(whether the C++ compiler supports RTTI,lyx_cv_rtti,
222  [AC_TRY_RUN([
223 class rtti {
224 public:
225    virtual int tag() { return 0; }
226 };
227 class derived1 : public rtti {
228 public:
229     int tag() { return 1; }
230 };
231 class derived2 : public rtti {
232 public:
233     int tag() { return 2; }
234 };
235 int main() {
236     derived1 * foo1 = new derived1();
237     derived2 * foo2 = new derived2();
238     rtti * bar = foo1;
239     derived1 * bar1 = dynamic_cast<derived1 *>(bar);
240     if (bar1 == 0)
241         exit(1);
242     bar = foo2;
243     bar1 = dynamic_cast<derived1 *>(bar);
244     if (bar1 != 0)
245         exit(1);
246     return 0;
247 }
248 ],lyx_cv_rtti=yes,lyx_cv_rtti=no,lyx_cv_rtti=no)
249 ])
250 if test x$lyx_cv_rtti = xyes ; then
251   AC_DEFINE(HAVE_RTTI, 1, 
252    [Define to 1 if your compiler supports runtime type information])
253 fi])
254
255
256 dnl Usage: LYX_CXX_EXPLICIT : checks whether the C++ compiler
257 dnl   understands the "explicit" directive.
258 AC_DEFUN(LYX_CXX_EXPLICIT,[
259 ### Check whether the compiler understands the keyword `explicit'
260 AC_CACHE_CHECK(whether the C++ compiler understands explicit,lyx_cv_explicit,
261  [AC_TRY_COMPILE([
262 class Expl {
263 public:
264         explicit Expl() {};
265 };],,lyx_cv_explicit=yes,lyx_cv_explicit=no)
266 ])
267 if test $lyx_cv_explicit = no ; then
268   AC_DEFINE(explicit,[ ], 
269    [Define to nothing if your compiler does not understand the
270    'explicit' directive])
271 fi])
272
273
274 dnl Usage: LYX_CXX_STL_STACK : checks whether the C++ compiler
275 dnl   has a working stl stack template
276 AC_DEFUN(LYX_CXX_STL_STACK,[
277 AC_CACHE_CHECK(for broken STL stack template,lyx_cv_broken_stack,
278  [AC_TRY_COMPILE([
279 #include <stack>
280 using std::stack;
281 ],[
282     stack<int> stakk;
283     stakk.push(0);
284 ],lyx_cv_broken_stack=no,lyx_cv_broken_stack=yes)
285 ])
286 if test $lyx_cv_broken_stack = yes ; then
287   AC_DEFINE(BROKEN_STL_STACK, 1, 
288    [Define if you have the STL from libg++ 2.7.x, where stack<> is not defined
289    correctly])
290 fi])
291
292
293 dnl Usage: LYX_STD_COUNT : checks wherer the C++ library have a conforming
294 dnl    count template, if not the old HP version is assumed.
295 AC_DEFUN(LYX_STD_COUNT,[
296 AC_CACHE_CHECK(for conforming std::count,lyx_cv_std_count,
297  [AC_TRY_COMPILE([
298 #include <string>
299 #include <algorithm>
300 using std::string;
301 using std::count;
302 int countChar(string const & a, char const c)
303 {
304         return count(a.begin(), a.end(), c);
305 }
306 ],[
307     string a("hello");
308     int i = countChar(a, 'l');
309 ],lyx_cv_std_count=yes,lyx_cv_std_count=no)
310 ])
311 if test $lyx_cv_std_count = yes ; then
312     AC_DEFINE(HAVE_STD_COUNT, 1,
313     [Define if you have a conforming std::count template, otherwise HP version of count template is assumed.])
314 fi])
315
316
317 dnl Usage: LYX_CXX_STL_MODERN_STREAMS : checks whether the C++ compiler
318 dnl   supports modern STL streams
319 AC_DEFUN(LYX_CXX_STL_MODERN_STREAMS,[
320 AC_CACHE_CHECK(for modern STL streams,lyx_cv_modern_streams,
321  [AC_TRY_COMPILE([
322 #include <iostream>
323 ],[
324  std::streambuf * test = std::cerr.rdbuf();
325  test->pubsync();
326 ],lyx_cv_modern_streams=yes,lyx_cv_modern_streams=no)
327 ])
328 if test $lyx_cv_modern_streams = yes ; then
329   AC_DEFINE(MODERN_STL_STREAMS, 1, 
330    [Define if you have modern standard-compliant STL streams])
331 fi])
332
333
334 dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler
335 dnl   has a working stl string container, the check is really stupid
336 dnl   and could need some improvement.
337 AC_DEFUN(LYX_CXX_STL_STRING,[
338     AC_REQUIRE([LYX_PROG_CXX])
339     AC_MSG_CHECKING(whether the included std::string should be used)
340     AC_ARG_WITH(included-string,
341        [  --with-included-string  use LyX string class instead of STL string],
342        [with_included_string=$withval],
343        [AC_TRY_COMPILE([
344             #include <string>
345             using std::string;
346         ],[
347             string a("hello there");
348             a.erase();
349             a = "hey";
350             char s[] = "y";
351             int t = a.compare(a.length() - 1, 1, s);
352             a.erase();
353         ],[
354             with_included_string=no
355         ],[
356             with_included_string=yes
357             
358         ])
359     ])
360     if test x$with_included_string = xyes ; then
361         AC_DEFINE(USE_INCLUDED_STRING, 1,
362             [Define to use the lyxstring class bundled with LyX.])
363             lyx_flags="$lyx_flags included-string"
364     fi
365     AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes)
366     AC_MSG_RESULT([$with_included_string])
367 ])
368
369
370 dnl Usage: LYX_REGEX : checks if the header regex.h is available
371 dnl   if it is not available the automake variable USE_REGEX will be
372 dnl   defined and the regex.h and regex.c that we provide will be used.
373 AC_DEFUN(LYX_REGEX,[
374     AC_CHECK_HEADERS(regex.h, lyx_regex=no, lyx_regex=yes)
375     AM_CONDITIONAL(USE_REGEX, test x$lyx_regex = xyes)
376 ])
377
378
379 dnl LYX_CXX_MUTABLE
380 AC_DEFUN(LYX_CXX_MUTABLE, [
381 AC_REQUIRE([LYX_PROG_CXX])
382 AC_MSG_CHECKING(if C++ compiler supports mutable)
383 AC_TRY_COMPILE(
384 [
385 class k {       
386         mutable char *c;
387 public:
388    void foo() const { c=0; }
389 };
390 ],[
391 ],[
392   ac_mutable=yes
393   AC_DEFINE(HAVE_MUTABLE, 1, 
394    [Defined if you compiler supports 'mutable'.])
395 ],[
396   ac_mutable=no
397 ]) 
398 AC_MSG_RESULT([$ac_mutable])
399 ])
400
401
402 dnl LYX_CXX_PARTIAL
403 AC_DEFUN(LYX_CXX_PARTIAL, [
404 AC_REQUIRE([LYX_PROG_CXX])
405 AC_MSG_CHECKING(if C++ compiler supports partial specialization)
406 AC_TRY_COMPILE(
407 [
408 template<class T, class K>
409 class k {       
410 public:
411 };
412 template<class T> class k<void,T> { };
413 ],[
414   k<float, float> b;
415   k<void,void> a;
416 ],[
417   ac_partial_specialization=yes
418   AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION, 1, 
419    [Defined if your compiler supports partial specialization.])
420 ],[
421   ac_partial_specialization=no
422 ]) 
423 AC_MSG_RESULT([$ac_partial_specialization])
424 ])
425
426
427 dnl Usage: LYX_CXX_NAMESPACES : checks whether the C++ compiler
428 dnl   has a correct namespace handling and define CXX_WORKING_NAMESPACES 
429 dnl   if true. This macro does not do a thourough test, but it should be 
430 dnl   good enough to suit our needs.
431 AC_DEFUN(LYX_CXX_NAMESPACES,[
432 AC_CACHE_CHECK(for correct namespaces support,lyx_cv_cxx_namespace,
433  [AC_TRY_COMPILE([
434   namespace foo {
435     int bar;
436   }
437 ],[
438         foo::bar = 0;
439         return 0;
440 ],lyx_cv_cxx_namespace=yes,lyx_cv_cxx_namespace=no)
441 ])
442 if test $lyx_cv_cxx_namespace = yes ; then
443   AC_DEFINE(CXX_WORKING_NAMESPACES, 1, 
444    [Define if your C++ compiler has correct support for namespaces])
445 fi])
446
447
448 dnl Usage: LYX_CXX_CHEADERS : checks whether the C++ compiler
449 dnl   provides wrappers for C headers and use our alternate version otherwise.
450 AC_DEFUN(LYX_CXX_CHEADERS,[
451 AC_CACHE_CHECK(for C headers wrappers,lyx_cv_cxx_cheaders,
452  [AC_TRY_CPP([
453 #include <clocale>
454 #include <cctype>
455 #include <cerrno>
456 #include <cmath>
457 #include <csignal>
458 #include <cstdio>
459 #include <cstdlib>
460 #include <cstring>
461 #include <ctime>],[lyx_cv_cxx_cheaders=yes],[lyx_cv_cxx_cheaders=no])])
462 if test $lyx_cv_cxx_cheaders = no ; then
463   LYX_ADD_INC_DIR(lyx_cppflags,\$(top_srcdir)/src/cheaders)  
464 fi])
465
466
467 dnl Usage LYX_PATH_XPM: Checks for xpm library and header
468 AC_DEFUN(LYX_PATH_XPM,[
469 ### Check for Xpm library
470 AC_CHECK_LIB(Xpm, XpmCreateBufferFromImage,LYX_LIBS="-lXpm $LYX_LIBS",
471         [LYX_LIB_ERROR(libXpm,Xpm)], $LYX_LIBS)
472
473 ### Check for Xpm headers
474 lyx_cv_xpm_h_location="<xpm.h>"
475 AC_CHECK_HEADER(X11/xpm.h,[
476   ac_cv_header_xpm_h=yes
477   lyx_cv_xpm_h_location="<X11/xpm.h>"],[
478 AC_CHECK_HEADER(xpm.h,[],[
479 LYX_LIB_ERROR(xpm.h,Xpm)])])
480 AC_DEFINE_UNQUOTED(XPM_H_LOCATION,$lyx_cv_xpm_h_location)
481
482 ### Test for the header version
483 if test $ac_cv_header_xpm_h = yes; then
484   AC_CACHE_CHECK([xpm header version],lyx_cv_xpmversion,
485   [ cat > conftest.$ac_ext <<EOF
486 #line __oline__ "configure"
487 #include "confdefs.h"
488
489 #include XPM_H_LOCATION
490 "%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
491 EOF
492     eval `(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
493       grep '^"%%%"'  2>/dev/null | \
494       sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
495     case "$lyx_cv_xpmr" in
496 changequote(,)
497      [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
498             lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
499 changequote([,])
500          *) ;;
501     esac
502     lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
503     rm -f conftest*])
504   case "$lyx_cv_xpmr" in 
505 changequote(,)
506         [789]|[0-9][0-9]*) ;;
507 changequote([,])
508         *) LYX_WARNING([Version $lyx_cv_xpmversion of the Xpm library is a bit old. 
509    If you experience strange crashes with LyX, try to upgrade 
510    to at least version 4.7 (aka 3.4g).
511    If you have installed a newer version of the library, check whether you
512    have an old xpm.h header file in your include path.]);;
513   esac
514 fi])
515
516
517 dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
518 AC_DEFUN(LYX_PATH_XFORMS,[
519 ### Check for xforms library
520 AC_CHECK_LIB(forms, fl_initialize, LYX_LIBS="-lforms $LYX_LIBS", 
521   [AC_CHECK_LIB(xforms, fl_initialize, LYX_LIBS="-lxforms $LYX_LIBS", 
522     [LYX_LIB_ERROR(libforms or libxforms,xforms)], $LYX_LIBS)], $LYX_LIBS) 
523
524 ### Check for xforms headers
525 lyx_cv_forms_h_location="<forms.h>"
526 AC_CHECK_HEADER(X11/forms.h,[
527   ac_cv_header_forms_h=yes
528   lyx_cv_forms_h_location="<X11/forms.h>"],[
529 AC_CHECK_HEADER(forms.h,[],[
530 LYX_LIB_ERROR(forms.h,forms)])])
531 AC_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
532 if test $ac_cv_header_forms_h = yes; then
533   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
534   [ cat > conftest.$ac_ext <<EOF
535 #line __oline__ "configure"
536 #include "confdefs.h"
537
538 #include FORMS_H_LOCATION
539 #if ! defined(FL_INCLUDE_VERSION)
540 "%%%"(unknown)"%%%"
541 #else
542 "%%%"FL_VERSION.FL_REVISION"%%%"
543 #endif
544 EOF
545 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
546   grep '^"%%%"'  2>/dev/null | \
547   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
548 rm -f conftest*])
549 case "$lyx_cv_xfversion" in 
550   "(unknown)"|0.8[1-7]) 
551          LYX_ERROR(dnl
552 Version $lyx_cv_xfversion of xforms is not compatible with LyX. 
553    This version of LyX works best with versions 0.88 (recommended) and later.) ;;
554     0.88) ;;
555     0.89) LYX_WARNING(dnl
556 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
557 it is an unproven version and might still have some bugs. If you
558 have problems[,] please use version 0.88 instead.) ;;
559        *) LYX_WARNING(dnl
560 Version $lyx_cv_xfversion of xforms might not be compatible with LyX[,] 
561  since it is newer than 0.88. You might have slight problems with it.);;
562 esac
563 fi])
564
565
566 dnl Usage: LYX_HPUX  Checks for HP-UX and update CXXFLAGS accordingly
567 AC_DEFUN(LYX_HPUX,
568 [#It seems that HPUX requires using -fpcc-struct-return with gcc.
569 AC_CACHE_CHECK(for HP-UX,ac_cv_hpux,[
570 os=`uname -s | tr '[A-Z]' '[a-z]'`
571 ac_cv_hpux=no
572 test "$os" = hp-ux && ac_cv_hpux=yes])
573 if test "$ac_cv_hpux" = yes; then
574  test "x$GXX" = xyes && CXXFLAGS="$CXXFLAGS -fpcc-struct-return"
575 fi])
576
577
578 dnl Usage: LYX_SUNOS4 Checks for SunOS 4.x and sets the flag lyx_broken_headers
579 dnl   if necessary
580 AC_DEFUN(LYX_SUNOS4,
581 [#The headers are not correct under SunOS4
582 AC_CACHE_CHECK(for SunOS 4.x,ac_cv_sunos4,[
583 changequote(, ) dnl
584 os=`uname -a | sed -e 's/^\([^ ]*\) [^ ]* \([0-9]\)\..*/\1\2/'`
585 changequote([, ]) dnl
586 ac_cv_sunos4=no
587 test "$os" = SunOS4 && ac_cv_sunos4=yes])
588 if test "$ac_cv_sunos4" = yes; then
589  test "x$GXX" = xyes && lyx_broken_headers=yes
590 fi])
591
592
593 dnl Usage: LYX_SCO Checks for SCO and sets the flag lyx_broken_headers
594 dnl   if necessary
595 AC_DEFUN(LYX_SCO,
596 [AC_CACHE_CHECK(for SCO 3.2v4,ac_cv_sco,[
597 ac_cv_sco=no
598 if test `uname -s` != "SCO_SV"; then
599   lyx_machine_rel=`uname -m`:`uname -r`
600   if test $lyx_machine_rel = i386:3.2 || test $lyx_machine_rel = i486:3.2;
601   then
602     if test -f /usr/options/cb.name; then
603       ac_cv_sco=no
604     elif /bin/uname -X 2>/dev/null >/dev/null ; then
605       ac_cv_sco=yes
606     fi
607   fi
608 fi])
609 if test "$ac_cv_sco" = yes; then
610  test "x$GXX" = xyes && lyx_broken_headers=yes
611 fi])
612
613 dnl Usage: LYX_FUNC_PUTENV_ARGTYPE
614 dnl Checks whether putenv() takes 'char const *' or 'char *' as
615 dnl argument. This is needed because Solaris 7 (wrongly?) uses 'char *', 
616 dnl while everybody else uses the former...
617 AC_DEFUN(LYX_FUNC_PUTENV_ARGTYPE,
618 [AC_MSG_CHECKING([type of argument for putenv()])
619  AC_CACHE_VAL(lyx_cv_func_putenv_arg,dnl
620   [AC_TRY_COMPILE(dnl
621 [#include <cstdlib>],
622 [char const * foo = "bar";
623  putenv(foo);],dnl
624    [lyx_cv_func_putenv_arg='char const *'],[lyx_cv_func_putenv_arg='char *'])])
625  AC_MSG_RESULT($lyx_cv_func_putenv_arg)
626  AC_DEFINE_UNQUOTED(PUTENV_TYPE_ARG,$lyx_cv_func_putenv_arg,dnl
627    [Define to the type of the argument of putenv(). Needed on Solaris 7.])])
628
629
630 dnl Usage: LYX_WITH_DIR(dir-name,desc,dir-var-name,default-value, 
631 dnl                       [default-yes-value])  
632 dnl  Adds a --with-'dir-name' option (described by 'desc') and puts the 
633 dnl  resulting directory name in 'dir-var-name'.
634 AC_DEFUN(LYX_WITH_DIR,[
635   AC_ARG_WITH($1,[  --with-$1        specify $2])
636   AC_MSG_CHECKING([for $2])
637   if test -z "$with_$3"; then
638      AC_CACHE_VAL(lyx_cv_$3, lyx_cv_$3=$4)
639   else
640     test "x$with_$3" = xyes && with_$3=$5
641     lyx_cv_$3="$with_$3"
642   fi
643   AC_MSG_RESULT($lyx_cv_$3)])
644
645
646 dnl Usage: LYX_LOOP_DIR(value,action)
647 dnl Executes action for values of variable `dir' in `values'. `values' can 
648 dnl use ":" as a separator.
649 AC_DEFUN(LYX_LOOP_DIR,[
650 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
651 for dir in `eval "echo $1"`; do
652   if test ! "$dir" = NONE; then
653     test ! -d "$dir" && AC_ERROR([\"$dir\" is not a directory])
654     $2
655   fi
656 done
657 IFS=$ac_save_ifs
658 ])
659
660
661 dnl Usage: LYX_ADD_LIB_DIR(var-name,dir) Adds a -L directive to variable 
662 dnl var-name. 
663 AC_DEFUN(LYX_ADD_LIB_DIR,[
664 $1="${$1} -L$2"
665 if test "`(uname) 2>/dev/null`" = SunOS &&
666     uname -r | grep '^5' >/dev/null; then
667   if test $ac_cv_prog_gxx = yes ; then 
668     $1="${$1} -Wl[,]-R$2" 
669   else
670     $1="${$1} -R$2"
671   fi
672 fi])
673
674
675 dnl Usage: LYX_ADD_INC_DIR(var-name,dir) Adds a -I directive to variable 
676 dnl var-name. 
677 AC_DEFUN(LYX_ADD_INC_DIR,[$1="${$1} -I$2 "])
678
679 ### Check which libsigc++ we're using and make sure any external one works
680 ### Check for libsigc++ library
681 AC_DEFUN(LYX_WITH_SIGC,
682 [AC_MSG_CHECKING(whether the included libsigc++ should be used)
683 AC_ARG_WITH([included-libsigc],
684   [  --without-included-libsigc
685                              Use the libsigc++ installed on the system],
686   [lyx_use_included_libsigc=$withval],
687   [lyx_use_included_libsigc=yes])
688 AC_MSG_RESULT([$lyx_use_included_libsigc])
689 if test x$lyx_use_included_libsigc = xno; then
690   ### Check for libsigc++
691   ## can't use AC_SUBST right here!
692   AM_PATH_SIGC(0.8.7,
693     [ INCLUDED_SIGC=
694     ],
695     [LYX_ERROR(dnl
696     [Cannot find libsigc++ library or headers at least as recent as 0.8.7.
697      Check your installation.  Have you installed the development package?])
698   ])
699 else
700   ### Use the included libsigc++
701   ### sigc-config hasn't been created yet so we can't just do the same as above
702   ### unless of course someone gets keen and merges the sigc++ configure.in 
703   ### with this one.  We don't really gain much by doing that though except
704   ### a considerably smaller dist and more difficult maintenance.
705   ### It'd also mean we'd have the equivalent of config/gettext.m4
706   lyx_flags="$lyx_flags included-libsigc"
707   SIGC_LIBS="\`\${top_builddir}/sigc++/sigc-config --libs-names | sed -e 's/-lsigc//'\`"
708   # Libsigc++ always installs into a subdirectory called sigc++.  Therefore we
709   # have to always use #include <sigc++/signal_system.h> in our code.
710   # Remember if you decide to do anything to the sigc++ code to do your mods on
711   # the makeLyXsigc.sh script in development/tools using a current cvs checkout
712   # of libsigc++.  A tarball distribution doesn't have everything in it that we
713   # need.
714   # We need both these -I entries to build when builddir != srcdir
715   if test "x$src_dir" = "x." ; then
716     SIGC_CFLAGS="-I\${top_srcdir}"
717   else
718     SIGC_CFLAGS="-I\${top_builddir} -I\${top_srcdir}"
719   fi
720   INCLUDED_SIGC="\${top_builddir}/sigc++/libsigc.la"
721   ## can't substitute these here like this otherwise all remaining tests fail
722   ## instead we SUBST directly into the Makefiles
723   ##LIBS="$LIBS \$SIGC_LIBS"
724   ##CPPFLAGS="$CPPFLAGS \$SIGC_CFLAGS"
725   AC_SUBST(SIGC_LIBS)
726   AC_SUBST(SIGC_CFLAGS)
727 fi
728 AC_SUBST(INCLUDED_SIGC)
729 ])
730
731 ### Check for a headers existence and location iff it exists
732 ## This is supposed to be a generalised version of LYX_STL_STRING_FWD
733 ## It almost works.  I've tried a few variations but they give errors
734 ## of one sort or other: bad substitution or file not found etc.  The
735 ## actual header _is_ found though and the cache variable is set however
736 ## the reported setting (on screen) is equal to $ac_safe for some unknown
737 ## reason.
738 AC_DEFUN(LYX_PATH_HEADER,
739 [ AC_CHECK_HEADER($1,[
740   ac_tr_safe=PATH_`echo $ac_safe | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
741   AC_CACHE_CHECK([path to $1],lyx_cv_path_$ac_safe,
742   [ cat > conftest.$ac_ext <<EOF
743 #line __oline__ "configure"
744 #include "confdefs.h"
745
746 #include <$1>
747 EOF
748 lyx_cv_path_$ac_safe=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
749   grep $1  2>/dev/null | \
750   sed -e 's/.*\(".*$1"\).*/\1/' -e "1q"`
751 rm -f conftest*])
752   AC_DEFINE_UNQUOTED(${ac_tr_safe},${lyx_cv_path_$ac_safe})])
753 ])
754 ### end of LYX_PATH_HEADER
755
756 ### Check for stl_string_fwd.h existence and location if it exists
757 AC_DEFUN(LYX_STL_STRING_FWD,
758 [ AC_CHECK_HEADER(stl_string_fwd.h,[
759   AC_CACHE_CHECK([path to stl_string_fwd.h],lyx_cv_path_stl_string_fwd_h,
760   [ cat > conftest.$ac_ext <<EOF
761 #line __oline__ "configure"
762 #include "confdefs.h"
763
764 #include <stl_string_fwd.h>
765 EOF
766 lyx_cv_path_stl_string_fwd_h=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
767   grep 'stl_string_fwd.h'  2>/dev/null | \
768   sed -e 's/.*\(".*stl_string_fwd.h"\).*/\1/' -e "1q"`
769 rm -f conftest*])
770   AC_DEFINE_UNQUOTED(STL_STRING_FWD_H_LOCATION,$lyx_cv_path_stl_string_fwd_h,
771 [define this to the location of stl_string_fwd.h to be used with #include,
772   NOTE: Do not set it to <stl_string_fwd.h> as that will find the LyX
773         supplied version of the header.
774   e.g. <../include/stl_string_fwd.h> or better yet use an absolute path])])
775 ])
776
777
778 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
779 dnl if the cache file is inconsistent with the current host,
780 dnl target and build system types, execute CMD or print a default
781 dnl error message.
782 AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
783     AC_REQUIRE([AC_CANONICAL_SYSTEM])
784     AC_MSG_CHECKING([config.cache system type])
785     if { test x"${ac_cv_host_system_type+set}" = x"set" &&
786          test x"$ac_cv_host_system_type" != x"$host"; } ||
787        { test x"${ac_cv_build_system_type+set}" = x"set" &&
788          test x"$ac_cv_build_system_type" != x"$build"; } ||
789        { test x"${ac_cv_target_system_type+set}" = x"set" &&
790          test x"$ac_cv_target_system_type" != x"$target"; }; then
791         AC_MSG_RESULT([different])
792         ifelse($#, 1, [$1],
793                 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
794     else
795         AC_MSG_RESULT([same])
796     fi
797     ac_cv_host_system_type="$host"
798     ac_cv_build_system_type="$build"
799     ac_cv_target_system_type="$target"
800 ])
801
802 dnl We use this until autoconf fixes its version.
803 AC_DEFUN(LYX_FUNC_SELECT_ARGTYPES,
804 [AC_MSG_CHECKING([types of arguments for select()])
805  AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
806  [AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
807   [AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
808    [for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
809      for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do      for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
810        AC_TRY_COMPILE(dnl
811 [#ifdef HAVE_SYS_TYPES_H
812 #include <sys/types.h>
813 #endif
814 #ifdef HAVE_SYS_TIME_H
815 #include <sys/time.h>
816 #endif
817 #ifdef HAVE_SYS_SELECT_H
818 #include <sys/select.h>
819 #endif
820 #ifdef HAVE_SYS_SOCKET_H
821 #include <sys/socket.h>
822 #endif
823 extern int select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
824         [ac_not_found=no ; break 3],ac_not_found=yes)
825       done
826      done
827     done
828    ])dnl AC_CACHE_VAL
829   ])dnl AC_CACHE_VAL
830  ])dnl AC_CACHE_VAL
831  if test "$ac_not_found" = yes; then
832   ac_cv_func_select_arg1=int 
833   ac_cv_func_select_arg234='int *' 
834   ac_cv_func_select_arg5='struct timeval *'
835  fi
836  AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
837  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1,$ac_cv_func_select_arg1)
838  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234,($ac_cv_func_select_arg234))
839  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5,($ac_cv_func_select_arg5))
840 ])
841
842 ### Check which frontend we want to use. The default is XForms
843 ###
844 AC_DEFUN(LYX_USE_FRONTEND,
845 [AC_MSG_CHECKING(what frontend should be used as main GUI)
846 AC_ARG_WITH(frontend,
847   [  --with-frontend[=value] Use THIS frontend as main GUI:
848                           Possible values: xforms,kde],
849   [lyx_use_frontend="$withval"], [lyx_use_frontend="xforms"])
850 AC_MSG_RESULT($lyx_use_frontend)
851 lyx_flags="$lyx_flags frontend-$lyx_use_frontend"
852 AC_SUBST(FRONTEND)
853 AC_SUBST(FRONTEND_GUILIB)
854 AC_SUBST(FRONTEND_LDFLAGS)
855 AC_SUBST(FRONTEND_INCLUDES)
856 AC_SUBST(FRONTEND_LIBS)
857 ])
858 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
859 ## Copyright (C) 1996-1999 Free Software Foundation, Inc.
860 ## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
861 ##
862 ## This program is free software; you can redistribute it and/or modify
863 ## it under the terms of the GNU General Public License as published by
864 ## the Free Software Foundation; either version 2 of the License, or
865 ## (at your option) any later version.
866 ##
867 ## This program is distributed in the hope that it will be useful, but
868 ## WITHOUT ANY WARRANTY; without even the implied warranty of
869 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
870 ## General Public License for more details.
871 ##
872 ## You should have received a copy of the GNU General Public License
873 ## along with this program; if not, write to the Free Software
874 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
875 ##
876 ## As a special exception to the GNU General Public License, if you
877 ## distribute this file as part of a program that contains a
878 ## configuration script generated by Autoconf, you may include it under
879 ## the same distribution terms that you use for the rest of that program.
880
881 # serial 40 AC_PROG_LIBTOOL
882 AC_DEFUN(AC_PROG_LIBTOOL,
883 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
884
885 # Save cache, so that ltconfig can load it
886 AC_CACHE_SAVE
887
888 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
889 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
890 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
891 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
892 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
893 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
894 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
895 || AC_MSG_ERROR([libtool configure failed])
896
897 # Reload cache, that may have been modified by ltconfig
898 AC_CACHE_LOAD
899
900 # This can be used to rebuild libtool when needed
901 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
902
903 # Always use our own libtool.
904 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
905 AC_SUBST(LIBTOOL)dnl
906
907 # Redirect the config.log output again, so that the ltconfig log is not
908 # clobbered by the next message.
909 exec 5>>./config.log
910 ])
911
912 AC_DEFUN(AC_LIBTOOL_SETUP,
913 [AC_PREREQ(2.13)dnl
914 AC_REQUIRE([AC_ENABLE_SHARED])dnl
915 AC_REQUIRE([AC_ENABLE_STATIC])dnl
916 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
917 AC_REQUIRE([AC_CANONICAL_HOST])dnl
918 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
919 AC_REQUIRE([AC_PROG_RANLIB])dnl
920 AC_REQUIRE([AC_PROG_CC])dnl
921 AC_REQUIRE([AC_PROG_LD])dnl
922 AC_REQUIRE([AC_PROG_NM])dnl
923 AC_REQUIRE([AC_PROG_LN_S])dnl
924 dnl
925
926 case "$target" in
927 NONE) lt_target="$host" ;;
928 *) lt_target="$target" ;;
929 esac
930
931 # Check for any special flags to pass to ltconfig.
932 libtool_flags="--cache-file=$cache_file"
933 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
934 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
935 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
936 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
937 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
938 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
939 [libtool_flags="$libtool_flags --enable-dlopen"])
940 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
941 [libtool_flags="$libtool_flags --enable-win32-dll"])
942 AC_ARG_ENABLE(libtool-lock,
943   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
944 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
945 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
946
947 # Some flags need to be propagated to the compiler or linker for good
948 # libtool support.
949 case "$lt_target" in
950 *-*-irix6*)
951   # Find out which ABI we are using.
952   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
953   if AC_TRY_EVAL(ac_compile); then
954     case "`/usr/bin/file conftest.o`" in
955     *32-bit*)
956       LD="${LD-ld} -32"
957       ;;
958     *N32*)
959       LD="${LD-ld} -n32"
960       ;;
961     *64-bit*)
962       LD="${LD-ld} -64"
963       ;;
964     esac
965   fi
966   rm -rf conftest*
967   ;;
968
969 *-*-sco3.2v5*)
970   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
971   SAVE_CFLAGS="$CFLAGS"
972   CFLAGS="$CFLAGS -belf"
973   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
974     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
975   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
976     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
977     CFLAGS="$SAVE_CFLAGS"
978   fi
979   ;;
980
981 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
982 [*-*-cygwin* | *-*-mingw*)
983   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
984   AC_CHECK_TOOL(AS, as, false)
985   AC_CHECK_TOOL(OBJDUMP, objdump, false)
986   ;;
987 ])
988 esac
989 ])
990
991 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
992 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
993
994 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
995 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
996
997 # AC_ENABLE_SHARED - implement the --enable-shared flag
998 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
999 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1000 #   `yes'.
1001 AC_DEFUN(AC_ENABLE_SHARED, [dnl
1002 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
1003 AC_ARG_ENABLE(shared,
1004 changequote(<<, >>)dnl
1005 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
1006 changequote([, ])dnl
1007 [p=${PACKAGE-default}
1008 case "$enableval" in
1009 yes) enable_shared=yes ;;
1010 no) enable_shared=no ;;
1011 *)
1012   enable_shared=no
1013   # Look at the argument we got.  We use all the common list separators.
1014   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1015   for pkg in $enableval; do
1016     if test "X$pkg" = "X$p"; then
1017       enable_shared=yes
1018     fi
1019   done
1020   IFS="$ac_save_ifs"
1021   ;;
1022 esac],
1023 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
1024 ])
1025
1026 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
1027 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1028 AC_ENABLE_SHARED(no)])
1029
1030 # AC_ENABLE_STATIC - implement the --enable-static flag
1031 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
1032 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1033 #   `yes'.
1034 AC_DEFUN(AC_ENABLE_STATIC, [dnl
1035 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
1036 AC_ARG_ENABLE(static,
1037 changequote(<<, >>)dnl
1038 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
1039 changequote([, ])dnl
1040 [p=${PACKAGE-default}
1041 case "$enableval" in
1042 yes) enable_static=yes ;;
1043 no) enable_static=no ;;
1044 *)
1045   enable_static=no
1046   # Look at the argument we got.  We use all the common list separators.
1047   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1048   for pkg in $enableval; do
1049     if test "X$pkg" = "X$p"; then
1050       enable_static=yes
1051     fi
1052   done
1053   IFS="$ac_save_ifs"
1054   ;;
1055 esac],
1056 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
1057 ])
1058
1059 # AC_DISABLE_STATIC - set the default static flag to --disable-static
1060 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1061 AC_ENABLE_STATIC(no)])
1062
1063
1064 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
1065 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
1066 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1067 #   `yes'.
1068 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
1069 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
1070 AC_ARG_ENABLE(fast-install,
1071 changequote(<<, >>)dnl
1072 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
1073 changequote([, ])dnl
1074 [p=${PACKAGE-default}
1075 case "$enableval" in
1076 yes) enable_fast_install=yes ;;
1077 no) enable_fast_install=no ;;
1078 *)
1079   enable_fast_install=no
1080   # Look at the argument we got.  We use all the common list separators.
1081   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1082   for pkg in $enableval; do
1083     if test "X$pkg" = "X$p"; then
1084       enable_fast_install=yes
1085     fi
1086   done
1087   IFS="$ac_save_ifs"
1088   ;;
1089 esac],
1090 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
1091 ])
1092
1093 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
1094 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1095 AC_ENABLE_FAST_INSTALL(no)])
1096
1097 # AC_PROG_LD - find the path to the GNU or non-GNU linker
1098 AC_DEFUN(AC_PROG_LD,
1099 [AC_ARG_WITH(gnu-ld,
1100 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
1101 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
1102 AC_REQUIRE([AC_PROG_CC])dnl
1103 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1104 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1105 ac_prog=ld
1106 if test "$ac_cv_prog_gcc" = yes; then
1107   # Check if gcc -print-prog-name=ld gives a path.
1108   AC_MSG_CHECKING([for ld used by GCC])
1109   ac_prog=`($CC -print-prog-name=ld) 2>&5`
1110   case "$ac_prog" in
1111     # Accept absolute paths.
1112 changequote(,)dnl
1113     [\\/]* | [A-Za-z]:[\\/]*)
1114       re_direlt='/[^/][^/]*/\.\./'
1115 changequote([,])dnl
1116       # Canonicalize the path of ld
1117       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
1118       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1119         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1120       done
1121       test -z "$LD" && LD="$ac_prog"
1122       ;;
1123   "")
1124     # If it fails, then pretend we aren't using GCC.
1125     ac_prog=ld
1126     ;;
1127   *)
1128     # If it is relative, then search for the first ld in PATH.
1129     with_gnu_ld=unknown
1130     ;;
1131   esac
1132 elif test "$with_gnu_ld" = yes; then
1133   AC_MSG_CHECKING([for GNU ld])
1134 else
1135   AC_MSG_CHECKING([for non-GNU ld])
1136 fi
1137 AC_CACHE_VAL(ac_cv_path_LD,
1138 [if test -z "$LD"; then
1139   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1140   for ac_dir in $PATH; do
1141     test -z "$ac_dir" && ac_dir=.
1142     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
1143       ac_cv_path_LD="$ac_dir/$ac_prog"
1144       # Check to see if the program is GNU ld.  I'd rather use --version,
1145       # but apparently some GNU ld's only accept -v.
1146       # Break only if it was the GNU/non-GNU ld that we prefer.
1147       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
1148         test "$with_gnu_ld" != no && break
1149       else
1150         test "$with_gnu_ld" != yes && break
1151       fi
1152     fi
1153   done
1154   IFS="$ac_save_ifs"
1155 else
1156   ac_cv_path_LD="$LD" # Let the user override the test with a path.
1157 fi])
1158 LD="$ac_cv_path_LD"
1159 if test -n "$LD"; then
1160   AC_MSG_RESULT($LD)
1161 else
1162   AC_MSG_RESULT(no)
1163 fi
1164 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
1165 AC_PROG_LD_GNU
1166 ])
1167
1168 AC_DEFUN(AC_PROG_LD_GNU,
1169 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
1170 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1171 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
1172   ac_cv_prog_gnu_ld=yes
1173 else
1174   ac_cv_prog_gnu_ld=no
1175 fi])
1176 ])
1177
1178 # AC_PROG_NM - find the path to a BSD-compatible name lister
1179 AC_DEFUN(AC_PROG_NM,
1180 [AC_MSG_CHECKING([for BSD-compatible nm])
1181 AC_CACHE_VAL(ac_cv_path_NM,
1182 [if test -n "$NM"; then
1183   # Let the user override the test.
1184   ac_cv_path_NM="$NM"
1185 else
1186   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1187   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
1188     test -z "$ac_dir" && ac_dir=.
1189     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
1190       # Check to see if the nm accepts a BSD-compat flag.
1191       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
1192       #   nm: unknown option "B" ignored
1193       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1194         ac_cv_path_NM="$ac_dir/nm -B"
1195         break
1196       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1197         ac_cv_path_NM="$ac_dir/nm -p"
1198         break
1199       else
1200         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
1201         continue # so that we can try to find one that supports BSD flags
1202       fi
1203     fi
1204   done
1205   IFS="$ac_save_ifs"
1206   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
1207 fi])
1208 NM="$ac_cv_path_NM"
1209 AC_MSG_RESULT([$NM])
1210 ])
1211
1212 # AC_CHECK_LIBM - check for math library
1213 AC_DEFUN(AC_CHECK_LIBM,
1214 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1215 LIBM=
1216 case "$lt_target" in
1217 *-*-beos* | *-*-cygwin*)
1218   # These system don't have libm
1219   ;;
1220 *-ncr-sysv4.3*)
1221   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
1222   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
1223   ;;
1224 *)
1225   AC_CHECK_LIB(m, main, LIBM="-lm")
1226   ;;
1227 esac
1228 ])
1229
1230 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
1231 # the libltdl convenience library, adds --enable-ltdl-convenience to
1232 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1233 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1234 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1235 # '${top_builddir}/' (note the single quotes!) if your package is not
1236 # flat, and, if you're not using automake, define top_builddir as
1237 # appropriate in the Makefiles.
1238 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1239   case "$enable_ltdl_convenience" in
1240   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
1241   "") enable_ltdl_convenience=yes
1242       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
1243   esac
1244   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
1245   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1246 ])
1247
1248 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
1249 # the libltdl installable library, and adds --enable-ltdl-install to
1250 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1251 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1252 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1253 # '${top_builddir}/' (note the single quotes!) if your package is not
1254 # flat, and, if you're not using automake, define top_builddir as
1255 # appropriate in the Makefiles.
1256 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
1257 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1258   AC_CHECK_LIB(ltdl, main,
1259   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
1260   [if test x"$enable_ltdl_install" = xno; then
1261      AC_MSG_WARN([libltdl not installed, but installation disabled])
1262    else
1263      enable_ltdl_install=yes
1264    fi
1265   ])
1266   if test x"$enable_ltdl_install" = x"yes"; then
1267     ac_configure_args="$ac_configure_args --enable-ltdl-install"
1268     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
1269     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1270   else
1271     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
1272     LIBLTDL="-lltdl"
1273     INCLTDL=
1274   fi
1275 ])
1276
1277 dnl old names
1278 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
1279 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
1280 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
1281 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
1282 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
1283 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
1284 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
1285
1286 dnl This is just to silence aclocal about the macro not being used
1287 ifelse([AC_DISABLE_FAST_INSTALL])dnl
1288 # Macro to add for using GNU gettext.
1289 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1290 #
1291 # This file can be copied and used freely without restrictions.  It can
1292 # be used in projects which are not available under the GNU Public License
1293 # but which still want to provide support for the GNU gettext functionality.
1294 # Please note that the actual code is *not* freely available.
1295
1296 # serial 5
1297
1298 AC_DEFUN(AM_WITH_NLS,
1299   [AC_MSG_CHECKING([whether NLS is requested])
1300     dnl Default is enabled NLS
1301     AC_ARG_ENABLE(nls,
1302       [  --disable-nls           do not use Native Language Support],
1303       USE_NLS=$enableval, USE_NLS=yes)
1304     AC_MSG_RESULT($USE_NLS)
1305     AC_SUBST(USE_NLS)
1306
1307     USE_INCLUDED_LIBINTL=no
1308
1309     dnl If we use NLS figure out what method
1310     if test "$USE_NLS" = "yes"; then
1311       AC_DEFINE(ENABLE_NLS)
1312       AC_MSG_CHECKING([whether included gettext is requested])
1313       AC_ARG_WITH(included-gettext,
1314         [  --with-included-gettext use the GNU gettext library included here],
1315         nls_cv_force_use_gnu_gettext=$withval,
1316         nls_cv_force_use_gnu_gettext=no)
1317       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
1318
1319       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
1320       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
1321         dnl User does not insist on using GNU NLS library.  Figure out what
1322         dnl to use.  If gettext or catgets are available (in this order) we
1323         dnl use this.  Else we have to fall back to GNU NLS library.
1324         dnl catgets is only used if permitted by option --with-catgets.
1325         nls_cv_header_intl=
1326         nls_cv_header_libgt=
1327         CATOBJEXT=NONE
1328
1329         AC_CHECK_HEADER(libintl.h,
1330           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
1331             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
1332                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
1333
1334            if test "$gt_cv_func_gettext_libc" != "yes"; then
1335              AC_CHECK_LIB(intl, bindtextdomain,
1336                [AC_CACHE_CHECK([for gettext in libintl],
1337                  gt_cv_func_gettext_libintl,
1338                  [AC_CHECK_LIB(intl, gettext,
1339 dnl ============== A fix is here! ======================
1340 dnl -lintl was not added to the LIBS variable in this case
1341                   [gt_cv_func_gettext_libintl=yes
1342                    INTLLIBS="-lintl"],
1343 dnl ==== end of fix
1344                   gt_cv_func_gettext_libintl=no)],
1345                  gt_cv_func_gettext_libintl=no)])
1346            fi
1347
1348            if test "$gt_cv_func_gettext_libc" = "yes" \
1349               || test "$gt_cv_func_gettext_libintl" = "yes"; then
1350               AC_DEFINE(HAVE_GETTEXT)
1351               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1352                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
1353               if test "$MSGFMT" != "no"; then
1354                 AC_CHECK_FUNCS(dcgettext)
1355                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1356                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1357                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1358                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
1359                                return _nl_msg_cat_cntr],
1360                   [CATOBJEXT=.gmo
1361                    DATADIRNAME=share],
1362                   [CATOBJEXT=.mo
1363                    DATADIRNAME=lib])
1364                 INSTOBJEXT=.mo
1365               fi
1366             fi
1367         ])
1368
1369         if test "$CATOBJEXT" = "NONE"; then
1370           AC_MSG_CHECKING([whether catgets can be used])
1371           AC_ARG_WITH(catgets,
1372             [  --with-catgets          use catgets functions if available],
1373             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
1374           AC_MSG_RESULT($nls_cv_use_catgets)
1375
1376           if test "$nls_cv_use_catgets" = "yes"; then
1377             dnl No gettext in C library.  Try catgets next.
1378             AC_CHECK_LIB(i, main)
1379             AC_CHECK_FUNC(catgets,
1380               [AC_DEFINE(HAVE_CATGETS)
1381                INTLOBJS="\$(CATOBJS)"
1382                AC_PATH_PROG(GENCAT, gencat, no)dnl
1383                if test "$GENCAT" != "no"; then
1384                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
1385                  if test "$GMSGFMT" = "no"; then
1386                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
1387                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
1388                  fi
1389                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1390                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1391                  USE_INCLUDED_LIBINTL=yes
1392                  CATOBJEXT=.cat
1393                  INSTOBJEXT=.cat
1394                  DATADIRNAME=lib
1395                  INTLDEPS='$(top_builddir)/intl/libintl.a'
1396                  INTLLIBS=$INTLDEPS
1397                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
1398                  nls_cv_header_intl=intl/libintl.h
1399                  nls_cv_header_libgt=intl/libgettext.h
1400                fi])
1401           fi
1402         fi
1403
1404         if test "$CATOBJEXT" = "NONE"; then
1405           dnl Neither gettext nor catgets in included in the C library.
1406           dnl Fall back on GNU gettext library.
1407           nls_cv_use_gnu_gettext=yes
1408         fi
1409       fi
1410
1411       if test "$nls_cv_use_gnu_gettext" = "yes"; then
1412         dnl Mark actions used to generate GNU NLS library.
1413         INTLOBJS="\$(GETTOBJS)"
1414         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1415           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
1416         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1417         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1418           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1419         AC_SUBST(MSGFMT)
1420         USE_INCLUDED_LIBINTL=yes
1421         CATOBJEXT=.gmo
1422         INSTOBJEXT=.mo
1423         DATADIRNAME=share
1424         INTLDEPS='$(top_builddir)/intl/libintl.a'
1425         INTLLIBS=$INTLDEPS
1426         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
1427         nls_cv_header_intl=intl/libintl.h
1428         nls_cv_header_libgt=intl/libgettext.h
1429       fi
1430
1431       dnl Test whether we really found GNU xgettext.
1432       if test "$XGETTEXT" != ":"; then
1433         dnl If it is no GNU xgettext we define it as : so that the
1434         dnl Makefiles still can work.
1435         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
1436           : ;
1437         else
1438           AC_MSG_RESULT(
1439             [found xgettext program is not GNU xgettext; ignore it])
1440           XGETTEXT=":"
1441         fi
1442       fi
1443
1444       # We need to process the po/ directory.
1445       POSUB=po
1446     else
1447       DATADIRNAME=share
1448       nls_cv_header_intl=intl/libintl.h
1449       nls_cv_header_libgt=intl/libgettext.h
1450     fi
1451     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
1452     AC_OUTPUT_COMMANDS(
1453      [case "$CONFIG_FILES" in *po/Makefile.in*)
1454         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
1455       esac])
1456
1457
1458     # If this is used in GNU gettext we have to set USE_NLS to `yes'
1459     # because some of the sources are only built for this goal.
1460     if test "$PACKAGE" = gettext; then
1461       USE_NLS=yes
1462       USE_INCLUDED_LIBINTL=yes
1463     fi
1464
1465     dnl These rules are solely for the distribution goal.  While doing this
1466     dnl we only have to keep exactly one list of the available catalogs
1467     dnl in configure.in.
1468     for lang in $ALL_LINGUAS; do
1469       GMOFILES="$GMOFILES $lang.gmo"
1470       POFILES="$POFILES $lang.po"
1471     done
1472
1473     dnl Make all variables we use known to autoconf.
1474     AC_SUBST(USE_INCLUDED_LIBINTL)
1475     AC_SUBST(CATALOGS)
1476     AC_SUBST(CATOBJEXT)
1477     AC_SUBST(DATADIRNAME)
1478     AC_SUBST(GMOFILES)
1479     AC_SUBST(INSTOBJEXT)
1480     AC_SUBST(INTLDEPS)
1481     AC_SUBST(INTLLIBS)
1482     AC_SUBST(INTLOBJS)
1483     AC_SUBST(POFILES)
1484     AC_SUBST(POSUB)
1485   ])
1486
1487 AC_DEFUN(AM_GNU_GETTEXT,
1488   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1489    AC_REQUIRE([AC_PROG_CC])dnl
1490    AC_REQUIRE([AC_PROG_RANLIB])dnl
1491    AC_REQUIRE([AC_ISC_POSIX])dnl
1492    AC_REQUIRE([AC_HEADER_STDC])dnl
1493    AC_REQUIRE([AC_C_CONST])dnl
1494    AC_REQUIRE([AC_C_INLINE])dnl
1495    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1496    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1497    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1498    AC_REQUIRE([AC_FUNC_MMAP])dnl
1499
1500    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
1501 unistd.h sys/param.h])
1502    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
1503 strdup __argz_count __argz_stringify __argz_next])
1504
1505    if test "${ac_cv_func_stpcpy+set}" != "set"; then
1506      AC_CHECK_FUNCS(stpcpy)
1507    fi
1508    if test "${ac_cv_func_stpcpy}" = "yes"; then
1509      AC_DEFINE(HAVE_STPCPY)
1510    fi
1511
1512    AM_LC_MESSAGES
1513    AM_WITH_NLS
1514
1515    if test "x$CATOBJEXT" != "x"; then
1516      if test "x$ALL_LINGUAS" = "x"; then
1517        LINGUAS=
1518      else
1519        AC_MSG_CHECKING(for catalogs to be installed)
1520        NEW_LINGUAS=
1521 dnl ============== Fix is here! ======================
1522 dnl Some sh do not like substitution in bounds of for loops
1523 dnl    for lang in ${LINGUAS=$ALL_LINGUAS}; do
1524     tmplinguas=${LINGUAS=$ALL_LINGUAS}
1525     for lang in ${tmplinguas}; do
1526 dnl ==== end of fix
1527          case "$ALL_LINGUAS" in
1528           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
1529          esac
1530        done
1531        LINGUAS=$NEW_LINGUAS
1532        AC_MSG_RESULT($LINGUAS)
1533      fi
1534
1535      dnl Construct list of names of catalog files to be constructed.
1536      if test -n "$LINGUAS"; then
1537        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1538      fi
1539    fi
1540
1541    dnl The reference to <locale.h> in the installed <libintl.h> file
1542    dnl must be resolved because we cannot expect the users of this
1543    dnl to define HAVE_LOCALE_H.
1544    if test $ac_cv_header_locale_h = yes; then
1545      INCLUDE_LOCALE_H="#include <locale.h>"
1546    else
1547      INCLUDE_LOCALE_H="\
1548 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
1549    fi
1550    AC_SUBST(INCLUDE_LOCALE_H)
1551
1552    dnl Determine which catalog format we have (if any is needed)
1553    dnl For now we know about two different formats:
1554    dnl   Linux libc-5 and the normal X/Open format
1555    test -d intl || mkdir intl
1556    if test "$CATOBJEXT" = ".cat"; then
1557      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
1558
1559      dnl Transform the SED scripts while copying because some dumb SEDs
1560      dnl cannot handle comments.
1561      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
1562    fi
1563    dnl po2tbl.sed is always needed.
1564    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
1565      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
1566
1567    dnl In the intl/Makefile.in we have a special dependency which makes
1568    dnl only sense for gettext.  We comment this out for non-gettext
1569    dnl packages.
1570    if test "$PACKAGE" = "gettext"; then
1571      GT_NO="#NO#"
1572      GT_YES=
1573    else
1574      GT_NO=
1575      GT_YES="#YES#"
1576    fi
1577    AC_SUBST(GT_NO)
1578    AC_SUBST(GT_YES)
1579
1580    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1581    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
1582    dnl Try to locate is.
1583    MKINSTALLDIRS=
1584    if test -n "$ac_aux_dir"; then
1585      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1586    fi
1587    if test -z "$MKINSTALLDIRS"; then
1588      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1589    fi
1590    AC_SUBST(MKINSTALLDIRS)
1591
1592    dnl *** For now the libtool support in intl/Makefile is not for real.
1593    l=
1594    AC_SUBST(l)
1595
1596    dnl Generate list of files to be processed by xgettext which will
1597    dnl be included in po/Makefile.
1598    test -d po || mkdir po
1599    if test "x$srcdir" != "x."; then
1600      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
1601        posrcprefix="$srcdir/"
1602      else
1603        posrcprefix="../$srcdir/"
1604      fi
1605    else
1606      posrcprefix="../"
1607    fi
1608    rm -f po/POTFILES
1609    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
1610         < $srcdir/po/POTFILES.in > po/POTFILES
1611   ])
1612 # Check whether LC_MESSAGES is available in <locale.h>.
1613 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1614 #
1615 # This file can be copied and used freely without restrictions.  It can
1616 # be used in projects which are not available under the GNU Public License
1617 # but which still want to provide support for the GNU gettext functionality.
1618 # Please note that the actual code is *not* freely available.
1619
1620 # serial 1
1621
1622 AC_DEFUN(AM_LC_MESSAGES,
1623   [if test $ac_cv_header_locale_h = yes; then
1624     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
1625       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1626        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
1627     if test $am_cv_val_LC_MESSAGES = yes; then
1628       AC_DEFINE(HAVE_LC_MESSAGES)
1629     fi
1630   fi])
1631 # Search path for a program which passes the given test.
1632 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1633 #
1634 # This file can be copied and used freely without restrictions.  It can
1635 # be used in projects which are not available under the GNU Public License
1636 # but which still want to provide support for the GNU gettext functionality.
1637 # Please note that the actual code is *not* freely available.
1638
1639 # serial 1
1640
1641 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1642 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1643 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
1644 [# Extract the first word of "$2", so it can be a program name with args.
1645 set dummy $2; ac_word=[$]2
1646 AC_MSG_CHECKING([for $ac_word])
1647 AC_CACHE_VAL(ac_cv_path_$1,
1648 [case "[$]$1" in
1649   /*)
1650   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1651   ;;
1652   *)
1653   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1654   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1655     test -z "$ac_dir" && ac_dir=.
1656     if test -f $ac_dir/$ac_word; then
1657       if [$3]; then
1658         ac_cv_path_$1="$ac_dir/$ac_word"
1659         break
1660       fi
1661     fi
1662   done
1663   IFS="$ac_save_ifs"
1664 dnl If no 4th arg is given, leave the cache variable unset,
1665 dnl so AC_PATH_PROGS will keep looking.
1666 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1667 ])dnl
1668   ;;
1669 esac])dnl
1670 $1="$ac_cv_path_$1"
1671 if test -n "[$]$1"; then
1672   AC_MSG_RESULT([$]$1)
1673 else
1674   AC_MSG_RESULT(no)
1675 fi
1676 AC_SUBST($1)dnl
1677 ])
1678 # Configure paths for Libsigc++
1679 # Based on Gtk-- script by Erik Andersen and Tero Pulkkinen 
1680
1681 dnl Test for Libsigc++, and define SIGC_CFLAGS and SIGC_LIBS
1682 dnl   to be used as follows:
1683 dnl AM_PATH_SIGC(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1684 dnl
1685 AC_DEFUN(AM_PATH_SIGC,
1686 [dnl 
1687 dnl Get the cflags and libraries from the sigc-config script
1688 dnl
1689
1690 dnl
1691 dnl Prefix options
1692 dnl
1693 AC_ARG_WITH(sigc-prefix,
1694 [  --with-sigc-prefix=PREFIX
1695                           Prefix where libsigc++ is installed (optional)]
1696 , sigc_config_prefix="$withval", sigc_config_prefix="")
1697
1698 AC_ARG_WITH(sigc-exec-prefix,
1699 [  --with-sigc-exec-prefix=PREFIX 
1700                           Exec prefix where  libsigc++ is installed (optional)]
1701 , sigc_config_exec_prefix="$withval", sigc_config_exec_prefix="")
1702
1703 AC_ARG_ENABLE(sigctest, 
1704 [  --disable-sigctest     Do not try to compile and run a test libsigc++ 
1705                           program],
1706 , enable_sigctest=yes)
1707
1708 dnl
1709 dnl Prefix handling
1710 dnl
1711   if test x$sigc_config_exec_prefix != x ; then
1712      sigc_config_args="$sigc_config_args --exec-prefix=$sigc_config_exec_prefix"
1713      if test x${SIGC_CONFIG+set} != xset ; then
1714         SIGC_CONFIG=$sigc_config_exec_prefix/bin/sigc-config
1715      fi
1716   fi
1717   if test x$sigc_config_prefix != x ; then
1718      sigc_config_args="$sigc_config_args --prefix=$sigc_config_prefix"
1719      if test x${SIGC_CONFIG+set} != xset ; then
1720         SIGC_CONFIG=$sigc_config_prefix/bin/sigc-config
1721      fi
1722   fi
1723
1724 dnl
1725 dnl See if sigc-config is alive
1726 dnl
1727   AC_PATH_PROG(SIGC_CONFIG, sigc-config, no)
1728   sigc_version_min=$1
1729
1730 dnl
1731 dnl  Version check
1732 dnl
1733   AC_MSG_CHECKING(for libsigc++ - version >= $sigc_version_min)
1734   no_sigc=""
1735   if test "$SIGC_CONFIG" = "no" ; then
1736     no_sigc=yes
1737   else
1738     sigc_version=`$SIGC_CONFIG --version`
1739
1740     SIGC_CFLAGS=`$SIGC_CONFIG $sigc_config_args --cflags`
1741     SIGC_LIBS=`$SIGC_CONFIG $sigc_config_args --libs`
1742     SIGC_MACROS=`$SIGC_CONFIG $sigc_config_args --libs`
1743
1744     sigc_major_version=`echo $sigc_version | \
1745            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1746     sigc_minor_version=`echo $sigc_version | \
1747            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1748     sigc_micro_version=`echo $sigc_version | \
1749            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1750
1751     sigc_major_min=`echo $sigc_version_min | \
1752            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1753     sigc_minor_min=`echo $sigc_version_min | \
1754            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1755     sigc_micro_min=`echo $sigc_version_min | \
1756            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1757
1758     sigc_version_proper=`expr \
1759         $sigc_major_version \> $sigc_major_min \| \
1760         $sigc_major_version \= $sigc_major_min \& \
1761         $sigc_minor_version \> $sigc_minor_min \| \
1762         $sigc_major_version \= $sigc_major_min \& \
1763         $sigc_minor_version \= $sigc_minor_min \& \
1764         $sigc_micro_version \>= $sigc_micro_min `
1765
1766     if test "$sigc_version_proper" = "1" ; then
1767       AC_MSG_RESULT([$sigc_major_version.$sigc_minor_version.$sigc_micro_version])
1768     else
1769       AC_MSG_RESULT(no)
1770       no_sigc=yes
1771     fi
1772
1773     if test "X$no_sigc" = "Xyes" ; then
1774       enable_sigctest=no
1775     fi
1776
1777     AC_LANG_SAVE
1778     AC_LANG_CPLUSPLUS
1779
1780 dnl
1781 dnl
1782 dnl
1783     if test "x$enable_sigctest" = "xyes" ; then
1784       AC_MSG_CHECKING(if libsigc++ sane)
1785       ac_save_CXXFLAGS="$CXXFLAGS"
1786       ac_save_LIBS="$LIBS"
1787       CXXFLAGS="$CXXFLAGS $SIGC_CFLAGS"
1788       LIBS="$LIBS $SIGC_LIBS"
1789
1790       rm -f conf.sigctest
1791       AC_TRY_RUN([
1792 #include <stdio.h>
1793 #include <sigc++/signal_system.h>
1794
1795 #ifdef SIGC_CXX_NAMESPACES
1796 using namespace SigC;
1797 #endif
1798
1799 int foo1(int i) 
1800   {
1801    return 1;
1802   }
1803
1804 int main(int argc,char **argv)
1805   {
1806    if (sigc_major_version!=$sigc_major_version ||
1807        sigc_minor_version!=$sigc_minor_version ||
1808        sigc_micro_version!=$sigc_micro_version)
1809      { printf("(%d.%d.%d) ",
1810          sigc_major_version,sigc_minor_version,sigc_micro_version);
1811        return 1;
1812      }
1813    Signal1<int,int> sig1;
1814    sig1.connect(slot(foo1));
1815    sig1(1);
1816    return 0;
1817   }
1818
1819 ],[
1820   AC_MSG_RESULT(yes)
1821 ],[
1822   AC_MSG_RESULT(no)
1823   no_sigc=yes
1824 ]
1825 ,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1826
1827        CXXFLAGS="$ac_save_CXXFLAGS"
1828        LIBS="$ac_save_LIBS"
1829      fi
1830   fi
1831
1832   dnl
1833   dnl
1834   if test "x$no_sigc" = x ; then
1835      ifelse([$2], , :, [$2])     
1836   else
1837      SIGC_CFLAGS=""
1838      SIGC_LIBS=""
1839      SIGC_MACROS=""
1840      ifelse([$3], , :, [$3])
1841   fi
1842
1843   AC_LANG_RESTORE
1844
1845   AC_SUBST(SIGC_CFLAGS)
1846   AC_SUBST(SIGC_LIBS)
1847   AC_SUBST(SIGC_MACROS)
1848 ])
1849
1850 # Configure paths and libs when using KDE GUI
1851 ##    -*- shell-script -*-
1852
1853 ##    This file is part of the KDE libraries/packages
1854 ##    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
1855 ##              (C) 1997 Stephan Kulow (coolo@kde.org)
1856
1857 ##    This file is free software; you can redistribute it and/or
1858 ##    modify it under the terms of the GNU Library General Public
1859 ##    License as published by the Free Software Foundation; either
1860 ##    version 2 of the License, or (at your option) any later version.
1861
1862 ##    This library is distributed in the hope that it will be useful,
1863 ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
1864 ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1865 ##    Library General Public License for more details.
1866
1867 ##    You should have received a copy of the GNU Library General Public License
1868 ##    along with this library; see the file COPYING.LIB.  If not, write to
1869 ##    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1870 ##    Boston, MA 02111-1307, USA.        
1871
1872 ## IMPORTANT NOTE:
1873 ## Please do not modify this file unless you expect your modifications to be
1874 ## carried into every other module in the repository. If you decide that you
1875 ## really want to modify it, contact coolo@kde.org mentioning that you have
1876 ## and that the modified file should be committed to every module.
1877 ##
1878 ## Single-module modifications are best placed in configure.in for kdelibs
1879 ## and kdebase or configure.in.1 if present.
1880
1881
1882 ## ------------------------------------------------------------------------
1883 ## Find a file (or one of more files in a list of dirs)
1884 ## ------------------------------------------------------------------------
1885 ##
1886 AC_DEFUN(AC_FIND_FILE,
1887 [
1888 $3=NO
1889 for i in $2;
1890 do
1891   for j in $1;
1892   do
1893     if test -r "$i/$j"; then
1894       $3=$i
1895       break 2
1896     fi
1897   done
1898 done
1899 ])
1900
1901 AC_DEFUN(KDE_FIND_PATH,
1902 [
1903    AC_MSG_CHECKING([for $1])
1904    AC_CACHE_VAL(kde_cv_path_$1,
1905    [
1906      kde_cv_path_$1="NONE"
1907      if test -n "$$2"; then
1908         kde_cv_path_$1="$$2";
1909      else
1910         dirs="$3"
1911         kde_save_IFS=$IFS
1912         IFS=':'
1913         for dir in $PATH; do
1914           dirs="$dirs $dir"
1915         done
1916         IFS=$kde_save_IFS
1917  
1918         for dir in $dirs; do
1919           if test -x "$dir/$1"; then
1920             if test -n "$5"
1921             then
1922               evalstr="$dir/$1 $5 2>&1 "
1923               if eval $evalstr; then
1924                 kde_cv_path_$1="$dir/$1"
1925                 break
1926               fi
1927             else
1928                 kde_cv_path_$1="$dir/$1"
1929                 break
1930             fi
1931           fi
1932         done
1933  
1934      fi
1935  
1936    ])
1937  
1938    if test -z "$kde_cv_path_$1" || test "$kde_cv_path_$1" = "NONE"; then
1939       AC_MSG_RESULT(not found)
1940       $4
1941    else
1942      AC_MSG_RESULT($kde_cv_path_$1)
1943      $2=$kde_cv_path_$1
1944    fi
1945 ])
1946 AC_DEFUN(KDE_MOC_ERROR_MESSAGE,
1947 [
1948     AC_MSG_ERROR([No Qt meta object compiler (moc) found!
1949 Please check whether you installed Qt correctly.
1950 You need to have a running moc binary.
1951 configure tried to run $ac_cv_path_moc and the test didn't
1952 succeed. If configure shouldn't have tried this one, set
1953 the environment variable MOC to the right one before running
1954 configure.
1955 ])
1956 ])
1957
1958 dnl ------------------------------------------------------------------------
1959 dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some
1960 dnl more usual places
1961 dnl ------------------------------------------------------------------------
1962 dnl
1963 AC_DEFUN(AC_PATH_QT_MOC,
1964 [
1965    KDE_FIND_PATH(moc, MOC, [$ac_qt_bindir $QTDIR/bin \
1966             /usr/bin /usr/X11R6/bin /usr/lib/qt/bin \
1967             /usr/local/qt/bin], [KDE_MOC_ERROR_MESSAGE])
1968  
1969    if test -z "$MOC"; then
1970      if test -n "$ac_cv_path_moc"; then
1971        output=`eval "$ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt"`
1972      fi
1973      echo "configure:__oline__: tried to call $ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC
1974      echo "configure:__oline__: moc output: $output" >&AC_FD_CC
1975  
1976      if test -z "$output"; then
1977        KDE_MOC_ERROR_MESSAGE
1978     fi
1979    fi
1980  
1981    AC_SUBST(MOC)
1982 ])
1983
1984 AC_DEFUN(KDE_REPLACE_ROOT,
1985   $1=`echo "$$1" | sed -e "s#^/#\$\{install_root\}/#"`
1986 )
1987
1988 AC_DEFUN(AC_CREATE_KFSSTND,
1989 [
1990 AC_REQUIRE([AC_CHECK_RPATH])
1991
1992 if test "$1" = "default"; then
1993
1994   AC_MSG_CHECKING(for KDE paths)
1995
1996   if test -z "$kde_htmldir"; then
1997     kde_htmldir="\$(prefix)/share/doc/HTML"
1998   fi
1999   if test -z "$kde_appsdir"; then
2000     kde_appsdir="\$(prefix)/share/applnk"
2001   fi
2002   if test -z "$kde_icondir"; then
2003     kde_icondir="\$(prefix)/share/icons"
2004   fi
2005   if test -z "$kde_sounddir"; then
2006     kde_sounddir="\$(prefix)/share/sounds"
2007   fi
2008   if test -z "$kde_datadir"; then
2009     kde_datadir="\$(prefix)/share/apps"
2010   fi
2011   if test -z "$kde_locale"; then
2012     kde_locale="\$(prefix)/share/locale"
2013   fi
2014   if test -z "$kde_cgidir"; then
2015     kde_cgidir="\$(exec_prefix)/cgi-bin"
2016   fi
2017   if test -z "$kde_confdir"; then
2018     kde_confdir="\$(prefix)/share/config"
2019   fi
2020   if test -z "$kde_mimedir"; then
2021     kde_mimedir="\$(prefix)/share/mimelnk"
2022   fi
2023   if test -z "$kde_toolbardir"; then
2024     kde_toolbardir="\$(prefix)/share/toolbar"
2025   fi
2026   if test -z "$kde_wallpaperdir"; then
2027     kde_wallpaperdir="\$(prefix)/share/wallpapers"
2028   fi
2029   if test -z "$kde_bindir"; then
2030     kde_bindir="\$(exec_prefix)/bin"
2031   fi
2032   if test -z "$kde_partsdir"; then
2033     kde_partsdir="\$(exec_prefix)/parts"
2034   fi
2035   AC_MSG_RESULT(defaults)       
2036
2037 else 
2038
2039 AC_CACHE_VAL(kde_cv_all_paths,
2040 [
2041 AC_MSG_CHECKING([for kde headers installed])
2042 AC_LANG_CPLUSPLUS
2043 cat > conftest.$ac_ext <<EOF
2044 #include <stdio.h>
2045 #include "confdefs.h"
2046 #include <kapp.h>
2047
2048 int main() {
2049 printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
2050 printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
2051 printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
2052 printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
2053 printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
2054 printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
2055 printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
2056 printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
2057 printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
2058 printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
2059 printf("kde_wallpaperdir=\\"%s\\"\n", KApplication::kde_wallpaperdir().data());
2060 printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
2061 printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
2062 return 0;
2063 }
2064 EOF
2065
2066 if test -n "$kde_libraries"; then
2067   KDE_TEST_RPATH="-rpath $kde_libraries"
2068 fi
2069
2070 if test -n "$qt_libraries"; then
2071   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $qt_libraries"
2072 fi
2073
2074 if test -n "$x_libraries"; then
2075   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $x_libraries"
2076 fi
2077
2078 KDE_TEST_RPATH="$KDE_TEST_RPATH $KDE_EXTRA_RPATH"
2079
2080 ac_compile='${CXX-g++} -c $CXXFLAGS $all_includes $CPPFLAGS conftest.$ac_ext'
2081 if AC_TRY_EVAL(ac_compile); then
2082   AC_MSG_RESULT(yes)
2083 else
2084   AC_MSG_ERROR([your system is not able to compile a small KDE application!
2085 Check, if you installed the KDE header files correctly.])
2086 fi
2087
2088 AC_MSG_CHECKING([for kde libraries installed])
2089 ac_link='/bin/sh ./libtool --mode=link ${CXX-g++} -o conftest $CXXFLAGS $all_includes $CPPFLAGS $LDFLAGS $all_libraries conftest.$ac_ext $LIBS -lkdecore -lqt -lXext -lX11 $LIBSOCKET $KDE_TEST_RPATH 1>&5'
2090
2091 if AC_TRY_EVAL(ac_link) && test -s conftest; then 
2092   AC_MSG_RESULT(yes)
2093 else
2094   AC_MSG_ERROR([your system fails at linking a small KDE application!
2095 Check, if your compiler is installed correctly and if you have used the
2096 same compiler to compile Qt and kdelibs as you did use now])
2097 fi
2098
2099 AC_MSG_CHECKING([for KDE paths])
2100 if eval `./conftest 2>&5`; then
2101   AC_MSG_RESULT(done)
2102 else
2103   AC_MSG_RESULT(problems)
2104 fi
2105
2106 ./conftest 2> /dev/null >&5 # make an echo for config.log
2107 kde_have_all_paths=yes
2108 AC_LANG_CPLUSPLUS
2109
2110 if test "$kde_have_all_paths" = "yes"; then
2111 kde_cv_all_paths="kde_have_all_paths=\"yes\" \
2112         kde_htmldir=\"$kde_htmldir\" \
2113         kde_appsdir=\"$kde_appsdir\" \
2114         kde_icondir=\"$kde_icondir\" \
2115         kde_sounddir=\"$kde_sounddir\" \
2116         kde_datadir=\"$kde_datadir\" \
2117         kde_locale=\"$kde_locale\" \
2118         kde_cgidir=\"$kde_cgidir\" \
2119         kde_confdir=\"$kde_confdir\" \
2120         kde_mimedir=\"$kde_mimedir\" \
2121         kde_toolbardir=\"$kde_toolbardir\" \
2122         kde_wallpaperdir=\"$kde_wallpaperdir\" \
2123         kde_bindir=\"$kde_bindir\" \
2124         kde_partsdir=\"$kde_partsdir\""
2125 fi
2126 rm -fr conftest*
2127
2128 ])
2129
2130 eval "$kde_cv_all_paths"
2131
2132 if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
2133    test -z "$kde_icondir" || test -z "$kde_sounddir" ||
2134    test -z "$kde_datadir" || test -z "$kde_locale"  ||
2135    test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
2136    test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
2137    test -z "$kde_wallpaperdir" || test -z "$kde_bindir" ||
2138    test -z "$kde_partsdir" || test "$kde_have_all_paths" != "yes"; then
2139   kde_have_all_paths=no
2140   AC_MSG_ERROR([configure could not run a little KDE program to test the environment. 
2141 Since it had compiled and linked before, it must be a strange problem on your system.
2142 Look at config.log for details. If you are not able to fix this, please contact Stephan Kulow <coolo@kde.org>.])
2143 fi
2144
2145 if test -n "$install_root"; then
2146   KDE_REPLACE_ROOT(kde_htmldir)
2147   KDE_REPLACE_ROOT(kde_appsdir)
2148   KDE_REPLACE_ROOT(kde_icondir)
2149   KDE_REPLACE_ROOT(kde_sounddir)
2150   KDE_REPLACE_ROOT(kde_datadir)
2151   KDE_REPLACE_ROOT(kde_locale)
2152   KDE_REPLACE_ROOT(kde_cgidir)
2153   KDE_REPLACE_ROOT(kde_confdir)
2154   KDE_REPLACE_ROOT(kde_mimedir)
2155   KDE_REPLACE_ROOT(kde_toolbardir)
2156   KDE_REPLACE_ROOT(kde_wallpaperdir)
2157   KDE_REPLACE_ROOT(kde_bindir)
2158   KDE_REPLACE_ROOT(kde_partsdir)
2159   AC_SUBST(install_root)
2160 fi
2161
2162 fi
2163
2164 bindir=$kde_bindir
2165
2166 ])
2167
2168 AC_DEFUN(AC_SUBST_KFSSTND,
2169 [
2170 AC_SUBST(kde_htmldir)
2171 AC_SUBST(kde_appsdir)
2172 AC_SUBST(kde_icondir)
2173 AC_SUBST(kde_sounddir)
2174 kde_minidir="$kde_icondir/mini"
2175 AC_SUBST(kde_minidir)
2176 AC_SUBST(kde_datadir)
2177 AC_SUBST(kde_locale)
2178 AC_SUBST(kde_cgidir)
2179 AC_SUBST(kde_confdir)
2180 AC_SUBST(kde_mimedir)
2181 AC_SUBST(kde_toolbardir)
2182 AC_SUBST(kde_wallpaperdir)
2183 AC_SUBST(kde_bindir)
2184 AC_SUBST(kde_partsdir)
2185 ])
2186
2187 AC_DEFUN(KDE_MISC_TESTS,
2188 [
2189    AC_LANG_C
2190    dnl Checks for libraries. 
2191    AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"]) dnl for FreeBSD
2192    AC_SUBST(LIBCOMPAT)
2193    AC_CHECK_LIB(crypt, main, [LIBCRYPT="-lcrypt"]) dnl for BSD
2194    AC_SUBST(LIBCRYPT)
2195    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
2196    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
2197       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
2198         [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
2199    fi
2200    AC_CHECK_FUNC(gethostbyname)
2201    if test $ac_cv_func_gethostbyname = no; then
2202      AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
2203    fi
2204    AC_CHECK_FUNC(connect)
2205    if test $ac_cv_func_connect = no; then
2206       AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
2207         $X_EXTRA_LIBS)
2208    fi
2209
2210    AC_CHECK_FUNC(remove)
2211    if test $ac_cv_func_remove = no; then
2212       AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
2213    fi
2214  
2215    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
2216    AC_CHECK_FUNC(shmat)
2217    if test $ac_cv_func_shmat = no; then
2218      AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
2219    fi
2220
2221    LIBSOCKET=$X_EXTRA_LIBS
2222    AC_SUBST(LIBSOCKET)
2223    AC_SUBST(X_EXTRA_LIBS)
2224    AC_CHECK_LIB(ucb, killpg, [LIBUCB="-lucb"]) dnl for Solaris2.4
2225    AC_SUBST(LIBUCB)
2226
2227    case $host in  dnl this *is* LynxOS specific
2228    *-*-lynxos* )
2229         AC_MSG_CHECKING([LynxOS header file wrappers])
2230         [CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"]
2231         AC_MSG_RESULT(disabled)
2232         AC_CHECK_LIB(bsd, gethostbyname, [LIBSOCKET="-lbsd"]) dnl for LynxOS
2233          ;;
2234     esac
2235
2236 ])
2237
2238 ## ------------------------------------------------------------------------
2239 ## Find the header files and libraries for X-Windows. Extended the 
2240 ## macro AC_PATH_X
2241 ## ------------------------------------------------------------------------
2242 ##
2243 AC_DEFUN(K_PATH_X,
2244 [
2245 AC_MSG_CHECKING(for X)
2246 AC_CACHE_VAL(ac_cv_have_x,
2247 [# One or both of the vars are not set, and there is no cached value.
2248 ac_x_includes=NO ac_x_libraries=NO
2249 AC_PATH_X_DIRECT
2250 AC_PATH_X_XMKMF
2251 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
2252   AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
2253 else
2254   # Record where we found X for the cache.
2255   ac_cv_have_x="have_x=yes \
2256                 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
2257 fi])dnl
2258 eval "$ac_cv_have_x"
2259  
2260 if test "$have_x" != yes; then
2261   AC_MSG_RESULT($have_x)
2262   no_x=yes
2263 else
2264   # If each of the values was on the command line, it overrides each guess.
2265   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
2266   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
2267   # Update the cache value to reflect the command line values.
2268   ac_cv_have_x="have_x=yes \
2269                 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
2270   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
2271 fi
2272
2273 if test -z "$x_includes" || test "x$x_includes" = xNONE; then
2274   X_INCLUDES=""
2275   x_includes="."; dnl better than nothing :-
2276  else
2277   X_INCLUDES="-I$x_includes"
2278 fi
2279
2280 if test -z "$x_libraries" || test "x$x_libraries" = xNONE; then
2281   X_LDFLAGS=""
2282   x_libraries="/usr/lib"; dnl better than nothing :-
2283  else
2284   X_LDFLAGS="-L$x_libraries"
2285 fi
2286 all_includes="$all_includes $X_INCLUDES"  
2287 all_libraries="$all_libraries $X_LDFLAGS"  
2288
2289 AC_SUBST(X_INCLUDES)
2290 AC_SUBST(X_LDFLAGS)
2291 AC_SUBST(x_libraries)
2292 AC_SUBST(x_includes)
2293 ])
2294
2295 AC_DEFUN(KDE_PRINT_QT_PROGRAM,
2296 [
2297 AC_LANG_CPLUSPLUS
2298 cat > conftest.$ac_ext <<EOF
2299 #include "confdefs.h"
2300 #include <qmovie.h>
2301 #include <qapplication.h>
2302 int main() {
2303   QMovie m;
2304   m.setSpeed(20);
2305   return 0;
2306 }
2307 EOF
2308 ])
2309
2310 AC_DEFUN(KDE_CHECK_QT_DIRECT,
2311 [
2312 AC_MSG_CHECKING([if Qt compiles without flags])
2313 AC_CACHE_VAL(kde_cv_qt_direct,
2314 [
2315 ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
2316 ac_LIBRARY_PATH="$LIBRARY_PATH"
2317 ac_cxxflags_safe="$CXXFLAGS"
2318 ac_ldflags_safe="$LDFLAGS"
2319 ac_libs_safe="$LIBS"
2320
2321 CXXFLAGS="$CXXFLAGS -I$qt_includes"
2322 LDFLAGS="$X_LDFLAGS"
2323 LIBS="-lqt -lXext -lX11 $LIBSOCKET"
2324 LD_LIBRARY_PATH=
2325 export LD_LIBRARY_PATH
2326 LIBRARY_PATH=
2327 export LIBRARY_PATH
2328
2329 KDE_PRINT_QT_PROGRAM
2330
2331 if AC_TRY_EVAL(ac_link) && test -s conftest; then
2332   kde_cv_qt_direct="yes"
2333 else
2334   kde_cv_qt_direct="no"
2335   echo "configure: failed program was:" >&AC_FD_CC
2336   cat conftest.$ac_ext >&AC_FD_CC
2337 fi
2338 rm -f conftest*
2339 CXXFLAGS="$ac_cxxflags_safe"
2340 LDFLAGS="$ac_ldflags_safe"
2341 LIBS="$ac_libs_safe"
2342
2343 LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
2344 export LD_LIBRARY_PATH
2345 LIBRARY_PATH="$ac_LIBRARY_PATH"
2346 export LIBRARY_PATH
2347 ])
2348
2349 if test "$kde_cv_qt_direct" = "yes"; then
2350   AC_MSG_RESULT(yes)
2351   $1
2352 else
2353   AC_MSG_RESULT(no)
2354   $2
2355 fi
2356 ])
2357
2358 ## ------------------------------------------------------------------------
2359 ## Try to find the Qt headers and libraries.
2360 ## $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
2361 ## and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
2362 ## ------------------------------------------------------------------------
2363 ##
2364 AC_DEFUN(AC_PATH_QT_1_3,
2365 [
2366 AC_REQUIRE([K_PATH_X])
2367
2368 AC_MSG_CHECKING([for Qt])
2369 ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
2370 qt_libraries=""
2371 qt_includes=""
2372 AC_ARG_WITH(qt-dir,
2373     [  --with-qt-dir           where the root of qt is installed ],
2374     [  ac_qt_includes="$withval"/include
2375        ac_qt_libraries="$withval"/lib
2376        ac_qt_bindir="$withval"/bin
2377     ])
2378
2379 AC_ARG_WITH(qt-includes,
2380     [  --with-qt-includes      where the Qt includes are. ],
2381     [  
2382        ac_qt_includes="$withval"
2383     ])
2384     
2385 kde_qt_libs_given=no
2386
2387 AC_ARG_WITH(qt-libraries,
2388     [  --with-qt-libraries     where the Qt library is installed.],
2389     [  ac_qt_libraries="$withval"
2390        kde_qt_libs_given=yes
2391     ])
2392
2393 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
2394
2395 AC_CACHE_VAL(ac_cv_have_qt,
2396 [#try to guess Qt locations
2397
2398 qt_incdirs="$ac_qt_includes /usr/lib/qt/include /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt $x_includes $QTINC"
2399 test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs"
2400 AC_FIND_FILE(qmovie.h, $qt_incdirs, qt_incdir)
2401 ac_qt_includes="$qt_incdir"
2402
2403 if test ! "$ac_qt_libraries" = "NO"; then
2404   qt_libdirs="$ac_qt_libraries"
2405 fi
2406
2407 qt_libdirs="$qt_libdirs /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt $x_libraries $QTLIB"
2408 test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs"
2409
2410 test=NONE
2411 qt_libdir=NONE
2412 for dir in $qt_libdirs; do
2413   try="ls -1 $dir/libqt*"
2414   if test=`eval $try 2> /dev/null`; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
2415 done
2416
2417 dnl AC_FIND_FILE(libqt.so libqt.so.1.40 libqt.so.1.41 libqt.so.1 libqt.a libqt.sl, $qt_libdirs, qt_libdir)
2418 ac_qt_libraries="$qt_libdir"
2419
2420 ac_cxxflags_safe="$CXXFLAGS"
2421 ac_ldflags_safe="$LDFLAGS"
2422 ac_libs_safe="$LIBS"
2423
2424 CXXFLAGS="$CXXFLAGS -I$qt_incdir"
2425 LDFLAGS="-L$qt_libdir $X_LDFLAGS"
2426 LIBS="$LIBS -lqt -lXext -lX11 $LIBSOCKET"
2427
2428 KDE_PRINT_QT_PROGRAM
2429
2430 if AC_TRY_EVAL(ac_link) && test -s conftest; then
2431   rm -f conftest*
2432 else
2433   echo "configure: failed program was:" >&AC_FD_CC
2434   cat conftest.$ac_ext >&AC_FD_CC
2435   ac_qt_libraries="NO"
2436 fi
2437 rm -f conftest*
2438 CXXFLAGS="$ac_cxxflags_safe"
2439 LDFLAGS="$ac_ldflags_safe"
2440 LIBS="$ac_libs_safe"
2441
2442 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
2443   ac_cv_have_qt="have_qt=no"
2444   ac_qt_notfound=""
2445   if test "$ac_qt_includes" = NO; then
2446     if test "$ac_qt_libraries" = NO; then
2447       ac_qt_notfound="(headers and libraries)";
2448     else
2449       ac_qt_notfound="(headers)";
2450     fi
2451   else
2452     ac_qt_notfound="(libraries)";
2453   fi
2454
2455   AC_MSG_ERROR([Qt-1.4 $ac_qt_notfound not found. Please check your installation! ]);
2456 else
2457   have_qt="yes"
2458 fi
2459 ])
2460 else
2461   have_qt="yes"
2462 fi
2463
2464 eval "$ac_cv_have_qt"
2465
2466 if test "$have_qt" != yes; then
2467   AC_MSG_RESULT([$have_qt]);
2468 else
2469   ac_cv_have_qt="have_qt=yes \
2470     ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
2471   AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes])
2472   
2473   qt_libraries="$ac_qt_libraries"
2474   qt_includes="$ac_qt_includes"
2475 fi
2476
2477 if test ! "$kde_qt_libs_given" = "yes"; then
2478 KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
2479 fi
2480
2481 AC_SUBST(qt_libraries)
2482 AC_SUBST(qt_includes)
2483
2484 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
2485  QT_INCLUDES="";
2486 else
2487  QT_INCLUDES="-I$qt_includes"
2488  all_includes="$QT_INCLUDES $all_includes"
2489 fi
2490
2491 if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
2492  QT_LDFLAGS=""
2493 else
2494  QT_LDFLAGS="-L$qt_libraries"
2495  all_libraries="$QT_LDFLAGS $all_libraries"
2496 fi
2497
2498 AC_SUBST(QT_INCLUDES)
2499 AC_SUBST(QT_LDFLAGS)
2500 AC_PATH_QT_MOC
2501 ])
2502
2503 AC_DEFUN(AC_PATH_QT,
2504 [
2505 AC_PATH_QT_1_3
2506 ])
2507
2508 ## ------------------------------------------------------------------------
2509 ## Now, the same with KDE
2510 ## $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
2511 ## and $(kde_includes) will be the kdehdrlocation (if needed)
2512 ## ------------------------------------------------------------------------
2513 ##
2514 AC_DEFUN(AC_BASE_PATH_KDE,
2515 [
2516 AC_REQUIRE([KDE_MISC_TESTS])
2517 AC_REQUIRE([AC_PATH_QT])dnl
2518 AC_MSG_CHECKING([for KDE])
2519
2520 if test "${prefix}" != NONE; then
2521   kde_includes=${prefix}/include
2522   ac_kde_includes=$prefix/include
2523
2524   if test "${exec_prefix}" != NONE; then
2525     kde_libraries=${exec_prefix}/lib
2526     ac_kde_libraries=$exec_prefix/lib
2527   else
2528     kde_libraries=${prefix}/lib
2529     ac_kde_libraries=$prefix/lib
2530   fi
2531 else
2532   ac_kde_includes=
2533   ac_kde_libraries=
2534   kde_libraries=""
2535   kde_includes=""
2536 fi
2537
2538 AC_CACHE_VAL(ac_cv_have_kde,
2539 [#try to guess kde locations
2540
2541 if test -z "$1"; then
2542
2543 kde_incdirs="$ac_kde_includes /usr/lib/kde/include /usr/local/kde/include /usr/kde/include /usr/include/kde /usr/include /opt/kde/include $x_includes $qt_includes"
2544 test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include $KDEDIR $kde_incdirs"
2545 AC_FIND_FILE(ksock.h, $kde_incdirs, kde_incdir)
2546 ac_kde_includes="$kde_incdir"
2547
2548 if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/ksock.h"; then
2549   AC_MSG_ERROR([
2550 in the prefix, you've chosen, are no kde headers installed. This will fail.
2551 So, check this please and use another prefix!])
2552 fi
2553
2554 kde_libdirs="$ac_kde_libraries /usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib /usr/X11R6/lib /opt/kde/lib /usr/X11R6/kde/lib"
2555 test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib $KDEDIR $kde_libdirs"
2556 AC_FIND_FILE(libkdecore.la, $kde_libdirs, kde_libdir)
2557 ac_kde_libraries="$kde_libdir"
2558
2559 if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/libkdecore.la"; then
2560 AC_MSG_ERROR([
2561 in the prefix, you've chosen $ac_kde_libraries, are no kde libraries installed. This will fail.
2562 So, check this please and use another prefix!])
2563 fi
2564 ac_kde_libraries="$kde_libdir"
2565
2566 if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO; then
2567   ac_cv_have_kde="have_kde=no"
2568 else
2569   ac_cv_have_kde="have_kde=yes \
2570     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
2571 fi
2572
2573 else dnl test -z $1 
2574   
2575   ac_cv_have_kde="have_kde=no"
2576
2577 fi
2578 ])dnl
2579
2580 eval "$ac_cv_have_kde"
2581
2582 if test "$have_kde" != "yes"; then
2583  if test "${prefix}" = NONE; then
2584   ac_kde_prefix="$ac_default_prefix"
2585  else
2586   ac_kde_prefix="$prefix"
2587  fi
2588  if test "$exec_prefix" = NONE; then
2589   ac_kde_exec_prefix="$ac_kde_prefix"
2590   AC_MSG_RESULT([will be installed in $ac_kde_prefix])
2591  else
2592   ac_kde_exec_prefix="$exec_prefix"
2593   AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
2594  fi
2595
2596  kde_libraries="${ac_kde_exec_prefix}/lib"
2597  kde_includes=${ac_kde_prefix}/include
2598
2599 else
2600   ac_cv_have_kde="have_kde=yes \
2601     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
2602   AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
2603   
2604   kde_libraries="$ac_kde_libraries"
2605   kde_includes="$ac_kde_includes"
2606 fi
2607 AC_SUBST(kde_libraries)
2608 AC_SUBST(kde_includes)
2609
2610 if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes" ; then
2611  KDE_INCLUDES=""
2612 else
2613  KDE_INCLUDES="-I$kde_includes"
2614  all_includes="$KDE_INCLUDES $all_includes"
2615 fi
2616
2617 if test "$kde_libraries" = "$x_libraries" || test "$kde_libraries" = "$qt_libraries" ; then
2618  KDE_LDFLAGS=""
2619 else
2620  KDE_LDFLAGS="-L$kde_libraries"
2621  all_libraries="$KDE_LDFLAGS $all_libraries"
2622 fi
2623
2624 AC_SUBST(KDE_LDFLAGS)
2625 AC_SUBST(KDE_INCLUDES)
2626
2627 KDE_CHECK_EXTRA_LIBS
2628
2629 AC_SUBST(all_includes)
2630 AC_SUBST(all_libraries)
2631
2632 ])
2633
2634 AC_DEFUN(KDE_CHECK_EXTRA_LIBS,
2635 [
2636 AC_MSG_CHECKING(for extra includes)
2637 AC_ARG_WITH(extra-includes, [  --with-extra-includes   adds non standard include paths], 
2638   kde_use_extra_includes="$withval",
2639   kde_use_extra_includes=NONE
2640 )
2641 if test -n "$kde_use_extra_includes" && \
2642    test "$kde_use_extra_includes" != "NONE"; then
2643
2644    ac_save_ifs=$IFS
2645    IFS=':'
2646    for dir in $kde_use_extra_includes; do
2647      all_includes="$all_includes -I$dir"
2648      USER_INCLUDES="$USER_INCLUDES -I$dir"
2649    done
2650    IFS=$ac_save_ifs
2651    kde_use_extra_includes="added"
2652 else
2653    kde_use_extra_includes="no"
2654 fi
2655
2656 AC_MSG_RESULT($kde_use_extra_includes)
2657
2658 AC_MSG_CHECKING(for extra libs)
2659 AC_ARG_WITH(extra-libs, [  --with-extra-libs       adds non standard library paths], 
2660   kde_use_extra_libs=$withval,
2661   kde_use_extra_libs=NONE
2662 )
2663 if test -n "$kde_use_extra_libs" && \
2664    test "$kde_use_extra_libs" != "NONE"; then
2665
2666    ac_save_ifs=$IFS
2667    IFS=':'
2668    for dir in $kde_use_extra_libs; do
2669      all_libraries="$all_libraries -L$dir"
2670      KDE_EXTRA_RPATH="$KDE_EXTRA_RPATH -rpath $dir"
2671      USER_LDFLAGS="$USER_LDFLAGS -L$dir"
2672    done
2673    IFS=$ac_save_ifs
2674    kde_use_extra_libs="added"
2675 else
2676    kde_use_extra_libs="no"
2677 fi
2678
2679 AC_MSG_RESULT($kde_use_extra_libs)
2680
2681 ])
2682
2683 AC_DEFUN(KDE_CHECK_KIMGIO,
2684 [
2685    AC_REQUIRE([AC_FIND_TIFF])
2686    AC_REQUIRE([AC_FIND_JPEG]) 
2687    AC_REQUIRE([AC_FIND_PNG]) 
2688
2689    LIB_KIMGIO='-lkimgio $(LIBJPEG) $(LIBTIFF) $(LIBPNG) -lm'
2690    AC_SUBST(LIB_KIMGIO)
2691    LIB_KHTMLW='-lkhtmlw $(LIB_KIMGIO) -ljscript'
2692    AC_SUBST(LIB_KHTMLW)
2693    LIB_KHTML='-lkhtml $(LIB_KIMGIO) -ljscript'
2694    AC_SUBST(LIB_KHTML)
2695 ])
2696
2697 AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
2698 [
2699    AC_REQUIRE([KDE_MISC_TESTS])
2700
2701    KDE_LIBS='-lqt -lkdecore -lkdeui -lkfm -lkfile'
2702    AC_SUBST(KDE_LIBS)
2703 #   LIB_X11='-lX11 $(LIBSOCKET)'
2704 #   AC_SUBST(LIB_X11)
2705 #   LIB_QT='-lqt $(LIB_X11)'
2706 #   AC_SUBST(LIB_QT)
2707 #   LIB_KDECORE='-lkdecore -lXext $(LIB_QT)'
2708 #   AC_SUBST(LIB_KDECORE)
2709 #   LIB_KDEUI='-lkdeui $(LIB_KDECORE)'
2710 #   AC_SUBST(LIB_KDEUI)
2711 #   LIB_KFM='-lkfm $(LIB_KDECORE)'
2712 #   AC_SUBST(LIB_KFM)
2713 #   LIB_KFILE='-lkfile $(LIB_KFM) $(LIB_KDEUI)'
2714 #   AC_SUBST(LIB_KFILE)
2715 ])
2716
2717 AC_DEFUN(AC_PATH_KDE,
2718 [
2719   AC_BASE_PATH_KDE
2720   AC_ARG_ENABLE(path-check, [  --disable-path-check    don't try to find out, where to install],
2721   [
2722   if test "$enableval" = "no"; 
2723     then ac_use_path_checking="default"
2724     else ac_use_path_checking=""
2725   fi
2726   ], [ac_use_path_checking=""]
2727   )
2728
2729   AC_ARG_WITH(install-root, [  --with-install-root     the root, where to install to [default=/]],
2730   [
2731   if test "$withval" = "no";
2732     then kde_install_root="";
2733     else kde_install_root=$withval;
2734   fi
2735   ], [kde_install_root=""]
2736   )
2737   
2738   if test -n "$kde_install_root"; then
2739      install_root="$kde_install_root"
2740   else
2741      install_root=
2742   fi
2743
2744   AC_CREATE_KFSSTND($ac_use_path_checking)
2745
2746   AC_SUBST_KFSSTND
2747   KDE_CREATE_LIBS_ALIASES
2748 ])
2749
2750 dnl slightly changed version of AC_CHECK_FUNC(setenv)
2751 AC_DEFUN(AC_CHECK_SETENV,
2752 [AC_MSG_CHECKING([for setenv])
2753 AC_CACHE_VAL(ac_cv_func_setenv,
2754 [AC_LANG_C
2755 AC_TRY_LINK(
2756 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
2757 dnl which includes <sys/select.h> which contains a prototype for
2758 dnl select.  Similarly for bzero.
2759 [#include <assert.h>
2760 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
2761 extern "C"
2762 #endif
2763 ])dnl
2764 [/* We use char because int might match the return type of a gcc2
2765     builtin and then its argument prototype would still apply.  */
2766 #include <stdlib.h>
2767 ], [
2768 /* The GNU C library defines this for functions which it implements
2769     to always fail with ENOSYS.  Some functions are actually named
2770     something starting with __ and the normal name is an alias.  */
2771 #if defined (__stub_$1) || defined (__stub___$1)
2772 choke me
2773 #else
2774 setenv("TEST", "alle", 1);
2775 #endif
2776 ], eval "ac_cv_func_setenv=yes", eval "ac_cv_func_setenv=no")])
2777
2778 if test "$ac_cv_func_setenv" = "yes"; then
2779   AC_MSG_RESULT(yes)
2780   AC_DEFINE_UNQUOTED(HAVE_FUNC_SETENV)
2781 else
2782   AC_MSG_RESULT(no)
2783 fi
2784 ])
2785
2786 AC_DEFUN(AC_CHECK_GETDOMAINNAME,
2787 [
2788 AC_LANG_CPLUSPLUS
2789 save_CXXFLAGS="$CXXFLAGS"
2790 if test "$GCC" = "yes"; then
2791 CXXFLAGS="$CXXFLAGS -pedantic-errors"
2792 fi
2793 AC_MSG_CHECKING(for getdomainname)
2794 AC_CACHE_VAL(ac_cv_func_getdomainname,
2795 [
2796 AC_TRY_COMPILE([
2797 #include <stdlib.h>
2798 #include <unistd.h>
2799 ],
2800 [
2801 char buffer[200];
2802 getdomainname(buffer, 200);
2803 ],
2804 ac_cv_func_getdomainname=yes,
2805 ac_cv_func_getdomainname=no)
2806 ])
2807 AC_MSG_RESULT($ac_cv_func_getdomainname)
2808 if eval "test \"`echo `$ac_cv_func_getdomainname\" = yes"; then
2809   AC_DEFINE(HAVE_GETDOMAINNAME)
2810 fi
2811 CXXFLAGS="$save_CXXFLAGS"
2812 ])
2813
2814 AC_DEFUN(AC_CHECK_GETHOSTNAME,
2815 [
2816 AC_LANG_CPLUSPLUS
2817 save_CXXFLAGS="$CXXFLAGS"
2818 if test "$GCC" = "yes"; then
2819 CXXFLAGS="$CXXFLAGS -pedantic-errors"
2820 fi
2821
2822 AC_MSG_CHECKING([for gethostname])
2823 AC_CACHE_VAL(ac_cv_func_gethostname,
2824 [
2825 AC_TRY_COMPILE([
2826 #include <stdlib.h>
2827 #include <unistd.h>
2828 ],
2829 [
2830 char buffer[200];
2831 gethostname(buffer, 200);
2832 ],
2833 ac_cv_func_gethostname=yes,
2834 ac_cv_func_gethostname=no)
2835 ])
2836 AC_MSG_RESULT($ac_cv_func_gethostname)
2837 if eval "test \"`echo `$ac_cv_func_gethostname\" = yes"; then
2838   AC_DEFINE(HAVE_GETHOSTNAME)
2839 fi
2840 CXXFLAGS="$save_CXXFLAGS"
2841 ])
2842
2843 AC_DEFUN(AC_CHECK_USLEEP,
2844 [
2845 AC_LANG_CPLUSPLUS
2846
2847 AC_MSG_CHECKING([for usleep])
2848 AC_CACHE_VAL(ac_cv_func_usleep,
2849 [
2850 ac_libs_safe="$LIBS"
2851 LIBS="$LIBS $LIBUCB"
2852 AC_TRY_LINK([
2853 #include <stdlib.h>
2854 #include <unistd.h>
2855 ],
2856 [
2857 usleep(200);
2858 ],
2859 ac_cv_func_usleep=yes,
2860 ac_cv_func_usleep=no)
2861 ])
2862 AC_MSG_RESULT($ac_cv_func_usleep)
2863 if eval "test \"`echo `$ac_cv_func_usleep\" = yes"; then
2864   AC_DEFINE(HAVE_USLEEP)
2865 fi
2866 LIBS="$ac_libs_safe"
2867 ])
2868
2869 AC_DEFUN(AC_FIND_GIF,
2870    [AC_MSG_CHECKING([for giflib])
2871 AC_CACHE_VAL(ac_cv_lib_gif,
2872 [ac_save_LIBS="$LIBS"
2873 LIBS="$all_libraries -lgif -lX11 $LIBSOCKET"
2874 AC_TRY_LINK(dnl
2875 [
2876 #ifdef __cplusplus
2877 extern "C" {
2878 #endif
2879 int GifLastError(void);
2880 #ifdef __cplusplus
2881 }
2882 #endif
2883 /* We use char because int might match the return type of a gcc2
2884     builtin and then its argument prototype would still apply.  */
2885 ],
2886             [return GifLastError();],
2887             eval "ac_cv_lib_gif=yes",
2888             eval "ac_cv_lib_gif=no")
2889 LIBS="$ac_save_LIBS"
2890 ])dnl
2891 if eval "test \"`echo $ac_cv_lib_gif`\" = yes"; then
2892   AC_MSG_RESULT(yes)
2893   AC_DEFINE_UNQUOTED(HAVE_LIBGIF)
2894 else
2895   AC_MSG_ERROR(You need giflib23. Please install the kdesupport package)
2896 fi
2897 ])
2898
2899 AC_DEFUN(AC_FIND_JPEG,
2900    [AC_MSG_CHECKING([for jpeglib])
2901 AC_CACHE_VAL(ac_cv_lib_jpeg,
2902 [ac_save_LIBS="$LIBS"
2903 LIBS="$all_libraries -ljpeg -lm"
2904 AC_TRY_LINK(
2905 [/* Override any gcc2 internal prototype to avoid an error.  */
2906 struct jpeg_decompress_struct;
2907 typedef struct jpeg_decompress_struct * j_decompress_ptr;
2908 typedef int size_t;
2909 #ifdef __cplusplus
2910 extern "C" {
2911 #endif
2912     void jpeg_CreateDecompress(j_decompress_ptr cinfo,
2913                                     int version, size_t structsize);
2914 #ifdef __cplusplus
2915 }
2916 #endif
2917 /* We use char because int might match the return type of a gcc2
2918     builtin and then its argument prototype would still apply.  */
2919 ],
2920             [jpeg_CreateDecompress(0L, 0, 0);],
2921             eval "ac_cv_lib_jpeg=-ljpeg",
2922             eval "ac_cv_lib_jpeg=no")
2923 LIBS="$ac_save_LIBS"
2924
2925 dnl what to do, if the normal way fails:
2926 if eval "test \"`echo $ac_cv_lib_jpeg`\" = no"; then
2927         if test -f "$kde_libraries/libjpeg.so"; then
2928            test -f ./libjpegkde.so || $LN_S $kde_libraries/libjpeg.so ./libjpegkde.so
2929            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
2930         else if test -f "$kde_libraries/libjpeg.sl"; then
2931            test -f ./libjpegkde.sl ||$LN_S $kde_libraries/libjpeg.sl ./libjpegkde.sl
2932            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"      
2933         else if test -f "$kde_libraries/libjpeg.a"; then
2934            test -f ./libjpegkde.a || $LN_S $kde_libraries/libjpeg.a ./libjpegkde.a
2935            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
2936         else
2937           AC_MSG_ERROR([
2938 You need jpeglib6a. Please install the kdesupport package.
2939 If you have already installed kdesupport, you may have an
2940 old libjpeg somewhere. 
2941 In this case copy $KDEDIR/lib/libjpeg* to /usr/lib.
2942 ])
2943         fi
2944       fi
2945    fi
2946 fi
2947 ])dnl
2948 if eval "test ! \"`echo $ac_cv_lib_jpeg`\" = no"; then
2949   LIBJPEG="$ac_cv_lib_jpeg"
2950   AC_SUBST(LIBJPEG)
2951   AC_MSG_RESULT($ac_cv_lib_jpeg)
2952   AC_DEFINE_UNQUOTED(HAVE_LIBJPEG)
2953 fi
2954 ])
2955
2956 AC_DEFUN(AC_FIND_ZLIB,
2957 [
2958 AC_MSG_CHECKING([for libz])
2959 AC_CACHE_VAL(ac_cv_lib_z,
2960 [ac_save_LIBS="$LIBS"
2961 LIBS="$all_libraries -lz $LIBSOCKET"
2962 AC_TRY_LINK(dnl
2963 [
2964 #include<zlib.h>
2965 ],
2966             [return (zlibVersion() == ZLIB_VERSION); ],
2967             eval "ac_cv_lib_z='-lz'",
2968             eval "ac_cv_lib_z=no")
2969 LIBS="$ac_save_LIBS"
2970 ])dnl
2971 if eval "test ! \"`echo $ac_cv_lib_z`\" = no"; then
2972 dnl  AC_DEFINE_UNQUOTED(HAVE_LIBZ)
2973   LIBZ="$ac_cv_lib_z"
2974   AC_SUBST(LIBZ)
2975   AC_MSG_RESULT($ac_cv_lib_z)
2976 else
2977   AC_MSG_RESULT(no)
2978   LIBZ=""
2979   AC_SUBST(LIBZ)
2980 fi
2981 ])
2982
2983 AC_DEFUN(AC_FIND_TIFF,
2984 [
2985 AC_REQUIRE([AC_FIND_ZLIB])
2986 AC_REQUIRE([AC_FIND_JPEG])
2987 AC_MSG_CHECKING([for libtiff])
2988 AC_CACHE_VAL(ac_cv_lib_tiff,
2989 [ac_save_LIBS="$LIBS"
2990 LIBS="$all_libraries -ltiff $LIBJPEG $LIBZ -lX11 $LIBSOCKET"
2991 AC_TRY_LINK(dnl
2992 [
2993 #include<tiffio.h>
2994 ],
2995             [return (TIFFOpen( "", "r") == 0); ],
2996             eval "ac_cv_lib_tiff='-ltiff $LIBJPEG $LIBZ'",
2997             eval "ac_cv_lib_tiff=no")
2998 LIBS="$ac_save_LIBS"
2999 ])dnl
3000 if eval "test ! \"`echo $ac_cv_lib_tiff`\" = no"; then
3001   AC_DEFINE_UNQUOTED(HAVE_LIBTIFF)
3002   LIBTIFF="$ac_cv_lib_tiff"
3003   AC_SUBST(LIBTIFF)
3004   AC_MSG_RESULT($ac_cv_lib_tiff)
3005 else
3006   AC_MSG_RESULT(no)
3007   LIBTIFF=""
3008   AC_SUBST(LIBTIFF)
3009 fi
3010 ])
3011
3012
3013 AC_DEFUN(AC_FIND_PNG,
3014 [
3015 AC_REQUIRE([AC_FIND_ZLIB])
3016 AC_MSG_CHECKING([for libpng])
3017 AC_CACHE_VAL(ac_cv_lib_png,
3018 [ac_save_LIBS="$LIBS"
3019 LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET"
3020 AC_LANG_C
3021 AC_TRY_LINK(dnl
3022     [
3023     #include<png.h>
3024     ],
3025     [
3026     png_structp png_ptr = png_create_read_struct(  // image ptr
3027                 PNG_LIBPNG_VER_STRING, 0, 0, 0 );
3028     return( png_ptr != 0 ); 
3029     ],
3030     eval "ac_cv_lib_png='-lpng $LIBZ -lm'",
3031     eval "ac_cv_lib_png=no")
3032     LIBS="$ac_save_LIBS"
3033 ])dnl
3034 if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
3035   AC_DEFINE_UNQUOTED(HAVE_LIBPNG)
3036   LIBPNG="$ac_cv_lib_png"
3037   AC_SUBST(LIBPNG)
3038   AC_MSG_RESULT($ac_cv_lib_png)
3039 else
3040   AC_MSG_RESULT(no)
3041   LIBPNG=""
3042   AC_SUBST(LIBPNG)
3043 fi
3044 ])
3045
3046 AC_DEFUN(AC_CHECK_GNU_EXTENSIONS,
3047 [
3048 AC_MSG_CHECKING(if you need GNU extensions)
3049 AC_CACHE_VAL(ac_cv_gnu_extensions,
3050 [
3051 cat > conftest.c << EOF
3052 #include <features.h>
3053
3054 #ifdef __GNU_LIBRARY__
3055 yes
3056 #endif
3057 EOF
3058
3059 if (eval "$ac_cpp conftest.c") 2>&5 |
3060   egrep "yes" >/dev/null 2>&1; then
3061   rm -rf conftest*
3062   ac_cv_gnu_extensions=yes
3063 else
3064   ac_cv_gnu_extensions=no
3065 fi
3066 ])
3067
3068 AC_MSG_RESULT($ac_cv_gnu_extensions)
3069 if test "$ac_cv_gnu_extensions" = "yes"; then
3070   AC_DEFINE_UNQUOTED(_GNU_SOURCE)
3071 fi
3072 ])
3073
3074 AC_DEFUN(AC_CHECK_COMPILERS,
3075 [
3076   dnl this is somehow a fat lie, but prevents other macros from double checking
3077   AC_PROVIDE([AC_PROG_CC])
3078   AC_PROVIDE([AC_PROG_CPP])
3079   AC_ARG_ENABLE(debug,[  --enable-debug           creates debugging code [default=no]],
3080   [ 
3081    if test $enableval = "no"; dnl 
3082      then ac_use_debug_code="no"
3083      else ac_use_debug_code="yes"
3084    fi
3085   ], [ac_use_debug_code="no"])
3086
3087   AC_ARG_ENABLE(strict,[  --enable-strict         compiles with strict compiler options (may not work!)],
3088    [ 
3089     if test $enableval = "no"; then 
3090          ac_use_strict_options="no"
3091        else 
3092          ac_use_strict_options="yes"
3093     fi
3094    ], [ac_use_strict_options="no"])
3095
3096 dnl this was AC_PROG_CC. I had to include it manualy, since I had to patch it
3097   AC_MSG_CHECKING(for a C-Compiler)
3098   dnl if there is one, print out. if not, don't matter
3099   AC_MSG_RESULT($CC) 
3100  
3101   if test -z "$CC"; then AC_CHECK_PROG(CC, gcc, gcc) fi
3102   if test -z "$CC"; then AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) fi
3103   if test -z "$CC"; then AC_CHECK_PROG(CC, xlc, xlc) fi
3104   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
3105
3106   AC_PROG_CC_WORKS
3107   AC_PROG_CC_GNU
3108
3109   if test $ac_cv_prog_gcc = yes; then
3110     GCC=yes
3111   else
3112     GCC=
3113   fi
3114
3115   if test -z "$CFLAGS"; then
3116     if test "$ac_use_debug_code" = "yes"; then
3117       AC_PROG_CC_G
3118       if test $ac_cv_prog_cc_g = yes; then
3119         CFLAGS="-g"
3120       fi
3121     else
3122       if test "$GCC" = "yes"; then
3123         CFLAGS="-O2"
3124       else
3125         CFLAGS=""
3126       fi
3127     fi
3128
3129     if test "$GCC" = "yes"; then
3130      CFLAGS="$CFLAGS -Wall"
3131
3132      if test "$ac_use_strict_options" = "yes"; then
3133         CFLAGS="$CFLAGS -W -ansi -pedantic"     
3134      fi
3135     fi
3136
3137   fi
3138
3139   case "$host" in 
3140   *-*-sysv4.2uw*) CFLAGS="$CFLAGS -D_UNIXWARE";;
3141   esac
3142
3143   if test -z "$LDFLAGS" && test "$ac_use_debug_code" = "no" && test "$GCC" = "yes"; then
3144      LDFLAGS="-s"
3145   fi
3146
3147
3148 dnl this is AC_PROG_CPP. I had to include it here, since autoconf checks
3149 dnl dependecies between AC_PROG_CPP and AC_PROG_CC (or is it automake?)
3150
3151   AC_MSG_CHECKING(how to run the C preprocessor)
3152   # On Suns, sometimes $CPP names a directory.
3153   if test -n "$CPP" && test -d "$CPP"; then
3154     CPP=
3155   fi
3156   if test -z "$CPP"; then
3157   AC_CACHE_VAL(ac_cv_prog_CPP,
3158   [  # This must be in double quotes, not single quotes, because CPP may get
3159     # substituted into the Makefile and "${CC-cc}" will confuse make.
3160     CPP="${CC-cc} -E"
3161     # On the NeXT, cc -E runs the code through the compiler's parser,
3162     # not just through cpp.
3163     dnl Use a header file that comes with gcc, so configuring glibc    
3164     dnl with a fresh cross-compiler works.
3165     AC_TRY_CPP([#include <assert.h>
3166     Syntax Error], ,
3167     CPP="${CC-cc} -E -traditional-cpp"
3168     AC_TRY_CPP([#include <assert.h>
3169     Syntax Error], , CPP=/lib/cpp))
3170     ac_cv_prog_CPP="$CPP"])dnl
3171     CPP="$ac_cv_prog_CPP"
3172   else
3173     ac_cv_prog_CPP="$CPP"
3174   fi
3175   AC_MSG_RESULT($CPP)
3176   AC_SUBST(CPP)dnl
3177
3178
3179   AC_MSG_CHECKING(for a C++-Compiler)
3180   dnl if there is one, print out. if not, don't matter
3181   AC_MSG_RESULT($CXX) 
3182  
3183   if test -z "$CXX"; then AC_CHECK_PROG(CXX, g++, g++) fi
3184   if test -z "$CXX"; then AC_CHECK_PROG(CXX, CC, CC) fi
3185   if test -z "$CXX"; then AC_CHECK_PROG(CXX, xlC, xlC) fi
3186   if test -z "$CXX"; then AC_CHECK_PROG(CXX, DCC, DCC) fi
3187   test -z "$CXX" && AC_MSG_ERROR([no acceptable C++-compiler found in \$PATH])
3188
3189   AC_PROG_CXX_WORKS
3190   AC_PROG_CXX_GNU
3191
3192   if test $ac_cv_prog_gxx = yes; then
3193     GXX=yes
3194   else
3195     AC_MSG_CHECKING(whether we are using SPARC CC)
3196     GXX=
3197     cat > conftest.C << EOF
3198 #ifdef __SUNPRO_CC
3199    yes;
3200 #endif
3201 EOF
3202
3203     ac_try="$CXX -E conftest.C"
3204     if { (eval echo configure:__online__: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } | egrep yes >/dev/null 2>&1; then
3205       ac_cv_prog_CC=yes
3206     else
3207       ac_cv_prog_CC=no
3208     fi
3209     AC_MSG_RESULT($ac_cv_prog_CC)
3210   fi
3211
3212   if test -z "$CXXFLAGS"; then 
3213     if test "$ac_use_debug_code" = "yes"; then
3214       AC_PROG_CXX_G
3215       if test $ac_cv_prog_cxx_g = yes; then
3216         CXXFLAGS="-g"
3217       fi
3218       if test "$ac_cv_prog_CC" = "yes"; then
3219         CXXFLAGS="$CXXFLAGS -pto"
3220       fi
3221     else
3222       if test "$GXX" = "yes"; then
3223          CXXFLAGS="-O2"
3224       else
3225          if test "$ac_cv_prog_CC" = "yes"; then
3226             CXXFLAGS="-pto -O2"
3227          else
3228             CXXFLAGS=""
3229          fi
3230       fi
3231     fi
3232
3233     if test "$GXX" = "yes"; then
3234        CXXFLAGS="$CXXFLAGS -Wall"
3235  
3236        if test "$ac_use_strict_options" = "yes"; then
3237         CXXFLAGS="$CXXFLAGS -W -ansi -Wtraditional  -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Woverloaded-virtual -Wbad-function-cast  -Wsynth"
3238        fi
3239
3240        if test "$kde_very_strict" = "yes"; then
3241          CXXFLAGS="$CXXFLAGS -Wold-style-cast -Wshadow -Wredundant-decls -Wconversion"
3242        fi
3243     fi
3244   fi  
3245
3246     case "$host" in
3247       *-*-sysv4.2uw*) CXXFLAGS="$CXXFLAGS -D_UNIXWARE";;
3248     esac    
3249
3250 ])
3251
3252 dnl just a wrapper to clean up configure.in
3253 AC_DEFUN(KDE_PROG_LIBTOOL,
3254 [
3255 AC_REQUIRE([AM_ENABLE_SHARED])
3256 AC_REQUIRE([AM_ENABLE_STATIC])
3257 dnl libtool is only for C, so I must force him
3258 dnl to find the correct flags for C++
3259 ac_save_cc=$CC
3260 ac_save_cflags="$CFLAGS"
3261 CC=$CXX
3262 CFLAGS="$CXXFLAGS"
3263 AM_PROG_LIBTOOL dnl for libraries
3264 CC=$ac_save_cc
3265 CFLAGS="$ac_save_cflags"
3266 ])
3267
3268 AC_DEFUN(KDE_DO_IT_ALL,
3269 [
3270 AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde})
3271 KDE_PROG_LIBTOOL
3272 AM_KDE_WITH_NLS
3273 AC_PATH_KDE
3274 ])
3275
3276 AC_DEFUN(AC_CHECK_RPATH,
3277 [
3278 AC_MSG_CHECKING(for rpath)
3279 AC_ARG_ENABLE(rpath,
3280       [  --disable-rpath         do not use the rpath feature of ld],
3281       USE_RPATH=$enableval, USE_RPATH=yes)
3282 if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
3283
3284   KDE_RPATH="-rpath \$(kde_libraries)"
3285
3286   if test -n "$qt_libraries"; then
3287     KDE_RPATH="$KDE_RPATH -rpath \$(qt_libraries)"
3288   fi
3289   dnl $x_libraries is set to /usr/lib in case
3290   if test -n "$X_LDFLAGS"; then 
3291     KDE_RPATH="$KDE_RPATH -rpath \$(x_libraries)"
3292   fi
3293   if test -n "$KDE_EXTRA_RPATH"; then
3294     KDE_RPATH="$KDE_RPATH \$(KDE_EXTRA_RPATH)"
3295   fi
3296 fi 
3297 AC_SUBST(KDE_EXTRA_RPATH)
3298 AC_SUBST(KDE_RPATH)
3299 AC_MSG_RESULT($USE_RPATH)
3300 ])
3301
3302 dnl This is a merge of some macros out of the gettext aclocal.m4
3303 dnl since we don't need anything, I took the things we need
3304 AC_DEFUN(AM_KDE_WITH_NLS,
3305   [AC_MSG_CHECKING([whether NLS is requested])
3306     AC_LANG_CPLUSPLUS
3307     dnl Default is enabled NLS
3308     AC_ARG_ENABLE(nls,
3309       [  --disable-nls           do not use Native Language Support],
3310       USE_NLS=$enableval, USE_NLS=yes)
3311     AC_MSG_RESULT($USE_NLS)
3312     AC_SUBST(USE_NLS)
3313
3314     dnl If we use NLS figure out what method
3315     if test "$USE_NLS" = "yes"; then
3316       AC_DEFINE(ENABLE_NLS)
3317
3318       AM_PATH_PROG_WITH_TEST_KDE(MSGFMT, msgfmt, 
3319          [test -n "`$ac_dir/$ac_word --version 2>&1 | grep 'GNU gettext'`"], msgfmt)
3320       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
3321
3322       if test -z "`$MSGFMT --version 2>&1 | grep 'GNU gettext'`"; then
3323         AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; ignore it])
3324         msgfmt=":"
3325       fi
3326       AC_SUBST(MSGFMT)
3327
3328       AM_PATH_PROG_WITH_TEST_KDE(XGETTEXT, xgettext,
3329         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
3330
3331       dnl Test whether we really found GNU xgettext.
3332       if test "$XGETTEXT" != ":"; then
3333         dnl If it is no GNU xgettext we define it as : so that the
3334         dnl Makefiles still can work.
3335         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
3336           : ;
3337         else
3338           AC_MSG_RESULT(
3339             [found xgettext programs is not GNU xgettext; ignore it])
3340           XGETTEXT=":"
3341         fi
3342       fi
3343      AC_SUBST(XGETTEXT)
3344     fi
3345
3346   ])
3347
3348 # Search path for a program which passes the given test.
3349 # Ulrich Drepper <drepper@cygnus.com>, 1996.
3350
3351 # serial 1
3352 # Stephan Kulow: I appended a _KDE against name conflicts
3353
3354 dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR,
3355 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
3356 AC_DEFUN(AM_PATH_PROG_WITH_TEST_KDE,
3357 [# Extract the first word of "$2", so it can be a program name with args.
3358 set dummy $2; ac_word=[$]2
3359 AC_MSG_CHECKING([for $ac_word])
3360 AC_CACHE_VAL(ac_cv_path_$1,
3361 [case "[$]$1" in
3362   /*)
3363   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
3364   ;;
3365   *)
3366   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
3367   for ac_dir in ifelse([$5], , $PATH, [$5]); do
3368     test -z "$ac_dir" && ac_dir=.
3369     if test -f $ac_dir/$ac_word; then
3370       if [$3]; then
3371         ac_cv_path_$1="$ac_dir/$ac_word"
3372         break
3373       fi
3374     fi
3375   done
3376   IFS="$ac_save_ifs"
3377 dnl If no 4th arg is given, leave the cache variable unset,
3378 dnl so AC_PATH_PROGS will keep looking.
3379 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
3380 ])dnl
3381   ;;
3382 esac])dnl
3383 $1="$ac_cv_path_$1"
3384 if test -n "[$]$1"; then
3385   AC_MSG_RESULT([$]$1)
3386 else
3387   AC_MSG_RESULT(no)
3388 fi
3389 AC_SUBST($1)dnl
3390 ])
3391
3392
3393 dnl From Jim Meyering.
3394 dnl FIXME: migrate into libit.
3395
3396 AC_DEFUN(AM_FUNC_OBSTACK,
3397 [AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
3398  [AC_TRY_LINK([#include "obstack.h"],
3399               [struct obstack *mem;obstack_free(mem,(char *) 0)],
3400               am_cv_func_obstack=yes,
3401               am_cv_func_obstack=no)])
3402  if test $am_cv_func_obstack = yes; then
3403    AC_DEFINE(HAVE_OBSTACK)
3404  else
3405    LIBOBJS="$LIBOBJS obstack.o"
3406  fi
3407 ])
3408
3409 dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
3410 dnl FIXME: Migrate into libit
3411
3412 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
3413 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
3414  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
3415               am_cv_lib_error_at_line=yes,
3416               am_cv_lib_error_at_line=no)])
3417  if test $am_cv_lib_error_at_line = no; then
3418    LIBOBJS="$LIBOBJS error.o"
3419  fi
3420  AC_SUBST(LIBOBJS)dnl
3421 ])
3422
3423 # Macro to add for using GNU gettext.
3424 # Ulrich Drepper <drepper@cygnus.com>, 1995.
3425
3426 # serial 1
3427 # Stephan Kulow: I put a KDE in it to avoid name conflicts
3428
3429 AC_DEFUN(AM_KDE_GNU_GETTEXT,
3430   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
3431    AC_REQUIRE([AC_PROG_RANLIB])dnl
3432    AC_REQUIRE([AC_HEADER_STDC])dnl
3433    AC_REQUIRE([AC_C_INLINE])dnl
3434    AC_REQUIRE([AC_TYPE_OFF_T])dnl
3435    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
3436    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
3437    AC_REQUIRE([AC_FUNC_MMAP])dnl
3438    AC_REQUIRE([AM_KDE_WITH_NLS])dnl
3439    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
3440 unistd.h values.h alloca.h])
3441    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
3442 __argz_count __argz_stringify __argz_next stpcpy])
3443
3444    AM_LC_MESSAGES
3445
3446    if test "x$CATOBJEXT" != "x"; then
3447      if test "x$ALL_LINGUAS" = "x"; then
3448        LINGUAS=
3449      else
3450        AC_MSG_CHECKING(for catalogs to be installed)
3451        NEW_LINGUAS=
3452        for lang in ${LINGUAS=$ALL_LINGUAS}; do
3453          case "$ALL_LINGUAS" in
3454           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
3455          esac
3456        done
3457        LINGUAS=$NEW_LINGUAS
3458        AC_MSG_RESULT($LINGUAS)
3459      fi
3460
3461      dnl Construct list of names of catalog files to be constructed.
3462      if test -n "$LINGUAS"; then
3463        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
3464      fi
3465    fi
3466
3467   ])
3468
3469 AC_DEFUN(AC_HAVE_XPM,
3470  [AC_REQUIRE_CPP()dnl
3471
3472  test -z "$XPM_LDFLAGS" && XPM_LDFLAGS=
3473  test -z "$XPM_INCLUDE" && XPM_INCLUDE=
3474
3475  AC_ARG_WITH(xpm, [  --without-xpm           disable color pixmap XPM tests],
3476         xpm_test=$withval, xpm_test="yes")
3477  if test "x$xpm_test" = xno; then
3478    ac_cv_have_xpm=no
3479  else
3480    AC_MSG_CHECKING(for XPM)
3481    AC_CACHE_VAL(ac_cv_have_xpm,
3482    [
3483     AC_LANG_C
3484     ac_save_ldflags="$LDFLAGS"
3485     ac_save_cflags="$CFLAGS"
3486     LDFLAGS="$LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm -lX11 -lXext $LIBSOCKET"
3487     CFLAGS="$CFLAGS $X_INCLUDES"
3488     test ! -z "$XPM_INCLUDE" && CFLAGS="-I$XPM_INCLUDE $CFLAGS"
3489     AC_TRY_LINK([#include <X11/xpm.h>],[],
3490         ac_cv_have_xpm="yes",ac_cv_have_xpm="no")
3491     LDFLAGS="$ac_save_ldflags"
3492     CFLAGS="$ac_save_cflags"
3493    ])dnl
3494  
3495   if test "$ac_cv_have_xpm" = no; then
3496     AC_MSG_RESULT(no)
3497     XPM_LDFLAGS=""
3498     XPMINC=""
3499     $2
3500   else
3501     AC_DEFINE(HAVE_XPM)
3502     if test "$XPM_LDFLAGS" = ""; then
3503        XPMLIB="-lXpm"
3504     else
3505        XPMLIB="-L$XPM_LDFLAGS -lXpm"
3506     fi
3507     if test "$XPM_INCLUDE" = ""; then
3508        XPMINC=""
3509     else
3510        XPMINC="-I$XPM_INCLUDE"
3511     fi
3512     AC_MSG_RESULT(yes)
3513     $1
3514   fi
3515  fi
3516  AC_SUBST(XPMINC)
3517  AC_SUBST(XPMLIB)
3518 ]) 
3519
3520 AC_DEFUN(AC_HAVE_GL,
3521  [AC_REQUIRE_CPP()dnl
3522
3523  test -z "$GL_LDFLAGS" && GL_LDFLAGS=
3524  test -z "$GL_INCLUDE" && GL_INCLUDE=
3525
3526  AC_ARG_WITH(gl, [  --without-gl            disable 3D GL modes],
3527         gl_test=$withval, gl_test="yes")
3528  if test "x$gl_test" = xno; then
3529    ac_cv_have_gl=no
3530  else
3531    AC_MSG_CHECKING(for GL)
3532    AC_CACHE_VAL(ac_cv_have_gl,
3533    [
3534     AC_LANG_C
3535     ac_save_ldflags="$LDFLAGS"
3536     ac_save_cflags="$CFLAGS"
3537     LDFLAGS="$LDFLAGS $GL_LDFLAGS $all_libraries -lMesaGL -lMesaGLU -lX11 -lXext -lm $LIBSOCKET"
3538     CFLAGS="$CFLAGS $X_INCLUDES"
3539     test ! -z "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
3540     AC_TRY_LINK([],[],
3541         ac_cv_have_gl="yes",ac_cv_have_gl="no")
3542     LDFLAGS="$ac_save_ldflags"
3543     CFLAGS="$ac_save_cflags"
3544    ])dnl
3545  
3546   if test "$ac_cv_have_gl" = no; then
3547     AC_MSG_RESULT(no)
3548     GL_LDFLAGS=""
3549     GLINC=""
3550     $2
3551   else
3552     AC_DEFINE(HAVE_GL)
3553     if test "$GL_LDFLAGS" = ""; then
3554        GLLIB="-lMesaGL -lMesaGLU"
3555     else
3556        GLLIB="-L$GL_LDFLAGS -lMesaGL -lMesaGLU"
3557     fi
3558     if test "$GL_INCLUDE" = ""; then
3559        GLINC=""
3560     else
3561        GLINC="-I$GL_INCLUDE"
3562     fi
3563     AC_MSG_RESULT(yes)
3564     $1
3565   fi
3566  fi
3567  AC_SUBST(GLINC)
3568  AC_SUBST(GLLIB)
3569 ]) 
3570
3571  dnl PAM pam
3572  
3573  dnl Should test for PAM (Pluggable Authentication Modules)
3574  AC_DEFUN(AC_PATH_PAM_DIRECT,
3575  [
3576  test -z "$pam_direct_test_library" && pam_direct_test_library=pam
3577  test -z "$pam_direct_test_include" && pam_direct_test_include=security/pam_appl.h
3578  
3579    for ac_dir in               \
3580                                \
3581      /usr/local/include        \
3582      /usr/include              \
3583      /usr/unsupported/include  \
3584      /opt/include              \
3585      /usr/pam/include          \
3586      /usr/local/pam/include    \
3587      /usr/lib/pam/include      \
3588                               \
3589      $extra_include            \
3590      ; \
3591    do
3592      if test -r "$ac_dir/$pam_direct_test_include"; then
3593        no_pam= ac_pam_includes=$ac_dir
3594        break
3595      fi
3596    done
3597  
3598  # First see if replacing the include by lib works.
3599  for ac_dir in `echo "$ac_pam_includes" | sed s/include/lib/` \
3600                            \
3601      /lib                  \
3602      /usr/lib              \
3603      /usr/local/lib        \
3604      /usr/unsupported/lib  \
3605      /lib/security         \
3606      /usr/security/lib     \
3607      $extra_lib            \
3608      ; \
3609  do
3610    for ac_extension in a so sl; do
3611      if test -r $ac_dir/lib${pam_direct_test_library}.$ac_extension; then
3612        no_pam= ac_pam_libraries=$ac_dir
3613        break 2
3614      fi
3615    done
3616  done
3617 ])
3618
3619 AC_DEFUN(AC_PATH_PAM,
3620  [AC_REQUIRE_CPP()dnl
3621
3622   AC_CHECK_LIB(pam_misc, main, [PAM_MISC_LIB="-lpam_misc"], [], [-lpam -ldl])
3623
3624  AC_MSG_CHECKING(for PAM)
3625  AC_ARG_WITH(pam, 
3626 [  --with-pam[=ARG]        enable support for PAM: ARG=[yes|no|service name]],
3627   [
3628     if test "x$withval" = "xyes"; then
3629       no_pam=
3630       default_pam=yes
3631     elif test "x$withval" = "xno"; then
3632       no_pam=yes
3633     else
3634       no_pam=
3635       pam_service="$withval"
3636         if test -z "$pam_service"; then
3637         default_pam=yes
3638         else
3639         default_pam=
3640         fi 
3641       fi
3642   ], no_pam=yes
3643  )
3644
3645  if test ! "$no_pam" = yes; then
3646
3647  AC_CACHE_VAL(ac_cv_path_pam,
3648  [
3649  ac_pam_includes=NONE
3650  ac_pam_libraries=NONE
3651  if test -z "$pam_libraries"; then
3652    pam_libraries=NONE
3653  fi
3654  if test -z "$pam_includes"; then
3655    pam_includes=NONE
3656  fi
3657
3658  AC_PATH_PAM_DIRECT
3659  
3660  test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
3661  test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
3662  
3663  if test ! "x$pam_includes" = xNONE && test ! "x$pam_libraries" = xNONE; then
3664    ac_pam_libs="-lpam $PAM_MISC_LIB -ldl"
3665    ac_cv_path_pam="no_pam= ac_pam_includes=$ac_pam_includes ac_pam_libraries=$ac_pam_libraries ac_pam_libs=\"$ac_pam_libs\""
3666  else
3667    ac_cv_path_pam="no_pam=yes"
3668  fi
3669  ])
3670
3671  eval "$ac_cv_path_pam"
3672  
3673  fi
3674
3675  if test "$no_pam" = yes; then
3676    AC_MSG_RESULT(no)
3677  else
3678    AC_DEFINE(HAVE_PAM)
3679    PAMLIBS="$ac_pam_libs"
3680    test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
3681    test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
3682    AC_MSG_RESULT([libraries $pam_libraries, headers $pam_includes])
3683  if test "$default_pam" = yes; then
3684    AC_MSG_RESULT(["default pam service name will be used"])
3685  else
3686    AC_DEFINE_UNQUOTED(KDE_PAM_SERVICE,"$pam_service")
3687    AC_MSG_RESULT(["pam service name will be: " $pam_service])
3688  fi
3689 dnl test whether struct pam_message is const (Linux) or not (Sun)
3690    pam_appl_h="$ac_pam_includes/security/pam_appl.h"
3691    AC_MSG_CHECKING(for const pam_message)
3692    AC_EGREP_HEADER([struct pam_message],
3693       $pam_appl_h,
3694       [ AC_EGREP_HEADER([const struct pam_message],
3695                         $pam_appl_h,
3696                         [AC_MSG_RESULT(["const: Linux-type PAM"]) ],
3697                         [AC_MSG_RESULT(["nonconst: Sun-type PAM"])
3698                         AC_DEFINE(PAM_MESSAGE_NONCONST)] 
3699                         )],
3700        [AC_MSG_RESULT(["not found - assume const, Linux-type PAM"])]
3701        )
3702  fi
3703  
3704  if test "x$pam_libraries" != x && test "x$pam_libraries" != xNONE ; then
3705      PAMLIBPATHS="-L$pam_libraries"
3706  fi
3707  if test "x$pam_includes" != x && test "x$pam_includes" != xNONE ; then
3708      PAMINC="-I$pam_includes"
3709  fi
3710  
3711  AC_SUBST(PAMINC)
3712  AC_SUBST(PAMLIBS)
3713  AC_SUBST(PAMLIBPATHS)
3714
3715 ]) 
3716
3717 AC_DEFUN(KDE_CHECK_LIBDL,
3718 [
3719 AC_CHECK_LIB(dl, dlopen, [
3720 LIBDL="-ldl"
3721 ac_cv_have_dlfcn=yes
3722 ])
3723
3724 AC_CHECK_LIB(dld, shl_unload, [
3725 LIBDL="-ldld"
3726 ac_cv_have_shload=yes
3727 ])
3728
3729 AC_SUBST(LIBDL)
3730 ])
3731
3732 AC_DEFUN(KDE_CHECK_DLOPEN,
3733 [
3734 KDE_CHECK_LIBDL
3735 AC_CHECK_HEADERS(dlfcn.h dl.h)
3736 if test "$ac_cv_header_dlfcn_h" = "no"; then
3737   ac_cv_have_dlfcn=no
3738 fi
3739
3740 if test "$ac_cv_header_dl_h" = "no"; then
3741   ac_cv_have_shload=no
3742 fi
3743
3744 enable_dlopen=no
3745 AC_ARG_ENABLE(dlopen,
3746 [  --disable-dlopen        link staticly [default=no]] ,
3747 [if test "$enableval" = yes; then
3748   enable_dlopen=yes
3749 fi],
3750 enable_dlopen=yes)
3751
3752 # override the user's opinion, if we know it better ;)
3753 if test "$ac_cv_have_dlfcn" = "no" && test "$ac_cv_have_shload" = "no"; then
3754   enable_dlopen=no
3755 fi
3756
3757 if test "$ac_cv_have_dlfcn" = "yes"; then
3758   AC_DEFINE_UNQUOTED(HAVE_DLFCN)
3759 fi
3760
3761 if test "$ac_cv_have_shload" = "yes"; then
3762   AC_DEFINE_UNQUOTED(HAVE_SHLOAD)
3763 fi
3764
3765 if test "$enable_dlopen" = no ; then
3766   test -n "$1" && eval $1
3767 else
3768   test -n "$2" && eval $2
3769 fi
3770
3771 ])
3772
3773 AC_DEFUN(KDE_CHECK_DYNAMIC_LOADING,
3774 [
3775 KDE_CHECK_DLOPEN(libtool_enable_shared=no, libtool_enable_static=no)
3776 KDE_PROG_LIBTOOL
3777 AC_MSG_CHECKING([dynamic loading])
3778 eval "`egrep '^build_libtool_libs=' libtool`"
3779 if test "$build_libtool_libs" = "yes" && test "$enable_dlopen" = "yes"; then
3780   dynamic_loading=yes
3781   AC_DEFINE_UNQUOTED(HAVE_DYNAMIC_LOADING)
3782 else
3783   dynamic_loading=no
3784 fi
3785 AC_MSG_RESULT($dynamic_loading)
3786 if test "$dynamic_loading" = "yes"; then
3787   $1
3788 else
3789   $2
3790 fi
3791 ])
3792
3793 AC_DEFUN(KDE_ADD_INCLUDES,
3794 [
3795 if test -z "$1"; then 
3796   test_include="Pix.h"
3797 else
3798   test_include="$1"
3799 fi
3800
3801 AC_MSG_CHECKING([for libg++ ($test_include)])
3802
3803 AC_CACHE_VAL(kde_cv_libgpp_includes,
3804 [
3805 kde_cv_libgpp_includes=no
3806
3807    for ac_dir in               \
3808                                \
3809      /usr/include/g++          \
3810      /usr/include              \
3811      /usr/unsupported/include  \
3812      /opt/include              \
3813      $extra_include            \
3814      ; \
3815    do
3816      if test -r "$ac_dir/$test_include"; then
3817        kde_cv_libgpp_includes=$ac_dir
3818        break
3819      fi
3820    done
3821 ])
3822
3823 AC_MSG_RESULT($kde_cv_libgpp_includes)
3824 if test "$kde_cv_libgpp_includes" != "no"; then
3825   all_includes="-I$kde_cv_libgpp_includes $all_includes"
3826 fi
3827 ])
3828 ])
3829
3830
3831 AC_DEFUN(KDE_CHECK_MICO,
3832 [
3833 AC_REQUIRE([KDE_CHECK_LIBDL])
3834 AC_MSG_CHECKING(for MICO)
3835 AC_ARG_WITH(micodir,
3836   [  --with-micodir=micodir  where mico is installed ],
3837   kde_micodir=$withval,
3838   kde_micodir=/usr/local
3839 )
3840 AC_MSG_RESULT($kde_micodir)
3841 if test ! -r  $kde_micodir/include/CORBA.h; then
3842   AC_MSG_ERROR([No CORBA.h found, specify another micodir])
3843 fi
3844
3845 MICO_INCLUDES=-I$kde_micodir/include
3846 AC_SUBST(MICO_INCLUDES)
3847 MICO_LDFLAGS=-L$kde_micodir/lib
3848 AC_SUBST(MICO_LDFLAGS)
3849
3850 AC_MSG_CHECKING([for MICO version])
3851 AC_CACHE_VAL(kde_cv_mico_version,
3852 [
3853 AC_LANG_C
3854 cat >conftest.$ac_ext <<EOF
3855 #include <stdio.h>
3856 #include <mico/version.h>
3857 int main() { 
3858     
3859    printf("MICO_VERSION=%s\n",MICO_VERSION); 
3860    return (0); 
3861 }
3862 EOF
3863 ac_compile='${CC-gcc} $CFLAGS $MICO_INCLUDES conftest.$ac_ext -o conftest'
3864 if AC_TRY_EVAL(ac_compile); then
3865   if eval `./conftest 2>&5`; then
3866     kde_cv_mico_version=$MICO_VERSION
3867   else
3868     AC_MSG_ERROR([your system is not able to execute a small application to
3869     find MICO version! Check $kde_micodir/include/mico/version.h])
3870   fi 
3871 else
3872   AC_MSG_ERROR([your system is not able to compile a small application to
3873   find MICO version! Check $kde_micodir/include/mico/version.h])
3874 fi
3875 ])
3876
3877 dnl installed MICO version
3878 mico_v_maj=`echo $kde_cv_mico_version | sed -e 's/^\(.*\)\..*\..*$/\1/'`
3879 mico_v_mid=`echo $kde_cv_mico_version | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
3880 mico_v_min=`echo $kde_cv_mico_version | sed -e 's/^.*\..*\.\(.*\)$/\1/'`
3881
3882 dnl required MICO version
3883 req_v_maj=`echo $1 | sed -e 's/^\(.*\)\..*\..*$/\1/'`
3884 req_v_mid=`echo $1 | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
3885 req_v_min=`echo $1 | sed -e 's/^.*\..*\.\(.*\)$/\1/'` 
3886
3887 if test "$mico_v_maj" -lt "$req_v_maj" || \
3888    ( test "$mico_v_maj" -eq "$req_v_maj" && \
3889         test "$mico_v_mid" -lt "$req_v_mid" ) || \
3890    ( test "$mico_v_mid" -eq "$req_v_mid" && \
3891         test "$mico_v_min" -lt "$req_v_min" )
3892
3893 then
3894   AC_MSG_ERROR([found MICO version $kde_cv_mico_version but version $1 \
3895 at least is required. You should upgrade MICO.])
3896 else
3897   AC_MSG_RESULT([$kde_cv_mico_version (minimum version $1, ok)])
3898 fi
3899
3900 LIBMICO="-lmico$kde_cv_mico_version $LIBDL"
3901 AC_SUBST(LIBMICO)
3902 IDL=$kde_micodir/bin/idl
3903 AC_SUBST(IDL)
3904 ])
3905
3906
3907 AC_DEFUN(KDE_CHECK_MINI_STL,
3908 [
3909 AC_REQUIRE([KDE_CHECK_MICO])
3910
3911 AC_MSG_CHECKING(if we use mico's mini-STL)
3912 AC_CACHE_VAL(kde_cv_have_mini_stl,
3913 [
3914 AC_LANG_CPLUSPLUS
3915 kde_save_cxxflags="$CXXFLAGS"
3916 CXXFLAGS="$CXXFLAGS $MICO_INCLUDES"
3917 AC_TRY_COMPILE(
3918 [
3919 #include <mico/config.h>
3920 ],
3921 [
3922 #ifdef HAVE_MINI_STL
3923 #error "nothing"
3924 #endif
3925 ],
3926 kde_cv_have_mini_stl=no,
3927 kde_cv_have_mini_stl=yes)
3928 CXXFLAGS="$kde_save_cxxflags"
3929 ])
3930
3931
3932 AC_MSG_RESULT($kde_cv_have_mini_stl)
3933 if test "$kde_cv_have_mini_stl" = "yes"; then
3934   AC_DEFINE_UNQUOTED(HAVE_MINI_STL)
3935 fi
3936 ])
3937
3938 ])
3939
3940
3941 AC_DEFUN(KDE_CHECK_LIBPTHREAD,
3942 [
3943 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"], LIBPTHREAD= )
3944 AC_SUBST(LIBPTHREAD)
3945 ])
3946
3947 AC_DEFUN(KDE_TRY_LINK_PYTHON,
3948 [
3949 AC_CACHE_VAL(kde_cv_try_link_python_$1,
3950 [
3951 kde_save_cxxflags="$CXXFLAGS"
3952 CXXFLAGS="$CXXFLAGS $PYTHONINC"
3953 kde_save_libs="$LIBS"
3954 LIBS="$LIBS $LIBPYTHON $2 $LIBDL $LIBSOCKET"
3955 kde_save_ldflags="$LDFLAGS"
3956 LDFLAGS="$LDFLAGS $PYTHONLIB"
3957
3958 AC_TRY_LINK(
3959 [
3960 #include <Python.h>
3961 ],[
3962         PySys_SetArgv(1, 0);
3963 ],
3964         [kde_cv_try_link_python_$1=yes],
3965         [kde_cv_try_link_python_$1=no]
3966 )
3967 CXXFLAGS="$kde_save_cxxflags"
3968 LIBS="$kde_save_libs"
3969 LDFLAGS="$kde_save_ldflags"
3970 ])
3971
3972 if test "$kde_cv_try_link_python_$1" = "yes"; then
3973   $3
3974 else
3975   $4
3976 fi
3977
3978 ])
3979
3980 AC_DEFUN(KDE_CHECK_PYTHON,
3981 [
3982 AC_REQUIRE([KDE_CHECK_LIBDL])
3983 AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
3984 if test -z "$1"; then 
3985   version="1.5"
3986 else
3987   version="$1"
3988 fi
3989
3990 AC_MSG_CHECKING([for Python$version])
3991
3992 AC_ARG_WITH(pythondir, 
3993 [  --with-pythondir=pythondir   use python installed in pythondir ],
3994 [
3995   ac_python_dir=$withval
3996 ], ac_python_dir=/usr/local
3997 )
3998
3999 python_incdirs="$ac_python_dir/include/python$version /usr/include/python$version /usr/local/include/python$version /usr/local/include"
4000 AC_FIND_FILE(Python.h, $python_incdirs, python_incdir)
4001 if test ! -r $python_incdir/Python.h; then
4002   AC_MSG_ERROR(Python.h not found.)
4003 fi
4004
4005 PYTHONINC=-I$python_incdir
4006
4007 python_libdirs="$ac_python_dir/lib/python$version/config /usr/lib/python$version/config /usr/local/python$version/config"
4008 AC_FIND_FILE(libpython$version.a, $python_libdirs, python_libdir)
4009 if test ! -r $python_libdir/libpython$version.a; then
4010   AC_MSG_ERROR(libpython$version.a not found.)
4011 fi
4012
4013 PYTHONLIB=-L$python_libdir
4014 LIBPYTHON=-lpython$version
4015
4016 AC_MSG_RESULT(header $python_incdir library $python_libdir)
4017
4018 dnl Note: this test is very weak
4019 AC_MSG_CHECKING(if an Python application links)
4020 KDE_TRY_LINK_PYTHON(normal, "", AC_MSG_RESULT(yes),
4021  [
4022     AC_MSG_RESULT(no)
4023     AC_MSG_CHECKING(if Python depends on -lpthread)
4024     KDE_TRY_LINK_PYTHON(pthread, "$LIBPTHREAD",
4025     [  
4026        AC_MSG_RESULT(yes)
4027        LIBPYTHON="$LIBPYTHON $LIBPTHREAD $LIBDL"
4028     ],
4029     [
4030        AC_MSG_RESULT(no)
4031        AC_MSG_CHECKING(if Python depeds on -ltcl)
4032        KDE_TRY_LINK_PYTHON(tcl, "-ltcl",
4033        [
4034           AC_MSG_RESULT(yes)
4035           LIBPYTHON="$LIBPYTHON -ltcl"
4036        ],
4037        [
4038           AC_MSG_RESULT(no)
4039         AC_MSG_WARN([it seems, Python depends on another library. 
4040     Pleae use \"make LIBPTYHON='-lpython$version -lotherlib'\" to fix this
4041     and contact the authors to let them know about this problem])
4042         ])
4043     ])
4044  ]) 
4045
4046 AC_SUBST(PYTHONINC)
4047 AC_SUBST(PYTHONLIB)
4048 AC_SUBST(LIBPYTHON)
4049
4050 ])
4051
4052
4053 AC_DEFUN(KDE_CHECK_STL_SGI,
4054 [
4055     AC_MSG_CHECKING([if STL implementation is SGI like])
4056     AC_CACHE_VAL(kde_cv_stl_type_sgi,
4057     [
4058       AC_TRY_COMPILE([
4059 #include <string>
4060 ],[
4061   string astring="Hallo Welt.";
4062   astring.erase(0, 6); // now astring is "Welt"
4063   return 0;
4064 ], kde_cv_stl_type_sgi=yes,
4065    kde_cv_stl_type_sgi=no)
4066 ])
4067
4068    AC_MSG_RESULT($kde_cv_stl_type_sgi)
4069
4070    if test "$kde_cv_stl_type_sgi" = "yes"; then
4071         AC_DEFINE_UNQUOTED(HAVE_SGI_STL) 
4072    fi
4073 ])
4074
4075 AC_DEFUN(KDE_CHECK_STL_HP,
4076 [
4077     AC_MSG_CHECKING([if STL implementation is HP like])
4078     AC_CACHE_VAL(kde_cv_stl_type_hp,
4079     [
4080       AC_TRY_COMPILE([
4081 #include <string>
4082 ],[
4083   string astring="Hello World";
4084   astring.remove(0, 6); // now astring is "World"
4085   return 0;
4086 ], kde_cv_stl_type_hp=yes,
4087    kde_cv_stl_type_hp=no)
4088 ])
4089    AC_MSG_RESULT($kde_cv_stl_type_hp)
4090
4091    if test "$kde_cv_stl_type_hp" = "yes"; then
4092         AC_DEFINE_UNQUOTED(HAVE_HP_STL) 
4093    fi
4094 ])
4095
4096 AC_DEFUN(KDE_CHECK_STL,
4097 [
4098     KDE_CHECK_STL_SGI
4099     
4100     if test "$kde_cv_stl_type_sgi" = "no"; then
4101        KDE_CHECK_STL_HP
4102
4103        if test "$kde_cv_stl_type_hp" = "no"; then
4104          AC_MSG_ERROR("no known STL type found")
4105        fi
4106     fi
4107
4108 ])
4109
4110 AC_DEFUN(AC_FIND_QIMGIO,
4111    [AC_REQUIRE([AC_FIND_JPEG])
4112 AC_MSG_CHECKING([for qimgio])
4113 AC_CACHE_VAL(ac_cv_lib_qimgio,
4114 [ac_save_LIBS="$LIBS"
4115 LIBS="$all_libraries -lqimgio -lpng -lz -lqt $LIBJPEG -lX11 $LIBSOCKET"
4116 AC_TRY_LINK(dnl
4117 [
4118 void qInitImageIO ();
4119 ],
4120             [qInitImageIO();],
4121             eval "ac_cv_lib_qimgio=yes",
4122             eval "ac_cv_lib_qimgio=no")
4123 LIBS="$ac_save_LIBS"
4124 ])dnl
4125 if eval "test \"`echo $ac_cv_lib_qimgio`\" = yes"; then
4126   LIBQIMGIO="-lqimgio -lpng -lz $LIBJPEG"
4127   AC_MSG_RESULT(yes)
4128   AC_DEFINE_UNQUOTED(HAVE_QIMGIO)
4129   AC_SUBST(LIBQIMGIO)
4130 else
4131   AC_MSG_RESULT(not found)
4132 fi
4133 ])
4134
4135 AC_DEFUN(KDE_CHECK_ANSI,
4136 [
4137 AC_MSG_CHECKING([for strdup])
4138
4139     AC_CACHE_VAL(kde_cv_stl_type_sgi,
4140     [
4141 AC_LANG_CPLUSPLUS
4142 save_CXXFLAGS="$CXXFLAGS"
4143 if test "$GCC" = "yes"; then
4144   CXXFLAGS="$CXXFLAGS -pedantic-errors"
4145 fi
4146
4147 AC_TRY_COMPILE([
4148 #include <string.h>
4149 ],[
4150   char buffer[] = "Hallo";
4151   strdup(buffer)
4152 ], kde_cv_has_strdup=yes,
4153    kde_cv_has_strdup=no)
4154 CXXFLAGS="$save_CXXFLAGS"
4155 ])
4156 AC_MSG_RESULT($kde_cv_has_strdup)
4157
4158 if test "$kde_cv_has_strdup" = "yes"; then
4159   AC_DEFINE_UNQUOTED(HAVE_STRDUP)
4160 fi
4161
4162 ])
4163
4164 AC_DEFUN(KDE_CHECK_INSURE,
4165 [
4166   AC_ARG_ENABLE(insure, [  --enable-insure             use insure++ for debugging [default=no]],
4167   [
4168   if test $enableval = "no"; dnl
4169         then ac_use_insure="no"
4170         else ac_use_insure="yes"
4171    fi
4172   ], [ac_use_insure="no"])
4173
4174   AC_MSG_CHECKING(if we will use Insure++ to debug)
4175   AC_MSG_RESULT($ac_use_insure)
4176   if test "$ac_use_insure" = "yes"; dnl
4177        then CC="insure"; CXX="insure"; dnl CFLAGS="$CLAGS -fno-rtti -fno-exceptions "????
4178    fi
4179 ])          
4180
4181 dnl this is for kdm:
4182
4183 AC_DEFUN(AC_CHECK_KDM,
4184 [
4185 AC_CHECK_FUNCS(getsecretkey)
4186 dnl checks for X server
4187
4188 AC_PATH_PROG(X_SERVER, X)
4189 if test ! -z "$X_SERVER"; then
4190 X_SERVER=`echo $X_SERVER | sed -e 's+/X$++'`
4191 AC_DEFINE_UNQUOTED(XBINDIR,$X_SERVER)
4192 XBINDIR=$X_SERVER
4193 AC_SUBST(XBINDIR)
4194 fi
4195
4196 dnl This one tries to find XDMDIR for config files
4197 AC_ARG_WITH(xdmdir,
4198         [  --with-xdmdir                  If the xdm config dir can't be found automaticly],
4199         [ ac_xdmdir=$withval],
4200         [ ac_xdmdir="no"])
4201
4202 AC_MSG_CHECKING([for xdm configuration dir])
4203 if test "$ac_xdmdir" = "no"; then
4204     rm -fr conftestdir
4205     if mkdir conftestdir; then
4206         cd conftestdir
4207     cat > Imakefile <<'EOF'
4208 acfindxdm:
4209         @echo 'ac_xdmdir="$(XDMDIR)";'
4210 EOF
4211         if (xmkmf) > /dev/null 2> /dev/null && test -f Makefile; then
4212             eval `${MAKE-make} acfindxdm 2>/dev/null 2>/dev/null | grep -v make`
4213         fi
4214         cd ..
4215         rm -fr conftestdir
4216         dnl Check if Imake was right
4217         if test -f $ac_xdmdir/xdm-config; then
4218             AC_MSG_RESULT($ac_xdmdir)
4219         else
4220             dnl Here we must do something else
4221             dnl Maybe look for xdm-config in standard places, and
4222             dnl if that fails use a fresh copy in $KDEDIR/config/kdm/
4223             AC_FIND_FILE(xdm-config,/etc/X11/xdm /var/X11/xdm /usr/openwin/xdm /usr/X11R6/lib/X11/xdm,ac_xdmdir)
4224             if test -f $ac_xdmdir/xdm-config; then
4225                 AC_MSG_RESULT($ac_xdmdir)
4226             else                                 
4227                 if test "${prefix}" = NONE; then
4228                         ac_xdmdir=$ac_default_prefix/config/kdm
4229                 else
4230                         ac_xdmdir=$prefix/config/kdm
4231                 fi
4232                 AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
4233                 xdmconfigsubdir=xdmconfig
4234                 AC_SUBST(xdmconfigsubdir)
4235             fi
4236         fi
4237     fi
4238 else
4239     if test -f $ac_xdmdir/xdm-config; then
4240         AC_MSG_RESULT($ac_xdmdir)
4241     else
4242
4243         AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
4244         xdmconfigsubdir=xdmconfig
4245         AC_SUBST(xdmconfigsubdir)
4246     fi
4247 fi
4248 AC_DEFINE_UNQUOTED(XDMDIR,"$ac_xdmdir")
4249 AC_SUBST(ac_xdmdir)
4250
4251 AC_PATH_PAM
4252 if test "x$no_pam" = "xyes"; then 
4253         pam_support="no"
4254 else
4255         pam_support="yes"
4256         shadow_support="no" # if pam is installed, use it. We can't savely 
4257                             # test, if it works *sigh*
4258 fi
4259
4260 AC_ARG_WITH(shadow,
4261         [  --with-shadow                  If you want shadow password support ],
4262         [ if test "$withval" = "yes"; then
4263              shadow_support="yes"
4264           else
4265              shadow_support="no"
4266           fi
4267           if test "$pam_support" = "yes" && test "$shadow_support=yes"; then
4268                 AC_MSG_WARN("You can not define both pam AND shadow")
4269           fi
4270         ],
4271         [ if test -z "$shadow_support"; then shadow_support="no"; fi ] )
4272
4273 if test "$pam_support" = "yes"; then
4274   AC_CHECK_LIB(pam, main, [PASSWDLIB="-lpam -ldl"
4275   AC_DEFINE_UNQUOTED(HAVE_PAM_LIB)],
4276   [],-ldl)
4277 fi
4278
4279 if test -z "$PASSWDLIB" && test "$shadow_support" = "yes"; then
4280   AC_CHECK_LIB(shadow, main,
4281     [ PASSWDLIB="-lshadow"
4282       AC_DEFINE_UNQUOTED(HAVE_SHADOW_LIB)
4283     ])
4284 fi
4285 AC_SUBST(PASSWDLIB)
4286 AC_CHECK_LIB(util, main, [LIBUTIL="-lutil"]) dnl for FreeBSD
4287 AC_SUBST(LIBUTIL)
4288 AC_CHECK_LIB(s, main, [LIB_LIBS="-ls"]) dnl for AIX
4289 AC_SUBST(LIB_LIBS)
4290 AC_CHECK_LIB(Xdmcp, main, [LIBXDMCP="-lXdmcp"], , $X_LDFLAGS -lX11) dnl for Unixware
4291 AC_SUBST(LIBXDMCP)
4292
4293 if test -n "$LIBXDMCP"; then
4294   ac_cpp_safe=$ac_cpp
4295   ac_cpp='$CXXCPP $CPPFLAGS $X_INCLUDES'
4296   AC_CHECK_HEADERS(X11/Xdmcp.h)
4297   ac_cpp=$ac_cpp_safe
4298 fi
4299
4300 ])