]> git.lyx.org Git - lyx.git/blob - acinclude.m4
Menubar and toolbar fixes. New OptItem menu option. Add gtk.m4.
[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 dnl         Allan Rae (rae@lyx.org)
5
6
7 dnl Usage LYX_GET_VERSION   Sets "lyx_version" to the version of LyX being 
8 dnl   built, displays it and sets variable "lyx_devel" to yes or no depending 
9 dnl   whether the version is a development release or not. 
10 AC_DEFUN(LYX_GET_VERSION,[
11 changequote(, ) dnl
12 VERSION=`grep '#define *LYX_VERSION' $1 |
13               sed -e 's/^.*"\(.*\)"$/\1/' 2>/dev/null`
14 echo "configuring LyX version $VERSION"
15 if echo "$VERSION" | grep 'cvs' >/dev/null ; then
16   lyx_devel_version=yes
17   echo "WARNING: This is a development version. Expect bugs."
18 else
19   lyx_devel_version=no
20 fi
21 if echo "$VERSION" | grep 'pre' > /dev/null ; then
22     lyx_prerelease=yes
23     echo "WARNING: This is a prerelease. Be careful and backup your documents."
24 else
25     lyx_prerelease=no
26 fi
27 changequote([, ]) dnl
28 PACKAGE=lyx${program_suffix}
29 AC_SUBST(lyx_devel_version)
30 if test $lyx_devel_version = yes ; then 
31   AC_DEFINE(DEVEL_VERSION, 1, Define if you are building a development version of LyX)
32 fi])
33
34 dnl Usage: LYX_ERROR(message)  Displays the warning "message" and sets the
35 dnl flag lyx_error to yes.
36 AC_DEFUN(LYX_ERROR,[
37 lyx_error_txt="$lyx_error_txt
38 ** $1
39 "
40 lyx_error=yes])
41
42
43 dnl Usage: LYX_WARNING(message)  Displays the warning "message" and sets the
44 dnl flag lyx_warning to yes.
45 AC_DEFUN(LYX_WARNING,[
46 lyx_warning_txt="$lyx_warning_txt
47 == $1
48 "
49 lyx_warning=yes])
50
51
52 dnl Usage: LYX_LIB_ERROR(file,library)  Displays an error message indication 
53 dnl  that 'file' cannot be found because 'lib' may be uncorrectly installed.
54 AC_DEFUN(LYX_LIB_ERROR,[
55 LYX_ERROR([Cannot find $1. Please check that the $2 library
56    is correctly installed on your system.])])
57
58
59 dnl Usage: LYX_CHECK_ERRORS  Displays a warning message if a LYX_ERROR
60 dnl   has occured previously. 
61 AC_DEFUN(LYX_CHECK_ERRORS,[
62 if test x$lyx_error = xyes; then
63 cat <<EOF
64 **** The following problems have been detected by configure. 
65 **** Please check the messages below before running 'make'.
66 **** (see the section 'Problems' in the INSTALL file)
67 $lyx_error_txt
68 $lyx_warning_txt
69 deleting cache $cache_file
70 EOF
71   rm -f $cache_file
72 else
73
74 if test x$lyx_warning = xyes; then
75 cat <<EOF
76 === The following minor problems have been detected by configure. 
77 === Please check the messages below before running 'make'.
78 === (see the section 'Problems' in the INSTALL file)
79 $lyx_warning_txt
80 EOF
81 fi
82 cat <<EOF
83 Configuration of LyX was successful.  
84 Type 'make' to compile the program, 
85 and then 'make install' to install it.
86 EOF
87 fi])
88
89
90 dnl LYX_SEARCH_PROG(VARIABLE-NAME,PROGRAMS-LIST,ACTION-IF-FOUND)
91 dnl             
92 define(LYX_SEARCH_PROG,[dnl
93 for ac_prog in $2 ; do
94 # Extract the first word of "$ac_prog", so it can be a program name with args.
95   set dummy $ac_prog ; ac_word=$[2]
96   if test -z "[$]$1"; then
97     IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS=":"
98     for ac_dir in $PATH; do
99       test -z "$ac_dir" && ac_dir=.
100       if test -f [$ac_dir/$ac_word]; then
101         $1="$ac_prog"
102         break
103       fi
104     done
105     IFS="$ac_save_ifs"
106   fi
107
108   if test -n "[$]$1"; then
109     ac_result=yes
110   else
111     ac_result=no
112   fi
113   ifelse($3,,,[$3])
114   test -n "[$]$1" && break
115 done
116 ])dnl
117
118
119 AC_DEFUN(LYX_PROG_CXX_WORKS,
120 [AC_LANG_SAVE
121 AC_LANG_CPLUSPLUS
122 AC_TRY_COMPILER([class foo { int bar; }; int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
123 AC_LANG_RESTORE
124 if test $ac_cv_prog_cxx_works = no; then
125   CXX=
126 fi
127 cross_compiling=$ac_cv_prog_cxx_cross
128 ])
129
130
131 AC_DEFUN(LYX_PROG_CXX,
132 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
133 AC_MSG_CHECKING([for a working C++ compiler])
134 LYX_SEARCH_PROG(CXX, $CCC g++ gcc c++ CC cxx xlC cc++, LYX_PROG_CXX_WORKS)
135
136 if test -z "$CXX" ; then
137   AC_ERROR([Unable to find a working C++ compiler])
138 fi
139
140 AC_SUBST(CXX)
141 AC_MSG_RESULT($CXX)
142
143 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
144 AC_MSG_RESULT($cross_compiling)
145
146 AC_PROG_CXX_GNU
147
148 dnl We might want to get or shut warnings.
149 AC_ARG_WITH(warnings,
150   [  --with-warnings         tell the compiler to display more warnings],,
151   [ if test $lyx_devel_version = yes -o $lyx_prerelease = yes && test $ac_cv_prog_gxx = yes ; then
152         with_warnings=yes;
153     else
154         with_warnings=no;
155     fi;])
156 if test x$with_warnings = xyes ; then
157   lyx_flags="$lyx_flags warnings"
158   AC_DEFINE(WITH_WARNINGS, 1,
159   [Define this if you want to see the warning directives put here and
160    there by the developpers to get attention])
161 fi
162
163 # optimize less for development versions
164 if test $lyx_devel_version = yes -o $lyx_prerelease = yes ; then
165   lyx_opt="-O"
166 else
167   lyx_opt="-O2"
168 fi
169
170 # set the debug flags correctly.
171 if test $ac_cv_prog_gxx = yes; then
172   GXX=yes
173 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
174 dnl plays around with CXXFLAGS (such as to build both debugging and
175 dnl normal versions of a library), tasteless as that idea is.
176   ac_test_CXXFLAGS="${CXXFLAGS+set}"
177   ac_save_CXXFLAGS="$CXXFLAGS"
178   CXXFLAGS=
179 dnl Check the version of g++
180   gxx_version=`${CXX} --version`
181   
182   AC_PROG_CXX_G
183   if test "$ac_test_CXXFLAGS" = set; then
184     CXXFLAGS="$ac_save_CXXFLAGS"
185   elif test $ac_cv_prog_cxx_g = yes; then
186     case $gxx_version in
187       2.95.1)  CXXFLAGS="-g $lyx_opt -fpermissive -fno-rtti -fno-exceptions";;
188       2.95.*)  CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
189       2.96*)   CXXFLAGS="-g $lyx_opt -fhonor-std";;
190       *2.91.*) CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
191       *)       CXXFLAGS="-g $lyx_opt -fno-rtti -fno-exceptions";;
192     esac
193   else
194     CXXFLAGS="$lyx_opt"
195   fi
196   if test x$with_warnings = xyes ; then
197     case $gxx_version in
198         2.95.*) CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
199         2.96*)  CXXFLAGS="$CXXFLAGS -W -Wall -Wconversion -Winline";;
200         *)      CXXFLAGS="$CXXFLAGS -ansi -W -Wall -Wno-return-type";;
201     esac
202     if test $lyx_devel_version = yes ; then
203         case $gxx_version in
204             2.95.*) ;;
205             2.96*) ;;
206             *2.91*) ;;
207             *) CXXFLAGS="$CXXFLAGS -pedantic";;
208         esac
209     fi
210   fi
211 else
212   GXX=
213   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
214 fi
215 ])dnl
216
217
218 dnl Usage: LYX_CXX_RTTI : checks whether the C++ compiler
219 dnl   supports RTTI
220 AC_DEFUN(LYX_CXX_RTTI,[
221 ### Check whether the compiler supports runtime type information
222 AC_CACHE_CHECK(whether the C++ compiler supports RTTI,lyx_cv_rtti,
223  [AC_TRY_RUN([
224 class rtti {
225 public:
226    virtual int tag() { return 0; }
227 };
228 class derived1 : public rtti {
229 public:
230     int tag() { return 1; }
231 };
232 class derived2 : public rtti {
233 public:
234     int tag() { return 2; }
235 };
236 int main() {
237     derived1 * foo1 = new derived1();
238     derived2 * foo2 = new derived2();
239     rtti * bar = foo1;
240     derived1 * bar1 = dynamic_cast<derived1 *>(bar);
241     if (bar1 == 0)
242         exit(1);
243     bar = foo2;
244     bar1 = dynamic_cast<derived1 *>(bar);
245     if (bar1 != 0)
246         exit(1);
247     return 0;
248 }
249 ],lyx_cv_rtti=yes,lyx_cv_rtti=no,lyx_cv_rtti=no)
250 ])
251 if test x$lyx_cv_rtti = xyes ; then
252   AC_DEFINE(HAVE_RTTI, 1, 
253    [Define to 1 if your compiler supports runtime type information])
254 fi])
255
256
257 dnl Usage: LYX_CXX_EXPLICIT : checks whether the C++ compiler
258 dnl   understands the "explicit" directive.
259 AC_DEFUN(LYX_CXX_EXPLICIT,[
260 ### Check whether the compiler understands the keyword `explicit'
261 AC_CACHE_CHECK(whether the C++ compiler understands explicit,lyx_cv_explicit,
262  [AC_TRY_COMPILE([
263 class Expl {
264 public:
265         explicit Expl() {};
266 };],,lyx_cv_explicit=yes,lyx_cv_explicit=no)
267 ])
268 if test $lyx_cv_explicit = no ; then
269   AC_DEFINE(explicit,[ ], 
270    [Define to nothing if your compiler does not understand the
271    'explicit' directive])
272 fi])
273
274
275 dnl Usage: LYX_CXX_STL_STACK : checks whether the C++ compiler
276 dnl   has a working stl stack template
277 AC_DEFUN(LYX_CXX_STL_STACK,[
278 AC_CACHE_CHECK(for broken STL stack template,lyx_cv_broken_stack,
279  [AC_TRY_COMPILE([
280 #include <stack>
281 using std::stack;
282 ],[
283     stack<int> stakk;
284     stakk.push(0);
285 ],lyx_cv_broken_stack=no,lyx_cv_broken_stack=yes)
286 ])
287 if test $lyx_cv_broken_stack = yes ; then
288   AC_DEFINE(BROKEN_STL_STACK, 1, 
289    [Define if you have the STL from libg++ 2.7.x, where stack<> is not defined
290    correctly])
291 fi])
292
293
294 dnl Usage: LYX_STD_COUNT : checks wherer the C++ library have a conforming
295 dnl    count template, if not the old HP version is assumed.
296 AC_DEFUN(LYX_STD_COUNT,[
297 AC_CACHE_CHECK(for conforming std::count,lyx_cv_std_count,
298  [AC_TRY_COMPILE([
299 #include <string>
300 #include <algorithm>
301 using std::string;
302 using std::count;
303 int countChar(string const & a, char const c)
304 {
305         return count(a.begin(), a.end(), c);
306 }
307 ],[
308     string a("hello");
309     int i = countChar(a, 'l');
310 ],lyx_cv_std_count=yes,lyx_cv_std_count=no)
311 ])
312 if test $lyx_cv_std_count = yes ; then
313     AC_DEFINE(HAVE_STD_COUNT, 1,
314     [Define if you have a conforming std::count template, otherwise HP version of count template is assumed.])
315 fi])
316
317
318 dnl Usage: LYX_CXX_STL_MODERN_STREAMS : checks whether the C++ compiler
319 dnl   supports modern STL streams
320 AC_DEFUN(LYX_CXX_STL_MODERN_STREAMS,[
321 AC_CACHE_CHECK(for modern STL streams,lyx_cv_modern_streams,
322  [AC_TRY_COMPILE([
323 #include <iostream>
324 ],[
325  std::streambuf * test = std::cerr.rdbuf();
326  test->pubsync();
327 ],lyx_cv_modern_streams=yes,lyx_cv_modern_streams=no)
328 ])
329 if test $lyx_cv_modern_streams = yes ; then
330   AC_DEFINE(MODERN_STL_STREAMS, 1, 
331    [Define if you have modern standard-compliant STL streams])
332 fi])
333
334
335 dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler
336 dnl   has a std::string that is usable for LyX. LyX does not require this
337 dnl   std::string to be standard.
338 AC_DEFUN(LYX_CXX_STL_STRING,[
339     AC_REQUIRE([LYX_PROG_CXX])
340     AC_MSG_CHECKING(whether the included std::string should be used)
341     AC_ARG_WITH(included-string,
342        [  --with-included-string  use LyX string class instead of STL string],
343        [lyx_cv_with_included_string=$withval],
344        [AC_CACHE_CHECK([],lyx_cv_with_included_string,
345         [AC_TRY_COMPILE([
346             #include <string>
347             using std::string;
348         ],[
349             // LyX has reduced its requirements on the basic_string
350             // implementation so that the basic_string supplied
351             // with gcc is usable. In particular this means that
352             // lyx does not use std::string::clear and not the
353             // strncmp version of std::string::compare. This is mainly
354             // done so that LyX can use precompiled C++ libraries that
355             // already uses the systems basic_string, e.g. gtk--
356             string a("hello there");
357             a.erase();
358             a = "hey";
359             //char s[] = "y";
360             //int t = a.compare(a.length() - 1, 1, s);
361             a.erase();
362         ],[
363             lyx_cv_with_included_string=no
364         ],[
365             lyx_cv_with_included_string=yes
366         ])
367         ])
368     ])
369     if test x$lyx_cv_with_included_string = xyes ; then
370         AC_DEFINE(USE_INCLUDED_STRING, 1,
371             [Define to use the lyxstring class bundled with LyX.])
372             lyx_flags="$lyx_flags included-string"
373     fi
374     AM_CONDITIONAL(USE_LYXSTRING, test x$lyx_cv_with_included_string = xyes)
375 dnl    AC_MSG_RESULT([$with_included_string])
376 ])
377
378
379 dnl Usage: LYX_CXX_GOOD_STD_STRING : checks whether the C++ compiler
380 dnl   has a std::string that is close to the standard. So close that
381 dnl   methods not found in "unstandard" std::strings are present here.
382 AC_DEFUN(LYX_CXX_GOOD_STD_STRING,[
383     AC_REQUIRE([LYX_PROG_CXX])
384     AC_CACHE_CHECK([whether the systems std::string is really good],
385     [lyx_cv_std_string_good],
386     [AC_TRY_COMPILE([
387             #include <string>
388             using std::string;
389         ],[
390             // From a std::string that is supposed to be close to the
391             // standard we require at least three things:
392             // - clear() and erase()
393             // - the strncmp of compare()
394             // - push_back()
395             string a("hello there");
396             a.erase();
397             a = "hey";
398             char s[] = "y";
399             int t = a.compare(a.length() - 1, 1, s);
400             a.push_back('g');
401             a.clear();
402         ],[
403             lyx_cv_std_string_good=yes
404         ],[
405             lyx_cv_std_string_good=no
406             
407         ])
408     ])
409     if test x$lyx_cv_std_string_good = xyes ; then
410         AC_DEFINE(STD_STRING_IS_GOOD, 1,
411             [Define is the systems std::string is really good.])
412     fi
413 ])
414
415
416 dnl Usage: LYX_REGEX : checks if the header regex.h is available
417 dnl   if it is not available the automake variable USE_REGEX will be
418 dnl   defined and the regex.h and regex.c that we provide will be used.
419 AC_DEFUN(LYX_REGEX,[
420     AC_CHECK_HEADERS(regex.h, lyx_regex=no, lyx_regex=yes)
421     AM_CONDITIONAL(USE_REGEX, test x$lyx_regex = xyes)
422 ])
423
424
425 dnl LYX_CXX_MUTABLE
426 AC_DEFUN(LYX_CXX_MUTABLE, [
427     AC_REQUIRE([LYX_PROG_CXX])
428     AC_CACHE_CHECK([if C++ compiler supports mutable],
429     lyx_cv_cxx_mutable,[
430         AC_TRY_COMPILE(
431         [
432         class k {       
433                 mutable char *c;
434         public:
435                 void foo() const { c=0; }
436         };
437         ],[
438         ],[
439         lyx_cv_cxx_mutable=yes
440         ],[
441         lyx_cv_cxx_mutable=no
442         ])
443     ])
444     if test $lyx_cv_cxx_mutable = yes ; then
445         AC_DEFINE(HAVE_MUTABLE, 1,
446         [Defined if your compiler suports 'mutable'.])
447     fi
448 ])
449
450
451 dnl LYX_CXX_PARTIAL
452 AC_DEFUN(LYX_CXX_PARTIAL, [
453     AC_REQUIRE([LYX_PROG_CXX])
454     AC_CACHE_CHECK([if C++ compiler supports partial specialization],
455         [lyx_cv_cxx_partial_specialization],
456         [AC_TRY_COMPILE(
457             [
458             template<class T, class K>
459             class k {       
460             public:
461             };
462             template<class T> class k<void,T> { };
463             ],[
464             k<float, float> b;
465             k<void,void> a;
466             ],[
467             lyx_cv_cxx_partial_specialization=yes
468             ],[
469             lyx_cv_cxx_partial_specialization=no
470             ])
471         ])
472     if test x$lyx_cv_cxx_partial_specialization = xyes ; then
473         AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION, 1, 
474         [Defined if your compiler supports partial specialization.])
475     fi
476 ])
477
478
479 dnl Usage: LYX_CXX_NAMESPACES : checks whether the C++ compiler
480 dnl   has a correct namespace handling and define CXX_WORKING_NAMESPACES 
481 dnl   if true. This macro does not do a thourough test, but it should be 
482 dnl   good enough to suit our needs.
483 AC_DEFUN(LYX_CXX_NAMESPACES,[
484     AC_CACHE_CHECK(for correct namespaces support,lyx_cv_cxx_namespace,
485     [AC_TRY_COMPILE([
486     namespace foo {
487         int bar;
488     }
489     ],[
490         foo::bar = 0;
491         return 0;
492     ],lyx_cv_cxx_namespace=yes,lyx_cv_cxx_namespace=no)
493     ])
494     if test x$lyx_cv_cxx_namespace = xyes ; then
495         AC_DEFINE(CXX_WORKING_NAMESPACES, 1, 
496         [Define if your C++ compiler has correct support for namespaces])
497     fi
498 ])
499
500
501 dnl Usage: LYX_CXX_CHEADERS : checks whether the C++ compiler
502 dnl   provides wrappers for C headers and use our alternate version otherwise.
503 AC_DEFUN(LYX_CXX_CHEADERS,[
504 AC_CACHE_CHECK(for C headers wrappers,lyx_cv_cxx_cheaders,
505  [AC_TRY_CPP([
506 #include <clocale>
507 #include <cctype>
508 #include <cerrno>
509 #include <cmath>
510 #include <csignal>
511 #include <cstdio>
512 #include <cstdlib>
513 #include <cstring>
514 #include <ctime>],[lyx_cv_cxx_cheaders=yes],[lyx_cv_cxx_cheaders=no])])
515 if test $lyx_cv_cxx_cheaders = no ; then
516   LYX_ADD_INC_DIR(lyx_cppflags,\$(top_srcdir)/src/cheaders)  
517 fi])
518
519
520 dnl Usage LYX_PATH_XPM: Checks for xpm library and header
521 AC_DEFUN(LYX_PATH_XPM,[
522 ### Check for Xpm library
523 AC_CHECK_LIB(Xpm, XpmCreateBufferFromImage,LYX_LIBS="-lXpm $LYX_LIBS",
524         [LYX_LIB_ERROR(libXpm,Xpm)], $LYX_LIBS)
525
526 ### Check for Xpm headers
527 lyx_cv_xpm_h_location="<xpm.h>"
528 AC_CHECK_HEADER(X11/xpm.h,[
529   ac_cv_header_xpm_h=yes
530   lyx_cv_xpm_h_location="<X11/xpm.h>"],[
531 AC_CHECK_HEADER(xpm.h,[],[
532 LYX_LIB_ERROR(xpm.h,Xpm)])])
533 AC_DEFINE_UNQUOTED(XPM_H_LOCATION,$lyx_cv_xpm_h_location)
534
535 ### Test for the header version
536 if test $ac_cv_header_xpm_h = yes; then
537   AC_CACHE_CHECK([xpm header version],lyx_cv_xpmversion,
538   [ cat > conftest.$ac_ext <<EOF
539 #line __oline__ "configure"
540 #include "confdefs.h"
541
542 #include XPM_H_LOCATION
543 "%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
544 EOF
545     eval `(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
546       grep '^"%%%"'  2>/dev/null | \
547       sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
548     case "$lyx_cv_xpmr" in
549 changequote(,)
550      [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
551             lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
552 changequote([,])
553          *) ;;
554     esac
555     lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
556     rm -f conftest*])
557   case "$lyx_cv_xpmr" in 
558 changequote(,)
559         [789]|[0-9][0-9]*) ;;
560 changequote([,])
561         *) LYX_WARNING([Version $lyx_cv_xpmversion of the Xpm library is a bit old. 
562    If you experience strange crashes with LyX, try to upgrade 
563    to at least version 4.7 (aka 3.4g).
564    If you have installed a newer version of the library, check whether you
565    have an old xpm.h header file in your include path.]);;
566   esac
567 fi])
568
569
570 dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
571 AC_DEFUN(LYX_PATH_XFORMS,[
572 ### Check for xforms library
573 AC_CHECK_LIB(forms, fl_initialize, LYX_LIBS="-lforms $LYX_LIBS", 
574   [AC_CHECK_LIB(xforms, fl_initialize, LYX_LIBS="-lxforms $LYX_LIBS", 
575     [LYX_LIB_ERROR(libforms or libxforms,xforms)], $LYX_LIBS)], $LYX_LIBS) 
576
577 ### Check for xforms headers
578 lyx_cv_forms_h_location="<forms.h>"
579 AC_CHECK_HEADER(X11/forms.h,[
580   ac_cv_header_forms_h=yes
581   lyx_cv_forms_h_location="<X11/forms.h>"],[
582 AC_CHECK_HEADER(forms.h,[],[
583 LYX_LIB_ERROR(forms.h,forms)])])
584 AC_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
585 if test $ac_cv_header_forms_h = yes; then
586   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
587   [ cat > conftest.$ac_ext <<EOF
588 #line __oline__ "configure"
589 #include "confdefs.h"
590
591 #include FORMS_H_LOCATION
592 #if ! defined(FL_INCLUDE_VERSION)
593 "%%%"(unknown)"%%%"
594 #else
595 "%%%"FL_VERSION.FL_REVISION"%%%"
596 #endif
597 EOF
598 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
599   grep '^"%%%"'  2>/dev/null | \
600   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
601 rm -f conftest*])
602 case "$lyx_cv_xfversion" in 
603   "(unknown)"|0.8[1-7]) 
604          LYX_ERROR(dnl
605 Version $lyx_cv_xfversion of xforms is not compatible with LyX. 
606    This version of LyX works best with versions 0.88 (recommended) and later.) ;;
607     0.88) ;;
608     0.89) LYX_WARNING(dnl
609 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
610 it is an unproven version and might still have some bugs. If you
611 have problems[,] please use version 0.88 instead.) ;;
612        *) LYX_WARNING(dnl
613 Version $lyx_cv_xfversion of xforms might not be compatible with LyX[,] 
614  since it is newer than 0.88. You might have slight problems with it.);;
615 esac
616 fi])
617
618
619 dnl Usage: LYX_HPUX  Checks for HP-UX and update CXXFLAGS accordingly
620 AC_DEFUN(LYX_HPUX,
621 [#It seems that HPUX requires using -fpcc-struct-return with gcc.
622 AC_CACHE_CHECK(for HP-UX,ac_cv_hpux,[
623 os=`uname -s | tr '[A-Z]' '[a-z]'`
624 ac_cv_hpux=no
625 test "$os" = hp-ux && ac_cv_hpux=yes])
626 if test "$ac_cv_hpux" = yes; then
627  test "x$GXX" = xyes && CXXFLAGS="$CXXFLAGS -fpcc-struct-return"
628 fi])
629
630
631 dnl Usage: LYX_SUNOS4 Checks for SunOS 4.x and sets the flag lyx_broken_headers
632 dnl   if necessary
633 AC_DEFUN(LYX_SUNOS4,
634 [#The headers are not correct under SunOS4
635 AC_CACHE_CHECK(for SunOS 4.x,ac_cv_sunos4,[
636 changequote(, ) dnl
637 os=`uname -a | sed -e 's/^\([^ ]*\) [^ ]* \([0-9]\)\..*/\1\2/'`
638 changequote([, ]) dnl
639 ac_cv_sunos4=no
640 test "$os" = SunOS4 && ac_cv_sunos4=yes])
641 if test "$ac_cv_sunos4" = yes; then
642  test "x$GXX" = xyes && lyx_broken_headers=yes
643 fi])
644
645
646 dnl Usage: LYX_SCO Checks for SCO and sets the flag lyx_broken_headers
647 dnl   if necessary
648 AC_DEFUN(LYX_SCO,
649 [AC_CACHE_CHECK(for SCO 3.2v4,ac_cv_sco,[
650 ac_cv_sco=no
651 if test `uname -s` != "SCO_SV"; then
652   lyx_machine_rel=`uname -m`:`uname -r`
653   if test $lyx_machine_rel = i386:3.2 || test $lyx_machine_rel = i486:3.2;
654   then
655     if test -f /usr/options/cb.name; then
656       ac_cv_sco=no
657     elif /bin/uname -X 2>/dev/null >/dev/null ; then
658       ac_cv_sco=yes
659     fi
660   fi
661 fi])
662 if test "$ac_cv_sco" = yes; then
663  test "x$GXX" = xyes && lyx_broken_headers=yes
664 fi])
665
666 dnl Usage: LYX_FUNC_PUTENV_ARGTYPE
667 dnl Checks whether putenv() takes 'char const *' or 'char *' as
668 dnl argument. This is needed because Solaris 7 (wrongly?) uses 'char *', 
669 dnl while everybody else uses the former...
670 AC_DEFUN(LYX_FUNC_PUTENV_ARGTYPE,
671 [AC_MSG_CHECKING([type of argument for putenv()])
672  AC_CACHE_VAL(lyx_cv_func_putenv_arg,dnl
673   [AC_TRY_COMPILE(dnl
674 [#include <cstdlib>],
675 [char const * foo = "bar";
676  putenv(foo);],dnl
677    [lyx_cv_func_putenv_arg='char const *'],[lyx_cv_func_putenv_arg='char *'])])
678  AC_MSG_RESULT($lyx_cv_func_putenv_arg)
679  AC_DEFINE_UNQUOTED(PUTENV_TYPE_ARG,$lyx_cv_func_putenv_arg,dnl
680    [Define to the type of the argument of putenv(). Needed on Solaris 7.])])
681
682
683 dnl Usage: LYX_WITH_DIR(dir-name,desc,dir-var-name,default-value, 
684 dnl                       [default-yes-value])  
685 dnl  Adds a --with-'dir-name' option (described by 'desc') and puts the 
686 dnl  resulting directory name in 'dir-var-name'.
687 AC_DEFUN(LYX_WITH_DIR,[
688   AC_ARG_WITH($1,[  --with-$1        specify $2])
689   AC_MSG_CHECKING([for $2])
690   if test -z "$with_$3"; then
691      AC_CACHE_VAL(lyx_cv_$3, lyx_cv_$3=$4)
692   else
693     test "x$with_$3" = xyes && with_$3=$5
694     lyx_cv_$3="$with_$3"
695   fi
696   AC_MSG_RESULT($lyx_cv_$3)])
697
698
699 dnl Usage: LYX_LOOP_DIR(value,action)
700 dnl Executes action for values of variable `dir' in `values'. `values' can 
701 dnl use ":" as a separator.
702 AC_DEFUN(LYX_LOOP_DIR,[
703 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
704 for dir in `eval "echo $1"`; do
705   if test ! "$dir" = NONE; then
706     test ! -d "$dir" && AC_ERROR([\"$dir\" is not a directory])
707     $2
708   fi
709 done
710 IFS=$ac_save_ifs
711 ])
712
713
714 dnl Usage: LYX_ADD_LIB_DIR(var-name,dir) Adds a -L directive to variable 
715 dnl var-name. 
716 AC_DEFUN(LYX_ADD_LIB_DIR,[
717 $1="${$1} -L$2"
718 if test "`(uname) 2>/dev/null`" = SunOS &&
719     uname -r | grep '^5' >/dev/null; then
720   if test $ac_cv_prog_gxx = yes ; then 
721     $1="${$1} -Wl[,]-R$2" 
722   else
723     $1="${$1} -R$2"
724   fi
725 fi])
726
727
728 dnl Usage: LYX_ADD_INC_DIR(var-name,dir) Adds a -I directive to variable 
729 dnl var-name. 
730 AC_DEFUN(LYX_ADD_INC_DIR,[$1="${$1} -I$2 "])
731
732 ### Check which libsigc++ we're using and make sure any external one works
733 ### Check for libsigc++ library
734 AC_DEFUN(LYX_WITH_SIGC,
735 [AC_MSG_CHECKING(whether the included libsigc++ should be used)
736 AC_ARG_WITH([included-libsigc],
737   [  --without-included-libsigc
738                              Use the libsigc++ installed on the system],
739   [lyx_use_included_libsigc=$withval],
740   [lyx_use_included_libsigc=yes])
741 AC_MSG_RESULT([$lyx_use_included_libsigc])
742 if test x$lyx_use_included_libsigc = xno; then
743   ### Check for libsigc++
744   ## can't use AC_SUBST right here!
745   AM_PATH_SIGC(0.8.7,
746     [ INCLUDED_SIGC=
747     ],
748     [LYX_ERROR(dnl
749     [Cannot find libsigc++ library or headers at least as recent as 0.8.7.
750      Check your installation.  Have you installed the development package?])
751   ])
752 else
753   ### Use the included libsigc++
754   ### sigc-config hasn't been created yet so we can't just do the same as above
755   ### unless of course someone gets keen and merges the sigc++ configure.in 
756   ### with this one.  We don't really gain much by doing that though except
757   ### a considerably smaller dist and more difficult maintenance.
758   ### It'd also mean we'd have the equivalent of config/gettext.m4
759   lyx_flags="$lyx_flags included-libsigc"
760   SIGC_LIBS="\`\${top_builddir}/sigc++/sigc-config --libs-names | sed -e 's/-lsigc//'\`"
761   # Libsigc++ always installs into a subdirectory called sigc++.  Therefore we
762   # have to always use #include <sigc++/signal_system.h> in our code.
763   # Remember if you decide to do anything to the sigc++ code to do your mods on
764   # the makeLyXsigc.sh script in development/tools using a current cvs checkout
765   # of libsigc++.  A tarball distribution doesn't have everything in it that we
766   # need.
767   # We need both these -I entries to build when builddir != srcdir
768   if test "x$src_dir" = "x." ; then
769     SIGC_CFLAGS="-I\${top_srcdir}"
770   else
771     SIGC_CFLAGS="-I\${top_builddir} -I\${top_srcdir}"
772   fi
773   INCLUDED_SIGC="\${top_builddir}/sigc++/libsigc.la"
774   ## can't substitute these here like this otherwise all remaining tests fail
775   ## instead we SUBST directly into the Makefiles
776   ##LIBS="$LIBS \$SIGC_LIBS"
777   ##CPPFLAGS="$CPPFLAGS \$SIGC_CFLAGS"
778   AC_SUBST(SIGC_LIBS)
779   AC_SUBST(SIGC_CFLAGS)
780 fi
781 AC_SUBST(INCLUDED_SIGC)
782 ])
783
784 ### Check for a headers existence and location iff it exists
785 ## This is supposed to be a generalised version of LYX_STL_STRING_FWD
786 ## It almost works.  I've tried a few variations but they give errors
787 ## of one sort or other: bad substitution or file not found etc.  The
788 ## actual header _is_ found though and the cache variable is set however
789 ## the reported setting (on screen) is equal to $ac_safe for some unknown
790 ## reason.
791 ## Additionally, autoheader can't figure out what to use as the name in
792 ## the config.h.in file so we need to write our own entries there -- one for
793 ## each header in the form PATH_HEADER_NAME_H
794 ##
795 AC_DEFUN(LYX_PATH_HEADER,
796 [ AC_CHECK_HEADER($1,[
797   ac_tr_safe=PATH_`echo $ac_safe | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
798 ### the only remaining problem is getting the second parameter to this
799 ### AC_CACHE_CACHE to print correctly. Currently it just results in value
800 ### of $ac_safe being printed.
801   AC_CACHE_CHECK([path to $1],[lyx_cv_path2_$ac_safe],
802   [ cat > conftest.$ac_ext <<EOF
803 #line __oline__ "configure"
804 #include "confdefs.h"
805
806 #include <$1>
807 EOF
808 lyx_path_header_path=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
809   grep $1  2>/dev/null | \
810   sed -e 's/.*\(".*$1"\).*/\1/' -e "1q"`
811 eval "lyx_cv_path2_${ac_safe}=\$lyx_path_header_path"
812 rm -f conftest*])
813   AC_DEFINE_UNQUOTED($ac_tr_safe, $lyx_path_header_path)])
814 ])
815 ### end of LYX_PATH_HEADER
816
817 ### Check for stl_string_fwd.h existence and location if it exists
818 AC_DEFUN(LYX_STL_STRING_FWD,
819 [ AC_CHECK_HEADER(stl_string_fwd.h,[
820   AC_CACHE_CHECK([path to stl_string_fwd.h],lyx_cv_path_stl_string_fwd_h,
821   [ cat > conftest.$ac_ext <<EOF
822 #line __oline__ "configure"
823 #include "confdefs.h"
824
825 #include <stl_string_fwd.h>
826 EOF
827 lyx_cv_path_stl_string_fwd_h=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
828   grep 'stl_string_fwd.h'  2>/dev/null | \
829   sed -e 's/.*\(".*stl_string_fwd.h"\).*/\1/' -e "1q"`
830 rm -f conftest*])
831   AC_DEFINE_UNQUOTED(STL_STRING_FWD_H_LOCATION,$lyx_cv_path_stl_string_fwd_h,
832 [define this to the location of stl_string_fwd.h to be used with #include,
833   NOTE: Do not set it to <stl_string_fwd.h> as that will find the LyX
834         supplied version of the header.
835   e.g. <../include/stl_string_fwd.h> or better yet use an absolute path])])
836 ])
837
838
839 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
840 dnl if the cache file is inconsistent with the current host,
841 dnl target and build system types, execute CMD or print a default
842 dnl error message.
843 AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
844     AC_REQUIRE([AC_CANONICAL_SYSTEM])
845     AC_MSG_CHECKING([config.cache system type])
846     if { test x"${ac_cv_host_system_type+set}" = x"set" &&
847          test x"$ac_cv_host_system_type" != x"$host"; } ||
848        { test x"${ac_cv_build_system_type+set}" = x"set" &&
849          test x"$ac_cv_build_system_type" != x"$build"; } ||
850        { test x"${ac_cv_target_system_type+set}" = x"set" &&
851          test x"$ac_cv_target_system_type" != x"$target"; }; then
852         AC_MSG_RESULT([different])
853         ifelse($#, 1, [$1],
854                 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
855     else
856         AC_MSG_RESULT([same])
857     fi
858     ac_cv_host_system_type="$host"
859     ac_cv_build_system_type="$build"
860     ac_cv_target_system_type="$target"
861 ])
862
863 dnl We use this until autoconf fixes its version.
864 AC_DEFUN(LYX_FUNC_SELECT_ARGTYPES,
865 [AC_MSG_CHECKING([types of arguments for select()])
866  AC_CACHE_VAL(ac_cv_func_select_arg234,dnl
867  [AC_CACHE_VAL(ac_cv_func_select_arg1,dnl
868   [AC_CACHE_VAL(ac_cv_func_select_arg5,dnl
869    [for ac_cv_func_select_arg234 in 'fd_set *' 'int *' 'void *'; do
870      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
871        AC_TRY_COMPILE(dnl
872 [#ifdef HAVE_SYS_TYPES_H
873 #include <sys/types.h>
874 #endif
875 #ifdef HAVE_SYS_TIME_H
876 #include <sys/time.h>
877 #endif
878 #ifdef HAVE_SYS_SELECT_H
879 #include <sys/select.h>
880 #endif
881 #ifdef HAVE_SYS_SOCKET_H
882 #include <sys/socket.h>
883 #endif
884 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
885         [ac_not_found=no ; break 3],ac_not_found=yes)
886       done
887      done
888     done
889    ])dnl AC_CACHE_VAL
890   ])dnl AC_CACHE_VAL
891  ])dnl AC_CACHE_VAL
892  if test "$ac_not_found" = yes; then
893   ac_cv_func_select_arg1=int 
894   ac_cv_func_select_arg234='int *' 
895   ac_cv_func_select_arg5='struct timeval *'
896  fi
897  AC_MSG_RESULT([$ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5])
898  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1,$ac_cv_func_select_arg1)
899  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234,($ac_cv_func_select_arg234))
900  AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5,($ac_cv_func_select_arg5))
901 ])
902
903 ### Check which frontend we want to use. The default is XForms
904 ###
905 AC_DEFUN(LYX_USE_FRONTEND,
906 [AC_MSG_CHECKING(what frontend should be used as main GUI)
907 AC_ARG_WITH(frontend,
908   [  --with-frontend[=value] Use THIS frontend as main GUI:
909                           Possible values: xforms,kde,gtk],
910   [lyx_use_frontend="$withval"], [lyx_use_frontend="xforms"])
911 AC_MSG_RESULT($lyx_use_frontend)
912 lyx_flags="$lyx_flags frontend-$lyx_use_frontend"
913 AC_SUBST(FRONTEND)
914 AC_SUBST(FRONTEND_GUILIB)
915 AC_SUBST(FRONTEND_LDFLAGS)
916 AC_SUBST(FRONTEND_INCLUDES)
917 AC_SUBST(FRONTEND_LIBS)
918 ])
919 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
920 ## Copyright (C) 1996-1999 Free Software Foundation, Inc.
921 ## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
922 ##
923 ## This program is free software; you can redistribute it and/or modify
924 ## it under the terms of the GNU General Public License as published by
925 ## the Free Software Foundation; either version 2 of the License, or
926 ## (at your option) any later version.
927 ##
928 ## This program is distributed in the hope that it will be useful, but
929 ## WITHOUT ANY WARRANTY; without even the implied warranty of
930 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
931 ## General Public License for more details.
932 ##
933 ## You should have received a copy of the GNU General Public License
934 ## along with this program; if not, write to the Free Software
935 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
936 ##
937 ## As a special exception to the GNU General Public License, if you
938 ## distribute this file as part of a program that contains a
939 ## configuration script generated by Autoconf, you may include it under
940 ## the same distribution terms that you use for the rest of that program.
941
942 # serial 40 AC_PROG_LIBTOOL
943 AC_DEFUN(AC_PROG_LIBTOOL,
944 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
945
946 # Save cache, so that ltconfig can load it
947 AC_CACHE_SAVE
948
949 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
950 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
951 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
952 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
953 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
954 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
955 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
956 || AC_MSG_ERROR([libtool configure failed])
957
958 # Reload cache, that may have been modified by ltconfig
959 AC_CACHE_LOAD
960
961 # This can be used to rebuild libtool when needed
962 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
963
964 # Always use our own libtool.
965 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
966 AC_SUBST(LIBTOOL)dnl
967
968 # Redirect the config.log output again, so that the ltconfig log is not
969 # clobbered by the next message.
970 exec 5>>./config.log
971 ])
972
973 AC_DEFUN(AC_LIBTOOL_SETUP,
974 [AC_PREREQ(2.13)dnl
975 AC_REQUIRE([AC_ENABLE_SHARED])dnl
976 AC_REQUIRE([AC_ENABLE_STATIC])dnl
977 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
978 AC_REQUIRE([AC_CANONICAL_HOST])dnl
979 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
980 AC_REQUIRE([AC_PROG_RANLIB])dnl
981 AC_REQUIRE([AC_PROG_CC])dnl
982 AC_REQUIRE([AC_PROG_LD])dnl
983 AC_REQUIRE([AC_PROG_NM])dnl
984 AC_REQUIRE([AC_PROG_LN_S])dnl
985 dnl
986
987 case "$target" in
988 NONE) lt_target="$host" ;;
989 *) lt_target="$target" ;;
990 esac
991
992 # Check for any special flags to pass to ltconfig.
993 libtool_flags="--cache-file=$cache_file"
994 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
995 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
996 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
997 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
998 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
999 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
1000 [libtool_flags="$libtool_flags --enable-dlopen"])
1001 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1002 [libtool_flags="$libtool_flags --enable-win32-dll"])
1003 AC_ARG_ENABLE(libtool-lock,
1004   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
1005 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
1006 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
1007
1008 # Some flags need to be propagated to the compiler or linker for good
1009 # libtool support.
1010 case "$lt_target" in
1011 *-*-irix6*)
1012   # Find out which ABI we are using.
1013   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
1014   if AC_TRY_EVAL(ac_compile); then
1015     case "`/usr/bin/file conftest.o`" in
1016     *32-bit*)
1017       LD="${LD-ld} -32"
1018       ;;
1019     *N32*)
1020       LD="${LD-ld} -n32"
1021       ;;
1022     *64-bit*)
1023       LD="${LD-ld} -64"
1024       ;;
1025     esac
1026   fi
1027   rm -rf conftest*
1028   ;;
1029
1030 *-*-sco3.2v5*)
1031   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1032   SAVE_CFLAGS="$CFLAGS"
1033   CFLAGS="$CFLAGS -belf"
1034   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1035     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
1036   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1037     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1038     CFLAGS="$SAVE_CFLAGS"
1039   fi
1040   ;;
1041
1042 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1043 [*-*-cygwin* | *-*-mingw*)
1044   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
1045   AC_CHECK_TOOL(AS, as, false)
1046   AC_CHECK_TOOL(OBJDUMP, objdump, false)
1047   ;;
1048 ])
1049 esac
1050 ])
1051
1052 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
1053 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
1054
1055 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
1056 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
1057
1058 # AC_ENABLE_SHARED - implement the --enable-shared flag
1059 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
1060 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1061 #   `yes'.
1062 AC_DEFUN(AC_ENABLE_SHARED, [dnl
1063 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
1064 AC_ARG_ENABLE(shared,
1065 changequote(<<, >>)dnl
1066 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
1067 changequote([, ])dnl
1068 [p=${PACKAGE-default}
1069 case "$enableval" in
1070 yes) enable_shared=yes ;;
1071 no) enable_shared=no ;;
1072 *)
1073   enable_shared=no
1074   # Look at the argument we got.  We use all the common list separators.
1075   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1076   for pkg in $enableval; do
1077     if test "X$pkg" = "X$p"; then
1078       enable_shared=yes
1079     fi
1080   done
1081   IFS="$ac_save_ifs"
1082   ;;
1083 esac],
1084 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
1085 ])
1086
1087 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
1088 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1089 AC_ENABLE_SHARED(no)])
1090
1091 # AC_ENABLE_STATIC - implement the --enable-static flag
1092 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
1093 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1094 #   `yes'.
1095 AC_DEFUN(AC_ENABLE_STATIC, [dnl
1096 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
1097 AC_ARG_ENABLE(static,
1098 changequote(<<, >>)dnl
1099 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
1100 changequote([, ])dnl
1101 [p=${PACKAGE-default}
1102 case "$enableval" in
1103 yes) enable_static=yes ;;
1104 no) enable_static=no ;;
1105 *)
1106   enable_static=no
1107   # Look at the argument we got.  We use all the common list separators.
1108   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1109   for pkg in $enableval; do
1110     if test "X$pkg" = "X$p"; then
1111       enable_static=yes
1112     fi
1113   done
1114   IFS="$ac_save_ifs"
1115   ;;
1116 esac],
1117 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
1118 ])
1119
1120 # AC_DISABLE_STATIC - set the default static flag to --disable-static
1121 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1122 AC_ENABLE_STATIC(no)])
1123
1124
1125 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
1126 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
1127 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1128 #   `yes'.
1129 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
1130 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
1131 AC_ARG_ENABLE(fast-install,
1132 changequote(<<, >>)dnl
1133 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
1134 changequote([, ])dnl
1135 [p=${PACKAGE-default}
1136 case "$enableval" in
1137 yes) enable_fast_install=yes ;;
1138 no) enable_fast_install=no ;;
1139 *)
1140   enable_fast_install=no
1141   # Look at the argument we got.  We use all the common list separators.
1142   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1143   for pkg in $enableval; do
1144     if test "X$pkg" = "X$p"; then
1145       enable_fast_install=yes
1146     fi
1147   done
1148   IFS="$ac_save_ifs"
1149   ;;
1150 esac],
1151 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
1152 ])
1153
1154 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
1155 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1156 AC_ENABLE_FAST_INSTALL(no)])
1157
1158 # AC_PROG_LD - find the path to the GNU or non-GNU linker
1159 AC_DEFUN(AC_PROG_LD,
1160 [AC_ARG_WITH(gnu-ld,
1161 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
1162 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
1163 AC_REQUIRE([AC_PROG_CC])dnl
1164 AC_REQUIRE([AC_CANONICAL_HOST])dnl
1165 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1166 ac_prog=ld
1167 if test "$ac_cv_prog_gcc" = yes; then
1168   # Check if gcc -print-prog-name=ld gives a path.
1169   AC_MSG_CHECKING([for ld used by GCC])
1170   ac_prog=`($CC -print-prog-name=ld) 2>&5`
1171   case "$ac_prog" in
1172     # Accept absolute paths.
1173 changequote(,)dnl
1174     [\\/]* | [A-Za-z]:[\\/]*)
1175       re_direlt='/[^/][^/]*/\.\./'
1176 changequote([,])dnl
1177       # Canonicalize the path of ld
1178       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
1179       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1180         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1181       done
1182       test -z "$LD" && LD="$ac_prog"
1183       ;;
1184   "")
1185     # If it fails, then pretend we aren't using GCC.
1186     ac_prog=ld
1187     ;;
1188   *)
1189     # If it is relative, then search for the first ld in PATH.
1190     with_gnu_ld=unknown
1191     ;;
1192   esac
1193 elif test "$with_gnu_ld" = yes; then
1194   AC_MSG_CHECKING([for GNU ld])
1195 else
1196   AC_MSG_CHECKING([for non-GNU ld])
1197 fi
1198 AC_CACHE_VAL(ac_cv_path_LD,
1199 [if test -z "$LD"; then
1200   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1201   for ac_dir in $PATH; do
1202     test -z "$ac_dir" && ac_dir=.
1203     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
1204       ac_cv_path_LD="$ac_dir/$ac_prog"
1205       # Check to see if the program is GNU ld.  I'd rather use --version,
1206       # but apparently some GNU ld's only accept -v.
1207       # Break only if it was the GNU/non-GNU ld that we prefer.
1208       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
1209         test "$with_gnu_ld" != no && break
1210       else
1211         test "$with_gnu_ld" != yes && break
1212       fi
1213     fi
1214   done
1215   IFS="$ac_save_ifs"
1216 else
1217   ac_cv_path_LD="$LD" # Let the user override the test with a path.
1218 fi])
1219 LD="$ac_cv_path_LD"
1220 if test -n "$LD"; then
1221   AC_MSG_RESULT($LD)
1222 else
1223   AC_MSG_RESULT(no)
1224 fi
1225 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
1226 AC_PROG_LD_GNU
1227 ])
1228
1229 AC_DEFUN(AC_PROG_LD_GNU,
1230 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
1231 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1232 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
1233   ac_cv_prog_gnu_ld=yes
1234 else
1235   ac_cv_prog_gnu_ld=no
1236 fi])
1237 ])
1238
1239 # AC_PROG_NM - find the path to a BSD-compatible name lister
1240 AC_DEFUN(AC_PROG_NM,
1241 [AC_MSG_CHECKING([for BSD-compatible nm])
1242 AC_CACHE_VAL(ac_cv_path_NM,
1243 [if test -n "$NM"; then
1244   # Let the user override the test.
1245   ac_cv_path_NM="$NM"
1246 else
1247   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1248   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
1249     test -z "$ac_dir" && ac_dir=.
1250     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
1251       # Check to see if the nm accepts a BSD-compat flag.
1252       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
1253       #   nm: unknown option "B" ignored
1254       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1255         ac_cv_path_NM="$ac_dir/nm -B"
1256         break
1257       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1258         ac_cv_path_NM="$ac_dir/nm -p"
1259         break
1260       else
1261         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
1262         continue # so that we can try to find one that supports BSD flags
1263       fi
1264     fi
1265   done
1266   IFS="$ac_save_ifs"
1267   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
1268 fi])
1269 NM="$ac_cv_path_NM"
1270 AC_MSG_RESULT([$NM])
1271 ])
1272
1273 # AC_CHECK_LIBM - check for math library
1274 AC_DEFUN(AC_CHECK_LIBM,
1275 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1276 LIBM=
1277 case "$lt_target" in
1278 *-*-beos* | *-*-cygwin*)
1279   # These system don't have libm
1280   ;;
1281 *-ncr-sysv4.3*)
1282   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
1283   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
1284   ;;
1285 *)
1286   AC_CHECK_LIB(m, main, LIBM="-lm")
1287   ;;
1288 esac
1289 ])
1290
1291 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
1292 # the libltdl convenience library, adds --enable-ltdl-convenience to
1293 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1294 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1295 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1296 # '${top_builddir}/' (note the single quotes!) if your package is not
1297 # flat, and, if you're not using automake, define top_builddir as
1298 # appropriate in the Makefiles.
1299 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1300   case "$enable_ltdl_convenience" in
1301   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
1302   "") enable_ltdl_convenience=yes
1303       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
1304   esac
1305   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
1306   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1307 ])
1308
1309 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
1310 # the libltdl installable library, and adds --enable-ltdl-install to
1311 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
1312 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
1313 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
1314 # '${top_builddir}/' (note the single quotes!) if your package is not
1315 # flat, and, if you're not using automake, define top_builddir as
1316 # appropriate in the Makefiles.
1317 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
1318 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1319   AC_CHECK_LIB(ltdl, main,
1320   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
1321   [if test x"$enable_ltdl_install" = xno; then
1322      AC_MSG_WARN([libltdl not installed, but installation disabled])
1323    else
1324      enable_ltdl_install=yes
1325    fi
1326   ])
1327   if test x"$enable_ltdl_install" = x"yes"; then
1328     ac_configure_args="$ac_configure_args --enable-ltdl-install"
1329     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
1330     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
1331   else
1332     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
1333     LIBLTDL="-lltdl"
1334     INCLTDL=
1335   fi
1336 ])
1337
1338 dnl old names
1339 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
1340 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
1341 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
1342 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
1343 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
1344 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
1345 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
1346
1347 dnl This is just to silence aclocal about the macro not being used
1348 ifelse([AC_DISABLE_FAST_INSTALL])dnl
1349 # Macro to add for using GNU gettext.
1350 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1351 #
1352 # This file can be copied and used freely without restrictions.  It can
1353 # be used in projects which are not available under the GNU Public License
1354 # but which still want to provide support for the GNU gettext functionality.
1355 # Please note that the actual code is *not* freely available.
1356
1357 # serial 5
1358
1359 AC_DEFUN(AM_WITH_NLS,
1360   [AC_MSG_CHECKING([whether NLS is requested])
1361     dnl Default is enabled NLS
1362     AC_ARG_ENABLE(nls,
1363       [  --disable-nls           do not use Native Language Support],
1364       USE_NLS=$enableval, USE_NLS=yes)
1365     AC_MSG_RESULT($USE_NLS)
1366     AC_SUBST(USE_NLS)
1367
1368     USE_INCLUDED_LIBINTL=no
1369
1370     dnl If we use NLS figure out what method
1371     if test "$USE_NLS" = "yes"; then
1372       AC_DEFINE(ENABLE_NLS)
1373       AC_MSG_CHECKING([whether included gettext is requested])
1374       AC_ARG_WITH(included-gettext,
1375         [  --with-included-gettext use the GNU gettext library included here],
1376         nls_cv_force_use_gnu_gettext=$withval,
1377         nls_cv_force_use_gnu_gettext=no)
1378       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
1379
1380       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
1381       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
1382         dnl User does not insist on using GNU NLS library.  Figure out what
1383         dnl to use.  If gettext or catgets are available (in this order) we
1384         dnl use this.  Else we have to fall back to GNU NLS library.
1385         dnl catgets is only used if permitted by option --with-catgets.
1386         nls_cv_header_intl=
1387         nls_cv_header_libgt=
1388         CATOBJEXT=NONE
1389
1390         AC_CHECK_HEADER(libintl.h,
1391           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
1392             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
1393                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
1394
1395            if test "$gt_cv_func_gettext_libc" != "yes"; then
1396              AC_CHECK_LIB(intl, bindtextdomain,
1397                [AC_CACHE_CHECK([for gettext in libintl],
1398                  gt_cv_func_gettext_libintl,
1399                  [AC_CHECK_LIB(intl, gettext,
1400 dnl ============== A fix is here! ======================
1401 dnl -lintl was not added to the LIBS variable in this case
1402                   [gt_cv_func_gettext_libintl=yes
1403                    INTLLIBS="-lintl"],
1404 dnl ==== end of fix
1405                   gt_cv_func_gettext_libintl=no)],
1406                  gt_cv_func_gettext_libintl=no)])
1407            fi
1408
1409            if test "$gt_cv_func_gettext_libc" = "yes" \
1410               || test "$gt_cv_func_gettext_libintl" = "yes"; then
1411               AC_DEFINE(HAVE_GETTEXT)
1412               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1413                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
1414               if test "$MSGFMT" != "no"; then
1415                 AC_CHECK_FUNCS(dcgettext)
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_TRY_LINK(, [extern int _nl_msg_cat_cntr;
1420                                return _nl_msg_cat_cntr],
1421                   [CATOBJEXT=.gmo
1422                    DATADIRNAME=share],
1423                   [CATOBJEXT=.mo
1424                    DATADIRNAME=lib])
1425                 INSTOBJEXT=.mo
1426               fi
1427             fi
1428         ])
1429
1430         if test "$CATOBJEXT" = "NONE"; then
1431           AC_MSG_CHECKING([whether catgets can be used])
1432           AC_ARG_WITH(catgets,
1433             [  --with-catgets          use catgets functions if available],
1434             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
1435           AC_MSG_RESULT($nls_cv_use_catgets)
1436
1437           if test "$nls_cv_use_catgets" = "yes"; then
1438             dnl No gettext in C library.  Try catgets next.
1439             AC_CHECK_LIB(i, main)
1440             AC_CHECK_FUNC(catgets,
1441               [AC_DEFINE(HAVE_CATGETS)
1442                INTLOBJS="\$(CATOBJS)"
1443                AC_PATH_PROG(GENCAT, gencat, no)dnl
1444                if test "$GENCAT" != "no"; then
1445                  AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
1446                  if test "$GMSGFMT" = "no"; then
1447                    AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
1448                     [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
1449                  fi
1450                  AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1451                    [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1452                  USE_INCLUDED_LIBINTL=yes
1453                  CATOBJEXT=.cat
1454                  INSTOBJEXT=.cat
1455                  DATADIRNAME=lib
1456                  INTLDEPS='$(top_builddir)/intl/libintl.a'
1457                  INTLLIBS=$INTLDEPS
1458                  LIBS=`echo $LIBS | sed -e 's/-lintl//'`
1459                  nls_cv_header_intl=intl/libintl.h
1460                  nls_cv_header_libgt=intl/libgettext.h
1461                fi])
1462           fi
1463         fi
1464
1465         if test "$CATOBJEXT" = "NONE"; then
1466           dnl Neither gettext nor catgets in included in the C library.
1467           dnl Fall back on GNU gettext library.
1468           nls_cv_use_gnu_gettext=yes
1469         fi
1470       fi
1471
1472       if test "$nls_cv_use_gnu_gettext" = "yes"; then
1473         dnl Mark actions used to generate GNU NLS library.
1474         INTLOBJS="\$(GETTOBJS)"
1475         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1476           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
1477         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1478         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1479           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
1480         AC_SUBST(MSGFMT)
1481         USE_INCLUDED_LIBINTL=yes
1482         CATOBJEXT=.gmo
1483         INSTOBJEXT=.mo
1484         DATADIRNAME=share
1485         INTLDEPS='$(top_builddir)/intl/libintl.a'
1486         INTLLIBS=$INTLDEPS
1487         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
1488         nls_cv_header_intl=intl/libintl.h
1489         nls_cv_header_libgt=intl/libgettext.h
1490       fi
1491
1492       dnl Test whether we really found GNU xgettext.
1493       if test "$XGETTEXT" != ":"; then
1494         dnl If it is no GNU xgettext we define it as : so that the
1495         dnl Makefiles still can work.
1496         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
1497           : ;
1498         else
1499           AC_MSG_RESULT(
1500             [found xgettext program is not GNU xgettext; ignore it])
1501           XGETTEXT=":"
1502         fi
1503       fi
1504
1505       # We need to process the po/ directory.
1506       POSUB=po
1507     else
1508       DATADIRNAME=share
1509       nls_cv_header_intl=intl/libintl.h
1510       nls_cv_header_libgt=intl/libgettext.h
1511     fi
1512     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
1513     AC_OUTPUT_COMMANDS(
1514      [case "$CONFIG_FILES" in *po/Makefile.in*)
1515         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
1516       esac])
1517
1518
1519     # If this is used in GNU gettext we have to set USE_NLS to `yes'
1520     # because some of the sources are only built for this goal.
1521     if test "$PACKAGE" = gettext; then
1522       USE_NLS=yes
1523       USE_INCLUDED_LIBINTL=yes
1524     fi
1525
1526     dnl These rules are solely for the distribution goal.  While doing this
1527     dnl we only have to keep exactly one list of the available catalogs
1528     dnl in configure.in.
1529     for lang in $ALL_LINGUAS; do
1530       GMOFILES="$GMOFILES $lang.gmo"
1531       POFILES="$POFILES $lang.po"
1532     done
1533
1534     dnl Make all variables we use known to autoconf.
1535     AC_SUBST(USE_INCLUDED_LIBINTL)
1536     AC_SUBST(CATALOGS)
1537     AC_SUBST(CATOBJEXT)
1538     AC_SUBST(DATADIRNAME)
1539     AC_SUBST(GMOFILES)
1540     AC_SUBST(INSTOBJEXT)
1541     AC_SUBST(INTLDEPS)
1542     AC_SUBST(INTLLIBS)
1543     AC_SUBST(INTLOBJS)
1544     AC_SUBST(POFILES)
1545     AC_SUBST(POSUB)
1546   ])
1547
1548 AC_DEFUN(AM_GNU_GETTEXT,
1549   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1550    AC_REQUIRE([AC_PROG_CC])dnl
1551    AC_REQUIRE([AC_PROG_RANLIB])dnl
1552    AC_REQUIRE([AC_ISC_POSIX])dnl
1553    AC_REQUIRE([AC_HEADER_STDC])dnl
1554    AC_REQUIRE([AC_C_CONST])dnl
1555    AC_REQUIRE([AC_C_INLINE])dnl
1556    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1557    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1558    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1559    AC_REQUIRE([AC_FUNC_MMAP])dnl
1560
1561    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
1562 unistd.h sys/param.h])
1563    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
1564 strdup __argz_count __argz_stringify __argz_next])
1565
1566    if test "${ac_cv_func_stpcpy+set}" != "set"; then
1567      AC_CHECK_FUNCS(stpcpy)
1568    fi
1569    if test "${ac_cv_func_stpcpy}" = "yes"; then
1570      AC_DEFINE(HAVE_STPCPY)
1571    fi
1572
1573    AM_LC_MESSAGES
1574    AM_WITH_NLS
1575
1576    if test "x$CATOBJEXT" != "x"; then
1577      if test "x$ALL_LINGUAS" = "x"; then
1578        LINGUAS=
1579      else
1580        AC_MSG_CHECKING(for catalogs to be installed)
1581        NEW_LINGUAS=
1582 dnl ============== Fix is here! ======================
1583 dnl Some sh do not like substitution in bounds of for loops
1584 dnl    for lang in ${LINGUAS=$ALL_LINGUAS}; do
1585     tmplinguas=${LINGUAS=$ALL_LINGUAS}
1586     for lang in ${tmplinguas}; do
1587 dnl ==== end of fix
1588          case "$ALL_LINGUAS" in
1589           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
1590          esac
1591        done
1592        LINGUAS=$NEW_LINGUAS
1593        AC_MSG_RESULT($LINGUAS)
1594      fi
1595
1596      dnl Construct list of names of catalog files to be constructed.
1597      if test -n "$LINGUAS"; then
1598        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1599      fi
1600    fi
1601
1602    dnl The reference to <locale.h> in the installed <libintl.h> file
1603    dnl must be resolved because we cannot expect the users of this
1604    dnl to define HAVE_LOCALE_H.
1605    if test $ac_cv_header_locale_h = yes; then
1606      INCLUDE_LOCALE_H="#include <locale.h>"
1607    else
1608      INCLUDE_LOCALE_H="\
1609 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
1610    fi
1611    AC_SUBST(INCLUDE_LOCALE_H)
1612
1613    dnl Determine which catalog format we have (if any is needed)
1614    dnl For now we know about two different formats:
1615    dnl   Linux libc-5 and the normal X/Open format
1616    test -d intl || mkdir intl
1617    if test "$CATOBJEXT" = ".cat"; then
1618      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
1619
1620      dnl Transform the SED scripts while copying because some dumb SEDs
1621      dnl cannot handle comments.
1622      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
1623    fi
1624    dnl po2tbl.sed is always needed.
1625    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
1626      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
1627
1628    dnl In the intl/Makefile.in we have a special dependency which makes
1629    dnl only sense for gettext.  We comment this out for non-gettext
1630    dnl packages.
1631    if test "$PACKAGE" = "gettext"; then
1632      GT_NO="#NO#"
1633      GT_YES=
1634    else
1635      GT_NO=
1636      GT_YES="#YES#"
1637    fi
1638    AC_SUBST(GT_NO)
1639    AC_SUBST(GT_YES)
1640
1641    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1642    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
1643    dnl Try to locate is.
1644    MKINSTALLDIRS=
1645    if test -n "$ac_aux_dir"; then
1646      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1647    fi
1648    if test -z "$MKINSTALLDIRS"; then
1649      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1650    fi
1651    AC_SUBST(MKINSTALLDIRS)
1652
1653    dnl *** For now the libtool support in intl/Makefile is not for real.
1654    l=
1655    AC_SUBST(l)
1656
1657    dnl Generate list of files to be processed by xgettext which will
1658    dnl be included in po/Makefile.
1659    test -d po || mkdir po
1660    if test "x$srcdir" != "x."; then
1661      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
1662        posrcprefix="$srcdir/"
1663      else
1664        posrcprefix="../$srcdir/"
1665      fi
1666    else
1667      posrcprefix="../"
1668    fi
1669    rm -f po/POTFILES
1670    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
1671         < $srcdir/po/POTFILES.in > po/POTFILES
1672   ])
1673 # Check whether LC_MESSAGES is available in <locale.h>.
1674 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1675 #
1676 # This file can be copied and used freely without restrictions.  It can
1677 # be used in projects which are not available under the GNU Public License
1678 # but which still want to provide support for the GNU gettext functionality.
1679 # Please note that the actual code is *not* freely available.
1680
1681 # serial 1
1682
1683 AC_DEFUN(AM_LC_MESSAGES,
1684   [if test $ac_cv_header_locale_h = yes; then
1685     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
1686       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1687        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
1688     if test $am_cv_val_LC_MESSAGES = yes; then
1689       AC_DEFINE(HAVE_LC_MESSAGES)
1690     fi
1691   fi])
1692 # Search path for a program which passes the given test.
1693 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1694 #
1695 # This file can be copied and used freely without restrictions.  It can
1696 # be used in projects which are not available under the GNU Public License
1697 # but which still want to provide support for the GNU gettext functionality.
1698 # Please note that the actual code is *not* freely available.
1699
1700 # serial 1
1701
1702 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1703 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1704 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
1705 [# Extract the first word of "$2", so it can be a program name with args.
1706 set dummy $2; ac_word=[$]2
1707 AC_MSG_CHECKING([for $ac_word])
1708 AC_CACHE_VAL(ac_cv_path_$1,
1709 [case "[$]$1" in
1710   /*)
1711   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1712   ;;
1713   *)
1714   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1715   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1716     test -z "$ac_dir" && ac_dir=.
1717     if test -f $ac_dir/$ac_word; then
1718       if [$3]; then
1719         ac_cv_path_$1="$ac_dir/$ac_word"
1720         break
1721       fi
1722     fi
1723   done
1724   IFS="$ac_save_ifs"
1725 dnl If no 4th arg is given, leave the cache variable unset,
1726 dnl so AC_PATH_PROGS will keep looking.
1727 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1728 ])dnl
1729   ;;
1730 esac])dnl
1731 $1="$ac_cv_path_$1"
1732 if test -n "[$]$1"; then
1733   AC_MSG_RESULT([$]$1)
1734 else
1735   AC_MSG_RESULT(no)
1736 fi
1737 AC_SUBST($1)dnl
1738 ])
1739 # Configure paths for Libsigc++
1740 # Based on Gtk-- script by Erik Andersen and Tero Pulkkinen 
1741
1742 dnl Test for Libsigc++, and define SIGC_CFLAGS and SIGC_LIBS
1743 dnl   to be used as follows:
1744 dnl AM_PATH_SIGC(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1745 dnl
1746 AC_DEFUN(AM_PATH_SIGC,
1747 [dnl 
1748 dnl Get the cflags and libraries from the sigc-config script
1749 dnl
1750
1751 dnl
1752 dnl Prefix options
1753 dnl
1754 AC_ARG_WITH(sigc-prefix,
1755 [  --with-sigc-prefix=PREFIX
1756                           Prefix where libsigc++ is installed (optional)]
1757 , sigc_config_prefix="$withval", sigc_config_prefix="")
1758
1759 AC_ARG_WITH(sigc-exec-prefix,
1760 [  --with-sigc-exec-prefix=PREFIX 
1761                           Exec prefix where  libsigc++ is installed (optional)]
1762 , sigc_config_exec_prefix="$withval", sigc_config_exec_prefix="")
1763
1764 AC_ARG_ENABLE(sigctest, 
1765 [  --disable-sigctest     Do not try to compile and run a test libsigc++ 
1766                           program],
1767 , enable_sigctest=yes)
1768
1769 dnl
1770 dnl Prefix handling
1771 dnl
1772   if test x$sigc_config_exec_prefix != x ; then
1773      sigc_config_args="$sigc_config_args --exec-prefix=$sigc_config_exec_prefix"
1774      if test x${SIGC_CONFIG+set} != xset ; then
1775         SIGC_CONFIG=$sigc_config_exec_prefix/bin/sigc-config
1776      fi
1777   fi
1778   if test x$sigc_config_prefix != x ; then
1779      sigc_config_args="$sigc_config_args --prefix=$sigc_config_prefix"
1780      if test x${SIGC_CONFIG+set} != xset ; then
1781         SIGC_CONFIG=$sigc_config_prefix/bin/sigc-config
1782      fi
1783   fi
1784
1785 dnl
1786 dnl See if sigc-config is alive
1787 dnl
1788   AC_PATH_PROG(SIGC_CONFIG, sigc-config, no)
1789   sigc_version_min=$1
1790
1791 dnl
1792 dnl  Version check
1793 dnl
1794   AC_MSG_CHECKING(for libsigc++ - version >= $sigc_version_min)
1795   no_sigc=""
1796   if test "$SIGC_CONFIG" = "no" ; then
1797     no_sigc=yes
1798   else
1799     sigc_version=`$SIGC_CONFIG --version`
1800
1801     SIGC_CFLAGS=`$SIGC_CONFIG $sigc_config_args --cflags`
1802     SIGC_LIBS=`$SIGC_CONFIG $sigc_config_args --libs`
1803     SIGC_MACROS=`$SIGC_CONFIG $sigc_config_args --libs`
1804
1805     sigc_major_version=`echo $sigc_version | \
1806            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1807     sigc_minor_version=`echo $sigc_version | \
1808            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1809     sigc_micro_version=`echo $sigc_version | \
1810            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1811
1812     sigc_major_min=`echo $sigc_version_min | \
1813            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1814     sigc_minor_min=`echo $sigc_version_min | \
1815            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1816     sigc_micro_min=`echo $sigc_version_min | \
1817            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1818
1819     sigc_version_proper=`expr \
1820         $sigc_major_version \> $sigc_major_min \| \
1821         $sigc_major_version \= $sigc_major_min \& \
1822         $sigc_minor_version \> $sigc_minor_min \| \
1823         $sigc_major_version \= $sigc_major_min \& \
1824         $sigc_minor_version \= $sigc_minor_min \& \
1825         $sigc_micro_version \>= $sigc_micro_min `
1826
1827     if test "$sigc_version_proper" = "1" ; then
1828       AC_MSG_RESULT([$sigc_major_version.$sigc_minor_version.$sigc_micro_version])
1829     else
1830       AC_MSG_RESULT(no)
1831       no_sigc=yes
1832     fi
1833
1834     if test "X$no_sigc" = "Xyes" ; then
1835       enable_sigctest=no
1836     fi
1837
1838     AC_LANG_SAVE
1839     AC_LANG_CPLUSPLUS
1840
1841 dnl
1842 dnl
1843 dnl
1844     if test "x$enable_sigctest" = "xyes" ; then
1845       AC_MSG_CHECKING(if libsigc++ sane)
1846       ac_save_CXXFLAGS="$CXXFLAGS"
1847       ac_save_LIBS="$LIBS"
1848       CXXFLAGS="$CXXFLAGS $SIGC_CFLAGS"
1849       LIBS="$LIBS $SIGC_LIBS"
1850
1851       rm -f conf.sigctest
1852       AC_TRY_RUN([
1853 #include <stdio.h>
1854 #include <sigc++/signal_system.h>
1855
1856 #ifdef SIGC_CXX_NAMESPACES
1857 using namespace SigC;
1858 #endif
1859
1860 int foo1(int i) 
1861   {
1862    return 1;
1863   }
1864
1865 int main(int argc,char **argv)
1866   {
1867    if (sigc_major_version!=$sigc_major_version ||
1868        sigc_minor_version!=$sigc_minor_version ||
1869        sigc_micro_version!=$sigc_micro_version)
1870      { printf("(%d.%d.%d) ",
1871          sigc_major_version,sigc_minor_version,sigc_micro_version);
1872        return 1;
1873      }
1874    Signal1<int,int> sig1;
1875    sig1.connect(slot(foo1));
1876    sig1(1);
1877    return 0;
1878   }
1879
1880 ],[
1881   AC_MSG_RESULT(yes)
1882 ],[
1883   AC_MSG_RESULT(no)
1884   no_sigc=yes
1885 ]
1886 ,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1887
1888        CXXFLAGS="$ac_save_CXXFLAGS"
1889        LIBS="$ac_save_LIBS"
1890      fi
1891   fi
1892
1893   dnl
1894   dnl
1895   if test "x$no_sigc" = x ; then
1896      ifelse([$2], , :, [$2])     
1897   else
1898      SIGC_CFLAGS=""
1899      SIGC_LIBS=""
1900      SIGC_MACROS=""
1901      ifelse([$3], , :, [$3])
1902   fi
1903
1904   AC_LANG_RESTORE
1905
1906   AC_SUBST(SIGC_CFLAGS)
1907   AC_SUBST(SIGC_LIBS)
1908   AC_SUBST(SIGC_MACROS)
1909 ])
1910
1911 # Configure paths and libs when using KDE GUI
1912 ##    -*- shell-script -*-
1913
1914 ##    This file is part of the KDE libraries/packages
1915 ##    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
1916 ##              (C) 1997 Stephan Kulow (coolo@kde.org)
1917
1918 ##    This file is free software; you can redistribute it and/or
1919 ##    modify it under the terms of the GNU Library General Public
1920 ##    License as published by the Free Software Foundation; either
1921 ##    version 2 of the License, or (at your option) any later version.
1922
1923 ##    This library is distributed in the hope that it will be useful,
1924 ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
1925 ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1926 ##    Library General Public License for more details.
1927
1928 ##    You should have received a copy of the GNU Library General Public License
1929 ##    along with this library; see the file COPYING.LIB.  If not, write to
1930 ##    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1931 ##    Boston, MA 02111-1307, USA.        
1932
1933 ## IMPORTANT NOTE:
1934 ## Please do not modify this file unless you expect your modifications to be
1935 ## carried into every other module in the repository. If you decide that you
1936 ## really want to modify it, contact coolo@kde.org mentioning that you have
1937 ## and that the modified file should be committed to every module.
1938 ##
1939 ## Single-module modifications are best placed in configure.in for kdelibs
1940 ## and kdebase or configure.in.1 if present.
1941
1942
1943 ## ------------------------------------------------------------------------
1944 ## Find a file (or one of more files in a list of dirs)
1945 ## ------------------------------------------------------------------------
1946 ##
1947 AC_DEFUN(AC_FIND_FILE,
1948 [
1949 $3=NO
1950 for i in $2;
1951 do
1952   for j in $1;
1953   do
1954     if test -r "$i/$j"; then
1955       $3=$i
1956       break 2
1957     fi
1958   done
1959 done
1960 ])
1961
1962 AC_DEFUN(KDE_FIND_PATH,
1963 [
1964    AC_MSG_CHECKING([for $1])
1965    AC_CACHE_VAL(kde_cv_path_$1,
1966    [
1967      kde_cv_path_$1="NONE"
1968      if test -n "$$2"; then
1969         kde_cv_path_$1="$$2";
1970      else
1971         dirs="$3"
1972         kde_save_IFS=$IFS
1973         IFS=':'
1974         for dir in $PATH; do
1975           dirs="$dirs $dir"
1976         done
1977         IFS=$kde_save_IFS
1978  
1979         for dir in $dirs; do
1980           if test -x "$dir/$1"; then
1981             if test -n "$5"
1982             then
1983               evalstr="$dir/$1 $5 2>&1 "
1984               if eval $evalstr; then
1985                 kde_cv_path_$1="$dir/$1"
1986                 break
1987               fi
1988             else
1989                 kde_cv_path_$1="$dir/$1"
1990                 break
1991             fi
1992           fi
1993         done
1994  
1995      fi
1996  
1997    ])
1998  
1999    if test -z "$kde_cv_path_$1" || test "$kde_cv_path_$1" = "NONE"; then
2000       AC_MSG_RESULT(not found)
2001       $4
2002    else
2003      AC_MSG_RESULT($kde_cv_path_$1)
2004      $2=$kde_cv_path_$1
2005    fi
2006 ])
2007 AC_DEFUN(KDE_MOC_ERROR_MESSAGE,
2008 [
2009     AC_MSG_ERROR([No Qt meta object compiler (moc) found!
2010 Please check whether you installed Qt correctly.
2011 You need to have a running moc binary.
2012 configure tried to run $ac_cv_path_moc and the test didn't
2013 succeed. If configure shouldn't have tried this one, set
2014 the environment variable MOC to the right one before running
2015 configure.
2016 ])
2017 ])
2018
2019 dnl ------------------------------------------------------------------------
2020 dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some
2021 dnl more usual places
2022 dnl ------------------------------------------------------------------------
2023 dnl
2024 AC_DEFUN(AC_PATH_QT_MOC,
2025 [
2026    KDE_FIND_PATH(moc, MOC, [$ac_qt_bindir $QTDIR/bin \
2027             /usr/bin /usr/X11R6/bin /usr/lib/qt/bin \
2028             /usr/local/qt/bin], [KDE_MOC_ERROR_MESSAGE])
2029  
2030    if test -z "$MOC"; then
2031      if test -n "$ac_cv_path_moc"; then
2032        output=`eval "$ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt"`
2033      fi
2034      echo "configure:__oline__: tried to call $ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC
2035      echo "configure:__oline__: moc output: $output" >&AC_FD_CC
2036  
2037      if test -z "$output"; then
2038        KDE_MOC_ERROR_MESSAGE
2039     fi
2040    fi
2041  
2042    AC_SUBST(MOC)
2043 ])
2044
2045 AC_DEFUN(KDE_REPLACE_ROOT,
2046   $1=`echo "$$1" | sed -e "s#^/#\$\{install_root\}/#"`
2047 )
2048
2049 AC_DEFUN(AC_CREATE_KFSSTND,
2050 [
2051 AC_REQUIRE([AC_CHECK_RPATH])
2052
2053 if test "$1" = "default"; then
2054
2055   AC_MSG_CHECKING(for KDE paths)
2056
2057   if test -z "$kde_htmldir"; then
2058     kde_htmldir="\$(prefix)/share/doc/HTML"
2059   fi
2060   if test -z "$kde_appsdir"; then
2061     kde_appsdir="\$(prefix)/share/applnk"
2062   fi
2063   if test -z "$kde_icondir"; then
2064     kde_icondir="\$(prefix)/share/icons"
2065   fi
2066   if test -z "$kde_sounddir"; then
2067     kde_sounddir="\$(prefix)/share/sounds"
2068   fi
2069   if test -z "$kde_datadir"; then
2070     kde_datadir="\$(prefix)/share/apps"
2071   fi
2072   if test -z "$kde_locale"; then
2073     kde_locale="\$(prefix)/share/locale"
2074   fi
2075   if test -z "$kde_cgidir"; then
2076     kde_cgidir="\$(exec_prefix)/cgi-bin"
2077   fi
2078   if test -z "$kde_confdir"; then
2079     kde_confdir="\$(prefix)/share/config"
2080   fi
2081   if test -z "$kde_mimedir"; then
2082     kde_mimedir="\$(prefix)/share/mimelnk"
2083   fi
2084   if test -z "$kde_toolbardir"; then
2085     kde_toolbardir="\$(prefix)/share/toolbar"
2086   fi
2087   if test -z "$kde_wallpaperdir"; then
2088     kde_wallpaperdir="\$(prefix)/share/wallpapers"
2089   fi
2090   if test -z "$kde_bindir"; then
2091     kde_bindir="\$(exec_prefix)/bin"
2092   fi
2093   if test -z "$kde_partsdir"; then
2094     kde_partsdir="\$(exec_prefix)/parts"
2095   fi
2096   AC_MSG_RESULT(defaults)       
2097
2098 else 
2099
2100 AC_CACHE_VAL(kde_cv_all_paths,
2101 [
2102 AC_MSG_CHECKING([for kde headers installed])
2103 AC_LANG_CPLUSPLUS
2104 cat > conftest.$ac_ext <<EOF
2105 #include <stdio.h>
2106 #include "confdefs.h"
2107 #include <kapp.h>
2108
2109 int main() {
2110 printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
2111 printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
2112 printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
2113 printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
2114 printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
2115 printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
2116 printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
2117 printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
2118 printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
2119 printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
2120 printf("kde_wallpaperdir=\\"%s\\"\n", KApplication::kde_wallpaperdir().data());
2121 printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
2122 printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
2123 return 0;
2124 }
2125 EOF
2126
2127 if test -n "$kde_libraries"; then
2128   KDE_TEST_RPATH="-rpath $kde_libraries"
2129 fi
2130
2131 if test -n "$qt_libraries"; then
2132   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $qt_libraries"
2133 fi
2134
2135 if test -n "$x_libraries"; then
2136   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $x_libraries"
2137 fi
2138
2139 KDE_TEST_RPATH="$KDE_TEST_RPATH $KDE_EXTRA_RPATH"
2140
2141 ac_compile='${CXX-g++} -c $CXXFLAGS $all_includes $CPPFLAGS conftest.$ac_ext'
2142 if AC_TRY_EVAL(ac_compile); then
2143   AC_MSG_RESULT(yes)
2144 else
2145   AC_MSG_ERROR([your system is not able to compile a small KDE application!
2146 Check, if you installed the KDE header files correctly.])
2147 fi
2148
2149 AC_MSG_CHECKING([for kde libraries installed])
2150 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'
2151
2152 if AC_TRY_EVAL(ac_link) && test -s conftest; then 
2153   AC_MSG_RESULT(yes)
2154 else
2155   AC_MSG_ERROR([your system fails at linking a small KDE application!
2156 Check, if your compiler is installed correctly and if you have used the
2157 same compiler to compile Qt and kdelibs as you did use now])
2158 fi
2159
2160 AC_MSG_CHECKING([for KDE paths])
2161 if eval `./conftest 2>&5`; then
2162   AC_MSG_RESULT(done)
2163 else
2164   AC_MSG_RESULT(problems)
2165 fi
2166
2167 ./conftest 2> /dev/null >&5 # make an echo for config.log
2168 kde_have_all_paths=yes
2169 AC_LANG_CPLUSPLUS
2170
2171 if test "$kde_have_all_paths" = "yes"; then
2172 kde_cv_all_paths="kde_have_all_paths=\"yes\" \
2173         kde_htmldir=\"$kde_htmldir\" \
2174         kde_appsdir=\"$kde_appsdir\" \
2175         kde_icondir=\"$kde_icondir\" \
2176         kde_sounddir=\"$kde_sounddir\" \
2177         kde_datadir=\"$kde_datadir\" \
2178         kde_locale=\"$kde_locale\" \
2179         kde_cgidir=\"$kde_cgidir\" \
2180         kde_confdir=\"$kde_confdir\" \
2181         kde_mimedir=\"$kde_mimedir\" \
2182         kde_toolbardir=\"$kde_toolbardir\" \
2183         kde_wallpaperdir=\"$kde_wallpaperdir\" \
2184         kde_bindir=\"$kde_bindir\" \
2185         kde_partsdir=\"$kde_partsdir\""
2186 fi
2187 rm -fr conftest*
2188
2189 ])
2190
2191 eval "$kde_cv_all_paths"
2192
2193 if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
2194    test -z "$kde_icondir" || test -z "$kde_sounddir" ||
2195    test -z "$kde_datadir" || test -z "$kde_locale"  ||
2196    test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
2197    test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
2198    test -z "$kde_wallpaperdir" || test -z "$kde_bindir" ||
2199    test -z "$kde_partsdir" || test "$kde_have_all_paths" != "yes"; then
2200   kde_have_all_paths=no
2201   AC_MSG_ERROR([configure could not run a little KDE program to test the environment. 
2202 Since it had compiled and linked before, it must be a strange problem on your system.
2203 Look at config.log for details. If you are not able to fix this, please contact Stephan Kulow <coolo@kde.org>.])
2204 fi
2205
2206 if test -n "$install_root"; then
2207   KDE_REPLACE_ROOT(kde_htmldir)
2208   KDE_REPLACE_ROOT(kde_appsdir)
2209   KDE_REPLACE_ROOT(kde_icondir)
2210   KDE_REPLACE_ROOT(kde_sounddir)
2211   KDE_REPLACE_ROOT(kde_datadir)
2212   KDE_REPLACE_ROOT(kde_locale)
2213   KDE_REPLACE_ROOT(kde_cgidir)
2214   KDE_REPLACE_ROOT(kde_confdir)
2215   KDE_REPLACE_ROOT(kde_mimedir)
2216   KDE_REPLACE_ROOT(kde_toolbardir)
2217   KDE_REPLACE_ROOT(kde_wallpaperdir)
2218   KDE_REPLACE_ROOT(kde_bindir)
2219   KDE_REPLACE_ROOT(kde_partsdir)
2220   AC_SUBST(install_root)
2221 fi
2222
2223 fi
2224
2225 bindir=$kde_bindir
2226
2227 ])
2228
2229 AC_DEFUN(AC_SUBST_KFSSTND,
2230 [
2231 AC_SUBST(kde_htmldir)
2232 AC_SUBST(kde_appsdir)
2233 AC_SUBST(kde_icondir)
2234 AC_SUBST(kde_sounddir)
2235 kde_minidir="$kde_icondir/mini"
2236 AC_SUBST(kde_minidir)
2237 AC_SUBST(kde_datadir)
2238 AC_SUBST(kde_locale)
2239 AC_SUBST(kde_cgidir)
2240 AC_SUBST(kde_confdir)
2241 AC_SUBST(kde_mimedir)
2242 AC_SUBST(kde_toolbardir)
2243 AC_SUBST(kde_wallpaperdir)
2244 AC_SUBST(kde_bindir)
2245 AC_SUBST(kde_partsdir)
2246 ])
2247
2248 AC_DEFUN(KDE_MISC_TESTS,
2249 [
2250    AC_LANG_C
2251    dnl Checks for libraries. 
2252    AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"]) dnl for FreeBSD
2253    AC_SUBST(LIBCOMPAT)
2254    AC_CHECK_LIB(crypt, main, [LIBCRYPT="-lcrypt"]) dnl for BSD
2255    AC_SUBST(LIBCRYPT)
2256    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
2257    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
2258       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
2259         [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
2260    fi
2261    AC_CHECK_FUNC(gethostbyname)
2262    if test $ac_cv_func_gethostbyname = no; then
2263      AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
2264    fi
2265    AC_CHECK_FUNC(connect)
2266    if test $ac_cv_func_connect = no; then
2267       AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
2268         $X_EXTRA_LIBS)
2269    fi
2270
2271    AC_CHECK_FUNC(remove)
2272    if test $ac_cv_func_remove = no; then
2273       AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
2274    fi
2275  
2276    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
2277    AC_CHECK_FUNC(shmat)
2278    if test $ac_cv_func_shmat = no; then
2279      AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
2280    fi
2281
2282    LIBSOCKET=$X_EXTRA_LIBS
2283    AC_SUBST(LIBSOCKET)
2284    AC_SUBST(X_EXTRA_LIBS)
2285    AC_CHECK_LIB(ucb, killpg, [LIBUCB="-lucb"]) dnl for Solaris2.4
2286    AC_SUBST(LIBUCB)
2287
2288    case $host in  dnl this *is* LynxOS specific
2289    *-*-lynxos* )
2290         AC_MSG_CHECKING([LynxOS header file wrappers])
2291         [CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"]
2292         AC_MSG_RESULT(disabled)
2293         AC_CHECK_LIB(bsd, gethostbyname, [LIBSOCKET="-lbsd"]) dnl for LynxOS
2294          ;;
2295     esac
2296
2297 ])
2298
2299 ## ------------------------------------------------------------------------
2300 ## Find the header files and libraries for X-Windows. Extended the 
2301 ## macro AC_PATH_X
2302 ## ------------------------------------------------------------------------
2303 ##
2304 AC_DEFUN(K_PATH_X,
2305 [
2306 AC_MSG_CHECKING(for X)
2307 AC_CACHE_VAL(ac_cv_have_x,
2308 [# One or both of the vars are not set, and there is no cached value.
2309 ac_x_includes=NO ac_x_libraries=NO
2310 AC_PATH_X_DIRECT
2311 AC_PATH_X_XMKMF
2312 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
2313   AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
2314 else
2315   # Record where we found X for the cache.
2316   ac_cv_have_x="have_x=yes \
2317                 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
2318 fi])dnl
2319 eval "$ac_cv_have_x"
2320  
2321 if test "$have_x" != yes; then
2322   AC_MSG_RESULT($have_x)
2323   no_x=yes
2324 else
2325   # If each of the values was on the command line, it overrides each guess.
2326   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
2327   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
2328   # Update the cache value to reflect the command line values.
2329   ac_cv_have_x="have_x=yes \
2330                 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
2331   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
2332 fi
2333
2334 if test -z "$x_includes" || test "x$x_includes" = xNONE; then
2335   X_INCLUDES=""
2336   x_includes="."; dnl better than nothing :-
2337  else
2338   X_INCLUDES="-I$x_includes"
2339 fi
2340
2341 if test -z "$x_libraries" || test "x$x_libraries" = xNONE; then
2342   X_LDFLAGS=""
2343   x_libraries="/usr/lib"; dnl better than nothing :-
2344  else
2345   X_LDFLAGS="-L$x_libraries"
2346 fi
2347 all_includes="$all_includes $X_INCLUDES"  
2348 all_libraries="$all_libraries $X_LDFLAGS"  
2349
2350 AC_SUBST(X_INCLUDES)
2351 AC_SUBST(X_LDFLAGS)
2352 AC_SUBST(x_libraries)
2353 AC_SUBST(x_includes)
2354 ])
2355
2356 AC_DEFUN(KDE_PRINT_QT_PROGRAM,
2357 [
2358 AC_LANG_CPLUSPLUS
2359 cat > conftest.$ac_ext <<EOF
2360 #include "confdefs.h"
2361 #include <qmovie.h>
2362 #include <qapplication.h>
2363 int main() {
2364   QMovie m;
2365   m.setSpeed(20);
2366   return 0;
2367 }
2368 EOF
2369 ])
2370
2371 AC_DEFUN(KDE_CHECK_QT_DIRECT,
2372 [
2373 AC_MSG_CHECKING([if Qt compiles without flags])
2374 AC_CACHE_VAL(kde_cv_qt_direct,
2375 [
2376 ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
2377 ac_LIBRARY_PATH="$LIBRARY_PATH"
2378 ac_cxxflags_safe="$CXXFLAGS"
2379 ac_ldflags_safe="$LDFLAGS"
2380 ac_libs_safe="$LIBS"
2381
2382 CXXFLAGS="$CXXFLAGS -I$qt_includes"
2383 LDFLAGS="$X_LDFLAGS"
2384 LIBS="-lqt -lXext -lX11 $LIBSOCKET"
2385 LD_LIBRARY_PATH=
2386 export LD_LIBRARY_PATH
2387 LIBRARY_PATH=
2388 export LIBRARY_PATH
2389
2390 KDE_PRINT_QT_PROGRAM
2391
2392 if AC_TRY_EVAL(ac_link) && test -s conftest; then
2393   kde_cv_qt_direct="yes"
2394 else
2395   kde_cv_qt_direct="no"
2396   echo "configure: failed program was:" >&AC_FD_CC
2397   cat conftest.$ac_ext >&AC_FD_CC
2398 fi
2399 rm -f conftest*
2400 CXXFLAGS="$ac_cxxflags_safe"
2401 LDFLAGS="$ac_ldflags_safe"
2402 LIBS="$ac_libs_safe"
2403
2404 LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
2405 export LD_LIBRARY_PATH
2406 LIBRARY_PATH="$ac_LIBRARY_PATH"
2407 export LIBRARY_PATH
2408 ])
2409
2410 if test "$kde_cv_qt_direct" = "yes"; then
2411   AC_MSG_RESULT(yes)
2412   $1
2413 else
2414   AC_MSG_RESULT(no)
2415   $2
2416 fi
2417 ])
2418
2419 ## ------------------------------------------------------------------------
2420 ## Try to find the Qt headers and libraries.
2421 ## $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
2422 ## and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
2423 ## ------------------------------------------------------------------------
2424 ##
2425 AC_DEFUN(AC_PATH_QT_1_3,
2426 [
2427 AC_REQUIRE([K_PATH_X])
2428
2429 AC_MSG_CHECKING([for Qt])
2430 ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
2431 qt_libraries=""
2432 qt_includes=""
2433 AC_ARG_WITH(qt-dir,
2434     [  --with-qt-dir           where the root of qt is installed ],
2435     [  ac_qt_includes="$withval"/include
2436        ac_qt_libraries="$withval"/lib
2437        ac_qt_bindir="$withval"/bin
2438     ])
2439
2440 AC_ARG_WITH(qt-includes,
2441     [  --with-qt-includes      where the Qt includes are. ],
2442     [  
2443        ac_qt_includes="$withval"
2444     ])
2445     
2446 kde_qt_libs_given=no
2447
2448 AC_ARG_WITH(qt-libraries,
2449     [  --with-qt-libraries     where the Qt library is installed.],
2450     [  ac_qt_libraries="$withval"
2451        kde_qt_libs_given=yes
2452     ])
2453
2454 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
2455
2456 AC_CACHE_VAL(ac_cv_have_qt,
2457 [#try to guess Qt locations
2458
2459 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"
2460 test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs"
2461 AC_FIND_FILE(qmovie.h, $qt_incdirs, qt_incdir)
2462 ac_qt_includes="$qt_incdir"
2463
2464 if test ! "$ac_qt_libraries" = "NO"; then
2465   qt_libdirs="$ac_qt_libraries"
2466 fi
2467
2468 qt_libdirs="$qt_libdirs /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt $x_libraries $QTLIB"
2469 test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs"
2470
2471 test=NONE
2472 qt_libdir=NONE
2473 for dir in $qt_libdirs; do
2474   try="ls -1 $dir/libqt*"
2475   if test=`eval $try 2> /dev/null`; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
2476 done
2477
2478 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)
2479 ac_qt_libraries="$qt_libdir"
2480
2481 ac_cxxflags_safe="$CXXFLAGS"
2482 ac_ldflags_safe="$LDFLAGS"
2483 ac_libs_safe="$LIBS"
2484
2485 CXXFLAGS="$CXXFLAGS -I$qt_incdir"
2486 LDFLAGS="-L$qt_libdir $X_LDFLAGS"
2487 LIBS="$LIBS -lqt -lXext -lX11 $LIBSOCKET"
2488
2489 KDE_PRINT_QT_PROGRAM
2490
2491 if AC_TRY_EVAL(ac_link) && test -s conftest; then
2492   rm -f conftest*
2493 else
2494   echo "configure: failed program was:" >&AC_FD_CC
2495   cat conftest.$ac_ext >&AC_FD_CC
2496   ac_qt_libraries="NO"
2497 fi
2498 rm -f conftest*
2499 CXXFLAGS="$ac_cxxflags_safe"
2500 LDFLAGS="$ac_ldflags_safe"
2501 LIBS="$ac_libs_safe"
2502
2503 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
2504   ac_cv_have_qt="have_qt=no"
2505   ac_qt_notfound=""
2506   if test "$ac_qt_includes" = NO; then
2507     if test "$ac_qt_libraries" = NO; then
2508       ac_qt_notfound="(headers and libraries)";
2509     else
2510       ac_qt_notfound="(headers)";
2511     fi
2512   else
2513     ac_qt_notfound="(libraries)";
2514   fi
2515
2516   AC_MSG_ERROR([Qt-1.4 $ac_qt_notfound not found. Please check your installation! ]);
2517 else
2518   have_qt="yes"
2519 fi
2520 ])
2521 else
2522   have_qt="yes"
2523 fi
2524
2525 eval "$ac_cv_have_qt"
2526
2527 if test "$have_qt" != yes; then
2528   AC_MSG_RESULT([$have_qt]);
2529 else
2530   ac_cv_have_qt="have_qt=yes \
2531     ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
2532   AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes])
2533   
2534   qt_libraries="$ac_qt_libraries"
2535   qt_includes="$ac_qt_includes"
2536 fi
2537
2538 if test ! "$kde_qt_libs_given" = "yes"; then
2539 KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
2540 fi
2541
2542 AC_SUBST(qt_libraries)
2543 AC_SUBST(qt_includes)
2544
2545 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
2546  QT_INCLUDES="";
2547 else
2548  QT_INCLUDES="-I$qt_includes"
2549  all_includes="$QT_INCLUDES $all_includes"
2550 fi
2551
2552 if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
2553  QT_LDFLAGS=""
2554 else
2555  QT_LDFLAGS="-L$qt_libraries"
2556  all_libraries="$QT_LDFLAGS $all_libraries"
2557 fi
2558
2559 AC_SUBST(QT_INCLUDES)
2560 AC_SUBST(QT_LDFLAGS)
2561 AC_PATH_QT_MOC
2562 ])
2563
2564 AC_DEFUN(AC_PATH_QT,
2565 [
2566 AC_PATH_QT_1_3
2567 ])
2568
2569 ## ------------------------------------------------------------------------
2570 ## Now, the same with KDE
2571 ## $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
2572 ## and $(kde_includes) will be the kdehdrlocation (if needed)
2573 ## ------------------------------------------------------------------------
2574 ##
2575 AC_DEFUN(AC_BASE_PATH_KDE,
2576 [
2577 AC_REQUIRE([KDE_MISC_TESTS])
2578 AC_REQUIRE([AC_PATH_QT])dnl
2579 AC_MSG_CHECKING([for KDE])
2580
2581 if test "${prefix}" != NONE; then
2582   kde_includes=${prefix}/include
2583   ac_kde_includes=$prefix/include
2584
2585   if test "${exec_prefix}" != NONE; then
2586     kde_libraries=${exec_prefix}/lib
2587     ac_kde_libraries=$exec_prefix/lib
2588   else
2589     kde_libraries=${prefix}/lib
2590     ac_kde_libraries=$prefix/lib
2591   fi
2592 else
2593   ac_kde_includes=
2594   ac_kde_libraries=
2595   kde_libraries=""
2596   kde_includes=""
2597 fi
2598
2599 AC_CACHE_VAL(ac_cv_have_kde,
2600 [#try to guess kde locations
2601
2602 if test -z "$1"; then
2603
2604 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"
2605 test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include $KDEDIR $kde_incdirs"
2606 AC_FIND_FILE(ksock.h, $kde_incdirs, kde_incdir)
2607 ac_kde_includes="$kde_incdir"
2608
2609 if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/ksock.h"; then
2610   AC_MSG_ERROR([
2611 in the prefix, you've chosen, are no kde headers installed. This will fail.
2612 So, check this please and use another prefix!])
2613 fi
2614
2615 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"
2616 test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib $KDEDIR $kde_libdirs"
2617 AC_FIND_FILE(libkdecore.la, $kde_libdirs, kde_libdir)
2618 ac_kde_libraries="$kde_libdir"
2619
2620 if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/libkdecore.la"; then
2621 AC_MSG_ERROR([
2622 in the prefix, you've chosen $ac_kde_libraries, are no kde libraries installed. This will fail.
2623 So, check this please and use another prefix!])
2624 fi
2625 ac_kde_libraries="$kde_libdir"
2626
2627 if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO; then
2628   ac_cv_have_kde="have_kde=no"
2629 else
2630   ac_cv_have_kde="have_kde=yes \
2631     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
2632 fi
2633
2634 else dnl test -z $1 
2635   
2636   ac_cv_have_kde="have_kde=no"
2637
2638 fi
2639 ])dnl
2640
2641 eval "$ac_cv_have_kde"
2642
2643 if test "$have_kde" != "yes"; then
2644  if test "${prefix}" = NONE; then
2645   ac_kde_prefix="$ac_default_prefix"
2646  else
2647   ac_kde_prefix="$prefix"
2648  fi
2649  if test "$exec_prefix" = NONE; then
2650   ac_kde_exec_prefix="$ac_kde_prefix"
2651   AC_MSG_RESULT([will be installed in $ac_kde_prefix])
2652  else
2653   ac_kde_exec_prefix="$exec_prefix"
2654   AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
2655  fi
2656
2657  kde_libraries="${ac_kde_exec_prefix}/lib"
2658  kde_includes=${ac_kde_prefix}/include
2659
2660 else
2661   ac_cv_have_kde="have_kde=yes \
2662     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
2663   AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
2664   
2665   kde_libraries="$ac_kde_libraries"
2666   kde_includes="$ac_kde_includes"
2667 fi
2668 AC_SUBST(kde_libraries)
2669 AC_SUBST(kde_includes)
2670
2671 if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes" ; then
2672  KDE_INCLUDES=""
2673 else
2674  KDE_INCLUDES="-I$kde_includes"
2675  all_includes="$KDE_INCLUDES $all_includes"
2676 fi
2677
2678 if test "$kde_libraries" = "$x_libraries" || test "$kde_libraries" = "$qt_libraries" ; then
2679  KDE_LDFLAGS=""
2680 else
2681  KDE_LDFLAGS="-L$kde_libraries"
2682  all_libraries="$KDE_LDFLAGS $all_libraries"
2683 fi
2684
2685 AC_SUBST(KDE_LDFLAGS)
2686 AC_SUBST(KDE_INCLUDES)
2687
2688 KDE_CHECK_EXTRA_LIBS
2689
2690 AC_SUBST(all_includes)
2691 AC_SUBST(all_libraries)
2692
2693 ])
2694
2695 AC_DEFUN(KDE_CHECK_EXTRA_LIBS,
2696 [
2697 AC_MSG_CHECKING(for extra includes)
2698 AC_ARG_WITH(extra-includes, [  --with-extra-includes   adds non standard include paths], 
2699   kde_use_extra_includes="$withval",
2700   kde_use_extra_includes=NONE
2701 )
2702 if test -n "$kde_use_extra_includes" && \
2703    test "$kde_use_extra_includes" != "NONE"; then
2704
2705    ac_save_ifs=$IFS
2706    IFS=':'
2707    for dir in $kde_use_extra_includes; do
2708      all_includes="$all_includes -I$dir"
2709      USER_INCLUDES="$USER_INCLUDES -I$dir"
2710    done
2711    IFS=$ac_save_ifs
2712    kde_use_extra_includes="added"
2713 else
2714    kde_use_extra_includes="no"
2715 fi
2716
2717 AC_MSG_RESULT($kde_use_extra_includes)
2718
2719 AC_MSG_CHECKING(for extra libs)
2720 AC_ARG_WITH(extra-libs, [  --with-extra-libs       adds non standard library paths], 
2721   kde_use_extra_libs=$withval,
2722   kde_use_extra_libs=NONE
2723 )
2724 if test -n "$kde_use_extra_libs" && \
2725    test "$kde_use_extra_libs" != "NONE"; then
2726
2727    ac_save_ifs=$IFS
2728    IFS=':'
2729    for dir in $kde_use_extra_libs; do
2730      all_libraries="$all_libraries -L$dir"
2731      KDE_EXTRA_RPATH="$KDE_EXTRA_RPATH -rpath $dir"
2732      USER_LDFLAGS="$USER_LDFLAGS -L$dir"
2733    done
2734    IFS=$ac_save_ifs
2735    kde_use_extra_libs="added"
2736 else
2737    kde_use_extra_libs="no"
2738 fi
2739
2740 AC_MSG_RESULT($kde_use_extra_libs)
2741
2742 ])
2743
2744 AC_DEFUN(KDE_CHECK_KIMGIO,
2745 [
2746    AC_REQUIRE([AC_FIND_TIFF])
2747    AC_REQUIRE([AC_FIND_JPEG]) 
2748    AC_REQUIRE([AC_FIND_PNG]) 
2749
2750    LIB_KIMGIO='-lkimgio $(LIBJPEG) $(LIBTIFF) $(LIBPNG) -lm'
2751    AC_SUBST(LIB_KIMGIO)
2752    LIB_KHTMLW='-lkhtmlw $(LIB_KIMGIO) -ljscript'
2753    AC_SUBST(LIB_KHTMLW)
2754    LIB_KHTML='-lkhtml $(LIB_KIMGIO) -ljscript'
2755    AC_SUBST(LIB_KHTML)
2756 ])
2757
2758 AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
2759 [
2760    AC_REQUIRE([KDE_MISC_TESTS])
2761
2762    KDE_LIBS='-lqt -lkdecore -lkdeui -lkfm -lkfile'
2763    AC_SUBST(KDE_LIBS)
2764 #   LIB_X11='-lX11 $(LIBSOCKET)'
2765 #   AC_SUBST(LIB_X11)
2766 #   LIB_QT='-lqt $(LIB_X11)'
2767 #   AC_SUBST(LIB_QT)
2768 #   LIB_KDECORE='-lkdecore -lXext $(LIB_QT)'
2769 #   AC_SUBST(LIB_KDECORE)
2770 #   LIB_KDEUI='-lkdeui $(LIB_KDECORE)'
2771 #   AC_SUBST(LIB_KDEUI)
2772 #   LIB_KFM='-lkfm $(LIB_KDECORE)'
2773 #   AC_SUBST(LIB_KFM)
2774 #   LIB_KFILE='-lkfile $(LIB_KFM) $(LIB_KDEUI)'
2775 #   AC_SUBST(LIB_KFILE)
2776 ])
2777
2778 AC_DEFUN(AC_PATH_KDE,
2779 [
2780   AC_BASE_PATH_KDE
2781   AC_ARG_ENABLE(path-check, [  --disable-path-check    don't try to find out, where to install],
2782   [
2783   if test "$enableval" = "no"; 
2784     then ac_use_path_checking="default"
2785     else ac_use_path_checking=""
2786   fi
2787   ], [ac_use_path_checking=""]
2788   )
2789
2790   AC_ARG_WITH(install-root, [  --with-install-root     the root, where to install to [default=/]],
2791   [
2792   if test "$withval" = "no";
2793     then kde_install_root="";
2794     else kde_install_root=$withval;
2795   fi
2796   ], [kde_install_root=""]
2797   )
2798   
2799   if test -n "$kde_install_root"; then
2800      install_root="$kde_install_root"
2801   else
2802      install_root=
2803   fi
2804
2805   AC_CREATE_KFSSTND($ac_use_path_checking)
2806
2807   AC_SUBST_KFSSTND
2808   KDE_CREATE_LIBS_ALIASES
2809 ])
2810
2811 dnl slightly changed version of AC_CHECK_FUNC(setenv)
2812 AC_DEFUN(AC_CHECK_SETENV,
2813 [AC_MSG_CHECKING([for setenv])
2814 AC_CACHE_VAL(ac_cv_func_setenv,
2815 [AC_LANG_C
2816 AC_TRY_LINK(
2817 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
2818 dnl which includes <sys/select.h> which contains a prototype for
2819 dnl select.  Similarly for bzero.
2820 [#include <assert.h>
2821 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
2822 extern "C"
2823 #endif
2824 ])dnl
2825 [/* We use char because int might match the return type of a gcc2
2826     builtin and then its argument prototype would still apply.  */
2827 #include <stdlib.h>
2828 ], [
2829 /* The GNU C library defines this for functions which it implements
2830     to always fail with ENOSYS.  Some functions are actually named
2831     something starting with __ and the normal name is an alias.  */
2832 #if defined (__stub_$1) || defined (__stub___$1)
2833 choke me
2834 #else
2835 setenv("TEST", "alle", 1);
2836 #endif
2837 ], eval "ac_cv_func_setenv=yes", eval "ac_cv_func_setenv=no")])
2838
2839 if test "$ac_cv_func_setenv" = "yes"; then
2840   AC_MSG_RESULT(yes)
2841   AC_DEFINE_UNQUOTED(HAVE_FUNC_SETENV)
2842 else
2843   AC_MSG_RESULT(no)
2844 fi
2845 ])
2846
2847 AC_DEFUN(AC_CHECK_GETDOMAINNAME,
2848 [
2849 AC_LANG_CPLUSPLUS
2850 save_CXXFLAGS="$CXXFLAGS"
2851 if test "$GCC" = "yes"; then
2852 CXXFLAGS="$CXXFLAGS -pedantic-errors"
2853 fi
2854 AC_MSG_CHECKING(for getdomainname)
2855 AC_CACHE_VAL(ac_cv_func_getdomainname,
2856 [
2857 AC_TRY_COMPILE([
2858 #include <stdlib.h>
2859 #include <unistd.h>
2860 ],
2861 [
2862 char buffer[200];
2863 getdomainname(buffer, 200);
2864 ],
2865 ac_cv_func_getdomainname=yes,
2866 ac_cv_func_getdomainname=no)
2867 ])
2868 AC_MSG_RESULT($ac_cv_func_getdomainname)
2869 if eval "test \"`echo `$ac_cv_func_getdomainname\" = yes"; then
2870   AC_DEFINE(HAVE_GETDOMAINNAME)
2871 fi
2872 CXXFLAGS="$save_CXXFLAGS"
2873 ])
2874
2875 AC_DEFUN(AC_CHECK_GETHOSTNAME,
2876 [
2877 AC_LANG_CPLUSPLUS
2878 save_CXXFLAGS="$CXXFLAGS"
2879 if test "$GCC" = "yes"; then
2880 CXXFLAGS="$CXXFLAGS -pedantic-errors"
2881 fi
2882
2883 AC_MSG_CHECKING([for gethostname])
2884 AC_CACHE_VAL(ac_cv_func_gethostname,
2885 [
2886 AC_TRY_COMPILE([
2887 #include <stdlib.h>
2888 #include <unistd.h>
2889 ],
2890 [
2891 char buffer[200];
2892 gethostname(buffer, 200);
2893 ],
2894 ac_cv_func_gethostname=yes,
2895 ac_cv_func_gethostname=no)
2896 ])
2897 AC_MSG_RESULT($ac_cv_func_gethostname)
2898 if eval "test \"`echo `$ac_cv_func_gethostname\" = yes"; then
2899   AC_DEFINE(HAVE_GETHOSTNAME)
2900 fi
2901 CXXFLAGS="$save_CXXFLAGS"
2902 ])
2903
2904 AC_DEFUN(AC_CHECK_USLEEP,
2905 [
2906 AC_LANG_CPLUSPLUS
2907
2908 AC_MSG_CHECKING([for usleep])
2909 AC_CACHE_VAL(ac_cv_func_usleep,
2910 [
2911 ac_libs_safe="$LIBS"
2912 LIBS="$LIBS $LIBUCB"
2913 AC_TRY_LINK([
2914 #include <stdlib.h>
2915 #include <unistd.h>
2916 ],
2917 [
2918 usleep(200);
2919 ],
2920 ac_cv_func_usleep=yes,
2921 ac_cv_func_usleep=no)
2922 ])
2923 AC_MSG_RESULT($ac_cv_func_usleep)
2924 if eval "test \"`echo `$ac_cv_func_usleep\" = yes"; then
2925   AC_DEFINE(HAVE_USLEEP)
2926 fi
2927 LIBS="$ac_libs_safe"
2928 ])
2929
2930 AC_DEFUN(AC_FIND_GIF,
2931    [AC_MSG_CHECKING([for giflib])
2932 AC_CACHE_VAL(ac_cv_lib_gif,
2933 [ac_save_LIBS="$LIBS"
2934 LIBS="$all_libraries -lgif -lX11 $LIBSOCKET"
2935 AC_TRY_LINK(dnl
2936 [
2937 #ifdef __cplusplus
2938 extern "C" {
2939 #endif
2940 int GifLastError(void);
2941 #ifdef __cplusplus
2942 }
2943 #endif
2944 /* We use char because int might match the return type of a gcc2
2945     builtin and then its argument prototype would still apply.  */
2946 ],
2947             [return GifLastError();],
2948             eval "ac_cv_lib_gif=yes",
2949             eval "ac_cv_lib_gif=no")
2950 LIBS="$ac_save_LIBS"
2951 ])dnl
2952 if eval "test \"`echo $ac_cv_lib_gif`\" = yes"; then
2953   AC_MSG_RESULT(yes)
2954   AC_DEFINE_UNQUOTED(HAVE_LIBGIF)
2955 else
2956   AC_MSG_ERROR(You need giflib23. Please install the kdesupport package)
2957 fi
2958 ])
2959
2960 AC_DEFUN(AC_FIND_JPEG,
2961    [AC_MSG_CHECKING([for jpeglib])
2962 AC_CACHE_VAL(ac_cv_lib_jpeg,
2963 [ac_save_LIBS="$LIBS"
2964 LIBS="$all_libraries -ljpeg -lm"
2965 AC_TRY_LINK(
2966 [/* Override any gcc2 internal prototype to avoid an error.  */
2967 struct jpeg_decompress_struct;
2968 typedef struct jpeg_decompress_struct * j_decompress_ptr;
2969 typedef int size_t;
2970 #ifdef __cplusplus
2971 extern "C" {
2972 #endif
2973     void jpeg_CreateDecompress(j_decompress_ptr cinfo,
2974                                     int version, size_t structsize);
2975 #ifdef __cplusplus
2976 }
2977 #endif
2978 /* We use char because int might match the return type of a gcc2
2979     builtin and then its argument prototype would still apply.  */
2980 ],
2981             [jpeg_CreateDecompress(0L, 0, 0);],
2982             eval "ac_cv_lib_jpeg=-ljpeg",
2983             eval "ac_cv_lib_jpeg=no")
2984 LIBS="$ac_save_LIBS"
2985
2986 dnl what to do, if the normal way fails:
2987 if eval "test \"`echo $ac_cv_lib_jpeg`\" = no"; then
2988         if test -f "$kde_libraries/libjpeg.so"; then
2989            test -f ./libjpegkde.so || $LN_S $kde_libraries/libjpeg.so ./libjpegkde.so
2990            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
2991         else if test -f "$kde_libraries/libjpeg.sl"; then
2992            test -f ./libjpegkde.sl ||$LN_S $kde_libraries/libjpeg.sl ./libjpegkde.sl
2993            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"      
2994         else if test -f "$kde_libraries/libjpeg.a"; then
2995            test -f ./libjpegkde.a || $LN_S $kde_libraries/libjpeg.a ./libjpegkde.a
2996            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
2997         else
2998           AC_MSG_ERROR([
2999 You need jpeglib6a. Please install the kdesupport package.
3000 If you have already installed kdesupport, you may have an
3001 old libjpeg somewhere. 
3002 In this case copy $KDEDIR/lib/libjpeg* to /usr/lib.
3003 ])
3004         fi
3005       fi
3006    fi
3007 fi
3008 ])dnl
3009 if eval "test ! \"`echo $ac_cv_lib_jpeg`\" = no"; then
3010   LIBJPEG="$ac_cv_lib_jpeg"
3011   AC_SUBST(LIBJPEG)
3012   AC_MSG_RESULT($ac_cv_lib_jpeg)
3013   AC_DEFINE_UNQUOTED(HAVE_LIBJPEG)
3014 fi
3015 ])
3016
3017 AC_DEFUN(AC_FIND_ZLIB,
3018 [
3019 AC_MSG_CHECKING([for libz])
3020 AC_CACHE_VAL(ac_cv_lib_z,
3021 [ac_save_LIBS="$LIBS"
3022 LIBS="$all_libraries -lz $LIBSOCKET"
3023 AC_TRY_LINK(dnl
3024 [
3025 #include<zlib.h>
3026 ],
3027             [return (zlibVersion() == ZLIB_VERSION); ],
3028             eval "ac_cv_lib_z='-lz'",
3029             eval "ac_cv_lib_z=no")
3030 LIBS="$ac_save_LIBS"
3031 ])dnl
3032 if eval "test ! \"`echo $ac_cv_lib_z`\" = no"; then
3033 dnl  AC_DEFINE_UNQUOTED(HAVE_LIBZ)
3034   LIBZ="$ac_cv_lib_z"
3035   AC_SUBST(LIBZ)
3036   AC_MSG_RESULT($ac_cv_lib_z)
3037 else
3038   AC_MSG_RESULT(no)
3039   LIBZ=""
3040   AC_SUBST(LIBZ)
3041 fi
3042 ])
3043
3044 AC_DEFUN(AC_FIND_TIFF,
3045 [
3046 AC_REQUIRE([AC_FIND_ZLIB])
3047 AC_REQUIRE([AC_FIND_JPEG])
3048 AC_MSG_CHECKING([for libtiff])
3049 AC_CACHE_VAL(ac_cv_lib_tiff,
3050 [ac_save_LIBS="$LIBS"
3051 LIBS="$all_libraries -ltiff $LIBJPEG $LIBZ -lX11 $LIBSOCKET"
3052 AC_TRY_LINK(dnl
3053 [
3054 #include<tiffio.h>
3055 ],
3056             [return (TIFFOpen( "", "r") == 0); ],
3057             eval "ac_cv_lib_tiff='-ltiff $LIBJPEG $LIBZ'",
3058             eval "ac_cv_lib_tiff=no")
3059 LIBS="$ac_save_LIBS"
3060 ])dnl
3061 if eval "test ! \"`echo $ac_cv_lib_tiff`\" = no"; then
3062   AC_DEFINE_UNQUOTED(HAVE_LIBTIFF)
3063   LIBTIFF="$ac_cv_lib_tiff"
3064   AC_SUBST(LIBTIFF)
3065   AC_MSG_RESULT($ac_cv_lib_tiff)
3066 else
3067   AC_MSG_RESULT(no)
3068   LIBTIFF=""
3069   AC_SUBST(LIBTIFF)
3070 fi
3071 ])
3072
3073
3074 AC_DEFUN(AC_FIND_PNG,
3075 [
3076 AC_REQUIRE([AC_FIND_ZLIB])
3077 AC_MSG_CHECKING([for libpng])
3078 AC_CACHE_VAL(ac_cv_lib_png,
3079 [ac_save_LIBS="$LIBS"
3080 LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET"
3081 AC_LANG_C
3082 AC_TRY_LINK(dnl
3083     [
3084     #include<png.h>
3085     ],
3086     [
3087     png_structp png_ptr = png_create_read_struct(  // image ptr
3088                 PNG_LIBPNG_VER_STRING, 0, 0, 0 );
3089     return( png_ptr != 0 ); 
3090     ],
3091     eval "ac_cv_lib_png='-lpng $LIBZ -lm'",
3092     eval "ac_cv_lib_png=no")
3093     LIBS="$ac_save_LIBS"
3094 ])dnl
3095 if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
3096   AC_DEFINE_UNQUOTED(HAVE_LIBPNG)
3097   LIBPNG="$ac_cv_lib_png"
3098   AC_SUBST(LIBPNG)
3099   AC_MSG_RESULT($ac_cv_lib_png)
3100 else
3101   AC_MSG_RESULT(no)
3102   LIBPNG=""
3103   AC_SUBST(LIBPNG)
3104 fi
3105 ])
3106
3107 AC_DEFUN(AC_CHECK_GNU_EXTENSIONS,
3108 [
3109 AC_MSG_CHECKING(if you need GNU extensions)
3110 AC_CACHE_VAL(ac_cv_gnu_extensions,
3111 [
3112 cat > conftest.c << EOF
3113 #include <features.h>
3114
3115 #ifdef __GNU_LIBRARY__
3116 yes
3117 #endif
3118 EOF
3119
3120 if (eval "$ac_cpp conftest.c") 2>&5 |
3121   egrep "yes" >/dev/null 2>&1; then
3122   rm -rf conftest*
3123   ac_cv_gnu_extensions=yes
3124 else
3125   ac_cv_gnu_extensions=no
3126 fi
3127 ])
3128
3129 AC_MSG_RESULT($ac_cv_gnu_extensions)
3130 if test "$ac_cv_gnu_extensions" = "yes"; then
3131   AC_DEFINE_UNQUOTED(_GNU_SOURCE)
3132 fi
3133 ])
3134
3135 AC_DEFUN(AC_CHECK_COMPILERS,
3136 [
3137   dnl this is somehow a fat lie, but prevents other macros from double checking
3138   AC_PROVIDE([AC_PROG_CC])
3139   AC_PROVIDE([AC_PROG_CPP])
3140   AC_ARG_ENABLE(debug,[  --enable-debug           creates debugging code [default=no]],
3141   [ 
3142    if test $enableval = "no"; dnl 
3143      then ac_use_debug_code="no"
3144      else ac_use_debug_code="yes"
3145    fi
3146   ], [ac_use_debug_code="no"])
3147
3148   AC_ARG_ENABLE(strict,[  --enable-strict         compiles with strict compiler options (may not work!)],
3149    [ 
3150     if test $enableval = "no"; then 
3151          ac_use_strict_options="no"
3152        else 
3153          ac_use_strict_options="yes"
3154     fi
3155    ], [ac_use_strict_options="no"])
3156
3157 dnl this was AC_PROG_CC. I had to include it manualy, since I had to patch it
3158   AC_MSG_CHECKING(for a C-Compiler)
3159   dnl if there is one, print out. if not, don't matter
3160   AC_MSG_RESULT($CC) 
3161  
3162   if test -z "$CC"; then AC_CHECK_PROG(CC, gcc, gcc) fi
3163   if test -z "$CC"; then AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) fi
3164   if test -z "$CC"; then AC_CHECK_PROG(CC, xlc, xlc) fi
3165   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
3166
3167   AC_PROG_CC_WORKS
3168   AC_PROG_CC_GNU
3169
3170   if test $ac_cv_prog_gcc = yes; then
3171     GCC=yes
3172   else
3173     GCC=
3174   fi
3175
3176   if test -z "$CFLAGS"; then
3177     if test "$ac_use_debug_code" = "yes"; then
3178       AC_PROG_CC_G
3179       if test $ac_cv_prog_cc_g = yes; then
3180         CFLAGS="-g"
3181       fi
3182     else
3183       if test "$GCC" = "yes"; then
3184         CFLAGS="-O2"
3185       else
3186         CFLAGS=""
3187       fi
3188     fi
3189
3190     if test "$GCC" = "yes"; then
3191      CFLAGS="$CFLAGS -Wall"
3192
3193      if test "$ac_use_strict_options" = "yes"; then
3194         CFLAGS="$CFLAGS -W -ansi -pedantic"     
3195      fi
3196     fi
3197
3198   fi
3199
3200   case "$host" in 
3201   *-*-sysv4.2uw*) CFLAGS="$CFLAGS -D_UNIXWARE";;
3202   esac
3203
3204   if test -z "$LDFLAGS" && test "$ac_use_debug_code" = "no" && test "$GCC" = "yes"; then
3205      LDFLAGS="-s"
3206   fi
3207
3208
3209 dnl this is AC_PROG_CPP. I had to include it here, since autoconf checks
3210 dnl dependecies between AC_PROG_CPP and AC_PROG_CC (or is it automake?)
3211
3212   AC_MSG_CHECKING(how to run the C preprocessor)
3213   # On Suns, sometimes $CPP names a directory.
3214   if test -n "$CPP" && test -d "$CPP"; then
3215     CPP=
3216   fi
3217   if test -z "$CPP"; then
3218   AC_CACHE_VAL(ac_cv_prog_CPP,
3219   [  # This must be in double quotes, not single quotes, because CPP may get
3220     # substituted into the Makefile and "${CC-cc}" will confuse make.
3221     CPP="${CC-cc} -E"
3222     # On the NeXT, cc -E runs the code through the compiler's parser,
3223     # not just through cpp.
3224     dnl Use a header file that comes with gcc, so configuring glibc    
3225     dnl with a fresh cross-compiler works.
3226     AC_TRY_CPP([#include <assert.h>
3227     Syntax Error], ,
3228     CPP="${CC-cc} -E -traditional-cpp"
3229     AC_TRY_CPP([#include <assert.h>
3230     Syntax Error], , CPP=/lib/cpp))
3231     ac_cv_prog_CPP="$CPP"])dnl
3232     CPP="$ac_cv_prog_CPP"
3233   else
3234     ac_cv_prog_CPP="$CPP"
3235   fi
3236   AC_MSG_RESULT($CPP)
3237   AC_SUBST(CPP)dnl
3238
3239
3240   AC_MSG_CHECKING(for a C++-Compiler)
3241   dnl if there is one, print out. if not, don't matter
3242   AC_MSG_RESULT($CXX) 
3243  
3244   if test -z "$CXX"; then AC_CHECK_PROG(CXX, g++, g++) fi
3245   if test -z "$CXX"; then AC_CHECK_PROG(CXX, CC, CC) fi
3246   if test -z "$CXX"; then AC_CHECK_PROG(CXX, xlC, xlC) fi
3247   if test -z "$CXX"; then AC_CHECK_PROG(CXX, DCC, DCC) fi
3248   test -z "$CXX" && AC_MSG_ERROR([no acceptable C++-compiler found in \$PATH])
3249
3250   AC_PROG_CXX_WORKS
3251   AC_PROG_CXX_GNU
3252
3253   if test $ac_cv_prog_gxx = yes; then
3254     GXX=yes
3255   else
3256     AC_MSG_CHECKING(whether we are using SPARC CC)
3257     GXX=
3258     cat > conftest.C << EOF
3259 #ifdef __SUNPRO_CC
3260    yes;
3261 #endif
3262 EOF
3263
3264     ac_try="$CXX -E conftest.C"
3265     if { (eval echo configure:__online__: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } | egrep yes >/dev/null 2>&1; then
3266       ac_cv_prog_CC=yes
3267     else
3268       ac_cv_prog_CC=no
3269     fi
3270     AC_MSG_RESULT($ac_cv_prog_CC)
3271   fi
3272
3273   if test -z "$CXXFLAGS"; then 
3274     if test "$ac_use_debug_code" = "yes"; then
3275       AC_PROG_CXX_G
3276       if test $ac_cv_prog_cxx_g = yes; then
3277         CXXFLAGS="-g"
3278       fi
3279       if test "$ac_cv_prog_CC" = "yes"; then
3280         CXXFLAGS="$CXXFLAGS -pto"
3281       fi
3282     else
3283       if test "$GXX" = "yes"; then
3284          CXXFLAGS="-O2"
3285       else
3286          if test "$ac_cv_prog_CC" = "yes"; then
3287             CXXFLAGS="-pto -O2"
3288          else
3289             CXXFLAGS=""
3290          fi
3291       fi
3292     fi
3293
3294     if test "$GXX" = "yes"; then
3295        CXXFLAGS="$CXXFLAGS -Wall"
3296  
3297        if test "$ac_use_strict_options" = "yes"; then
3298         CXXFLAGS="$CXXFLAGS -W -ansi -Wtraditional  -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Woverloaded-virtual -Wbad-function-cast  -Wsynth"
3299        fi
3300
3301        if test "$kde_very_strict" = "yes"; then
3302          CXXFLAGS="$CXXFLAGS -Wold-style-cast -Wshadow -Wredundant-decls -Wconversion"
3303        fi
3304     fi
3305   fi  
3306
3307     case "$host" in
3308       *-*-sysv4.2uw*) CXXFLAGS="$CXXFLAGS -D_UNIXWARE";;
3309     esac    
3310
3311 ])
3312
3313 dnl just a wrapper to clean up configure.in
3314 AC_DEFUN(KDE_PROG_LIBTOOL,
3315 [
3316 AC_REQUIRE([AM_ENABLE_SHARED])
3317 AC_REQUIRE([AM_ENABLE_STATIC])
3318 dnl libtool is only for C, so I must force him
3319 dnl to find the correct flags for C++
3320 ac_save_cc=$CC
3321 ac_save_cflags="$CFLAGS"
3322 CC=$CXX
3323 CFLAGS="$CXXFLAGS"
3324 AM_PROG_LIBTOOL dnl for libraries
3325 CC=$ac_save_cc
3326 CFLAGS="$ac_save_cflags"
3327 ])
3328
3329 AC_DEFUN(KDE_DO_IT_ALL,
3330 [
3331 AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde})
3332 KDE_PROG_LIBTOOL
3333 AM_KDE_WITH_NLS
3334 AC_PATH_KDE
3335 ])
3336
3337 AC_DEFUN(AC_CHECK_RPATH,
3338 [
3339 AC_MSG_CHECKING(for rpath)
3340 AC_ARG_ENABLE(rpath,
3341       [  --disable-rpath         do not use the rpath feature of ld],
3342       USE_RPATH=$enableval, USE_RPATH=yes)
3343 if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
3344
3345   KDE_RPATH="-rpath \$(kde_libraries)"
3346
3347   if test -n "$qt_libraries"; then
3348     KDE_RPATH="$KDE_RPATH -rpath \$(qt_libraries)"
3349   fi
3350   dnl $x_libraries is set to /usr/lib in case
3351   if test -n "$X_LDFLAGS"; then 
3352     KDE_RPATH="$KDE_RPATH -rpath \$(x_libraries)"
3353   fi
3354   if test -n "$KDE_EXTRA_RPATH"; then
3355     KDE_RPATH="$KDE_RPATH \$(KDE_EXTRA_RPATH)"
3356   fi
3357 fi 
3358 AC_SUBST(KDE_EXTRA_RPATH)
3359 AC_SUBST(KDE_RPATH)
3360 AC_MSG_RESULT($USE_RPATH)
3361 ])
3362
3363 dnl This is a merge of some macros out of the gettext aclocal.m4
3364 dnl since we don't need anything, I took the things we need
3365 AC_DEFUN(AM_KDE_WITH_NLS,
3366   [AC_MSG_CHECKING([whether NLS is requested])
3367     AC_LANG_CPLUSPLUS
3368     dnl Default is enabled NLS
3369     AC_ARG_ENABLE(nls,
3370       [  --disable-nls           do not use Native Language Support],
3371       USE_NLS=$enableval, USE_NLS=yes)
3372     AC_MSG_RESULT($USE_NLS)
3373     AC_SUBST(USE_NLS)
3374
3375     dnl If we use NLS figure out what method
3376     if test "$USE_NLS" = "yes"; then
3377       AC_DEFINE(ENABLE_NLS)
3378
3379       AM_PATH_PROG_WITH_TEST_KDE(MSGFMT, msgfmt, 
3380          [test -n "`$ac_dir/$ac_word --version 2>&1 | grep 'GNU gettext'`"], msgfmt)
3381       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
3382
3383       if test -z "`$MSGFMT --version 2>&1 | grep 'GNU gettext'`"; then
3384         AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; ignore it])
3385         msgfmt=":"
3386       fi
3387       AC_SUBST(MSGFMT)
3388
3389       AM_PATH_PROG_WITH_TEST_KDE(XGETTEXT, xgettext,
3390         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
3391
3392       dnl Test whether we really found GNU xgettext.
3393       if test "$XGETTEXT" != ":"; then
3394         dnl If it is no GNU xgettext we define it as : so that the
3395         dnl Makefiles still can work.
3396         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
3397           : ;
3398         else
3399           AC_MSG_RESULT(
3400             [found xgettext programs is not GNU xgettext; ignore it])
3401           XGETTEXT=":"
3402         fi
3403       fi
3404      AC_SUBST(XGETTEXT)
3405     fi
3406
3407   ])
3408
3409 # Search path for a program which passes the given test.
3410 # Ulrich Drepper <drepper@cygnus.com>, 1996.
3411
3412 # serial 1
3413 # Stephan Kulow: I appended a _KDE against name conflicts
3414
3415 dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR,
3416 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
3417 AC_DEFUN(AM_PATH_PROG_WITH_TEST_KDE,
3418 [# Extract the first word of "$2", so it can be a program name with args.
3419 set dummy $2; ac_word=[$]2
3420 AC_MSG_CHECKING([for $ac_word])
3421 AC_CACHE_VAL(ac_cv_path_$1,
3422 [case "[$]$1" in
3423   /*)
3424   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
3425   ;;
3426   *)
3427   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
3428   for ac_dir in ifelse([$5], , $PATH, [$5]); do
3429     test -z "$ac_dir" && ac_dir=.
3430     if test -f $ac_dir/$ac_word; then
3431       if [$3]; then
3432         ac_cv_path_$1="$ac_dir/$ac_word"
3433         break
3434       fi
3435     fi
3436   done
3437   IFS="$ac_save_ifs"
3438 dnl If no 4th arg is given, leave the cache variable unset,
3439 dnl so AC_PATH_PROGS will keep looking.
3440 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
3441 ])dnl
3442   ;;
3443 esac])dnl
3444 $1="$ac_cv_path_$1"
3445 if test -n "[$]$1"; then
3446   AC_MSG_RESULT([$]$1)
3447 else
3448   AC_MSG_RESULT(no)
3449 fi
3450 AC_SUBST($1)dnl
3451 ])
3452
3453
3454 dnl From Jim Meyering.
3455 dnl FIXME: migrate into libit.
3456
3457 AC_DEFUN(AM_FUNC_OBSTACK,
3458 [AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
3459  [AC_TRY_LINK([#include "obstack.h"],
3460               [struct obstack *mem;obstack_free(mem,(char *) 0)],
3461               am_cv_func_obstack=yes,
3462               am_cv_func_obstack=no)])
3463  if test $am_cv_func_obstack = yes; then
3464    AC_DEFINE(HAVE_OBSTACK)
3465  else
3466    LIBOBJS="$LIBOBJS obstack.o"
3467  fi
3468 ])
3469
3470 dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
3471 dnl FIXME: Migrate into libit
3472
3473 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
3474 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
3475  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
3476               am_cv_lib_error_at_line=yes,
3477               am_cv_lib_error_at_line=no)])
3478  if test $am_cv_lib_error_at_line = no; then
3479    LIBOBJS="$LIBOBJS error.o"
3480  fi
3481  AC_SUBST(LIBOBJS)dnl
3482 ])
3483
3484 # Macro to add for using GNU gettext.
3485 # Ulrich Drepper <drepper@cygnus.com>, 1995.
3486
3487 # serial 1
3488 # Stephan Kulow: I put a KDE in it to avoid name conflicts
3489
3490 AC_DEFUN(AM_KDE_GNU_GETTEXT,
3491   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
3492    AC_REQUIRE([AC_PROG_RANLIB])dnl
3493    AC_REQUIRE([AC_HEADER_STDC])dnl
3494    AC_REQUIRE([AC_C_INLINE])dnl
3495    AC_REQUIRE([AC_TYPE_OFF_T])dnl
3496    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
3497    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
3498    AC_REQUIRE([AC_FUNC_MMAP])dnl
3499    AC_REQUIRE([AM_KDE_WITH_NLS])dnl
3500    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
3501 unistd.h values.h alloca.h])
3502    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
3503 __argz_count __argz_stringify __argz_next stpcpy])
3504
3505    AM_LC_MESSAGES
3506
3507    if test "x$CATOBJEXT" != "x"; then
3508      if test "x$ALL_LINGUAS" = "x"; then
3509        LINGUAS=
3510      else
3511        AC_MSG_CHECKING(for catalogs to be installed)
3512        NEW_LINGUAS=
3513        for lang in ${LINGUAS=$ALL_LINGUAS}; do
3514          case "$ALL_LINGUAS" in
3515           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
3516          esac
3517        done
3518        LINGUAS=$NEW_LINGUAS
3519        AC_MSG_RESULT($LINGUAS)
3520      fi
3521
3522      dnl Construct list of names of catalog files to be constructed.
3523      if test -n "$LINGUAS"; then
3524        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
3525      fi
3526    fi
3527
3528   ])
3529
3530 AC_DEFUN(AC_HAVE_XPM,
3531  [AC_REQUIRE_CPP()dnl
3532
3533  test -z "$XPM_LDFLAGS" && XPM_LDFLAGS=
3534  test -z "$XPM_INCLUDE" && XPM_INCLUDE=
3535
3536  AC_ARG_WITH(xpm, [  --without-xpm           disable color pixmap XPM tests],
3537         xpm_test=$withval, xpm_test="yes")
3538  if test "x$xpm_test" = xno; then
3539    ac_cv_have_xpm=no
3540  else
3541    AC_MSG_CHECKING(for XPM)
3542    AC_CACHE_VAL(ac_cv_have_xpm,
3543    [
3544     AC_LANG_C
3545     ac_save_ldflags="$LDFLAGS"
3546     ac_save_cflags="$CFLAGS"
3547     LDFLAGS="$LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm -lX11 -lXext $LIBSOCKET"
3548     CFLAGS="$CFLAGS $X_INCLUDES"
3549     test ! -z "$XPM_INCLUDE" && CFLAGS="-I$XPM_INCLUDE $CFLAGS"
3550     AC_TRY_LINK([#include <X11/xpm.h>],[],
3551         ac_cv_have_xpm="yes",ac_cv_have_xpm="no")
3552     LDFLAGS="$ac_save_ldflags"
3553     CFLAGS="$ac_save_cflags"
3554    ])dnl
3555  
3556   if test "$ac_cv_have_xpm" = no; then
3557     AC_MSG_RESULT(no)
3558     XPM_LDFLAGS=""
3559     XPMINC=""
3560     $2
3561   else
3562     AC_DEFINE(HAVE_XPM)
3563     if test "$XPM_LDFLAGS" = ""; then
3564        XPMLIB="-lXpm"
3565     else
3566        XPMLIB="-L$XPM_LDFLAGS -lXpm"
3567     fi
3568     if test "$XPM_INCLUDE" = ""; then
3569        XPMINC=""
3570     else
3571        XPMINC="-I$XPM_INCLUDE"
3572     fi
3573     AC_MSG_RESULT(yes)
3574     $1
3575   fi
3576  fi
3577  AC_SUBST(XPMINC)
3578  AC_SUBST(XPMLIB)
3579 ]) 
3580
3581 AC_DEFUN(AC_HAVE_GL,
3582  [AC_REQUIRE_CPP()dnl
3583
3584  test -z "$GL_LDFLAGS" && GL_LDFLAGS=
3585  test -z "$GL_INCLUDE" && GL_INCLUDE=
3586
3587  AC_ARG_WITH(gl, [  --without-gl            disable 3D GL modes],
3588         gl_test=$withval, gl_test="yes")
3589  if test "x$gl_test" = xno; then
3590    ac_cv_have_gl=no
3591  else
3592    AC_MSG_CHECKING(for GL)
3593    AC_CACHE_VAL(ac_cv_have_gl,
3594    [
3595     AC_LANG_C
3596     ac_save_ldflags="$LDFLAGS"
3597     ac_save_cflags="$CFLAGS"
3598     LDFLAGS="$LDFLAGS $GL_LDFLAGS $all_libraries -lMesaGL -lMesaGLU -lX11 -lXext -lm $LIBSOCKET"
3599     CFLAGS="$CFLAGS $X_INCLUDES"
3600     test ! -z "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
3601     AC_TRY_LINK([],[],
3602         ac_cv_have_gl="yes",ac_cv_have_gl="no")
3603     LDFLAGS="$ac_save_ldflags"
3604     CFLAGS="$ac_save_cflags"
3605    ])dnl
3606  
3607   if test "$ac_cv_have_gl" = no; then
3608     AC_MSG_RESULT(no)
3609     GL_LDFLAGS=""
3610     GLINC=""
3611     $2
3612   else
3613     AC_DEFINE(HAVE_GL)
3614     if test "$GL_LDFLAGS" = ""; then
3615        GLLIB="-lMesaGL -lMesaGLU"
3616     else
3617        GLLIB="-L$GL_LDFLAGS -lMesaGL -lMesaGLU"
3618     fi
3619     if test "$GL_INCLUDE" = ""; then
3620        GLINC=""
3621     else
3622        GLINC="-I$GL_INCLUDE"
3623     fi
3624     AC_MSG_RESULT(yes)
3625     $1
3626   fi
3627  fi
3628  AC_SUBST(GLINC)
3629  AC_SUBST(GLLIB)
3630 ]) 
3631
3632  dnl PAM pam
3633  
3634  dnl Should test for PAM (Pluggable Authentication Modules)
3635  AC_DEFUN(AC_PATH_PAM_DIRECT,
3636  [
3637  test -z "$pam_direct_test_library" && pam_direct_test_library=pam
3638  test -z "$pam_direct_test_include" && pam_direct_test_include=security/pam_appl.h
3639  
3640    for ac_dir in               \
3641                                \
3642      /usr/local/include        \
3643      /usr/include              \
3644      /usr/unsupported/include  \
3645      /opt/include              \
3646      /usr/pam/include          \
3647      /usr/local/pam/include    \
3648      /usr/lib/pam/include      \
3649                               \
3650      $extra_include            \
3651      ; \
3652    do
3653      if test -r "$ac_dir/$pam_direct_test_include"; then
3654        no_pam= ac_pam_includes=$ac_dir
3655        break
3656      fi
3657    done
3658  
3659  # First see if replacing the include by lib works.
3660  for ac_dir in `echo "$ac_pam_includes" | sed s/include/lib/` \
3661                            \
3662      /lib                  \
3663      /usr/lib              \
3664      /usr/local/lib        \
3665      /usr/unsupported/lib  \
3666      /lib/security         \
3667      /usr/security/lib     \
3668      $extra_lib            \
3669      ; \
3670  do
3671    for ac_extension in a so sl; do
3672      if test -r $ac_dir/lib${pam_direct_test_library}.$ac_extension; then
3673        no_pam= ac_pam_libraries=$ac_dir
3674        break 2
3675      fi
3676    done
3677  done
3678 ])
3679
3680 AC_DEFUN(AC_PATH_PAM,
3681  [AC_REQUIRE_CPP()dnl
3682
3683   AC_CHECK_LIB(pam_misc, main, [PAM_MISC_LIB="-lpam_misc"], [], [-lpam -ldl])
3684
3685  AC_MSG_CHECKING(for PAM)
3686  AC_ARG_WITH(pam, 
3687 [  --with-pam[=ARG]        enable support for PAM: ARG=[yes|no|service name]],
3688   [
3689     if test "x$withval" = "xyes"; then
3690       no_pam=
3691       default_pam=yes
3692     elif test "x$withval" = "xno"; then
3693       no_pam=yes
3694     else
3695       no_pam=
3696       pam_service="$withval"
3697         if test -z "$pam_service"; then
3698         default_pam=yes
3699         else
3700         default_pam=
3701         fi 
3702       fi
3703   ], no_pam=yes
3704  )
3705
3706  if test ! "$no_pam" = yes; then
3707
3708  AC_CACHE_VAL(ac_cv_path_pam,
3709  [
3710  ac_pam_includes=NONE
3711  ac_pam_libraries=NONE
3712  if test -z "$pam_libraries"; then
3713    pam_libraries=NONE
3714  fi
3715  if test -z "$pam_includes"; then
3716    pam_includes=NONE
3717  fi
3718
3719  AC_PATH_PAM_DIRECT
3720  
3721  test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
3722  test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
3723  
3724  if test ! "x$pam_includes" = xNONE && test ! "x$pam_libraries" = xNONE; then
3725    ac_pam_libs="-lpam $PAM_MISC_LIB -ldl"
3726    ac_cv_path_pam="no_pam= ac_pam_includes=$ac_pam_includes ac_pam_libraries=$ac_pam_libraries ac_pam_libs=\"$ac_pam_libs\""
3727  else
3728    ac_cv_path_pam="no_pam=yes"
3729  fi
3730  ])
3731
3732  eval "$ac_cv_path_pam"
3733  
3734  fi
3735
3736  if test "$no_pam" = yes; then
3737    AC_MSG_RESULT(no)
3738  else
3739    AC_DEFINE(HAVE_PAM)
3740    PAMLIBS="$ac_pam_libs"
3741    test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
3742    test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
3743    AC_MSG_RESULT([libraries $pam_libraries, headers $pam_includes])
3744  if test "$default_pam" = yes; then
3745    AC_MSG_RESULT(["default pam service name will be used"])
3746  else
3747    AC_DEFINE_UNQUOTED(KDE_PAM_SERVICE,"$pam_service")
3748    AC_MSG_RESULT(["pam service name will be: " $pam_service])
3749  fi
3750 dnl test whether struct pam_message is const (Linux) or not (Sun)
3751    pam_appl_h="$ac_pam_includes/security/pam_appl.h"
3752    AC_MSG_CHECKING(for const pam_message)
3753    AC_EGREP_HEADER([struct pam_message],
3754       $pam_appl_h,
3755       [ AC_EGREP_HEADER([const struct pam_message],
3756                         $pam_appl_h,
3757                         [AC_MSG_RESULT(["const: Linux-type PAM"]) ],
3758                         [AC_MSG_RESULT(["nonconst: Sun-type PAM"])
3759                         AC_DEFINE(PAM_MESSAGE_NONCONST)] 
3760                         )],
3761        [AC_MSG_RESULT(["not found - assume const, Linux-type PAM"])]
3762        )
3763  fi
3764  
3765  if test "x$pam_libraries" != x && test "x$pam_libraries" != xNONE ; then
3766      PAMLIBPATHS="-L$pam_libraries"
3767  fi
3768  if test "x$pam_includes" != x && test "x$pam_includes" != xNONE ; then
3769      PAMINC="-I$pam_includes"
3770  fi
3771  
3772  AC_SUBST(PAMINC)
3773  AC_SUBST(PAMLIBS)
3774  AC_SUBST(PAMLIBPATHS)
3775
3776 ]) 
3777
3778 AC_DEFUN(KDE_CHECK_LIBDL,
3779 [
3780 AC_CHECK_LIB(dl, dlopen, [
3781 LIBDL="-ldl"
3782 ac_cv_have_dlfcn=yes
3783 ])
3784
3785 AC_CHECK_LIB(dld, shl_unload, [
3786 LIBDL="-ldld"
3787 ac_cv_have_shload=yes
3788 ])
3789
3790 AC_SUBST(LIBDL)
3791 ])
3792
3793 AC_DEFUN(KDE_CHECK_DLOPEN,
3794 [
3795 KDE_CHECK_LIBDL
3796 AC_CHECK_HEADERS(dlfcn.h dl.h)
3797 if test "$ac_cv_header_dlfcn_h" = "no"; then
3798   ac_cv_have_dlfcn=no
3799 fi
3800
3801 if test "$ac_cv_header_dl_h" = "no"; then
3802   ac_cv_have_shload=no
3803 fi
3804
3805 enable_dlopen=no
3806 AC_ARG_ENABLE(dlopen,
3807 [  --disable-dlopen        link staticly [default=no]] ,
3808 [if test "$enableval" = yes; then
3809   enable_dlopen=yes
3810 fi],
3811 enable_dlopen=yes)
3812
3813 # override the user's opinion, if we know it better ;)
3814 if test "$ac_cv_have_dlfcn" = "no" && test "$ac_cv_have_shload" = "no"; then
3815   enable_dlopen=no
3816 fi
3817
3818 if test "$ac_cv_have_dlfcn" = "yes"; then
3819   AC_DEFINE_UNQUOTED(HAVE_DLFCN)
3820 fi
3821
3822 if test "$ac_cv_have_shload" = "yes"; then
3823   AC_DEFINE_UNQUOTED(HAVE_SHLOAD)
3824 fi
3825
3826 if test "$enable_dlopen" = no ; then
3827   test -n "$1" && eval $1
3828 else
3829   test -n "$2" && eval $2
3830 fi
3831
3832 ])
3833
3834 AC_DEFUN(KDE_CHECK_DYNAMIC_LOADING,
3835 [
3836 KDE_CHECK_DLOPEN(libtool_enable_shared=no, libtool_enable_static=no)
3837 KDE_PROG_LIBTOOL
3838 AC_MSG_CHECKING([dynamic loading])
3839 eval "`egrep '^build_libtool_libs=' libtool`"
3840 if test "$build_libtool_libs" = "yes" && test "$enable_dlopen" = "yes"; then
3841   dynamic_loading=yes
3842   AC_DEFINE_UNQUOTED(HAVE_DYNAMIC_LOADING)
3843 else
3844   dynamic_loading=no
3845 fi
3846 AC_MSG_RESULT($dynamic_loading)
3847 if test "$dynamic_loading" = "yes"; then
3848   $1
3849 else
3850   $2
3851 fi
3852 ])
3853
3854 AC_DEFUN(KDE_ADD_INCLUDES,
3855 [
3856 if test -z "$1"; then 
3857   test_include="Pix.h"
3858 else
3859   test_include="$1"
3860 fi
3861
3862 AC_MSG_CHECKING([for libg++ ($test_include)])
3863
3864 AC_CACHE_VAL(kde_cv_libgpp_includes,
3865 [
3866 kde_cv_libgpp_includes=no
3867
3868    for ac_dir in               \
3869                                \
3870      /usr/include/g++          \
3871      /usr/include              \
3872      /usr/unsupported/include  \
3873      /opt/include              \
3874      $extra_include            \
3875      ; \
3876    do
3877      if test -r "$ac_dir/$test_include"; then
3878        kde_cv_libgpp_includes=$ac_dir
3879        break
3880      fi
3881    done
3882 ])
3883
3884 AC_MSG_RESULT($kde_cv_libgpp_includes)
3885 if test "$kde_cv_libgpp_includes" != "no"; then
3886   all_includes="-I$kde_cv_libgpp_includes $all_includes"
3887 fi
3888 ])
3889 ])
3890
3891
3892 AC_DEFUN(KDE_CHECK_MICO,
3893 [
3894 AC_REQUIRE([KDE_CHECK_LIBDL])
3895 AC_MSG_CHECKING(for MICO)
3896 AC_ARG_WITH(micodir,
3897   [  --with-micodir=micodir  where mico is installed ],
3898   kde_micodir=$withval,
3899   kde_micodir=/usr/local
3900 )
3901 AC_MSG_RESULT($kde_micodir)
3902 if test ! -r  $kde_micodir/include/CORBA.h; then
3903   AC_MSG_ERROR([No CORBA.h found, specify another micodir])
3904 fi
3905
3906 MICO_INCLUDES=-I$kde_micodir/include
3907 AC_SUBST(MICO_INCLUDES)
3908 MICO_LDFLAGS=-L$kde_micodir/lib
3909 AC_SUBST(MICO_LDFLAGS)
3910
3911 AC_MSG_CHECKING([for MICO version])
3912 AC_CACHE_VAL(kde_cv_mico_version,
3913 [
3914 AC_LANG_C
3915 cat >conftest.$ac_ext <<EOF
3916 #include <stdio.h>
3917 #include <mico/version.h>
3918 int main() { 
3919     
3920    printf("MICO_VERSION=%s\n",MICO_VERSION); 
3921    return (0); 
3922 }
3923 EOF
3924 ac_compile='${CC-gcc} $CFLAGS $MICO_INCLUDES conftest.$ac_ext -o conftest'
3925 if AC_TRY_EVAL(ac_compile); then
3926   if eval `./conftest 2>&5`; then
3927     kde_cv_mico_version=$MICO_VERSION
3928   else
3929     AC_MSG_ERROR([your system is not able to execute a small application to
3930     find MICO version! Check $kde_micodir/include/mico/version.h])
3931   fi 
3932 else
3933   AC_MSG_ERROR([your system is not able to compile a small application to
3934   find MICO version! Check $kde_micodir/include/mico/version.h])
3935 fi
3936 ])
3937
3938 dnl installed MICO version
3939 mico_v_maj=`echo $kde_cv_mico_version | sed -e 's/^\(.*\)\..*\..*$/\1/'`
3940 mico_v_mid=`echo $kde_cv_mico_version | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
3941 mico_v_min=`echo $kde_cv_mico_version | sed -e 's/^.*\..*\.\(.*\)$/\1/'`
3942
3943 dnl required MICO version
3944 req_v_maj=`echo $1 | sed -e 's/^\(.*\)\..*\..*$/\1/'`
3945 req_v_mid=`echo $1 | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
3946 req_v_min=`echo $1 | sed -e 's/^.*\..*\.\(.*\)$/\1/'` 
3947
3948 if test "$mico_v_maj" -lt "$req_v_maj" || \
3949    ( test "$mico_v_maj" -eq "$req_v_maj" && \
3950         test "$mico_v_mid" -lt "$req_v_mid" ) || \
3951    ( test "$mico_v_mid" -eq "$req_v_mid" && \
3952         test "$mico_v_min" -lt "$req_v_min" )
3953
3954 then
3955   AC_MSG_ERROR([found MICO version $kde_cv_mico_version but version $1 \
3956 at least is required. You should upgrade MICO.])
3957 else
3958   AC_MSG_RESULT([$kde_cv_mico_version (minimum version $1, ok)])
3959 fi
3960
3961 LIBMICO="-lmico$kde_cv_mico_version $LIBDL"
3962 AC_SUBST(LIBMICO)
3963 IDL=$kde_micodir/bin/idl
3964 AC_SUBST(IDL)
3965 ])
3966
3967
3968 AC_DEFUN(KDE_CHECK_MINI_STL,
3969 [
3970 AC_REQUIRE([KDE_CHECK_MICO])
3971
3972 AC_MSG_CHECKING(if we use mico's mini-STL)
3973 AC_CACHE_VAL(kde_cv_have_mini_stl,
3974 [
3975 AC_LANG_CPLUSPLUS
3976 kde_save_cxxflags="$CXXFLAGS"
3977 CXXFLAGS="$CXXFLAGS $MICO_INCLUDES"
3978 AC_TRY_COMPILE(
3979 [
3980 #include <mico/config.h>
3981 ],
3982 [
3983 #ifdef HAVE_MINI_STL
3984 #error "nothing"
3985 #endif
3986 ],
3987 kde_cv_have_mini_stl=no,
3988 kde_cv_have_mini_stl=yes)
3989 CXXFLAGS="$kde_save_cxxflags"
3990 ])
3991
3992
3993 AC_MSG_RESULT($kde_cv_have_mini_stl)
3994 if test "$kde_cv_have_mini_stl" = "yes"; then
3995   AC_DEFINE_UNQUOTED(HAVE_MINI_STL)
3996 fi
3997 ])
3998
3999 ])
4000
4001
4002 AC_DEFUN(KDE_CHECK_LIBPTHREAD,
4003 [
4004 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"], LIBPTHREAD= )
4005 AC_SUBST(LIBPTHREAD)
4006 ])
4007
4008 AC_DEFUN(KDE_TRY_LINK_PYTHON,
4009 [
4010 AC_CACHE_VAL(kde_cv_try_link_python_$1,
4011 [
4012 kde_save_cxxflags="$CXXFLAGS"
4013 CXXFLAGS="$CXXFLAGS $PYTHONINC"
4014 kde_save_libs="$LIBS"
4015 LIBS="$LIBS $LIBPYTHON $2 $LIBDL $LIBSOCKET"
4016 kde_save_ldflags="$LDFLAGS"
4017 LDFLAGS="$LDFLAGS $PYTHONLIB"
4018
4019 AC_TRY_LINK(
4020 [
4021 #include <Python.h>
4022 ],[
4023         PySys_SetArgv(1, 0);
4024 ],
4025         [kde_cv_try_link_python_$1=yes],
4026         [kde_cv_try_link_python_$1=no]
4027 )
4028 CXXFLAGS="$kde_save_cxxflags"
4029 LIBS="$kde_save_libs"
4030 LDFLAGS="$kde_save_ldflags"
4031 ])
4032
4033 if test "$kde_cv_try_link_python_$1" = "yes"; then
4034   $3
4035 else
4036   $4
4037 fi
4038
4039 ])
4040
4041 AC_DEFUN(KDE_CHECK_PYTHON,
4042 [
4043 AC_REQUIRE([KDE_CHECK_LIBDL])
4044 AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
4045 if test -z "$1"; then 
4046   version="1.5"
4047 else
4048   version="$1"
4049 fi
4050
4051 AC_MSG_CHECKING([for Python$version])
4052
4053 AC_ARG_WITH(pythondir, 
4054 [  --with-pythondir=pythondir   use python installed in pythondir ],
4055 [
4056   ac_python_dir=$withval
4057 ], ac_python_dir=/usr/local
4058 )
4059
4060 python_incdirs="$ac_python_dir/include/python$version /usr/include/python$version /usr/local/include/python$version /usr/local/include"
4061 AC_FIND_FILE(Python.h, $python_incdirs, python_incdir)
4062 if test ! -r $python_incdir/Python.h; then
4063   AC_MSG_ERROR(Python.h not found.)
4064 fi
4065
4066 PYTHONINC=-I$python_incdir
4067
4068 python_libdirs="$ac_python_dir/lib/python$version/config /usr/lib/python$version/config /usr/local/python$version/config"
4069 AC_FIND_FILE(libpython$version.a, $python_libdirs, python_libdir)
4070 if test ! -r $python_libdir/libpython$version.a; then
4071   AC_MSG_ERROR(libpython$version.a not found.)
4072 fi
4073
4074 PYTHONLIB=-L$python_libdir
4075 LIBPYTHON=-lpython$version
4076
4077 AC_MSG_RESULT(header $python_incdir library $python_libdir)
4078
4079 dnl Note: this test is very weak
4080 AC_MSG_CHECKING(if an Python application links)
4081 KDE_TRY_LINK_PYTHON(normal, "", AC_MSG_RESULT(yes),
4082  [
4083     AC_MSG_RESULT(no)
4084     AC_MSG_CHECKING(if Python depends on -lpthread)
4085     KDE_TRY_LINK_PYTHON(pthread, "$LIBPTHREAD",
4086     [  
4087        AC_MSG_RESULT(yes)
4088        LIBPYTHON="$LIBPYTHON $LIBPTHREAD $LIBDL"
4089     ],
4090     [
4091        AC_MSG_RESULT(no)
4092        AC_MSG_CHECKING(if Python depeds on -ltcl)
4093        KDE_TRY_LINK_PYTHON(tcl, "-ltcl",
4094        [
4095           AC_MSG_RESULT(yes)
4096           LIBPYTHON="$LIBPYTHON -ltcl"
4097        ],
4098        [
4099           AC_MSG_RESULT(no)
4100         AC_MSG_WARN([it seems, Python depends on another library. 
4101     Pleae use \"make LIBPTYHON='-lpython$version -lotherlib'\" to fix this
4102     and contact the authors to let them know about this problem])
4103         ])
4104     ])
4105  ]) 
4106
4107 AC_SUBST(PYTHONINC)
4108 AC_SUBST(PYTHONLIB)
4109 AC_SUBST(LIBPYTHON)
4110
4111 ])
4112
4113
4114 AC_DEFUN(KDE_CHECK_STL_SGI,
4115 [
4116     AC_MSG_CHECKING([if STL implementation is SGI like])
4117     AC_CACHE_VAL(kde_cv_stl_type_sgi,
4118     [
4119       AC_TRY_COMPILE([
4120 #include <string>
4121 ],[
4122   string astring="Hallo Welt.";
4123   astring.erase(0, 6); // now astring is "Welt"
4124   return 0;
4125 ], kde_cv_stl_type_sgi=yes,
4126    kde_cv_stl_type_sgi=no)
4127 ])
4128
4129    AC_MSG_RESULT($kde_cv_stl_type_sgi)
4130
4131    if test "$kde_cv_stl_type_sgi" = "yes"; then
4132         AC_DEFINE_UNQUOTED(HAVE_SGI_STL) 
4133    fi
4134 ])
4135
4136 AC_DEFUN(KDE_CHECK_STL_HP,
4137 [
4138     AC_MSG_CHECKING([if STL implementation is HP like])
4139     AC_CACHE_VAL(kde_cv_stl_type_hp,
4140     [
4141       AC_TRY_COMPILE([
4142 #include <string>
4143 ],[
4144   string astring="Hello World";
4145   astring.remove(0, 6); // now astring is "World"
4146   return 0;
4147 ], kde_cv_stl_type_hp=yes,
4148    kde_cv_stl_type_hp=no)
4149 ])
4150    AC_MSG_RESULT($kde_cv_stl_type_hp)
4151
4152    if test "$kde_cv_stl_type_hp" = "yes"; then
4153         AC_DEFINE_UNQUOTED(HAVE_HP_STL) 
4154    fi
4155 ])
4156
4157 AC_DEFUN(KDE_CHECK_STL,
4158 [
4159     KDE_CHECK_STL_SGI
4160     
4161     if test "$kde_cv_stl_type_sgi" = "no"; then
4162        KDE_CHECK_STL_HP
4163
4164        if test "$kde_cv_stl_type_hp" = "no"; then
4165          AC_MSG_ERROR("no known STL type found")
4166        fi
4167     fi
4168
4169 ])
4170
4171 AC_DEFUN(AC_FIND_QIMGIO,
4172    [AC_REQUIRE([AC_FIND_JPEG])
4173 AC_MSG_CHECKING([for qimgio])
4174 AC_CACHE_VAL(ac_cv_lib_qimgio,
4175 [ac_save_LIBS="$LIBS"
4176 LIBS="$all_libraries -lqimgio -lpng -lz -lqt $LIBJPEG -lX11 $LIBSOCKET"
4177 AC_TRY_LINK(dnl
4178 [
4179 void qInitImageIO ();
4180 ],
4181             [qInitImageIO();],
4182             eval "ac_cv_lib_qimgio=yes",
4183             eval "ac_cv_lib_qimgio=no")
4184 LIBS="$ac_save_LIBS"
4185 ])dnl
4186 if eval "test \"`echo $ac_cv_lib_qimgio`\" = yes"; then
4187   LIBQIMGIO="-lqimgio -lpng -lz $LIBJPEG"
4188   AC_MSG_RESULT(yes)
4189   AC_DEFINE_UNQUOTED(HAVE_QIMGIO)
4190   AC_SUBST(LIBQIMGIO)
4191 else
4192   AC_MSG_RESULT(not found)
4193 fi
4194 ])
4195
4196 AC_DEFUN(KDE_CHECK_ANSI,
4197 [
4198 AC_MSG_CHECKING([for strdup])
4199
4200     AC_CACHE_VAL(kde_cv_stl_type_sgi,
4201     [
4202 AC_LANG_CPLUSPLUS
4203 save_CXXFLAGS="$CXXFLAGS"
4204 if test "$GCC" = "yes"; then
4205   CXXFLAGS="$CXXFLAGS -pedantic-errors"
4206 fi
4207
4208 AC_TRY_COMPILE([
4209 #include <string.h>
4210 ],[
4211   char buffer[] = "Hallo";
4212   strdup(buffer)
4213 ], kde_cv_has_strdup=yes,
4214    kde_cv_has_strdup=no)
4215 CXXFLAGS="$save_CXXFLAGS"
4216 ])
4217 AC_MSG_RESULT($kde_cv_has_strdup)
4218
4219 if test "$kde_cv_has_strdup" = "yes"; then
4220   AC_DEFINE_UNQUOTED(HAVE_STRDUP)
4221 fi
4222
4223 ])
4224
4225 AC_DEFUN(KDE_CHECK_INSURE,
4226 [
4227   AC_ARG_ENABLE(insure, [  --enable-insure             use insure++ for debugging [default=no]],
4228   [
4229   if test $enableval = "no"; dnl
4230         then ac_use_insure="no"
4231         else ac_use_insure="yes"
4232    fi
4233   ], [ac_use_insure="no"])
4234
4235   AC_MSG_CHECKING(if we will use Insure++ to debug)
4236   AC_MSG_RESULT($ac_use_insure)
4237   if test "$ac_use_insure" = "yes"; dnl
4238        then CC="insure"; CXX="insure"; dnl CFLAGS="$CLAGS -fno-rtti -fno-exceptions "????
4239    fi
4240 ])          
4241
4242 dnl this is for kdm:
4243
4244 AC_DEFUN(AC_CHECK_KDM,
4245 [
4246 AC_CHECK_FUNCS(getsecretkey)
4247 dnl checks for X server
4248
4249 AC_PATH_PROG(X_SERVER, X)
4250 if test ! -z "$X_SERVER"; then
4251 X_SERVER=`echo $X_SERVER | sed -e 's+/X$++'`
4252 AC_DEFINE_UNQUOTED(XBINDIR,$X_SERVER)
4253 XBINDIR=$X_SERVER
4254 AC_SUBST(XBINDIR)
4255 fi
4256
4257 dnl This one tries to find XDMDIR for config files
4258 AC_ARG_WITH(xdmdir,
4259         [  --with-xdmdir                  If the xdm config dir can't be found automaticly],
4260         [ ac_xdmdir=$withval],
4261         [ ac_xdmdir="no"])
4262
4263 AC_MSG_CHECKING([for xdm configuration dir])
4264 if test "$ac_xdmdir" = "no"; then
4265     rm -fr conftestdir
4266     if mkdir conftestdir; then
4267         cd conftestdir
4268     cat > Imakefile <<'EOF'
4269 acfindxdm:
4270         @echo 'ac_xdmdir="$(XDMDIR)";'
4271 EOF
4272         if (xmkmf) > /dev/null 2> /dev/null && test -f Makefile; then
4273             eval `${MAKE-make} acfindxdm 2>/dev/null 2>/dev/null | grep -v make`
4274         fi
4275         cd ..
4276         rm -fr conftestdir
4277         dnl Check if Imake was right
4278         if test -f $ac_xdmdir/xdm-config; then
4279             AC_MSG_RESULT($ac_xdmdir)
4280         else
4281             dnl Here we must do something else
4282             dnl Maybe look for xdm-config in standard places, and
4283             dnl if that fails use a fresh copy in $KDEDIR/config/kdm/
4284             AC_FIND_FILE(xdm-config,/etc/X11/xdm /var/X11/xdm /usr/openwin/xdm /usr/X11R6/lib/X11/xdm,ac_xdmdir)
4285             if test -f $ac_xdmdir/xdm-config; then
4286                 AC_MSG_RESULT($ac_xdmdir)
4287             else                                 
4288                 if test "${prefix}" = NONE; then
4289                         ac_xdmdir=$ac_default_prefix/config/kdm
4290                 else
4291                         ac_xdmdir=$prefix/config/kdm
4292                 fi
4293                 AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
4294                 xdmconfigsubdir=xdmconfig
4295                 AC_SUBST(xdmconfigsubdir)
4296             fi
4297         fi
4298     fi
4299 else
4300     if test -f $ac_xdmdir/xdm-config; then
4301         AC_MSG_RESULT($ac_xdmdir)
4302     else
4303
4304         AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
4305         xdmconfigsubdir=xdmconfig
4306         AC_SUBST(xdmconfigsubdir)
4307     fi
4308 fi
4309 AC_DEFINE_UNQUOTED(XDMDIR,"$ac_xdmdir")
4310 AC_SUBST(ac_xdmdir)
4311
4312 AC_PATH_PAM
4313 if test "x$no_pam" = "xyes"; then 
4314         pam_support="no"
4315 else
4316         pam_support="yes"
4317         shadow_support="no" # if pam is installed, use it. We can't savely 
4318                             # test, if it works *sigh*
4319 fi
4320
4321 AC_ARG_WITH(shadow,
4322         [  --with-shadow                  If you want shadow password support ],
4323         [ if test "$withval" = "yes"; then
4324              shadow_support="yes"
4325           else
4326              shadow_support="no"
4327           fi
4328           if test "$pam_support" = "yes" && test "$shadow_support=yes"; then
4329                 AC_MSG_WARN("You can not define both pam AND shadow")
4330           fi
4331         ],
4332         [ if test -z "$shadow_support"; then shadow_support="no"; fi ] )
4333
4334 if test "$pam_support" = "yes"; then
4335   AC_CHECK_LIB(pam, main, [PASSWDLIB="-lpam -ldl"
4336   AC_DEFINE_UNQUOTED(HAVE_PAM_LIB)],
4337   [],-ldl)
4338 fi
4339
4340 if test -z "$PASSWDLIB" && test "$shadow_support" = "yes"; then
4341   AC_CHECK_LIB(shadow, main,
4342     [ PASSWDLIB="-lshadow"
4343       AC_DEFINE_UNQUOTED(HAVE_SHADOW_LIB)
4344     ])
4345 fi
4346 AC_SUBST(PASSWDLIB)
4347 AC_CHECK_LIB(util, main, [LIBUTIL="-lutil"]) dnl for FreeBSD
4348 AC_SUBST(LIBUTIL)
4349 AC_CHECK_LIB(s, main, [LIB_LIBS="-ls"]) dnl for AIX
4350 AC_SUBST(LIB_LIBS)
4351 AC_CHECK_LIB(Xdmcp, main, [LIBXDMCP="-lXdmcp"], , $X_LDFLAGS -lX11) dnl for Unixware
4352 AC_SUBST(LIBXDMCP)
4353
4354 if test -n "$LIBXDMCP"; then
4355   ac_cpp_safe=$ac_cpp
4356   ac_cpp='$CXXCPP $CPPFLAGS $X_INCLUDES'
4357   AC_CHECK_HEADERS(X11/Xdmcp.h)
4358   ac_cpp=$ac_cpp_safe
4359 fi
4360
4361 ])
4362 # Configure paths for GTK+
4363 # Owen Taylor     97-11-3
4364
4365 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
4366 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
4367 dnl
4368 AC_DEFUN(AM_PATH_GTK,
4369 [dnl 
4370 dnl Get the cflags and libraries from the gtk-config script
4371 dnl
4372 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
4373             gtk_config_prefix="$withval", gtk_config_prefix="")
4374 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
4375             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
4376 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
4377                     , enable_gtktest=yes)
4378
4379   for module in . $4
4380   do
4381       case "$module" in
4382          gthread) 
4383              gtk_config_args="$gtk_config_args gthread"
4384          ;;
4385       esac
4386   done
4387
4388   if test x$gtk_config_exec_prefix != x ; then
4389      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
4390      if test x${GTK_CONFIG+set} != xset ; then
4391         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
4392      fi
4393   fi
4394   if test x$gtk_config_prefix != x ; then
4395      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
4396      if test x${GTK_CONFIG+set} != xset ; then
4397         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
4398      fi
4399   fi
4400
4401   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
4402   min_gtk_version=ifelse([$1], ,0.99.7,$1)
4403   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
4404   no_gtk=""
4405   if test "$GTK_CONFIG" = "no" ; then
4406     no_gtk=yes
4407   else
4408     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
4409     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
4410     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
4411            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
4412     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
4413            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
4414     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
4415            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
4416     if test "x$enable_gtktest" = "xyes" ; then
4417       ac_save_CFLAGS="$CFLAGS"
4418       ac_save_LIBS="$LIBS"
4419       CFLAGS="$CFLAGS $GTK_CFLAGS"
4420       LIBS="$GTK_LIBS $LIBS"
4421 dnl
4422 dnl Now check if the installed GTK is sufficiently new. (Also sanity
4423 dnl checks the results of gtk-config to some extent
4424 dnl
4425       rm -f conf.gtktest
4426       AC_TRY_RUN([
4427 #include <gtk/gtk.h>
4428 #include <stdio.h>
4429 #include <stdlib.h>
4430
4431 int 
4432 main ()
4433 {
4434   int major, minor, micro;
4435   char *tmp_version;
4436
4437   system ("touch conf.gtktest");
4438
4439   /* HP/UX 9 (%@#!) writes to sscanf strings */
4440   tmp_version = g_strdup("$min_gtk_version");
4441   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
4442      printf("%s, bad version string\n", "$min_gtk_version");
4443      exit(1);
4444    }
4445
4446   if ((gtk_major_version != $gtk_config_major_version) ||
4447       (gtk_minor_version != $gtk_config_minor_version) ||
4448       (gtk_micro_version != $gtk_config_micro_version))
4449     {
4450       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
4451              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
4452              gtk_major_version, gtk_minor_version, gtk_micro_version);
4453       printf ("*** was found! If gtk-config was correct, then it is best\n");
4454       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
4455       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
4456       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
4457       printf("*** required on your system.\n");
4458       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
4459       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
4460       printf("*** before re-running configure\n");
4461     } 
4462 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
4463   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
4464            (gtk_minor_version != GTK_MINOR_VERSION) ||
4465            (gtk_micro_version != GTK_MICRO_VERSION))
4466     {
4467       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
4468              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
4469       printf("*** library (version %d.%d.%d)\n",
4470              gtk_major_version, gtk_minor_version, gtk_micro_version);
4471     }
4472 #endif /* defined (GTK_MAJOR_VERSION) ... */
4473   else
4474     {
4475       if ((gtk_major_version > major) ||
4476         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
4477         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
4478       {
4479         return 0;
4480        }
4481      else
4482       {
4483         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
4484                gtk_major_version, gtk_minor_version, gtk_micro_version);
4485         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
4486                major, minor, micro);
4487         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
4488         printf("***\n");
4489         printf("*** If you have already installed a sufficiently new version, this error\n");
4490         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
4491         printf("*** being found. The easiest way to fix this is to remove the old version\n");
4492         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
4493         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
4494         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
4495         printf("*** so that the correct libraries are found at run-time))\n");
4496       }
4497     }
4498   return 1;
4499 }
4500 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
4501        CFLAGS="$ac_save_CFLAGS"
4502        LIBS="$ac_save_LIBS"
4503      fi
4504   fi
4505   if test "x$no_gtk" = x ; then
4506      AC_MSG_RESULT(yes)
4507      ifelse([$2], , :, [$2])     
4508   else
4509      AC_MSG_RESULT(no)
4510      if test "$GTK_CONFIG" = "no" ; then
4511        echo "*** The gtk-config script installed by GTK could not be found"
4512        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
4513        echo "*** your path, or set the GTK_CONFIG environment variable to the"
4514        echo "*** full path to gtk-config."
4515      else
4516        if test -f conf.gtktest ; then
4517         :
4518        else
4519           echo "*** Could not run GTK test program, checking why..."
4520           CFLAGS="$CFLAGS $GTK_CFLAGS"
4521           LIBS="$LIBS $GTK_LIBS"
4522           AC_TRY_LINK([
4523 #include <gtk/gtk.h>
4524 #include <stdio.h>
4525 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
4526         [ echo "*** The test program compiled, but did not run. This usually means"
4527           echo "*** that the run-time linker is not finding GTK or finding the wrong"
4528           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
4529           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
4530           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
4531           echo "*** is required on your system"
4532           echo "***"
4533           echo "*** If you have an old version installed, it is best to remove it, although"
4534           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
4535           echo "***"
4536           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
4537           echo "*** came with the system with the command"
4538           echo "***"
4539           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
4540         [ echo "*** The test program failed to compile or link. See the file config.log for the"
4541           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
4542           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
4543           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
4544           CFLAGS="$ac_save_CFLAGS"
4545           LIBS="$ac_save_LIBS"
4546        fi
4547      fi
4548      GTK_CFLAGS=""
4549      GTK_LIBS=""
4550      ifelse([$3], , :, [$3])
4551   fi
4552   AC_SUBST(GTK_CFLAGS)
4553   AC_SUBST(GTK_LIBS)
4554   rm -f conf.gtktest
4555 ])
4556 # aclocal-include.m4
4557
4558 # This macro adds the name macrodir to the set of directories
4559 # that `aclocal' searches for macros.  
4560
4561 # serial 1
4562
4563 dnl AM_ACLOCAL_INCLUDE(macrodir)
4564 AC_DEFUN([AM_ACLOCAL_INCLUDE],
4565 [
4566         AM_CONDITIONAL(INSIDE_GNOME_COMMON, test x = y)
4567
4568         test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
4569
4570         for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done
4571 ])
4572 # Configure paths for GNOME-PRINT
4573 # Chris Lahey   99-2-5
4574 # stolen from Manish Singh again
4575 # stolen back from Frank Belew
4576 # stolen from Manish Singh
4577 # Shamelessly stolen from Owen Taylor
4578
4579 dnl AM_PATH_GNOME_PRINT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
4580 dnl Test for GNOME-PRINT, and define GNOME_PRINT_CFLAGS and GNOME_PRINT_LIBS
4581 dnl
4582 AC_DEFUN(AM_PATH_GNOME_PRINT,
4583 [dnl 
4584 dnl Get the cflags and libraries from the gnome-config script
4585 dnl
4586 AC_ARG_WITH(gnome-print-prefix,[  --with-gnome-print-prefix=PFX   Prefix where GNOME-PRINT is installed (optional)],
4587             gnome_print_prefix="$withval", gnome_print_prefix="")
4588 AC_ARG_WITH(gnome-print-exec-prefix,[  --with-gnome-print-exec-prefix=PFX Exec prefix where GNOME-PRINT is installed (optional)],
4589             gnome_print_exec_prefix="$withval", gnome_print_exec_prefix="")
4590 AC_ARG_ENABLE(gnome-printtest, [  --disable-gnome-printtest       Do not try to compile and run a test GNOME-PRINT program],
4591                     , enable_gnome_printtest=yes)
4592
4593   if test x$gnome_print_exec_prefix != x ; then
4594      gnome_print_args="$gnome_print_args --exec-prefix=$gnome_print_exec_prefix"
4595      if test x${GNOME_CONFIG+set} != xset ; then
4596         GNOME_CONFIG=$gnome_print_exec_prefix/bin/gnome-config
4597      fi
4598   fi
4599   if test x$gnome_print_prefix != x ; then
4600      gnome_print_args="$gnome_print_args --prefix=$gnome_print_prefix"
4601      if test x${GNOME_CONFIG+set} != xset ; then
4602         GNOME_CONFIG=$gnome_print_prefix/bin/gnome-config
4603      fi
4604   fi
4605
4606   AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
4607   min_gnome_print_version=ifelse([$1], ,0.1.0,$1)
4608   AC_MSG_CHECKING(for GNOME-PRINT - version >= $min_gnome_print_version)
4609   no_gnome_print=""
4610   if test "$GNOME_CONFIG" = "no" ; then
4611     no_gnome_print=yes
4612   else
4613     GNOME_PRINT_CFLAGS=`$GNOME_CONFIG $gnome_printconf_args --cflags print`
4614     GNOME_PRINT_LIBS=`$GNOME_CONFIG $gnome_printconf_args --libs print`
4615
4616     gnome_print_major_version=`$GNOME_CONFIG $gnome_print_args --version | \
4617            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
4618     gnome_print_minor_version=`$GNOME_CONFIG $gnome_print_args --version | \
4619            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
4620     gnome_print_micro_version=`$GNOME_CONFIG $gnome_print_config_args --version | \
4621            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
4622     if test "x$enable_gnome_printtest" = "xyes" ; then
4623       ac_save_CFLAGS="$CFLAGS"
4624       ac_save_LIBS="$LIBS"
4625       CFLAGS="$CFLAGS $GNOME_PRINT_CFLAGS"
4626       LIBS="$LIBS $GNOME_PRINT_LIBS"
4627 dnl
4628 dnl Now check if the installed GNOME-PRINT is sufficiently new. (Also sanity
4629 dnl checks the results of gnome-config to some extent
4630 dnl
4631       rm -f conf.gnome_printtest
4632       AC_TRY_RUN([
4633 #include <stdio.h>
4634 #include <stdlib.h>
4635 #include <string.h>
4636 #include <libgnomeprint/gnome-print.h>
4637
4638 static char*
4639 my_strdup (char *str)
4640 {
4641   char *new_str;
4642   
4643   if (str)
4644     {
4645       new_str = malloc ((strlen (str) + 1) * sizeof(char));
4646       strcpy (new_str, str);
4647     }
4648   else
4649     new_str = NULL;
4650   
4651   return new_str;
4652 }
4653
4654 int main ()
4655 {
4656   int major, minor, micro;
4657   char *tmp_version;
4658
4659   system ("touch conf.gnome_printtest");
4660
4661   /* HP/UX 9 (%@#!) writes to sscanf strings */
4662   tmp_version = my_strdup("$min_gnome_print_version");
4663   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
4664      printf("%s, bad version string\n", "$min_gnome_print_version");
4665      exit(1);
4666    }
4667   return 0;
4668 #if 0
4669    if (($gnome_print_major_version > major) ||
4670       (($gnome_print_major_version == major) && ($gnome_print_minor_version > minor)) ||
4671       (($gnome_print_major_version == major) && ($gnome_print_minor_version == minor) && ($gnome_print_micro_version >= micro)))
4672     {
4673       return 0;
4674     }
4675   else
4676     {
4677       printf("\n*** 'gnome-config print --version' returned %d.%d.%d, but the minimum version\n", $gnome_print_major_version, $gnome_print_minor_version, $gnome_print_micro_version);
4678       printf("*** of GNOME-PRINT required is %d.%d.%d. If gnome-config is correct, then it is\n", major, minor, micro);
4679       printf("*** best to upgrade to the required version.\n");
4680       printf("*** If gnome-config was wrong, set the environment variable GNOME_CONFIG\n");
4681       printf("*** to point to the correct copy of gnome-config, and remove the file\n");
4682       printf("*** config.cache before re-running configure\n");
4683       return 1;
4684     }
4685 #endif
4686 }
4687
4688 ],, no_gnome_print=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
4689        CFLAGS="$ac_save_CFLAGS"
4690        LIBS="$ac_save_LIBS"
4691      fi
4692   fi
4693   if test "x$no_gnome_print" = x ; then
4694      AC_MSG_RESULT(yes)
4695      ifelse([$2], , :, [$2])     
4696   else
4697      AC_MSG_RESULT(no)
4698      if test "$GNOME_CONFIG" = "no" ; then
4699        echo "*** The gnome-config script installed by GNOME-LIBS could not be found"
4700        echo "*** If GNOME-PRINT was installed in PREFIX, make sure PREFIX/bin is in"
4701        echo "*** your path, or set the GNOME_CONFIG environment variable to the"
4702        echo "*** full path to gnome-config."
4703      else
4704        if test -f conf.gnome_printtest ; then
4705         :
4706        else
4707           echo "*** Could not run GNOME-PRINT test program, checking why..."
4708           CFLAGS="$CFLAGS $GNOME_PRINT_CFLAGS"
4709           LIBS="$LIBS $GNOME_PRINT_LIBS"
4710           AC_TRY_LINK([
4711 #include <stdio.h>
4712 #include <libgnomeprint/gnome-print.h>
4713 ],      [ return 0; ],
4714         [ echo "*** The test program compiled, but did not run. This usually means"
4715           echo "*** that the run-time linker is not finding GNOME-PRINT or finding the wrong"
4716           echo "*** version of GNOME-PRINT. If it is not finding GNOME-PRINT, you'll need to set your"
4717           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
4718           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
4719           echo "*** is required on your system"
4720           echo "***"
4721           echo "*** If you have an old version installed, it is best to remove it, although"
4722           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
4723         [ echo "*** The test program failed to compile or link. See the file config.log for the"
4724           echo "*** exact error that occured. This usually means GNOME-PRINT was incorrectly installed"
4725           echo "*** or that you have moved GNOME-PRINT since it was installed. In the latter case, you"
4726           echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ])
4727           CFLAGS="$ac_save_CFLAGS"
4728           LIBS="$ac_save_LIBS"
4729        fi
4730      fi
4731      GNOME_PRINT_CFLAGS=""
4732      GNOME_PRINT_LIBS=""
4733      ifelse([$3], , :, [$3])
4734   fi
4735   AC_SUBST(GNOME_PRINT_CFLAGS)
4736   AC_SUBST(GNOME_PRINT_LIBS)
4737   rm -f conf.gnome_printtest
4738 ])
4739
4740 AC_DEFUN([GNOME_PRINT_CHECK], [
4741         AM_PATH_GNOME_PRINT(0.1.0,,[AC_MSG_ERROR(GNOME-PRINT not found)])
4742 ])
4743 dnl GNOME_COMPILE_WARNINGS
4744 dnl Turn on many useful compiler warnings
4745 dnl For now, only works on GCC
4746 AC_DEFUN([GNOME_COMPILE_WARNINGS],[
4747   AC_ARG_ENABLE(compile-warnings, 
4748     [  --enable-compile-warnings=[no/minimum/yes]       Turn on compiler warnings.],,enable_compile_warnings=minimum)
4749
4750   AC_MSG_CHECKING(what warning flags to pass to the C compiler)
4751   warnCFLAGS=
4752   if test "x$GCC" != xyes; then
4753     enable_compile_warnings=no
4754   fi
4755
4756   if test "x$enable_compile_warnings" != "xno"; then
4757     if test "x$GCC" = "xyes"; then
4758       case " $CFLAGS " in
4759       *[\ \     ]-Wall[\ \      ]*) ;;
4760       *) warnCFLAGS="-Wall -Wunused" ;;
4761       esac
4762
4763       ## -W is not all that useful.  And it cannot be controlled
4764       ## with individual -Wno-xxx flags, unlike -Wall
4765       if test "x$enable_compile_warnings" = "xyes"; then
4766         warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations"
4767       fi
4768     fi
4769   fi
4770   AC_MSG_RESULT($warnCFLAGS)
4771
4772   AC_ARG_ENABLE(iso-c,
4773     [  --enable-iso-c          Try to warn if code is not ISO C ],,
4774     enable_iso_c=no)
4775
4776   AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
4777   complCFLAGS=
4778   if test "x$enable_iso_c" != "xno"; then
4779     if test "x$GCC" = "xyes"; then
4780       case " $CFLAGS " in
4781       *[\ \     ]-ansi[\ \      ]*) ;;
4782       *) complCFLAGS="$complCFLAGS -ansi" ;;
4783       esac
4784
4785       case " $CFLAGS " in
4786       *[\ \     ]-pedantic[\ \  ]*) ;;
4787       *) complCFLAGS="$complCFLAGS -pedantic" ;;
4788       esac
4789     fi
4790   fi
4791   AC_MSG_RESULT($complCFLAGS)
4792   if test "x$cflags_set" != "xyes"; then
4793     CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
4794     cflags_set=yes
4795     AC_SUBST(cflags_set)
4796   fi
4797 ])
4798
4799 dnl For C++, do basically the same thing.
4800
4801 AC_DEFUN([GNOME_CXX_WARNINGS],[
4802   AC_ARG_ENABLE(cxx-warnings, 
4803     [  --enable-cxx-warnings=[no/minimum/yes]   Turn on compiler warnings.],,enable_cxx_warnings=minimum)
4804
4805   AC_MSG_CHECKING(what warning flags to pass to the C++ compiler)
4806   warnCXXFLAGS=
4807   if test "x$GCC" != xyes; then
4808     enable_compile_warnings=no
4809   fi
4810   if test "x$enable_cxx_warnings" != "xno"; then
4811     if test "x$GCC" = "xyes"; then
4812       case " $CXXFLAGS " in
4813       *[\ \     ]-Wall[\ \      ]*) ;;
4814       *) warnCXXFLAGS="-Wall -Wno-unused" ;;
4815       esac
4816
4817       ## -W is not all that useful.  And it cannot be controlled
4818       ## with individual -Wno-xxx flags, unlike -Wall
4819       if test "x$enable_cxx_warnings" = "xyes"; then
4820         warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wshadow -Woverloaded-virtual"
4821       fi
4822     fi
4823   fi
4824   AC_MSG_RESULT($warnCXXFLAGS)
4825
4826    AC_ARG_ENABLE(iso-cxx,
4827      [  --enable-iso-cxx          Try to warn if code is not ISO C++ ],,
4828      enable_iso_cxx=no)
4829
4830    AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler)
4831    complCXXFLAGS=
4832    if test "x$enable_iso_cxx" != "xno"; then
4833      if test "x$GCC" = "xyes"; then
4834       case " $CXXFLAGS " in
4835       *[\ \     ]-ansi[\ \      ]*) ;;
4836       *) complCXXFLAGS="$complCXXFLAGS -ansi" ;;
4837       esac
4838
4839       case " $CXXFLAGS " in
4840       *[\ \     ]-pedantic[\ \  ]*) ;;
4841       *) complCXXFLAGS="$complCXXFLAGS -pedantic" ;;
4842       esac
4843      fi
4844    fi
4845   AC_MSG_RESULT($complCXXFLAGS)
4846   if test "x$cxxflags_set" != "xyes"; then
4847     CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS"
4848     cxxflags_set=yes
4849     AC_SUBST(cxxflags_set)
4850   fi
4851 ])
4852 dnl
4853 dnl And better, use gthreads instead...
4854 dnl
4855
4856 AC_DEFUN([GNOME_PTHREAD_CHECK],[
4857         PTHREAD_LIB=""
4858         AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
4859                 [AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
4860                     [AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
4861                         [AC_CHECK_FUNC(pthread_create)]
4862                     )]
4863                 )]
4864         )
4865         AC_SUBST(PTHREAD_LIB)
4866         AC_PROVIDE([GNOME_PTHREAD_CHECK])
4867 ])
4868 dnl Curses detection: Munged from Midnight Commander's configure.in
4869 dnl
4870 dnl What it does:
4871 dnl =============
4872 dnl
4873 dnl - Determine which version of curses is installed on your system
4874 dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
4875 dnl   symbols 
4876 dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
4877 dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
4878 dnl   Makefile.in's
4879 dnl - Modify the following configure variables (these are the only
4880 dnl   curses.m4 variables you can access from within configure.in)
4881 dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
4882 dnl                       an ncurses.h that's been renamed to curses.h
4883 dnl                       is found.
4884 dnl   CURSES_LIBS       - sets -L and -l's appropriately
4885 dnl   CFLAGS            - if --with-sco, add -D_SVID3 
4886 dnl   has_curses        - exports result of tests to rest of configure
4887 dnl
4888 dnl Usage:
4889 dnl ======
4890 dnl 1) Add lines indicated below to acconfig.h
4891 dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
4892 dnl 3) Instead of #include <curses.h> you should use the following to
4893 dnl    properly locate ncurses or curses header file
4894 dnl
4895 dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
4896 dnl    #include <ncurses.h>
4897 dnl    #else
4898 dnl    #include <curses.h>
4899 dnl    #endif
4900 dnl
4901 dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
4902 dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
4903 dnl
4904 dnl Notes with automake:
4905 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
4906 dnl   configure.in
4907 dnl - your Makefile.am can look something like this
4908 dnl   -----------------------------------------------
4909 dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
4910 dnl   if HAS_CURSES
4911 dnl   CURSES_TARGETS=name_of_curses_prog
4912 dnl   endif
4913 dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
4914 dnl   other_programs_SOURCES = blah blah blah
4915 dnl   name_of_curses_prog_SOURCES = blah blah blah
4916 dnl   other_programs_LDADD = blah
4917 dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
4918 dnl   -----------------------------------------------
4919 dnl
4920 dnl
4921 dnl The following lines should be added to acconfig.h:
4922 dnl ==================================================
4923 dnl
4924 dnl /*=== Curses version detection defines ===*/
4925 dnl /* Found some version of curses that we're going to use */
4926 dnl #undef HAS_CURSES
4927 dnl    
4928 dnl /* Use SunOS SysV curses? */
4929 dnl #undef USE_SUNOS_CURSES
4930 dnl 
4931 dnl /* Use old BSD curses - not used right now */
4932 dnl #undef USE_BSD_CURSES
4933 dnl 
4934 dnl /* Use SystemV curses? */
4935 dnl #undef USE_SYSV_CURSES
4936 dnl 
4937 dnl /* Use Ncurses? */
4938 dnl #undef USE_NCURSES
4939 dnl 
4940 dnl /* If you Curses does not have color define this one */
4941 dnl #undef NO_COLOR_CURSES
4942 dnl 
4943 dnl /* Define if you want to turn on SCO-specific code */
4944 dnl #undef SCO_FLAVOR
4945 dnl 
4946 dnl /* Set to reflect version of ncurses *
4947 dnl  *   0 = version 1.*
4948 dnl  *   1 = version 1.9.9g
4949 dnl  *   2 = version 4.0/4.1 */
4950 dnl #undef NCURSES_970530
4951 dnl
4952 dnl /*=== End new stuff for acconfig.h ===*/
4953 dnl 
4954
4955
4956 AC_DEFUN(AC_CHECK_CURSES,[
4957         search_ncurses=true
4958         screen_manager=""
4959         has_curses=false
4960
4961         CFLAGS=${CFLAGS--O}
4962
4963         AC_SUBST(CURSES_LIBS)
4964         AC_SUBST(CURSES_INCLUDEDIR)
4965
4966         AC_ARG_WITH(sco,
4967           [  --with-sco              Use this to turn on SCO-specific code],[
4968           if test x$withval = xyes; then
4969                 AC_DEFINE(SCO_FLAVOR)
4970                 CFLAGS="$CFLAGS -D_SVID3"
4971           fi
4972         ])
4973
4974         AC_ARG_WITH(sunos-curses,
4975           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
4976           if test x$withval = xyes; then
4977                 AC_USE_SUNOS_CURSES
4978           fi
4979         ])
4980
4981         AC_ARG_WITH(osf1-curses,
4982           [  --with-osf1-curses      Used to force OSF/1 curses],[
4983           if test x$withval = xyes; then
4984                 AC_USE_OSF1_CURSES
4985           fi
4986         ])
4987
4988         AC_ARG_WITH(vcurses,
4989           [  --with-vcurses[=incdir] Used to force SysV curses],
4990           if test x$withval != xyes; then
4991                 CURSES_INCLUDEDIR="-I$withval"
4992           fi
4993           AC_USE_SYSV_CURSES
4994         )
4995
4996         AC_ARG_WITH(ncurses,
4997           [  --with-ncurses[=dir]  Compile with ncurses/locate base dir],
4998           if test x$withval = xno ; then
4999                 search_ncurses=false
5000           elif test x$withval != xyes ; then
5001                 CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
5002                 CURSES_INCLUDEDIR="-I$withval/include"
5003                 search_ncurses=false
5004                 screen_manager="ncurses"
5005                 AC_DEFINE(USE_NCURSES)
5006                 AC_DEFINE(HAS_CURSES)
5007                 has_curses=true
5008           fi
5009         )
5010
5011         if $search_ncurses
5012         then
5013                 AC_SEARCH_NCURSES()
5014         fi
5015
5016
5017 ])
5018
5019
5020 AC_DEFUN(AC_USE_SUNOS_CURSES, [
5021         search_ncurses=false
5022         screen_manager="SunOS 4.x /usr/5include curses"
5023         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
5024         AC_DEFINE(USE_SUNOS_CURSES)
5025         AC_DEFINE(HAS_CURSES)
5026         has_curses=true
5027         AC_DEFINE(NO_COLOR_CURSES)
5028         AC_DEFINE(USE_SYSV_CURSES)
5029         CURSES_INCLUDEDIR="-I/usr/5include"
5030         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
5031         AC_MSG_RESULT(Please note that some screen refreshs may fail)
5032 ])
5033
5034 AC_DEFUN(AC_USE_OSF1_CURSES, [
5035        AC_MSG_RESULT(Using OSF1 curses)
5036        search_ncurses=false
5037        screen_manager="OSF1 curses"
5038        AC_DEFINE(HAS_CURSES)
5039        has_curses=true
5040        AC_DEFINE(NO_COLOR_CURSES)
5041        AC_DEFINE(USE_SYSV_CURSES)
5042        CURSES_LIBS="-lcurses"
5043 ])
5044
5045 AC_DEFUN(AC_USE_SYSV_CURSES, [
5046         AC_MSG_RESULT(Using SysV curses)
5047         AC_DEFINE(HAS_CURSES)
5048         has_curses=true
5049         AC_DEFINE(USE_SYSV_CURSES)
5050         search_ncurses=false
5051         screen_manager="SysV/curses"
5052         CURSES_LIBS="-lcurses"
5053 ])
5054
5055 dnl AC_ARG_WITH(bsd-curses,
5056 dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
5057 dnl     search_ncurses=false
5058 dnl     screen_manager="Ultrix/cursesX"
5059 dnl     if test $system = ULTRIX
5060 dnl     then
5061 dnl         THIS_CURSES=cursesX
5062 dnl        else
5063 dnl         THIS_CURSES=curses
5064 dnl     fi
5065 dnl
5066 dnl     CURSES_LIBS="-l$THIS_CURSES -ltermcap"
5067 dnl     AC_DEFINE(HAS_CURSES)
5068 dnl     has_curses=true
5069 dnl     AC_DEFINE(USE_BSD_CURSES)
5070 dnl     AC_MSG_RESULT(Please note that some screen refreshs may fail)
5071 dnl     AC_WARN(Use of the bsdcurses extension has some)
5072 dnl     AC_WARN(display/input problems.)
5073 dnl     AC_WARN(Reconsider using xcurses)
5074 dnl)
5075
5076         
5077 dnl
5078 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
5079 dnl
5080 AC_DEFUN(AC_NCURSES, [
5081     if $search_ncurses
5082     then
5083         if test -f $1/$2
5084         then
5085             AC_MSG_RESULT(Found ncurses on $1/$2)
5086             CURSES_LIBS="$3"
5087             CURSES_INCLUDEDIR="$4"
5088             search_ncurses=false
5089             screen_manager=$5
5090             AC_DEFINE(HAS_CURSES)
5091             has_curses=true
5092             AC_DEFINE(USE_NCURSES)
5093         fi
5094     fi
5095 ])
5096
5097 AC_DEFUN(AC_SEARCH_NCURSES, [
5098     AC_CHECKING("location of ncurses.h file")
5099
5100     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
5101     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
5102     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
5103     AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
5104
5105     AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
5106
5107     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
5108
5109     dnl
5110     dnl We couldn't find ncurses, try SysV curses
5111     dnl
5112     if $search_ncurses 
5113     then
5114         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
5115             AC_USE_SYSV_CURSES)
5116         AC_EGREP_CPP(USE_NCURSES,[
5117 #include <curses.h>
5118 #ifdef __NCURSES_H
5119 #undef USE_NCURSES
5120 USE_NCURSES
5121 #endif
5122 ],[
5123         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
5124         AC_DEFINE(HAS_CURSES)
5125         has_curses=true
5126         AC_DEFINE(USE_NCURSES)
5127         search_ncurses=false
5128         screen_manager="ncurses installed as curses"
5129 ])
5130     fi
5131
5132     dnl
5133     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
5134     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
5135     dnl should be replaced by a more fine grained selection routine
5136     dnl
5137     if $search_ncurses
5138     then
5139         if test -f /usr/5include/curses.h
5140         then
5141             AC_USE_SUNOS_CURSES
5142         fi
5143     else
5144         # check for ncurses version, to properly ifdef mouse-fix
5145         AC_MSG_CHECKING(for ncurses version)
5146         ncurses_version=unknown
5147 cat > conftest.$ac_ext <<EOF
5148 [#]line __oline__ "configure"
5149 #include "confdefs.h"
5150 #ifdef RENAMED_NCURSES
5151 #include <curses.h>
5152 #else
5153 #include <ncurses.h>
5154 #endif
5155 #undef VERSION
5156 VERSION:NCURSES_VERSION
5157 EOF
5158         if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
5159   egrep "VERSION:" >conftest.out 2>&1; then
5160 changequote(,)dnl
5161             ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
5162 changequote([,])dnl
5163         fi
5164         rm -rf conftest*
5165         AC_MSG_RESULT($ncurses_version)
5166         case "$ncurses_version" in
5167 changequote(,)dnl
5168         4.[01])
5169 changequote([,])dnl
5170             AC_DEFINE(NCURSES_970530,2)
5171             ;;
5172         1.9.9g)
5173             AC_DEFINE(NCURSES_970530,1)
5174             ;;
5175         1*)
5176             AC_DEFINE(NCURSES_970530,0)
5177             ;;
5178         esac
5179     fi
5180 ])
5181
5182
5183
5184
5185
5186 dnl GNOME_SUPPORT_CHECKS
5187 dnl    Check for various support functions needed by the standard
5188 dnl    Gnome libraries.  Sets LIBOBJS, might define some macros.
5189 dnl    This should only be used when building the Gnome libs; 
5190 dnl    Gnome clients should not need this macro.
5191 AC_DEFUN([GNOME_SUPPORT_CHECKS],[
5192   # we need an `awk' to build `gnomesupport.h'
5193   AC_REQUIRE([AC_PROG_AWK])
5194
5195   # this should go away soon
5196   need_gnome_support=yes
5197
5198   save_LIBOBJS="$LIBOBJS"
5199   LIBOBJS=
5200
5201   AC_CHECK_FUNCS(getopt_long,,LIBOBJS="$LIBOBJS getopt.o getopt1.o")
5202
5203   # for `scandir'
5204   AC_HEADER_DIRENT
5205
5206   # copied from `configure.in' of `libiberty'
5207   vars="program_invocation_short_name program_invocation_name sys_errlist"
5208   for v in $vars; do
5209     AC_MSG_CHECKING([for $v])
5210     AC_CACHE_VAL(gnome_cv_var_$v,
5211       [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
5212                    [eval "gnome_cv_var_$v=yes"],
5213                    [eval "gnome_cv_var_$v=no"])])
5214     if eval "test \"`echo '$gnome_cv_var_'$v`\" = yes"; then
5215       AC_MSG_RESULT(yes)
5216       n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
5217       AC_DEFINE_UNQUOTED($n)
5218     else
5219       AC_MSG_RESULT(no)
5220     fi
5221   done
5222
5223   AC_REPLACE_FUNCS(memmove mkstemp scandir strcasecmp strerror strndup strnlen)
5224   AC_REPLACE_FUNCS(strtok_r strtod strtol strtoul vasprintf vsnprintf)
5225
5226   AC_CHECK_FUNCS(realpath,,LIBOBJS="$LIBOBJS canonicalize.o")
5227
5228   # to include `error.c' error.c has some HAVE_* checks
5229   AC_CHECK_FUNCS(vprintf doprnt strerror_r)
5230   AM_FUNC_ERROR_AT_LINE
5231
5232   # This is required if we declare setreuid () and setregid ().
5233   AC_TYPE_UID_T
5234
5235   # see if we need to declare some functions.  Solaris is notorious for
5236   # putting functions into the `libc' but not listing them in the headers
5237   AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h dirent.h)
5238   GCC_NEED_DECLARATIONS(gethostname setreuid setregid getpagesize)
5239   GCC_NEED_DECLARATION(scandir,[
5240 #ifdef HAVE_DIRENT_H
5241 #include <dirent.h>
5242 #endif
5243 ])
5244
5245   # Turn our LIBOBJS into libtool objects.  This is gross, but it
5246   # requires changes to autoconf before it goes away.
5247   LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'`
5248   AC_SUBST(need_gnome_support)
5249   AC_SUBST(LTLIBOBJS)
5250
5251   LIBOBJS="$save_LIBOBJS"
5252   AM_CONDITIONAL(BUILD_GNOME_SUPPORT, test "$need_gnome_support" = yes)
5253 ])
5254 # Configure paths for Bonobo
5255 # Miguel de Icaza, 99-04-12
5256 # Stolen from Chris Lahey       99-2-5
5257 # stolen from Manish Singh again
5258 # stolen back from Frank Belew
5259 # stolen from Manish Singh
5260 # Shamelessly stolen from Owen Taylor
5261
5262 dnl AM_PATH_BONOBO ([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5263 dnl Test for Bonobo, and define BONOBO_CFLAGS and BONOBO_LIBS
5264 dnl
5265 AC_DEFUN([AM_PATH_BONOBO],
5266 [
5267 dnl 
5268 dnl Get the cflags and libraries from the gnome-config script
5269 dnl
5270 AC_ARG_WITH(bonobo-prefix,[  --with-bonobo-prefix=PFX   Prefix where Bonobo is installed (optional)],
5271             bonobo_prefix="$withval", bonobo_prefix="")
5272 AC_ARG_WITH(bonobo-exec-prefix,[  --with-bonobo-exec-prefix=PFX Exec prefix where Bonobo is installed (optional)],
5273             bonobo_exec_prefix="$withval", bonobo_exec_prefix="")
5274 AC_ARG_ENABLE(bonobotest, [  --disable-bonobotest       Do not try to compile and run a test Bonobo program],
5275                     , enable_bonobotest=yes)
5276
5277   if test x$bonobo_exec_prefix != x ; then
5278      bonobo_args="$bonobo_args --exec-prefix=$bonobo_exec_prefix"
5279      if test x${GNOME_CONFIG+set} != xset ; then
5280         GNOME_CONFIG=$bonobo_exec_prefix/bin/gnome-config
5281      fi
5282   fi
5283   if test x$bonobo_prefix != x ; then
5284      bonobo_args="$bonobo_args --prefix=$bonobo_prefix"
5285      if test x${GNOME_CONFIG+set} != xset ; then
5286         GNOME_CONFIG=$bonobo_prefix/bin/gnome-config
5287      fi
5288   fi
5289
5290   AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
5291   min_bonobo_version=ifelse([$1], ,0.1.0,$1)
5292   AC_MSG_CHECKING(for BONOBO - version >= $min_bonobo_version)
5293   no_bonobo=""
5294   if test "$GNOME_CONFIG" = "no" ; then
5295     no_bonobo=yes
5296   else
5297     BONOBO_CFLAGS=`$GNOME_CONFIG $bonoboconf_args --cflags bonobo`
5298     BONOBO_LIBS=`$GNOME_CONFIG $bonoboconf_args --libs bonobo`
5299
5300     bonobo_major_version=`$GNOME_CONFIG $bonobo_args --version | \
5301            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
5302     bonobo_minor_version=`$GNOME_CONFIG $bonobo_args --version | \
5303            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
5304     bonobo_micro_version=`$GNOME_CONFIG $bonobo_config_args --version | \
5305            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
5306     if test "x$enable_bonobotest" = "xyes" ; then
5307       ac_save_CFLAGS="$CFLAGS"
5308       ac_save_LIBS="$LIBS"
5309       CFLAGS="$CFLAGS $BONOBO_CFLAGS"
5310       LIBS="$LIBS $BONOBO_LIBS"
5311 dnl
5312 dnl Now check if the installed BONOBO is sufficiently new. (Also sanity
5313 dnl checks the results of gnome-config to some extent
5314 dnl
5315       rm -f conf.bonobotest
5316       AC_TRY_RUN([
5317 #include <stdio.h>
5318 #include <stdlib.h>
5319 #include <string.h>
5320 #include <bonobo.h>
5321
5322 static char*
5323 my_strdup (char *str)
5324 {
5325   char *new_str;
5326   
5327   if (str)
5328     {
5329       new_str = malloc ((strlen (str) + 1) * sizeof(char));
5330       strcpy (new_str, str);
5331     }
5332   else
5333     new_str = NULL;
5334   
5335   return new_str;
5336 }
5337
5338 int main ()
5339 {
5340   int major, minor, micro;
5341   char *tmp_version;
5342
5343   system ("touch conf.bonobotest");
5344   bonobo_object_get_type ();
5345   return 0;
5346 }
5347
5348 ],, no_bonobo=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
5349        CFLAGS="$ac_save_CFLAGS"
5350        LIBS="$ac_save_LIBS"
5351      fi
5352   fi
5353   if test "x$no_bonobo" = x ; then
5354      AC_MSG_RESULT(yes)
5355      ifelse([$2], , :, [$2])     
5356   else
5357      AC_MSG_RESULT(no)
5358      if test "$GNOME_CONFIG" = "no" ; then
5359        echo "*** The gnome-config script installed by GNOME-LIBS could not be found"
5360        echo "*** If BONOBO was installed in PREFIX, make sure PREFIX/bin is in"
5361        echo "*** your path, or set the GNOME_CONFIG environment variable to the"
5362        echo "*** full path to gnome-config."
5363      else
5364        if test -f conf.bonobotest ; then
5365         :
5366        else
5367           echo "*** Could not run BONOBO test program, checking why..."
5368           CFLAGS="$CFLAGS $BONOBO_CFLAGS"
5369           LIBS="$LIBS $BONOBO_LIBS"
5370           AC_TRY_LINK([
5371 #include <stdio.h>
5372 #include <bonobo/gnome-object.h>
5373 ],      [ return 0; ],
5374         [ echo "*** The test program compiled, but did not run. This usually means"
5375           echo "*** that the run-time linker is not finding BONOBO or finding the wrong"
5376           echo "*** version of BONOBO. If it is not finding BONOBO, you'll need to set your"
5377           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
5378           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
5379           echo "*** is required on your system"
5380           echo "***"
5381           echo "*** If you have an old version installed, it is best to remove it, although"
5382           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
5383         [ echo "*** The test program failed to compile or link. See the file config.log for the"
5384           echo "*** exact error that occured. This usually means BONOBO was incorrectly installed"
5385           echo "*** or that you have moved BONOBO since it was installed. In the latter case, you"
5386           echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ])
5387           CFLAGS="$ac_save_CFLAGS"
5388           LIBS="$ac_save_LIBS"
5389        fi
5390      fi
5391      BONOBO_CFLAGS=""
5392      BONOBO_LIBS=""
5393      ifelse([$3], , :, [$3])
5394   fi
5395   AC_SUBST(BONOBO_CFLAGS)
5396   AC_SUBST(BONOBO_LIBS)
5397   rm -f conf.bonobotest
5398 ])
5399
5400 AC_DEFUN([BONOBO_CHECK], [
5401         AM_PATH_BONOBO(0.1.0,,[AC_MSG_ERROR(BONOBO not found)])
5402 ])
5403
5404 dnl GNOME_UNDELFS_CHECKS
5405 dnl    Check for ext2fs undel support.
5406 dnl    Set shell variable ext2fs_undel to "yes" if we have it,
5407 dnl    "no" otherwise.  May define USE_EXT2FSLIB for cpp.
5408 dnl    Will set EXT2FS_UNDEL_LIBS to required libraries.
5409
5410 AC_DEFUN([GNOME_UNDELFS_CHECKS], [
5411   AC_CHECK_HEADERS(ext2fs/ext2fs.h linux/ext2_fs.h)
5412   ext2fs_undel=no
5413   EXT2FS_UNDEL_LIBS=
5414   if test x$ac_cv_header_ext2fs_ext2fs_h = xyes
5415   then
5416     if test x$ac_cv_header_linux_ext2_fs_h = xyes
5417     then
5418       AC_DEFINE(USE_EXT2FSLIB)
5419       ext2fs_undel=yes
5420       EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err"
5421     fi
5422   fi
5423 ])
5424 # gnome-common.m4
5425
5426 # This only for packages that are not in the GNOME CVS tree.
5427
5428 dnl GNOME_COMMON_INIT
5429
5430 AC_DEFUN([GNOME_COMMON_INIT],
5431 [
5432         GNOME_ACLOCAL_DIR=`$ACLOCAL --print-ac-dir`/gnome
5433         AC_SUBST(GNOME_ACLOCAL_DIR)
5434
5435         ACLOCAL="$ACLOCAL -I $GNOME_ACLOCAL_DIR"
5436 ])
5437
5438 dnl GNOME_VFS_CHECKS
5439 dnl   Check for various functions needed by libvfs.
5440 dnl   This has various effects:
5441 dnl     Sets GNOME_VFS_LIBS to libraries required
5442 dnl     Sets termnet  to true or false depending on whether it is required.
5443 dnl        If yes, defines USE_TERMNET.
5444 dnl     Sets vfs_flags to "pretty" list of vfs implementations we include.
5445 dnl     Sets shell variable use_vfs to yes (default, --with-vfs) or
5446 dnl        "no" (--without-vfs).
5447 dnl     Calls AC_SUBST(mcserv), which is either empty or "mcserv".
5448
5449 dnl Private define
5450 AC_DEFUN([GNOME_WITH_VFS],[
5451   dnl FIXME: network checks should probably be in their own macro.
5452   AC_CHECK_LIB(nsl, t_accept)
5453   AC_CHECK_LIB(socket, socket)
5454
5455   have_socket=no
5456   AC_CHECK_FUNCS(socket, have_socket=yes)
5457   if test $have_socket = no; then
5458     # socket is not in the default libraries.  See if it's in some other.
5459     for lib in bsd socket inet; do
5460       AC_CHECK_LIB($lib, socket, [
5461           LIBS="$LIBS -l$lib"
5462           have_socket=yes
5463           AC_DEFINE(HAVE_SOCKET)
5464           break])
5465     done
5466   fi
5467
5468   have_gethostbyname=no
5469   AC_CHECK_FUNC(gethostbyname, have_gethostbyname=yes)
5470   if test $have_gethostbyname = no; then
5471     # gethostbyname is not in the default libraries.  See if it's in some other.
5472     for lib in bsd socket inet; do
5473       AC_CHECK_LIB($lib, gethostbyname, [LIBS="$LIBS -l$lib"; have_gethostbyname=yes; break])
5474     done
5475   fi
5476
5477   vfs_flags="tarfs"
5478   use_net_code=false
5479   if test $have_socket = yes; then
5480       AC_STRUCT_LINGER
5481       AC_CHECK_FUNCS(pmap_set, , [
5482          AC_CHECK_LIB(rpc, pmap_set, [
5483            LIBS="-lrpc $LIBS"
5484           AC_DEFINE(HAVE_PMAP_SET)
5485           ])])
5486       AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport)
5487       dnl add for source routing support setsockopt
5488       AC_CHECK_HEADERS(rpc/pmap_clnt.h)
5489       vfs_flags="$vfs_flags, mcfs, ftpfs, fish"
5490       use_net_code=true
5491   fi
5492
5493   dnl
5494   dnl Samba support
5495   dnl
5496   smbfs=""
5497   SAMBAFILES=""
5498   AC_ARG_WITH(samba,
5499           [--with-samba             Support smb virtual file system],[
5500           if test "x$withval != xno"; then
5501                   AC_DEFINE(WITH_SMBFS)
5502                   vfs_flags="$vfs_flags, smbfs"
5503                   smbfs="smbfs.o"
5504                   SAMBAFILES="\$(SAMBAFILES)"
5505           fi
5506   ])
5507   AC_SUBST(smbfs)
5508   AC_SUBST(SAMBAFILES)
5509   
5510   dnl
5511   dnl The termnet support
5512   dnl
5513   termnet=false
5514   AC_ARG_WITH(termnet,
5515           [--with-termnet             If you want a termified net support],[
5516           if test x$withval = xyes; then
5517                   AC_DEFINE(USE_TERMNET)
5518                   termnet=true          
5519           fi
5520   ])
5521
5522   TERMNET=""
5523   AC_DEFINE(USE_VFS)
5524   if $use_net_code; then
5525      AC_DEFINE(USE_NETCODE)
5526   fi
5527   mcserv=
5528   if test $have_socket = yes; then
5529      mcserv="mcserv"
5530      if $termnet; then
5531         TERMNET="-ltermnet"
5532      fi
5533   fi
5534
5535   AC_SUBST(TERMNET)
5536   AC_SUBST(mcserv)
5537
5538 dnl FIXME:
5539 dnl GNOME_VFS_LIBS=
5540
5541 ])
5542
5543 AC_DEFUN([GNOME_VFS_CHECKS],[
5544         use_vfs=yes
5545         AC_ARG_WITH(vfs,
5546                 [--with-vfs                Compile with the VFS code],
5547                 use_vfs=$withval
5548         )
5549         case $use_vfs in
5550                 yes)    GNOME_WITH_VFS;;
5551                 no)     use_vfs=no;;
5552                 *)      use_vfs=no;;
5553                         dnl Should we issue a warning?
5554         esac
5555 ])
5556
5557
5558 dnl
5559 dnl GNOME_FILEUTILS_CHECKS
5560 dnl
5561 dnl checks that are needed for the diskusage applet.
5562 dnl
5563
5564 AC_DEFUN([GNOME_FILEUTILS_CHECKS],
5565 [       
5566 AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \
5567 mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \
5568 sys/filsys.h sys/fs_types.h sys/fs/s5param.h)
5569
5570 AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \
5571 getcwd getmntinfo gettimeofday isascii lchown \
5572 listmntent memcpy mkfifo strchr strerror strrchr vprintf)
5573
5574 dnl Set some defaults when cross-compiling
5575
5576 if test x$cross_compiling = xyes ; then
5577         case "$host_os" in
5578         linux*)
5579           fu_cv_sys_mounted_getmntent1=yes
5580           fu_cv_sys_stat_statfs2_bsize=yes
5581           ;;
5582         sunos*)
5583           fu_cv_sys_stat_statfs4=yes
5584           ;;
5585         freebsd*)
5586           fu_cv_sys_stat_statfs2_bsize=yes
5587           ;;
5588         osf*)
5589           fu_cv_sys_stat_statfs3_osf1=yes
5590           ;;
5591         esac
5592 fi
5593
5594 # Determine how to get the list of mounted filesystems.
5595 list_mounted_fs=
5596
5597 # If the getmntent function is available but not in the standard library,
5598 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
5599 AC_FUNC_GETMNTENT
5600
5601 # This test must precede the ones for getmntent because Unicos-9 is
5602 # reported to have the getmntent function, but its support is incompatible
5603 # with other getmntent implementations.
5604
5605 # NOTE: Normally, I wouldn't use a check for system type as I've done for
5606 # `CRAY' below since that goes against the whole autoconf philosophy.  But
5607 # I think there is too great a chance that some non-Cray system has a
5608 # function named listmntent to risk the false positive.
5609
5610 if test -z "$list_mounted_fs"; then
5611 # Cray UNICOS 9
5612 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
5613 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
5614 [fu_cv_sys_mounted_cray_listmntent=no
5615 AC_EGREP_CPP(yes,
5616 [#ifdef _CRAY
5617 yes
5618 #endif
5619 ], [test $ac_cv_func_listmntent = yes \
5620 && fu_cv_sys_mounted_cray_listmntent=yes]
5621 )
5622 ]
5623 )
5624 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
5625 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
5626 list_mounted_fs=found
5627 AC_DEFINE(MOUNTED_LISTMNTENT)
5628 fi
5629 fi
5630
5631 if test $ac_cv_func_getmntent = yes; then
5632
5633 # This system has the getmntent function.
5634 # Determine whether it's the one-argument variant or the two-argument one.
5635
5636 if test -z "$list_mounted_fs"; then
5637 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
5638 AC_MSG_CHECKING([for one-argument getmntent function])
5639 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
5640 [test $ac_cv_header_mntent_h = yes \
5641 && fu_cv_sys_mounted_getmntent1=yes \
5642 || fu_cv_sys_mounted_getmntent1=no])
5643 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
5644 if test $fu_cv_sys_mounted_getmntent1 = yes; then
5645 list_mounted_fs=found
5646 AC_DEFINE(MOUNTED_GETMNTENT1)
5647 fi
5648 fi
5649
5650 if test -z "$list_mounted_fs"; then
5651 # SVR4
5652 AC_MSG_CHECKING([for two-argument getmntent function])
5653 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
5654 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
5655 fu_cv_sys_mounted_getmntent2=yes,
5656 fu_cv_sys_mounted_getmntent2=no)])
5657 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
5658 if test $fu_cv_sys_mounted_getmntent2 = yes; then
5659 list_mounted_fs=found
5660 AC_DEFINE(MOUNTED_GETMNTENT2)
5661 fi
5662 fi
5663
5664 if test -z "$list_mounted_fs"; then
5665 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
5666 fi
5667
5668 fi
5669
5670 if test -z "$list_mounted_fs"; then
5671 # DEC Alpha running OSF/1.
5672 AC_MSG_CHECKING([for getfsstat function])
5673 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
5674 [AC_TRY_LINK([
5675 #include <sys/types.h>
5676 #include <sys/mount.h>
5677 #include <sys/fs_types.h>],
5678 [struct statfs *stats;
5679 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
5680 fu_cv_sys_mounted_getsstat=yes,
5681 fu_cv_sys_mounted_getsstat=no)])
5682 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
5683 if test $fu_cv_sys_mounted_getsstat = yes; then
5684 list_mounted_fs=found
5685 AC_DEFINE(MOUNTED_GETFSSTAT)
5686 fi
5687 fi
5688
5689 if test -z "$list_mounted_fs"; then
5690 # AIX.
5691 AC_MSG_CHECKING([for mntctl function and struct vmount])
5692 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
5693 [AC_TRY_CPP([#include <fshelp.h>],
5694 fu_cv_sys_mounted_vmount=yes,
5695 fu_cv_sys_mounted_vmount=no)])
5696 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
5697 if test $fu_cv_sys_mounted_vmount = yes; then
5698 list_mounted_fs=found
5699 AC_DEFINE(MOUNTED_VMOUNT)
5700 fi
5701 fi
5702
5703 if test -z "$list_mounted_fs"; then
5704 # SVR3
5705 AC_MSG_CHECKING([for FIXME existence of three headers])
5706 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
5707 [AC_TRY_CPP([
5708 #include <sys/statfs.h>
5709 #include <sys/fstyp.h>
5710 #include <mnttab.h>],
5711 fu_cv_sys_mounted_fread_fstyp=yes,
5712 fu_cv_sys_mounted_fread_fstyp=no)])
5713 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
5714 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
5715 list_mounted_fs=found
5716 AC_DEFINE(MOUNTED_FREAD_FSTYP)
5717 fi
5718 fi
5719
5720 if test -z "$list_mounted_fs"; then
5721 # 4.4BSD and DEC OSF/1.
5722 AC_MSG_CHECKING([for getmntinfo function])
5723 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
5724 [
5725 ok=
5726 if test $ac_cv_func_getmntinfo = yes; then
5727 AC_EGREP_HEADER(f_type;, sys/mount.h,
5728 ok=yes)
5729 fi
5730 test -n "$ok" \
5731 && fu_cv_sys_mounted_getmntinfo=yes \
5732 || fu_cv_sys_mounted_getmntinfo=no
5733 ])
5734 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
5735 if test $fu_cv_sys_mounted_getmntinfo = yes; then
5736 list_mounted_fs=found
5737 AC_DEFINE(MOUNTED_GETMNTINFO)
5738 fi
5739 fi
5740
5741 # FIXME: add a test for netbsd-1.1 here
5742
5743 if test -z "$list_mounted_fs"; then
5744 # Ultrix
5745 AC_MSG_CHECKING([for getmnt function])
5746 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
5747 [AC_TRY_CPP([
5748 #include <sys/fs_types.h>
5749 #include <sys/mount.h>],
5750 fu_cv_sys_mounted_getmnt=yes,
5751 fu_cv_sys_mounted_getmnt=no)])
5752 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
5753 if test $fu_cv_sys_mounted_getmnt = yes; then
5754 list_mounted_fs=found
5755 AC_DEFINE(MOUNTED_GETMNT)
5756 fi
5757 fi
5758
5759 if test -z "$list_mounted_fs"; then
5760 # SVR2
5761 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
5762 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
5763 [AC_TRY_CPP([#include <mnttab.h>],
5764 fu_cv_sys_mounted_fread=yes,
5765 fu_cv_sys_mounted_fread=no)])
5766 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
5767 if test $fu_cv_sys_mounted_fread = yes; then
5768 list_mounted_fs=found
5769 AC_DEFINE(MOUNTED_FREAD)
5770 fi
5771 fi
5772
5773 if test -z "$list_mounted_fs"; then
5774 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
5775 # FIXME -- no need to abort building the whole package
5776 # Can't build mountlist.c or anything that needs its functions
5777 fi
5778
5779 AC_CHECKING(how to get filesystem space usage)
5780 space=no
5781
5782 # Perform only the link test since it seems there are no variants of the
5783 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
5784 # because that got a false positive on SCO OSR5.  Adding the declaration
5785 # of a `struct statvfs' causes this test to fail (as it should) on such
5786 # systems.  That system is reported to work fine with STAT_STATFS4 which
5787 # is what it gets when this test fails.
5788 if test $space = no; then
5789 # SVR4
5790 AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
5791 [AC_TRY_LINK([#include <sys/types.h>
5792 #include <sys/statvfs.h>],
5793 [struct statvfs fsd; statvfs (0, &fsd);],
5794 fu_cv_sys_stat_statvfs=yes,
5795 fu_cv_sys_stat_statvfs=no)])
5796 if test $fu_cv_sys_stat_statvfs = yes; then
5797 space=yes
5798 AC_DEFINE(STAT_STATVFS)
5799 fi
5800 fi
5801
5802 if test $space = no; then
5803 # DEC Alpha running OSF/1
5804 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
5805 AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
5806 [AC_TRY_RUN([
5807 #include <sys/param.h>
5808 #include <sys/types.h>
5809 #include <sys/mount.h>
5810 main ()
5811 {
5812 struct statfs fsd;
5813 fsd.f_fsize = 0;
5814 exit (statfs (".", &fsd, sizeof (struct statfs)));
5815 }],
5816 fu_cv_sys_stat_statfs3_osf1=yes,
5817 fu_cv_sys_stat_statfs3_osf1=no,
5818 fu_cv_sys_stat_statfs3_osf1=no)])
5819 AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
5820 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
5821 space=yes
5822 AC_DEFINE(STAT_STATFS3_OSF1)
5823 fi
5824 fi
5825
5826 if test $space = no; then
5827 # AIX
5828 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
5829 member (AIX, 4.3BSD)])
5830 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
5831 [AC_TRY_RUN([
5832 #ifdef HAVE_SYS_PARAM_H
5833 #include <sys/param.h>
5834 #endif
5835 #ifdef HAVE_SYS_MOUNT_H
5836 #include <sys/mount.h>
5837 #endif
5838 #ifdef HAVE_SYS_VFS_H
5839 #include <sys/vfs.h>
5840 #endif
5841 main ()
5842 {
5843 struct statfs fsd;
5844 fsd.f_bsize = 0;
5845 exit (statfs (".", &fsd));
5846 }],
5847 fu_cv_sys_stat_statfs2_bsize=yes,
5848 fu_cv_sys_stat_statfs2_bsize=no,
5849 fu_cv_sys_stat_statfs2_bsize=no)])
5850 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
5851 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
5852 space=yes
5853 AC_DEFINE(STAT_STATFS2_BSIZE)
5854 fi
5855 fi
5856
5857 if test $space = no; then
5858 # SVR3
5859 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
5860 AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
5861 [AC_TRY_RUN([#include <sys/types.h>
5862 #include <sys/statfs.h>
5863 main ()
5864 {
5865 struct statfs fsd;
5866 exit (statfs (".", &fsd, sizeof fsd, 0));
5867 }],
5868 fu_cv_sys_stat_statfs4=yes,
5869 fu_cv_sys_stat_statfs4=no,
5870 fu_cv_sys_stat_statfs4=no)])
5871 AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
5872 if test $fu_cv_sys_stat_statfs4 = yes; then
5873 space=yes
5874 AC_DEFINE(STAT_STATFS4)
5875 fi
5876 fi
5877
5878 if test $space = no; then
5879 # 4.4BSD and NetBSD
5880 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
5881 member (4.4BSD and NetBSD)])
5882 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
5883 [AC_TRY_RUN([#include <sys/types.h>
5884 #ifdef HAVE_SYS_PARAM_H
5885 #include <sys/param.h>
5886 #endif
5887 #ifdef HAVE_SYS_MOUNT_H
5888 #include <sys/mount.h>
5889 #endif
5890 main ()
5891 {
5892 struct statfs fsd;
5893 fsd.f_fsize = 0;
5894 exit (statfs (".", &fsd));
5895 }],
5896 fu_cv_sys_stat_statfs2_fsize=yes,
5897 fu_cv_sys_stat_statfs2_fsize=no,
5898 fu_cv_sys_stat_statfs2_fsize=no)])
5899 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
5900 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
5901 space=yes
5902 AC_DEFINE(STAT_STATFS2_FSIZE)
5903 fi
5904 fi
5905
5906 if test $space = no; then
5907 # Ultrix
5908 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
5909 AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
5910 [AC_TRY_RUN([#include <sys/types.h>
5911 #ifdef HAVE_SYS_PARAM_H
5912 #include <sys/param.h>
5913 #endif
5914 #ifdef HAVE_SYS_MOUNT_H
5915 #include <sys/mount.h>
5916 #endif
5917 #ifdef HAVE_SYS_FS_TYPES_H
5918 #include <sys/fs_types.h>
5919 #endif
5920 main ()
5921 {
5922 struct fs_data fsd;
5923 /* Ultrix's statfs returns 1 for success,
5924 0 for not mounted, -1 for failure.  */
5925 exit (statfs (".", &fsd) != 1);
5926 }],
5927 fu_cv_sys_stat_fs_data=yes,
5928 fu_cv_sys_stat_fs_data=no,
5929 fu_cv_sys_stat_fs_data=no)])
5930 AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
5931 if test $fu_cv_sys_stat_fs_data = yes; then
5932 space=yes
5933 AC_DEFINE(STAT_STATFS2_FS_DATA)
5934 fi
5935 fi
5936
5937 if test $space = no; then
5938 # SVR2
5939 AC_TRY_CPP([#include <sys/filsys.h>],
5940 AC_DEFINE(STAT_READ_FILSYS) space=yes)
5941 fi
5942
5943 if test -n "$list_mounted_fs" && test $space != no; then
5944 DF_PROG="df"
5945 # LIBOBJS="$LIBOBJS fsusage.o"
5946 # LIBOBJS="$LIBOBJS mountlist.o"
5947 fi
5948
5949 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
5950 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
5951 # enable the work-around code in fsusage.c.
5952 AC_MSG_CHECKING([for statfs that truncates block counts])
5953 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
5954 [AC_TRY_COMPILE([
5955 #if !defined(sun) && !defined(__sun)
5956 choke -- this is a workaround for a Sun-specific problem
5957 #endif
5958 #include <sys/types.h>
5959 #include <sys/vfs.h>],
5960 [struct statfs t; long c = *(t.f_spare);],
5961 fu_cv_sys_truncating_statfs=yes,
5962 fu_cv_sys_truncating_statfs=no,
5963 )])
5964 if test $fu_cv_sys_truncating_statfs = yes; then
5965 AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS)
5966 fi
5967 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
5968
5969 AC_CHECKING(for AFS)
5970 test -d /afs && AC_DEFINE(AFS)
5971 ])
5972 dnl GNOME_X_CHECKS
5973 dnl
5974 dnl Basic X11 related checks for X11.  At the end, the following will be
5975 dnl defined/changed:
5976 dnl   GTK_{CFLAGS,LIBS}      From AM_PATH_GTK
5977 dnl   CPPFLAGS               Will include $X_CFLAGS
5978 dnl   GNOME_HAVE_SM          `true' or `false' depending on whether session
5979 dnl                          management is available.  It is available if
5980 dnl                          both -lSM and X11/SM/SMlib.h exist.  (Some
5981 dnl                          Solaris boxes have the library but not the header)
5982 dnl   XPM_LIBS               -lXpm if Xpm library is present, otherwise ""
5983 dnl
5984 dnl The following configure cache variables are defined (but not used):
5985 dnl   gnome_cv_passdown_{x_libs,X_LIBS,X_CFLAGS}
5986 dnl
5987 AC_DEFUN([GNOME_X_CHECKS],
5988 [
5989         AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(GTK not installed, or gtk-config not in path))
5990         dnl Hope that GTK_CFLAGS have only -I and -D.  Otherwise, we could
5991         dnl   test -z "$x_includes" || CPPFLAGS="$CPPFLAGS -I$x_includes"
5992         dnl
5993         dnl Use CPPFLAGS instead of CFLAGS because AC_CHECK_HEADERS uses
5994         dnl CPPFLAGS, not CFLAGS
5995         CPPFLAGS="$CPPFLAGS $GTK_CFLAGS"
5996
5997         saved_ldflags="$LDFLAGS"
5998         LDFLAGS="$LDFLAGS $GTK_LIBS"
5999
6000         gnome_cv_passdown_x_libs="$GTK_LIBS"
6001         gnome_cv_passdown_X_LIBS="$GTK_LIBS"
6002         gnome_cv_passdown_X_CFLAGS="$GTK_CFLAGS"
6003         gnome_cv_passdown_GTK_LIBS="$GTK_LIBS"
6004
6005         LDFLAGS="$saved_ldflags $GTK_LIBS"
6006
6007 dnl We are requiring GTK >= 1.1.1, which means this will be fine anyhow.
6008         USE_DEVGTK=true
6009
6010 dnl     AC_MSG_CHECKING([whether to use features from (unstable) GTK+ 1.1.x])
6011 dnl     AC_EGREP_CPP(answer_affirmatively,
6012 dnl     [#include <gtk/gtkfeatures.h>
6013 dnl     #ifdef GTK_HAVE_FEATURES_1_1_0
6014 dnl        answer_affirmatively
6015 dnl     #endif
6016 dnl     ], dev_gtk=yes, dev_gtk=no)
6017 dnl     if test "$dev_gtk" = "yes"; then
6018 dnl        USE_DEVGTK=true
6019 dnl     fi
6020 dnl     AC_MSG_RESULT("$dev_gtk")
6021
6022         GNOME_HAVE_SM=true
6023         case "$GTK_LIBS" in
6024          *-lSM*)
6025             dnl Already found it.
6026             ;;
6027          *)
6028             dnl Assume that if we have -lSM then we also have -lICE.
6029             AC_CHECK_LIB(SM, SmcSaveYourselfDone,
6030                 [GTK_LIBS="-lSM -lICE $GTK_LIBS"],GNOME_HAVE_SM=false,
6031                 $x_libs -lICE)
6032             ;;
6033         esac
6034
6035         if test "$GNOME_HAVE_SM" = true; then
6036            AC_CHECK_HEADERS(X11/SM/SMlib.h,,GNOME_HAVE_SM=false)
6037         fi
6038
6039         if test "$GNOME_HAVE_SM" = true; then
6040            AC_DEFINE(HAVE_LIBSM)
6041         fi
6042
6043         XPM_LIBS=""
6044         AC_CHECK_LIB(Xpm, XpmFreeXpmImage, [XPM_LIBS="-lXpm"], , $x_libs)
6045         AC_SUBST(XPM_LIBS)
6046
6047         AC_REQUIRE([GNOME_PTHREAD_CHECK])
6048         LDFLAGS="$saved_ldflags"
6049
6050         AC_PROVIDE([GNOME_X_CHECKS])
6051 ])
6052 AC_DEFUN([GNOME_GHTTP_CHECK],[
6053         AC_REQUIRE([GNOME_INIT_HOOK])
6054         GHTTP_LIB=
6055         AC_CHECK_FUNC(connect,,[
6056           AC_CHECK_LIB(socket,connect,
6057                 GHTTP_LIB="-lsocket $GHTTP_LIB",,$GHTTP_LIB)])
6058         AC_CHECK_FUNC(gethostbyname,,[
6059           AC_CHECK_LIB(nsl,gethostbyname,
6060                 GHTTP_LIB="-lnsl $GHTTP_LIB",,$GHTTP_LIB)])
6061         AC_CHECK_LIB(ghttp, ghttp_request_new, 
6062                 GHTTP_LIB="-lghttp $GHTTP_LIB",GHTTP_LIB="",-L$gnome_prefix $GHTTP_LIB)
6063         AC_SUBST(GHTTP_LIB)
6064         AC_PROVIDE([GNOME_GHTTP_CHECK])
6065 ])
6066 dnl
6067 dnl GNOME_XML_HOOK (script-if-xml-found, failflag)
6068 dnl
6069 dnl If failflag is "failure", script aborts due to lack of XML
6070 dnl 
6071 dnl Check for availability of the libxml library
6072 dnl the XML parser uses libz if available too
6073 dnl
6074
6075 AC_DEFUN([GNOME_XML_HOOK],[
6076         AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
6077         if test "$GNOME_CONFIG" = no; then
6078                 if test x$2 = xfailure; then
6079                         AC_MSG_ERROR(Could not find gnome-config)
6080                 fi
6081         fi
6082         AC_CHECK_LIB(xml, xmlNewDoc, [
6083                 $1
6084                 GNOME_XML_LIB=`$GNOME_CONFIG --libs xml`
6085         ], [
6086                 if test x$2 = xfailure; then 
6087                         AC_MSG_ERROR(Could not link sample xml program)
6088                 fi
6089         ], `$GNOME_CONFIG --libs xml`)
6090         AC_SUBST(GNOME_XML_LIB)
6091 ])
6092
6093 AC_DEFUN([GNOME_XML_CHECK], [
6094         GNOME_XML_HOOK([],failure)
6095 ])
6096 dnl
6097 dnl GNOME_GNORBA_HOOK (script-if-gnorba-found, failflag)
6098 dnl
6099 dnl if failflag is "failure" it aborts if gnorba is not found.
6100 dnl
6101
6102 AC_DEFUN([GNOME_GNORBA_HOOK],[
6103         GNOME_ORBIT_HOOK([],$2)
6104         AC_CACHE_CHECK([for gnorba libraries],gnome_cv_gnorba_found,[
6105                 gnome_cv_gnorba_found=no
6106                 if test x$gnome_cv_orbit_found = xyes; then
6107                         GNORBA_CFLAGS="`gnome-config --cflags gnorba gnomeui`"
6108                         GNORBA_LIBS="`gnome-config --libs gnorba gnomeui`"
6109                         if test -n "$GNORBA_LIBS"; then
6110                                 gnome_cv_gnorba_found=yes
6111                         fi
6112                 fi
6113         ])
6114         AM_CONDITIONAL(HAVE_GNORBA, test x$gnome_cv_gnorba_found = xyes)
6115         if test x$gnome_cv_orbit_found = xyes; then
6116                 $1
6117                 GNORBA_CFLAGS="`gnome-config --cflags gnorba gnomeui`"
6118                 GNORBA_LIBS="`gnome-config --libs gnorba gnomeui`"
6119                 AC_SUBST(GNORBA_CFLAGS)
6120                 AC_SUBST(GNORBA_LIBS)
6121         else
6122                 if test x$2 = xfailure; then
6123                         AC_MSG_ERROR(gnorba library not installed or installation problem)
6124                 fi
6125         fi
6126 ])
6127
6128 AC_DEFUN([GNOME_GNORBA_CHECK], [
6129         GNOME_GNORBA_HOOK([],failure)
6130 ])
6131 dnl
6132 dnl GNOME_INIT_HOOK (script-if-gnome-enabled, [failflag], [additional-inits])
6133 dnl
6134 dnl if failflag is "fail" then GNOME_INIT_HOOK will abort if gnomeConf.sh
6135 dnl is not found. 
6136 dnl
6137
6138 AC_DEFUN([GNOME_INIT_HOOK],[
6139         AC_SUBST(GNOME_LIBS)
6140         AC_SUBST(GNOMEUI_LIBS)
6141         AC_SUBST(GNOMEGNORBA_LIBS)
6142         AC_SUBST(GTKXMHTML_LIBS)
6143         AC_SUBST(ZVT_LIBS)
6144         AC_SUBST(GNOME_LIBDIR)
6145         AC_SUBST(GNOME_INCLUDEDIR)
6146
6147         AC_ARG_WITH(gnome-includes,
6148         [  --with-gnome-includes   Specify location of GNOME headers],[
6149         CFLAGS="$CFLAGS -I$withval"
6150         ])
6151         
6152         AC_ARG_WITH(gnome-libs,
6153         [  --with-gnome-libs       Specify location of GNOME libs],[
6154         LDFLAGS="$LDFLAGS -L$withval"
6155         gnome_prefix=$withval
6156         ])
6157
6158         AC_ARG_WITH(gnome,
6159         [  --with-gnome            Specify prefix for GNOME files],
6160                 if test x$withval = xyes; then
6161                         want_gnome=yes
6162                         dnl Note that an empty true branch is not
6163                         dnl valid sh syntax.
6164                         ifelse([$1], [], :, [$1])
6165                 else
6166                         if test "x$withval" = xno; then
6167                                 want_gnome=no
6168                         else
6169                                 want_gnome=yes
6170                                 LDFLAGS="$LDFLAGS -L$withval/lib"
6171                                 CFLAGS="$CFLAGS -I$withval/include"
6172                                 gnome_prefix=$withval/lib
6173                         fi
6174                 fi,
6175                 want_gnome=yes)
6176
6177         if test "x$want_gnome" = xyes; then
6178
6179             AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
6180             if test "$GNOME_CONFIG" = "no"; then
6181               no_gnome_config="yes"
6182             else
6183               AC_MSG_CHECKING(if $GNOME_CONFIG works)
6184               if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then
6185                 AC_MSG_RESULT(yes)
6186                 GNOME_GNORBA_HOOK([],$2)
6187                 GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome`"
6188                 GNOMEUI_LIBS="`$GNOME_CONFIG --libs-only-l gnomeui`"
6189                 GNOMEGNORBA_LIBS="`$GNOME_CONFIG --libs-only-l gnorba gnomeui`"
6190                 GTKXMHTML_LIBS="`$GNOME_CONFIG --libs-only-l gtkxmhtml`"
6191                 ZVT_LIBS="`$GNOME_CONFIG --libs-only-l zvt`"
6192                 GNOME_LIBDIR="`$GNOME_CONFIG --libs-only-L gnorba gnomeui`"
6193                 GNOME_INCLUDEDIR="`$GNOME_CONFIG --cflags gnorba gnomeui`"
6194                 $1
6195               else
6196                 AC_MSG_RESULT(no)
6197                 no_gnome_config="yes"
6198               fi
6199             fi
6200
6201             if test x$exec_prefix = xNONE; then
6202                 if test x$prefix = xNONE; then
6203                     gnome_prefix=$ac_default_prefix/lib
6204                 else
6205                     gnome_prefix=$prefix/lib
6206                 fi
6207             else
6208                 gnome_prefix=`eval echo \`echo $libdir\``
6209             fi
6210         
6211             if test "$no_gnome_config" = "yes"; then
6212               AC_MSG_CHECKING(for gnomeConf.sh file in $gnome_prefix)
6213               if test -f $gnome_prefix/gnomeConf.sh; then
6214                 AC_MSG_RESULT(found)
6215                 echo "loading gnome configuration from" \
6216                      "$gnome_prefix/gnomeConf.sh"
6217                 . $gnome_prefix/gnomeConf.sh
6218                 $1
6219               else
6220                 AC_MSG_RESULT(not found)
6221                 if test x$2 = xfail; then
6222                   AC_MSG_ERROR(Could not find the gnomeConf.sh file that is generated by gnome-libs install)
6223                 fi
6224               fi
6225             fi
6226         fi
6227
6228         if test -n "$3"; then
6229           n="$3"
6230           for i in $n; do
6231             AC_MSG_CHECKING(extra library \"$i\")
6232             case $i in 
6233               applets)
6234                 AC_SUBST(GNOME_APPLETS_LIBS)
6235                 GNOME_APPLETS_LIBS=`$GNOME_CONFIG --libs-only-l applets`
6236                 AC_MSG_RESULT($GNOME_APPLETS_LIBS);;
6237               docklets)
6238                 AC_SUBST(GNOME_DOCKLETS_LIBS)
6239                 GNOME_DOCKLETS_LIBS=`$GNOME_CONFIG --libs-only-l docklets`
6240                 AC_MSG_RESULT($GNOME_DOCKLETS_LIBS);;
6241               capplet)
6242                 AC_SUBST(GNOME_CAPPLET_LIBS)
6243                 GNOME_CAPPLET_LIBS=`$GNOME_CONFIG --libs-only-l capplet`
6244                 AC_MSG_RESULT($GNOME_CAPPLET_LIBS);;
6245               *)
6246                 AC_MSG_RESULT(unknown library)
6247             esac
6248           done
6249         fi
6250 ])
6251
6252 dnl
6253 dnl GNOME_INIT ([additional-inits])
6254 dnl
6255
6256 AC_DEFUN([GNOME_INIT],[
6257         GNOME_INIT_HOOK([],fail,$1)
6258 ])
6259 dnl
6260 dnl GNOME_CHECK_GUILE (failflag)
6261 dnl
6262 dnl if failflag is "fail" then GNOME_CHECK_GUILE will abort if guile is not found.
6263 dnl
6264
6265 AC_DEFUN([GNOME_CHECK_GUILE],
6266 [
6267         saved_ldflags="$LDFLAGS"
6268         saved_cppflags="$CPPFLAGS"
6269         LDFLAGS="$LDFLAGS $GNOME_LIBDIR"
6270
6271         AC_CHECK_LIB(qthreads,qt_null,[
6272                 QTTHREADS_LIB="-lqthreads"
6273         ],[
6274                 AC_CHECK_LIB(qt, qt_null, QTTHREADS_LIB="-lqt")
6275         ],$LIBS)
6276         AC_SUBST(QTTHREADS_LIB)
6277
6278         AC_CHECK_LIB(termcap,main,TERMCAP_LIB="-ltermcap")
6279         AC_CHECK_LIB(readline,main,READLINE_LIB="-lreadline",,$TERMCAP_LIB)
6280
6281         AC_SUBST(TERMCAP_LIB)
6282         AC_SUBST(READLINE_LIB)
6283
6284         if test "x$cross_compiling" = "xyes" ; then
6285           name_build_guile="$target_alias-guile-config"
6286         else
6287           name_build_guile="guile-config"
6288         fi
6289
6290         AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
6291
6292         if test "x$BUILD_GUILE" = "xyes"; then
6293             AC_MSG_CHECKING(whether $name_build_guile works)
6294             if test x`$name_build_guile --version >/dev/null 2>&1 || \
6295                 echo no` = xno; then
6296                 BUILD_GUILE=no
6297             fi
6298             AC_MSG_RESULT($BUILD_GUILE)
6299         else
6300
6301             if test "x$cross_compiling" = "xyes" ; then
6302                 name_build_guile="$target_alias-build-guile"
6303             else        
6304                 name_build_guile="build-guile"
6305             fi
6306
6307             AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
6308
6309             if test "x$BUILD_GUILE" = "xyes"; then
6310                 AC_MSG_CHECKING(whether $name_build_guile works)
6311                 if test x`$name_build_guile --version >/dev/null 2>&1 || \
6312                     echo no` = xno; then
6313                     BUILD_GUILE=no
6314                 fi
6315                 AC_MSG_RESULT($BUILD_GUILE)
6316             fi
6317         fi
6318
6319         AC_CHECK_LIB(m, sin)
6320
6321         if test "x$BUILD_GUILE" = "xyes"; then
6322                 AC_MSG_CHECKING(for guile libraries)
6323                 GUILE_LIBS="`$name_build_guile link`"
6324                 AC_MSG_RESULT($GUILE_LIBS)
6325                 AC_MSG_CHECKING(for guile headers)
6326                 GUILE_INCS="`$name_build_guile compile`"
6327                 AC_MSG_RESULT($GUILE_INCS)
6328         else
6329                 GUILE_LIBS="$GNOME_LIBDIR"
6330                 GUILE_INCS="$GNOME_INCLUDEDIR"
6331                 AC_CHECK_LIB(rx, main, GUILE_LIBS="-lrx $GUILE_LIBS")
6332                 AC_CHECK_LIB(qt, qt_null, GUILE_LIBS="-lqt $GUILE_LIBS")
6333                 AC_CHECK_LIB(dl, dlopen, GUILE_LIBS="-ldl $GUILE_LIBS")
6334                 AC_CHECK_LIB(nsl, t_accept, GUILE_LIBS="$GUILE_LIBS -lnsl")
6335                 AC_CHECK_LIB(socket, socket, GUILE_LIBS="$GUILE_LIBS -lsocket")
6336                 GUILE_LIBS="-lguile $GUILE_LIBS $QTTHREADS_LIB $READLINE_LIB $TERMCAP_LIB"
6337         fi
6338
6339         AC_SUBST(GUILE_LIBS)
6340         AC_SUBST(GUILE_INCS)
6341
6342         saved_LIBS="$LIBS"
6343         LIBS="$LIBS $GUILE_LIBS"
6344         CPPFLAGS="$saved_cppflags $GUILE_INCS"
6345
6346         AC_MSG_CHECKING(whether guile works)
6347         AC_TRY_LINK([
6348                 #include <libguile.h>
6349                 #include <guile/gh.h>
6350         ],[
6351                 gh_eval_str("(newline)");
6352                 scm_boot_guile(0,NULL,NULL,NULL);
6353         ],[
6354                 ac_cv_guile_found=yes
6355                 AC_DEFINE(HAVE_GUILE)
6356         ],[
6357                 ac_cv_guile_found=no
6358         ])
6359         AC_MSG_RESULT($ac_cv_guile_found)
6360
6361         if test x$ac_cv_guile_found = xno ; then
6362                 if test x$1 = xfail ; then
6363                   AC_MSG_ERROR(Can not find Guile on this system)
6364                 else
6365                   AC_MSG_WARN(Can not find Guile on this system)
6366                 fi
6367                 ac_cv_guile_found=no
6368                 GUILE_LIBS= GUILE_INCS=
6369         fi
6370
6371         LIBS="$saved_LIBS"
6372         LDFLAGS="$saved_ldflags"
6373         CPPFLAGS="$saved_cppflags"
6374
6375         AC_SUBST(GUILE_LIBS)
6376         AM_CONDITIONAL(GUILE, test x$ac_cv_guile_found = xyes)
6377 ])
6378 dnl
6379 dnl AC_PROG_GPERF (MINIMUM-VERSION)
6380 dnl
6381 dnl Check for availability of gperf.
6382 dnl Abort if not found or if current version is not up to par.
6383 dnl
6384
6385 AC_DEFUN([AC_PROG_GPERF],[
6386         AC_PATH_PROG(GPERF, gperf, no)
6387         if test "$GPERF" = no; then
6388                 AC_MSG_ERROR(Could not find gperf)
6389         fi
6390         min_gperf_version=ifelse([$1], ,2.7,$1)
6391         AC_MSG_CHECKING(for gperf - version >= $min_gperf_version)
6392         gperf_major_version=`$GPERF --version | \
6393                 sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\1/'`
6394         gperf_minor_version=`$GPERF --version | \
6395                 sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\2/'`
6396         no_gperf=""
6397 dnl
6398 dnl Now check if the installed gperf is sufficiently new.
6399 dnl
6400         AC_TRY_RUN([
6401 #include <stdio.h>
6402 #include <stdlib.h>
6403 #include <string.h>
6404
6405 static char*
6406 my_strdup (char *str)
6407 {
6408   char *new_str;
6409   
6410   if (str)
6411     {
6412       new_str = malloc ((strlen (str) + 1) * sizeof(char));
6413       strcpy (new_str, str);
6414     }
6415   else
6416     new_str = NULL;
6417   
6418   return new_str;
6419 }
6420
6421 int 
6422 main ()
6423 {
6424   char  *tmp_version;
6425   
6426   int    major;
6427   int    minor;
6428
6429   /* HP/UX 9 (%@#!) writes to sscanf strings */
6430   tmp_version = my_strdup("$min_gperf_version");
6431   if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
6432     printf ("%s, bad version string\n", "$min_gperf_version");
6433     exit (1);
6434   }
6435
6436   if (($gperf_major_version > major) ||
6437       (($gperf_major_version == major) && ($gperf_minor_version >= minor))) {
6438     return 0;
6439   } else {
6440     printf ("\n");
6441     printf ("*** An old version of gperf ($gperf_major_version.$gperf_minor_version) was found.\n");
6442     printf ("*** You need a version of gperf newer than %d.%d.%d.  The latest version of\n",
6443                major, minor);
6444     printf ("*** gperf is always available from ftp://ftp.gnu.org.\n");
6445     printf ("***\n");
6446     return 1;
6447   }
6448 }
6449 ],,no_gperf=yes,[/bin/true])
6450         if test "x$no_gperf" = x ; then
6451                 AC_MSG_RESULT(yes)
6452         else
6453                 AC_MSG_RESULT(no)
6454         fi
6455
6456 ])
6457 dnl
6458 dnl LIBGTOP_CHECK_TYPE
6459 dnl
6460 dnl Improved version of AC_CHECK_TYPE which takes into account
6461 dnl that we need to #include some other header files on some
6462 dnl systems to get some types.
6463
6464 dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT)
6465 AC_DEFUN(AC_LIBGTOP_CHECK_TYPE,
6466 [AC_REQUIRE([AC_HEADER_STDC])dnl
6467 AC_MSG_CHECKING(for $1)
6468 AC_CACHE_VAL(ac_cv_type_$1,
6469 [AC_EGREP_CPP(dnl
6470 changequote(<<,>>)dnl
6471 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
6472 changequote([,]), [#include <sys/types.h>
6473 #if STDC_HEADERS
6474 #include <stdlib.h>
6475 #include <stddef.h>
6476 #endif
6477
6478 /* For Tru64 */
6479 #ifdef HAVE_SYS_BITYPES_H
6480 #include <sys/bitypes.h>
6481 #endif
6482 ], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
6483 AC_MSG_RESULT($ac_cv_type_$1)
6484 if test $ac_cv_type_$1 = no; then
6485   AC_DEFINE($1, $2)
6486 fi
6487 ])
6488
6489 dnl
6490 dnl GNOME_LIBGTOP_TYPES
6491 dnl
6492 dnl some typechecks for libgtop.
6493 dnl
6494
6495 AC_DEFUN([GNOME_LIBGTOP_TYPES],
6496 [
6497         AC_CHECK_HEADERS(sys/bitypes.h)
6498         AC_LIBGTOP_CHECK_TYPE(u_int64_t, unsigned long long int)
6499         AC_LIBGTOP_CHECK_TYPE(int64_t, signed long long int)
6500 ])
6501
6502 dnl
6503 dnl GNOME_LIBGTOP_HOOK (minversion, script-if-libgtop-enabled, failflag)
6504 dnl
6505 dnl if failflag is "fail" then GNOME_LIBGTOP_HOOK will abort if LibGTop
6506 dnl is not found. 
6507 dnl
6508
6509 AC_DEFUN([GNOME_LIBGTOP_HOOK],
6510 [       
6511         AC_REQUIRE([GNOME_LIBGTOP_TYPES])
6512
6513         AC_SUBST(LIBGTOP_LIBDIR)
6514         AC_SUBST(LIBGTOP_INCLUDEDIR)
6515         AC_SUBST(LIBGTOP_EXTRA_LIBS)
6516         AC_SUBST(LIBGTOP_LIBS)
6517         AC_SUBST(LIBGTOP_INCS)
6518         AC_SUBST(LIBGTOP_NAMES_LIBS)
6519         AC_SUBST(LIBGTOP_NAMES_INCS)
6520         AC_SUBST(LIBGTOP_MAJOR_VERSION)
6521         AC_SUBST(LIBGTOP_MINOR_VERSION)
6522         AC_SUBST(LIBGTOP_MICRO_VERSION)
6523         AC_SUBST(LIBGTOP_VERSION)
6524         AC_SUBST(LIBGTOP_VERSION_CODE)
6525         AC_SUBST(LIBGTOP_SERVER_VERSION)
6526         AC_SUBST(LIBGTOP_INTERFACE_AGE)
6527         AC_SUBST(LIBGTOP_BINARY_AGE)
6528         AC_SUBST(LIBGTOP_BINDIR)
6529         AC_SUBST(LIBGTOP_SERVER)
6530
6531         dnl Get the cflags and libraries from the libgtop-config script
6532         dnl
6533         AC_ARG_WITH(libgtop,
6534         [  --with-libgtop=PFX      Prefix where LIBGTOP is installed (optional)],
6535         libgtop_config_prefix="$withval", libgtop_config_prefix="")
6536         AC_ARG_WITH(libgtop-exec,
6537         [  --with-libgtop-exec=PFX Exec prefix where LIBGTOP is installed (optional)],
6538         libgtop_config_exec_prefix="$withval", libgtop_config_exec_prefix="")
6539
6540         if test x$libgtop_config_exec_prefix != x ; then
6541           libgtop_config_args="$libgtop_config_args --exec-prefix=$libgtop_config_exec_prefix"
6542           if test x${LIBGTOP_CONFIG+set} != xset ; then
6543             LIBGTOP_CONFIG=$libgtop_config_exec_prefix/bin/libgtop-config
6544           fi
6545         fi
6546         if test x$libgtop_config_prefix != x ; then
6547           libgtop_config_args="$libgtop_config_args --prefix=$libgtop_config_prefix"
6548           if test x${LIBGTOP_CONFIG+set} != xset ; then
6549             LIBGTOP_CONFIG=$libgtop_config_prefix/bin/libgtop-config
6550           fi
6551         fi
6552
6553         AC_PATH_PROG(LIBGTOP_CONFIG, libgtop-config, no)
6554         dnl IMPORTANT NOTICE:
6555         dnl   If you increase this number here, this means that *ALL*
6556         dnl   modules will require the new version, even if they explicitly
6557         dnl   give a lower number in their `configure.in' !!!
6558         real_min_libgtop_version=1.0.0
6559         min_libgtop_version=ifelse([$1], ,$real_min_libgtop_version,$1)
6560         dnl I know, the following code looks really ugly, but if you want
6561         dnl to make changes, please test it with a brain-dead /bin/sh and
6562         dnl with a brain-dead /bin/test (not all shells/tests support the
6563         dnl `<' operator to compare strings, that's why I convert everything
6564         dnl into numbers and test them).
6565         min_libgtop_major=`echo $min_libgtop_version | \
6566           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
6567         min_libgtop_minor=`echo $min_libgtop_version | \
6568           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
6569         min_libgtop_micro=`echo $min_libgtop_version | \
6570           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
6571         test x$min_libgtop_micro = x && min_libgtop_micro=0
6572         real_min_libgtop_major=`echo $real_min_libgtop_version | \
6573           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
6574         real_min_libgtop_minor=`echo $real_min_libgtop_version | \
6575           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
6576         real_min_libgtop_micro=`echo $real_min_libgtop_version | \
6577           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
6578         test x$real_min_libgtop_micro = x && real_min_libgtop_micro=0
6579         dnl You cannot require a version less then $real_min_libgtop_version,
6580         dnl so you don't need to update each `configure.in' when it's increased.
6581         if test $real_min_libgtop_major -gt $min_libgtop_major ; then
6582           min_libgtop_major=$real_min_libgtop_major
6583           min_libgtop_minor=$real_min_libgtop_minor
6584           min_libgtop_micro=$real_min_libgtop_micro
6585         elif test $real_min_libgtop_major = $min_libgtop_major ; then
6586           if test $real_min_libgtop_minor -gt $min_libgtop_minor ; then
6587             min_libgtop_minor=$real_min_libgtop_minor
6588             min_libgtop_micro=$real_min_libgtop_micro
6589           elif test $real_min_libgtop_minor = $min_libgtop_minor ; then
6590             if test $real_min_libgtop_micro -gt $min_libgtop_micro ; then
6591               min_libgtop_micro=$real_min_libgtop_micro
6592             fi
6593           fi
6594         fi
6595         min_libgtop_version="$min_libgtop_major.$min_libgtop_minor.$min_libgtop_micro"
6596         AC_MSG_CHECKING(for libgtop - version >= $min_libgtop_version)
6597         no_libgtop=""
6598         if test "$LIBGTOP_CONFIG" = "no" ; then
6599           no_libgtop=yes
6600         else
6601           configfile=`$LIBGTOP_CONFIG --config`
6602           libgtop_major_version=`$LIBGTOP_CONFIG --version | \
6603             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
6604           libgtop_minor_version=`$LIBGTOP_CONFIG --version | \
6605             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
6606           libgtop_micro_version=`$LIBGTOP_CONFIG --version | \
6607             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
6608           if test $libgtop_major_version != $min_libgtop_major ; then 
6609             no_libgtop=mismatch
6610           else 
6611             test $libgtop_minor_version -lt $min_libgtop_minor && no_libgtop=yes
6612             if test $libgtop_minor_version = $min_libgtop_minor ; then
6613               test $libgtop_micro_version -lt $min_libgtop_micro && no_libgtop=yes
6614             fi
6615           fi
6616           . $configfile
6617         fi
6618         if test x$no_libgtop = x ; then
6619           AC_DEFINE(HAVE_LIBGTOP)
6620           AC_DEFINE_UNQUOTED(LIBGTOP_VERSION, "$LIBGTOP_VERSION")
6621           AC_DEFINE_UNQUOTED(LIBGTOP_VERSION_CODE, $LIBGTOP_VERSION_CODE)
6622           AC_DEFINE_UNQUOTED(LIBGTOP_MAJOR_VERSION, $LIBGTOP_MAJOR_VERSION)
6623           AC_DEFINE_UNQUOTED(LIBGTOP_MINOR_VERSION, $LIBGTOP_MINOR_VERSION)
6624           AC_DEFINE_UNQUOTED(LIBGTOP_MICRO_VERSION, $LIBGTOP_MICRO_VERSION)
6625           AC_DEFINE_UNQUOTED(LIBGTOP_SERVER_VERSION, $LIBGTOP_SERVER_VERSION)
6626           AC_MSG_RESULT(yes)
6627           dnl Note that an empty true branch is not valid sh syntax.
6628           ifelse([$2], [], :, [$2])
6629         else
6630           AC_MSG_RESULT(no)
6631           if test "$no_libgtop"x = mismatchx; then
6632             AC_MSG_ERROR(LibGTop major version mismatch $libgtop_major_version != $min_libgtop_major)
6633           fi
6634           if test "x$3" = "xfail"; then
6635             AC_MSG_ERROR(LibGTop >= $min_libgtop_version not found)
6636           else
6637             AC_MSG_WARN(LibGTop >= $min_libgtop_version not found)
6638           fi
6639         fi
6640
6641         AM_CONDITIONAL(HAVE_LIBGTOP, test x$no_libgtop != xyes)
6642 ])
6643
6644 AC_DEFUN([GNOME_INIT_LIBGTOP],[
6645         GNOME_LIBGTOP_HOOK($1,[ifelse([$3], [], :, [$3])],$2)
6646 ])
6647
6648 dnl
6649 dnl GNOME_LIBGTOP_DOCU
6650 dnl
6651 dnl checks whether the documentation of LibGTop is installed
6652 dnl
6653
6654 AC_DEFUN([GNOME_LIBGTOP_DOCU],
6655 [
6656         AC_REQUIRE([GNOME_LIBGTOP_HOOK])
6657
6658         helpdir="$LIBGTOP_DATADIR/gnome/help/libgtop"
6659
6660         AC_MSG_CHECKING(whether you have the LibGTop Documentation)
6661
6662         if test -f "$helpdir/C/topic.dat" ; then
6663           have_libgtop_docu=yes
6664           AC_DEFINE(HAVE_LIBGTOP_DOCU)
6665         else
6666           have_libgtop_docu=no
6667         fi
6668
6669         AC_MSG_RESULT($have_libgtop_docu)
6670
6671         AM_CONDITIONAL(HAVE_LIBGTOP_DOCU, test x$have_libgtop_docu = xyes)
6672 ])
6673
6674 dnl
6675 dnl Check for struct linger
6676 dnl
6677 AC_DEFUN(AC_STRUCT_LINGER, [
6678 av_struct_linger=no
6679 AC_MSG_CHECKING(struct linger is available)
6680 AC_TRY_RUN([
6681 #include <sys/types.h>
6682 #include <sys/socket.h>
6683
6684 struct linger li;
6685
6686 main ()
6687 {
6688     li.l_onoff = 1;
6689     li.l_linger = 120;
6690     exit (0);
6691 }
6692 ],[
6693 AC_DEFINE(HAVE_STRUCT_LINGER)
6694 av_struct_linger=yes
6695 ],[
6696 av_struct_linger=no
6697 ],[
6698 av_struct_linger=no
6699 ])
6700 AC_MSG_RESULT($av_struct_linger)
6701 ])
6702 AC_DEFUN([GNOME_CHECK_OBJC],
6703 [
6704 dnl Look for an ObjC compiler.
6705 dnl FIXME: extend list of possible names of ObjC compilers.
6706   AC_CHECK_PROGS(OBJC, $OBJC egcs, "")
6707   if test "x$OBJC" = "x" ; then
6708     AC_CHECK_PROGS(OBJC, $OBJC egcc, "")
6709     if test "x$OBJC" = "x" ; then
6710       AC_CHECK_PROGS(OBJC, $OBJC gcc, "")
6711     fi
6712   fi
6713
6714   AC_REQUIRE([GNOME_PTHREAD_CHECK])
6715
6716   OBJC_LIBS="-lobjc $PTHREAD_LIB"
6717   AC_CHECK_FUNC(sched_yield,,[
6718     AC_CHECK_LIB(rt,sched_yield,
6719       OBJC_LIBS="$OBJC_LIBS -lrt",[
6720       AC_CHECK_LIB(posix4,sched_yield,
6721         OBJC_LIBS="$OBJC_LIBS -lposix4",, 
6722         $OBJC_LIBS)],
6723       $OBJC_LIBS)])
6724   AC_SUBST(OBJC_LIBS)
6725
6726   AC_CACHE_CHECK([if Objective C compiler ($OBJC) works],
6727                  ac_cv_prog_objc_works, [
6728     if test -n "$OBJC"; then
6729       cat > conftest.m <<EOF
6730 #include <objc/Object.h>
6731 @interface myRandomObj : Object
6732 {
6733 }
6734 @end
6735 @implementation myRandomObj
6736 @end
6737 int main () {
6738   /* No, you are not seeing double.  Remember that square brackets
6739      are the autoconf m4 quotes.  */
6740   id myid = [[myRandomObj alloc]];
6741   [[myid free]];
6742   return 0;
6743 }
6744 EOF
6745
6746       $OBJC $CFLAGS -o conftest $LDFLAGS conftest.m $OBJC_LIBS 1>&AC_FD_CC 2>&1
6747       result=$?
6748       rm -f conftest*
6749
6750       if test $result -eq 0; then
6751         ac_cv_prog_objc_works=yes
6752       fi
6753     else
6754       ac_cv_prog_objc_works=no
6755     fi
6756   ])
6757
6758   AM_CONDITIONAL(OBJECTIVE_C, test x$ac_cv_prog_objc_works = xyes)
6759   dnl Also set the shell variable OBJECTIVE_C to "yes" or "no".
6760   OBJECTIVE_C=$ac_cv_prog_objc_works
6761 ])
6762
6763 AC_DEFUN([GNOME_INIT_OBJC],
6764 [
6765         AC_MSG_CHECKING(for an obGnomeConf.sh)
6766         my_gnome_libdir=`$GNOME_CONFIG --libdir`
6767         if test -f $my_gnome_libdir/obGnomeConf.sh; then
6768             . $my_gnome_libdir/obGnomeConf.sh
6769             AC_MSG_RESULT(found $my_gnome_libdir)
6770             ac_cv_have_gnome_objc=yes
6771         else
6772             AC_MSG_RESULT(not found)
6773             AC_MSG_WARN(Could not find the obGnomeConf.sh file that is generated by gnome-objc install)
6774             ac_cv_have_gnome_objc=no
6775         fi
6776         
6777         dnl Add a conditional on whether or not we have gnome-objc
6778         AM_CONDITIONAL(HAVE_GNOME_OBJC, test x$ac_cv_have_gnome_objc = xyes)
6779         HAVE_GNOME_OBJC=$ac_cv_have_gnome_objc
6780
6781         AC_SUBST(OBGNOME_INCLUDEDIR)
6782         AC_SUBST(OBGNOME_LIBS)
6783         AC_SUBST(OBGTK_LIBS)
6784 ])
6785 dnl See whether we need a declaration for a function.
6786 dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
6787 AC_DEFUN(GCC_NEED_DECLARATION,
6788 [AC_MSG_CHECKING([whether $1 must be declared])
6789 AC_CACHE_VAL(gcc_cv_decl_needed_$1,
6790 [AC_TRY_COMPILE([
6791 #include <stdio.h>
6792 #ifdef HAVE_STRING_H
6793 #include <string.h>
6794 #else
6795 #ifdef HAVE_STRINGS_H
6796 #include <strings.h>
6797 #endif
6798 #endif
6799 #ifdef HAVE_STDLIB_H
6800 #include <stdlib.h>
6801 #endif
6802 #ifdef HAVE_UNISTD_H
6803 #include <unistd.h>
6804 #endif
6805 $2],
6806 [char *(*pfn) = (char *(*)) $1],
6807 eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
6808 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
6809   AC_MSG_RESULT(yes)
6810   gcc_need_declarations="$gcc_need_declarations $1"
6811   gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
6812   AC_DEFINE_UNQUOTED($gcc_tr_decl)
6813 else
6814   AC_MSG_RESULT(no)
6815 fi
6816 ])dnl
6817
6818 dnl Check multiple functions to see whether each needs a declaration.
6819 dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
6820 AC_DEFUN(GCC_NEED_DECLARATIONS,
6821 [for ac_func in $1
6822 do
6823 GCC_NEED_DECLARATION($ac_func, $2)
6824 done
6825 ]
6826 )
6827 dnl
6828 dnl GNOME_ORBIT_HOOK (script-if-orbit-found, failflag)
6829 dnl
6830 dnl if failflag is "failure" it aborts if orbit is not found.
6831 dnl
6832
6833 AC_DEFUN([GNOME_ORBIT_HOOK],[
6834         AC_PATH_PROG(ORBIT_CONFIG,orbit-config,no)
6835         AC_PATH_PROG(ORBIT_IDL,orbit-idl,no)
6836         AC_CACHE_CHECK([for working ORBit environment],gnome_cv_orbit_found,[
6837                 if test x$ORBIT_CONFIG = xno -o x$ORBIT_IDL = xno; then
6838                         gnome_cv_orbit_found=no
6839                 else
6840                         gnome_cv_orbit_found=yes
6841                 fi
6842         ])
6843         AM_CONDITIONAL(HAVE_ORBIT, test x$gnome_cv_orbit_found = xyes)
6844         if test x$gnome_cv_orbit_found = xyes; then
6845                 $1
6846                 ORBIT_CFLAGS=`orbit-config --cflags client server`
6847                 ORBIT_LIBS=`orbit-config --use-service=name --libs client server`
6848                 AC_SUBST(ORBIT_CFLAGS)
6849                 AC_SUBST(ORBIT_LIBS)
6850         else
6851                 if test x$2 = xfailure; then
6852                         AC_MSG_ERROR(ORBit not installed or installation problem)
6853                 fi
6854         fi
6855 ])
6856
6857 AC_DEFUN([GNOME_ORBIT_CHECK], [
6858         GNOME_ORBIT_HOOK([],failure)
6859 ])
6860 # Configure paths for GTK--
6861 # Erik Andersen 30 May 1998
6862 # Modified by Tero Pulkkinen (added the compiler checks... I hope they work..)
6863 # Modified by Thomas Langen 16 Jan 2000 (corrected CXXFLAGS)
6864
6865 dnl Test for GTKMM, and define GTKMM_CFLAGS and GTKMM_LIBS
6866 dnl   to be used as follows:
6867 dnl AM_PATH_GTKMM([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
6868 dnl
6869 AC_DEFUN(AM_PATH_GTKMM,
6870 [dnl 
6871 dnl Get the cflags and libraries from the gtkmm-config script
6872 dnl
6873 AC_ARG_WITH(gtkmm-prefix,[  --with-gtkmm-prefix=PREFIX
6874                           Prefix where GTK-- is installed (optional)],
6875             gtkmm_config_prefix="$withval", gtkmm_config_prefix="")
6876 AC_ARG_WITH(gtkmm-exec-prefix,[  --with-gtkmm-exec-prefix=PREFIX
6877                           Exec prefix where GTK-- is installed (optional)],
6878             gtkmm_config_exec_prefix="$withval", gtkmm_config_exec_prefix="")
6879 AC_ARG_ENABLE(gtkmmtest, [  --disable-gtkmmtest     Do not try to compile and run a test GTK-- program],
6880                     , enable_gtkmmtest=yes)
6881
6882   if test x$gtkmm_config_exec_prefix != x ; then
6883      gtkmm_config_args="$gtkmm_config_args --exec-prefix=$gtkmm_config_exec_prefix"
6884      if test x${GTKMM_CONFIG+set} != xset ; then
6885         GTKMM_CONFIG=$gtkmm_config_exec_prefix/bin/gtkmm-config
6886      fi
6887   fi
6888   if test x$gtkmm_config_prefix != x ; then
6889      gtkmm_config_args="$gtkmm_config_args --prefix=$gtkmm_config_prefix"
6890      if test x${GTKMM_CONFIG+set} != xset ; then
6891         GTKMM_CONFIG=$gtkmm_config_prefix/bin/gtkmm-config
6892      fi
6893   fi
6894
6895   AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no)
6896   min_gtkmm_version=ifelse([$1], ,0.10.0,$1)
6897
6898   AC_MSG_CHECKING(for GTK-- - version >= $min_gtkmm_version)
6899   no_gtkmm=""
6900   if test "$GTKMM_CONFIG" = "no" ; then
6901     no_gtkmm=yes
6902   else
6903     AC_LANG_SAVE
6904     AC_LANG_CPLUSPLUS
6905
6906     GTKMM_CFLAGS=`$GTKMM_CONFIG $gtkmm_config_args --cflags`
6907     GTKMM_LIBS=`$GTKMM_CONFIG $gtkmm_config_args --libs`
6908     gtkmm_config_major_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
6909            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
6910     gtkmm_config_minor_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
6911            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
6912     gtkmm_config_micro_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
6913            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
6914     if test "x$enable_gtkmmtest" = "xyes" ; then
6915       ac_save_CXXFLAGS="$CXXFLAGS"
6916       ac_save_LIBS="$LIBS"
6917       CXXFLAGS="$CXXFLAGS $GTKMM_CFLAGS"
6918       LIBS="$LIBS $GTKMM_LIBS"
6919 dnl
6920 dnl Now check if the installed GTK-- is sufficiently new. (Also sanity
6921 dnl checks the results of gtkmm-config to some extent
6922 dnl
6923       rm -f conf.gtkmmtest
6924       AC_TRY_RUN([
6925 #include <gtk--.h>
6926 #include <stdio.h>
6927 #include <stdlib.h>
6928
6929 int 
6930 main ()
6931 {
6932   int major, minor, micro;
6933   char *tmp_version;
6934
6935   system ("touch conf.gtkmmtest");
6936
6937   /* HP/UX 0 (%@#!) writes to sscanf strings */
6938   tmp_version = g_strdup("$min_gtkmm_version");
6939   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
6940      printf("%s, bad version string\n", "$min_gtkmm_version");
6941      exit(1);
6942    }
6943
6944   if ((gtkmm_major_version != $gtkmm_config_major_version) ||
6945       (gtkmm_minor_version != $gtkmm_config_minor_version) ||
6946       (gtkmm_micro_version != $gtkmm_config_micro_version))
6947     {
6948       printf("\n*** 'gtkmm-config --version' returned %d.%d.%d, but GTK-- (%d.%d.%d)\n", 
6949              $gtkmm_config_major_version, $gtkmm_config_minor_version, $gtkmm_config_micro_version,
6950              gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
6951       printf ("*** was found! If gtkmm-config was correct, then it is best\n");
6952       printf ("*** to remove the old version of GTK--. You may also be able to fix the error\n");
6953       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
6954       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
6955       printf("*** required on your system.\n");
6956       printf("*** If gtkmm-config was wrong, set the environment variable GTKMM_CONFIG\n");
6957       printf("*** to point to the correct copy of gtkmm-config, and remove the file config.cache\n");
6958       printf("*** before re-running configure\n");
6959     } 
6960 /* GTK-- does not have the GTKMM_*_VERSION constants */
6961 /* 
6962   else if ((gtkmm_major_version != GTKMM_MAJOR_VERSION) ||
6963            (gtkmm_minor_version != GTKMM_MINOR_VERSION) ||
6964            (gtkmm_micro_version != GTKMM_MICRO_VERSION))
6965     {
6966       printf("*** GTK-- header files (version %d.%d.%d) do not match\n",
6967              GTKMM_MAJOR_VERSION, GTKMM_MINOR_VERSION, GTKMM_MICRO_VERSION);
6968       printf("*** library (version %d.%d.%d)\n",
6969              gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
6970     }
6971 */
6972   else
6973     {
6974       if ((gtkmm_major_version > major) ||
6975         ((gtkmm_major_version == major) && (gtkmm_minor_version > minor)) ||
6976         ((gtkmm_major_version == major) && (gtkmm_minor_version == minor) && (gtkmm_micro_version >= micro)))
6977       {
6978         return 0;
6979        }
6980      else
6981       {
6982         printf("\n*** An old version of GTK-- (%d.%d.%d) was found.\n",
6983                gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
6984         printf("*** You need a version of GTK-- newer than %d.%d.%d. The latest version of\n",
6985                major, minor, micro);
6986         printf("*** GTK-- is always available from ftp://ftp.gtk.org.\n");
6987         printf("***\n");
6988         printf("*** If you have already installed a sufficiently new version, this error\n");
6989         printf("*** probably means that the wrong copy of the gtkmm-config shell script is\n");
6990         printf("*** being found. The easiest way to fix this is to remove the old version\n");
6991         printf("*** of GTK--, but you can also set the GTKMM_CONFIG environment to point to the\n");
6992         printf("*** correct copy of gtkmm-config. (In this case, you will have to\n");
6993         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
6994         printf("*** so that the correct libraries are found at run-time))\n");
6995       }
6996     }
6997   return 1;
6998 }
6999 ],, no_gtkmm=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
7000        CXXFLAGS="$ac_save_CXXFLAGS"
7001        LIBS="$ac_save_LIBS"
7002      fi
7003   fi
7004   if test "x$no_gtkmm" = x ; then
7005      AC_MSG_RESULT(yes)
7006      ifelse([$2], , :, [$2])     
7007   else
7008      AC_MSG_RESULT(no)
7009      if test "$GTKMM_CONFIG" = "no" ; then
7010        echo "*** The gtkmm-config script installed by GTK-- could not be found"
7011        echo "*** If GTK-- was installed in PREFIX, make sure PREFIX/bin is in"
7012        echo "*** your path, or set the GTKMM_CONFIG environment variable to the"
7013        echo "*** full path to gtkmm-config."
7014        echo "*** The gtkmm-config script was not available in GTK-- versions"
7015        echo "*** prior to 0.9.12. Perhaps you need to update your installed"
7016        echo "*** version to 0.9.12 or later"
7017      else
7018        if test -f conf.gtkmmtest ; then
7019         :
7020        else
7021           echo "*** Could not run GTK-- test program, checking why..."
7022           CXXFLAGS="$CXXFLAGS $GTKMM_CFLAGS"
7023           LIBS="$LIBS $GTKMM_LIBS"
7024           AC_TRY_LINK([
7025 #include <gtk--.h>
7026 #include <stdio.h>
7027 ],      [ return ((gtkmm_major_version) || (gtkmm_minor_version) || (gtkmm_micro_version)); ],
7028         [ echo "*** The test program compiled, but did not run. This usually means"
7029           echo "*** that the run-time linker is not finding GTK-- or finding the wrong"
7030           echo "*** version of GTK--. If it is not finding GTK--, you'll need to set your"
7031           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
7032           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
7033           echo "*** is required on your system"
7034           echo "***"
7035           echo "*** If you have an old version installed, it is best to remove it, although"
7036           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
7037         [ echo "*** The test program failed to compile or link. See the file config.log for the"
7038           echo "*** exact error that occured. This usually means GTK-- was incorrectly installed"
7039           echo "*** or that you have moved GTK-- since it was installed. In the latter case, you"
7040           echo "*** may want to edit the gtkmm-config script: $GTKMM_CONFIG" ])
7041           CXXFLAGS="$ac_save_CXXFLAGS"
7042           LIBS="$ac_save_LIBS"
7043        fi
7044      fi
7045      GTKMM_CFLAGS=""
7046      GTKMM_LIBS=""
7047      ifelse([$3], , :, [$3])
7048      AC_LANG_RESTORE
7049   fi
7050   AC_SUBST(GTKMM_CFLAGS)
7051   AC_SUBST(GTKMM_LIBS)
7052   rm -f conf.gtkmmtest
7053 ])
7054
7055 # Configure paths for GNOME--
7056 # Modified from GTK--.m4
7057
7058 dnl Test for GNOMEMM, and define GNOMEMM_INCLUDEDIR, GNOMEMM_LIBDIR, GNOMEMM_LIBS
7059 dnl   to be used as follows:
7060 dnl AM_PATH_GNOMEMM([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
7061 dnl
7062 AC_DEFUN(AM_PATH_GNOMEMM,
7063 [
7064 dnl 
7065 dnl Get the cflags and libraries from the gtkmm-config script
7066 dnl
7067 AC_ARG_WITH(gnomemm-config-path,[  --with-gnomemm-config-path=PREFIX
7068                           Path to GNOME-- configuration file gnomemmConf.sh (optional)],
7069             gnomemm_config_prefix="$withval", gnome_config_prefix="")
7070
7071   AC_MSG_CHECKING(for GNOME-- gnomemmConf.sh)
7072
7073   if test x$gnomemm_config_prefix != x; then
7074     if test -r $gnomemm_config_prefix; then
7075         source $gnomemm_config_prefix
7076     else 
7077         no_gnomemm=yes
7078     fi
7079   else
7080     if test -r /usr/lib/gnomemmConf.sh ; then
7081         source /usr/lib/gnomemmConf.sh
7082     elif test -r /opt/gnome/lib/gnomemmConf.sh ; then
7083         source /opt/gnome/lib/gnomemmConf.sh
7084     elif test -r /usr/local/lib/gnomemmConf.sh ; then
7085         source /usr/local/lib/gnomemmConf.sh
7086     else 
7087         no_gnomemm=yes
7088     fi
7089   fi
7090
7091   if test "x$no_gnomemm" = x ; then
7092      AC_MSG_RESULT(yes)
7093      ifelse([$2], , :, [$2])     
7094   else
7095      AC_MSG_RESULT(no)
7096      AC_MSG_ERROR(Cannot find GNOME-- configuration file gnomemmConf.sh)
7097   fi
7098
7099   AC_SUBST(GNOMEMM_INCLUDEDIR)
7100   AC_SUBST(GNOMEMM_LIBDIR)
7101   AC_SUBST(GNOMEMM_LIBS)
7102 ])
7103