]> git.lyx.org Git - lyx.git/blob - config/gnome.m4
the export patch from Dekel
[lyx.git] / config / gnome.m4
1 # aclocal-include.m4
2
3 # This macro adds the name macrodir to the set of directories
4 # that `aclocal' searches for macros.  
5
6 # serial 1
7
8 dnl AM_ACLOCAL_INCLUDE(macrodir)
9 AC_DEFUN([AM_ACLOCAL_INCLUDE],
10 [
11         AM_CONDITIONAL(INSIDE_GNOME_COMMON, test x = y)
12
13         test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
14
15         for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done
16 ])
17 dnl GNOME_COMPILE_WARNINGS
18 dnl Turn on many useful compiler warnings
19 dnl For now, only works on GCC
20 AC_DEFUN([GNOME_COMPILE_WARNINGS],[
21   AC_ARG_ENABLE(compile-warnings, 
22     [  --enable-compile-warnings=[no/minimum/yes]       Turn on compiler warnings.],,enable_compile_warnings=minimum)
23
24   AC_MSG_CHECKING(what warning flags to pass to the C compiler)
25   warnCFLAGS=
26   if test "x$GCC" != xyes; then
27     enable_compile_warnings=no
28   fi
29
30   if test "x$enable_compile_warnings" != "xno"; then
31     if test "x$GCC" = "xyes"; then
32       case " $CFLAGS " in
33       *[\ \     ]-Wall[\ \      ]*) ;;
34       *) warnCFLAGS="-Wall -Wunused" ;;
35       esac
36
37       ## -W is not all that useful.  And it cannot be controlled
38       ## with individual -Wno-xxx flags, unlike -Wall
39       if test "x$enable_compile_warnings" = "xyes"; then
40         warnCFLAGS="$warnCFLAGS -Wmissing-prototypes -Wmissing-declarations"
41       fi
42     fi
43   fi
44   AC_MSG_RESULT($warnCFLAGS)
45
46   AC_ARG_ENABLE(iso-c,
47     [  --enable-iso-c          Try to warn if code is not ISO C ],,
48     enable_iso_c=no)
49
50   AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
51   complCFLAGS=
52   if test "x$enable_iso_c" != "xno"; then
53     if test "x$GCC" = "xyes"; then
54       case " $CFLAGS " in
55       *[\ \     ]-ansi[\ \      ]*) ;;
56       *) complCFLAGS="$complCFLAGS -ansi" ;;
57       esac
58
59       case " $CFLAGS " in
60       *[\ \     ]-pedantic[\ \  ]*) ;;
61       *) complCFLAGS="$complCFLAGS -pedantic" ;;
62       esac
63     fi
64   fi
65   AC_MSG_RESULT($complCFLAGS)
66   if test "x$cflags_set" != "xyes"; then
67     CFLAGS="$CFLAGS $warnCFLAGS $complCFLAGS"
68     cflags_set=yes
69     AC_SUBST(cflags_set)
70   fi
71 ])
72
73 dnl For C++, do basically the same thing.
74
75 AC_DEFUN([GNOME_CXX_WARNINGS],[
76   AC_ARG_ENABLE(cxx-warnings, 
77     [  --enable-cxx-warnings=[no/minimum/yes]   Turn on compiler warnings.],,enable_cxx_warnings=minimum)
78
79   AC_MSG_CHECKING(what warning flags to pass to the C++ compiler)
80   warnCXXFLAGS=
81   if test "x$GCC" != xyes; then
82     enable_compile_warnings=no
83   fi
84   if test "x$enable_cxx_warnings" != "xno"; then
85     if test "x$GCC" = "xyes"; then
86       case " $CXXFLAGS " in
87       *[\ \     ]-Wall[\ \      ]*) ;;
88       *) warnCXXFLAGS="-Wall -Wno-unused" ;;
89       esac
90
91       ## -W is not all that useful.  And it cannot be controlled
92       ## with individual -Wno-xxx flags, unlike -Wall
93       if test "x$enable_cxx_warnings" = "xyes"; then
94         warnCXXFLAGS="$warnCXXFLAGS -Wmissing-prototypes -Wmissing-declarations -Wshadow -Woverloaded-virtual"
95       fi
96     fi
97   fi
98   AC_MSG_RESULT($warnCXXFLAGS)
99
100    AC_ARG_ENABLE(iso-cxx,
101      [  --enable-iso-cxx          Try to warn if code is not ISO C++ ],,
102      enable_iso_cxx=no)
103
104    AC_MSG_CHECKING(what language compliance flags to pass to the C++ compiler)
105    complCXXFLAGS=
106    if test "x$enable_iso_cxx" != "xno"; then
107      if test "x$GCC" = "xyes"; then
108       case " $CXXFLAGS " in
109       *[\ \     ]-ansi[\ \      ]*) ;;
110       *) complCXXFLAGS="$complCXXFLAGS -ansi" ;;
111       esac
112
113       case " $CXXFLAGS " in
114       *[\ \     ]-pedantic[\ \  ]*) ;;
115       *) complCXXFLAGS="$complCXXFLAGS -pedantic" ;;
116       esac
117      fi
118    fi
119   AC_MSG_RESULT($complCXXFLAGS)
120   if test "x$cxxflags_set" != "xyes"; then
121     CXXFLAGS="$CXXFLAGS $warnCXXFLAGS $complCXXFLAGS"
122     cxxflags_set=yes
123     AC_SUBST(cxxflags_set)
124   fi
125 ])
126 dnl Curses detection: Munged from Midnight Commander's configure.in
127 dnl
128 dnl What it does:
129 dnl =============
130 dnl
131 dnl - Determine which version of curses is installed on your system
132 dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
133 dnl   symbols 
134 dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
135 dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
136 dnl   Makefile.in's
137 dnl - Modify the following configure variables (these are the only
138 dnl   curses.m4 variables you can access from within configure.in)
139 dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
140 dnl                       an ncurses.h that's been renamed to curses.h
141 dnl                       is found.
142 dnl   CURSES_LIBS       - sets -L and -l's appropriately
143 dnl   CFLAGS            - if --with-sco, add -D_SVID3 
144 dnl   has_curses        - exports result of tests to rest of configure
145 dnl
146 dnl Usage:
147 dnl ======
148 dnl 1) Add lines indicated below to acconfig.h
149 dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
150 dnl 3) Instead of #include <curses.h> you should use the following to
151 dnl    properly locate ncurses or curses header file
152 dnl
153 dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
154 dnl    #include <ncurses.h>
155 dnl    #else
156 dnl    #include <curses.h>
157 dnl    #endif
158 dnl
159 dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
160 dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
161 dnl
162 dnl Notes with automake:
163 dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
164 dnl   configure.in
165 dnl - your Makefile.am can look something like this
166 dnl   -----------------------------------------------
167 dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
168 dnl   if HAS_CURSES
169 dnl   CURSES_TARGETS=name_of_curses_prog
170 dnl   endif
171 dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
172 dnl   other_programs_SOURCES = blah blah blah
173 dnl   name_of_curses_prog_SOURCES = blah blah blah
174 dnl   other_programs_LDADD = blah
175 dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
176 dnl   -----------------------------------------------
177 dnl
178 dnl
179 dnl The following lines should be added to acconfig.h:
180 dnl ==================================================
181 dnl
182 dnl /*=== Curses version detection defines ===*/
183 dnl /* Found some version of curses that we're going to use */
184 dnl #undef HAS_CURSES
185 dnl    
186 dnl /* Use SunOS SysV curses? */
187 dnl #undef USE_SUNOS_CURSES
188 dnl 
189 dnl /* Use old BSD curses - not used right now */
190 dnl #undef USE_BSD_CURSES
191 dnl 
192 dnl /* Use SystemV curses? */
193 dnl #undef USE_SYSV_CURSES
194 dnl 
195 dnl /* Use Ncurses? */
196 dnl #undef USE_NCURSES
197 dnl 
198 dnl /* If you Curses does not have color define this one */
199 dnl #undef NO_COLOR_CURSES
200 dnl 
201 dnl /* Define if you want to turn on SCO-specific code */
202 dnl #undef SCO_FLAVOR
203 dnl 
204 dnl /* Set to reflect version of ncurses *
205 dnl  *   0 = version 1.*
206 dnl  *   1 = version 1.9.9g
207 dnl  *   2 = version 4.0/4.1 */
208 dnl #undef NCURSES_970530
209 dnl
210 dnl /*=== End new stuff for acconfig.h ===*/
211 dnl 
212
213
214 AC_DEFUN(AC_CHECK_CURSES,[
215         search_ncurses=true
216         screen_manager=""
217         has_curses=false
218
219         CFLAGS=${CFLAGS--O}
220
221         AC_SUBST(CURSES_LIBS)
222         AC_SUBST(CURSES_INCLUDEDIR)
223
224         AC_ARG_WITH(sco,
225           [  --with-sco              Use this to turn on SCO-specific code],[
226           if test x$withval = xyes; then
227                 AC_DEFINE(SCO_FLAVOR)
228                 CFLAGS="$CFLAGS -D_SVID3"
229           fi
230         ])
231
232         AC_ARG_WITH(sunos-curses,
233           [  --with-sunos-curses     Used to force SunOS 4.x curses],[
234           if test x$withval = xyes; then
235                 AC_USE_SUNOS_CURSES
236           fi
237         ])
238
239         AC_ARG_WITH(osf1-curses,
240           [  --with-osf1-curses      Used to force OSF/1 curses],[
241           if test x$withval = xyes; then
242                 AC_USE_OSF1_CURSES
243           fi
244         ])
245
246         AC_ARG_WITH(vcurses,
247           [  --with-vcurses[=incdir] Used to force SysV curses],
248           if test x$withval != xyes; then
249                 CURSES_INCLUDEDIR="-I$withval"
250           fi
251           AC_USE_SYSV_CURSES
252         )
253
254         AC_ARG_WITH(ncurses,
255           [  --with-ncurses[=dir]  Compile with ncurses/locate base dir],
256           if test x$withval = xno ; then
257                 search_ncurses=false
258           elif test x$withval != xyes ; then
259                 CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
260                 CURSES_INCLUDEDIR="-I$withval/include"
261                 search_ncurses=false
262                 screen_manager="ncurses"
263                 AC_DEFINE(USE_NCURSES)
264                 AC_DEFINE(HAS_CURSES)
265                 has_curses=true
266           fi
267         )
268
269         if $search_ncurses
270         then
271                 AC_SEARCH_NCURSES()
272         fi
273
274
275 ])
276
277
278 AC_DEFUN(AC_USE_SUNOS_CURSES, [
279         search_ncurses=false
280         screen_manager="SunOS 4.x /usr/5include curses"
281         AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
282         AC_DEFINE(USE_SUNOS_CURSES)
283         AC_DEFINE(HAS_CURSES)
284         has_curses=true
285         AC_DEFINE(NO_COLOR_CURSES)
286         AC_DEFINE(USE_SYSV_CURSES)
287         CURSES_INCLUDEDIR="-I/usr/5include"
288         CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
289         AC_MSG_RESULT(Please note that some screen refreshs may fail)
290 ])
291
292 AC_DEFUN(AC_USE_OSF1_CURSES, [
293        AC_MSG_RESULT(Using OSF1 curses)
294        search_ncurses=false
295        screen_manager="OSF1 curses"
296        AC_DEFINE(HAS_CURSES)
297        has_curses=true
298        AC_DEFINE(NO_COLOR_CURSES)
299        AC_DEFINE(USE_SYSV_CURSES)
300        CURSES_LIBS="-lcurses"
301 ])
302
303 AC_DEFUN(AC_USE_SYSV_CURSES, [
304         AC_MSG_RESULT(Using SysV curses)
305         AC_DEFINE(HAS_CURSES)
306         has_curses=true
307         AC_DEFINE(USE_SYSV_CURSES)
308         search_ncurses=false
309         screen_manager="SysV/curses"
310         CURSES_LIBS="-lcurses"
311 ])
312
313 dnl AC_ARG_WITH(bsd-curses,
314 dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
315 dnl     search_ncurses=false
316 dnl     screen_manager="Ultrix/cursesX"
317 dnl     if test $system = ULTRIX
318 dnl     then
319 dnl         THIS_CURSES=cursesX
320 dnl        else
321 dnl         THIS_CURSES=curses
322 dnl     fi
323 dnl
324 dnl     CURSES_LIBS="-l$THIS_CURSES -ltermcap"
325 dnl     AC_DEFINE(HAS_CURSES)
326 dnl     has_curses=true
327 dnl     AC_DEFINE(USE_BSD_CURSES)
328 dnl     AC_MSG_RESULT(Please note that some screen refreshs may fail)
329 dnl     AC_WARN(Use of the bsdcurses extension has some)
330 dnl     AC_WARN(display/input problems.)
331 dnl     AC_WARN(Reconsider using xcurses)
332 dnl)
333
334         
335 dnl
336 dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
337 dnl
338 AC_DEFUN(AC_NCURSES, [
339     if $search_ncurses
340     then
341         if test -f $1/$2
342         then
343             AC_MSG_RESULT(Found ncurses on $1/$2)
344             CURSES_LIBS="$3"
345             CURSES_INCLUDEDIR="$4"
346             search_ncurses=false
347             screen_manager=$5
348             AC_DEFINE(HAS_CURSES)
349             has_curses=true
350             AC_DEFINE(USE_NCURSES)
351         fi
352     fi
353 ])
354
355 AC_DEFUN(AC_SEARCH_NCURSES, [
356     AC_CHECKING("location of ncurses.h file")
357
358     AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
359     AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
360     AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
361     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")
362
363     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")
364
365     AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
366
367     dnl
368     dnl We couldn't find ncurses, try SysV curses
369     dnl
370     if $search_ncurses 
371     then
372         AC_EGREP_HEADER(init_color, /usr/include/curses.h,
373             AC_USE_SYSV_CURSES)
374         AC_EGREP_CPP(USE_NCURSES,[
375 #include <curses.h>
376 #ifdef __NCURSES_H
377 #undef USE_NCURSES
378 USE_NCURSES
379 #endif
380 ],[
381         CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
382         AC_DEFINE(HAS_CURSES)
383         has_curses=true
384         AC_DEFINE(USE_NCURSES)
385         search_ncurses=false
386         screen_manager="ncurses installed as curses"
387 ])
388     fi
389
390     dnl
391     dnl Try SunOS 4.x /usr/5{lib,include} ncurses
392     dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
393     dnl should be replaced by a more fine grained selection routine
394     dnl
395     if $search_ncurses
396     then
397         if test -f /usr/5include/curses.h
398         then
399             AC_USE_SUNOS_CURSES
400         fi
401     else
402         # check for ncurses version, to properly ifdef mouse-fix
403         AC_MSG_CHECKING(for ncurses version)
404         ncurses_version=unknown
405 cat > conftest.$ac_ext <<EOF
406 [#]line __oline__ "configure"
407 #include "confdefs.h"
408 #ifdef RENAMED_NCURSES
409 #include <curses.h>
410 #else
411 #include <ncurses.h>
412 #endif
413 #undef VERSION
414 VERSION:NCURSES_VERSION
415 EOF
416         if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
417   egrep "VERSION:" >conftest.out 2>&1; then
418 changequote(,)dnl
419             ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
420 changequote([,])dnl
421         fi
422         rm -rf conftest*
423         AC_MSG_RESULT($ncurses_version)
424         case "$ncurses_version" in
425 changequote(,)dnl
426         4.[01])
427 changequote([,])dnl
428             AC_DEFINE(NCURSES_970530,2)
429             ;;
430         1.9.9g)
431             AC_DEFINE(NCURSES_970530,1)
432             ;;
433         1*)
434             AC_DEFINE(NCURSES_970530,0)
435             ;;
436         esac
437     fi
438 ])
439
440
441
442
443
444 # Configure paths for Bonobo
445 # Miguel de Icaza, 99-04-12
446 # Stolen from Chris Lahey       99-2-5
447 # stolen from Manish Singh again
448 # stolen back from Frank Belew
449 # stolen from Manish Singh
450 # Shamelessly stolen from Owen Taylor
451
452 dnl AM_PATH_BONOBO ([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
453 dnl Test for Bonobo, and define BONOBO_CFLAGS and BONOBO_LIBS
454 dnl
455 AC_DEFUN([AM_PATH_BONOBO],
456 [
457 dnl 
458 dnl Get the cflags and libraries from the gnome-config script
459 dnl
460 AC_ARG_WITH(bonobo-prefix,[  --with-bonobo-prefix=PFX   Prefix where Bonobo is installed (optional)],
461             bonobo_prefix="$withval", bonobo_prefix="")
462 AC_ARG_WITH(bonobo-exec-prefix,[  --with-bonobo-exec-prefix=PFX Exec prefix where Bonobo is installed (optional)],
463             bonobo_exec_prefix="$withval", bonobo_exec_prefix="")
464 AC_ARG_ENABLE(bonobotest, [  --disable-bonobotest       Do not try to compile and run a test Bonobo program],
465                     , enable_bonobotest=yes)
466
467   if test x$bonobo_exec_prefix != x ; then
468      bonobo_args="$bonobo_args --exec-prefix=$bonobo_exec_prefix"
469      if test x${GNOME_CONFIG+set} != xset ; then
470         GNOME_CONFIG=$bonobo_exec_prefix/bin/gnome-config
471      fi
472   fi
473   if test x$bonobo_prefix != x ; then
474      bonobo_args="$bonobo_args --prefix=$bonobo_prefix"
475      if test x${GNOME_CONFIG+set} != xset ; then
476         GNOME_CONFIG=$bonobo_prefix/bin/gnome-config
477      fi
478   fi
479
480   AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
481   min_bonobo_version=ifelse([$1], ,0.1.0,$1)
482   AC_MSG_CHECKING(for BONOBO - version >= $min_bonobo_version)
483   no_bonobo=""
484   if test "$GNOME_CONFIG" = "no" ; then
485     no_bonobo=yes
486   else
487     BONOBO_CFLAGS=`$GNOME_CONFIG $bonoboconf_args --cflags bonobo`
488     BONOBO_LIBS=`$GNOME_CONFIG $bonoboconf_args --libs bonobo`
489
490     bonobo_major_version=`$GNOME_CONFIG $bonobo_args --version | \
491            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
492     bonobo_minor_version=`$GNOME_CONFIG $bonobo_args --version | \
493            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
494     bonobo_micro_version=`$GNOME_CONFIG $bonobo_config_args --version | \
495            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
496     if test "x$enable_bonobotest" = "xyes" ; then
497       ac_save_CFLAGS="$CFLAGS"
498       ac_save_LIBS="$LIBS"
499       CFLAGS="$CFLAGS $BONOBO_CFLAGS"
500       LIBS="$LIBS $BONOBO_LIBS"
501 dnl
502 dnl Now check if the installed BONOBO is sufficiently new. (Also sanity
503 dnl checks the results of gnome-config to some extent
504 dnl
505       rm -f conf.bonobotest
506       AC_TRY_RUN([
507 #include <stdio.h>
508 #include <stdlib.h>
509 #include <string.h>
510 #include <bonobo.h>
511
512 static char*
513 my_strdup (char *str)
514 {
515   char *new_str;
516   
517   if (str)
518     {
519       new_str = malloc ((strlen (str) + 1) * sizeof(char));
520       strcpy (new_str, str);
521     }
522   else
523     new_str = NULL;
524   
525   return new_str;
526 }
527
528 int main ()
529 {
530   int major, minor, micro;
531   char *tmp_version;
532
533   system ("touch conf.bonobotest");
534   bonobo_object_get_type ();
535   return 0;
536 }
537
538 ],, no_bonobo=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
539        CFLAGS="$ac_save_CFLAGS"
540        LIBS="$ac_save_LIBS"
541      fi
542   fi
543   if test "x$no_bonobo" = x ; then
544      AC_MSG_RESULT(yes)
545      ifelse([$2], , :, [$2])     
546   else
547      AC_MSG_RESULT(no)
548      if test "$GNOME_CONFIG" = "no" ; then
549        echo "*** The gnome-config script installed by GNOME-LIBS could not be found"
550        echo "*** If BONOBO was installed in PREFIX, make sure PREFIX/bin is in"
551        echo "*** your path, or set the GNOME_CONFIG environment variable to the"
552        echo "*** full path to gnome-config."
553      else
554        if test -f conf.bonobotest ; then
555         :
556        else
557           echo "*** Could not run BONOBO test program, checking why..."
558           CFLAGS="$CFLAGS $BONOBO_CFLAGS"
559           LIBS="$LIBS $BONOBO_LIBS"
560           AC_TRY_LINK([
561 #include <stdio.h>
562 #include <bonobo/gnome-object.h>
563 ],      [ return 0; ],
564         [ echo "*** The test program compiled, but did not run. This usually means"
565           echo "*** that the run-time linker is not finding BONOBO or finding the wrong"
566           echo "*** version of BONOBO. If it is not finding BONOBO, you'll need to set your"
567           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
568           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
569           echo "*** is required on your system"
570           echo "***"
571           echo "*** If you have an old version installed, it is best to remove it, although"
572           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
573         [ echo "*** The test program failed to compile or link. See the file config.log for the"
574           echo "*** exact error that occured. This usually means BONOBO was incorrectly installed"
575           echo "*** or that you have moved BONOBO since it was installed. In the latter case, you"
576           echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ])
577           CFLAGS="$ac_save_CFLAGS"
578           LIBS="$ac_save_LIBS"
579        fi
580      fi
581      BONOBO_CFLAGS=""
582      BONOBO_LIBS=""
583      ifelse([$3], , :, [$3])
584   fi
585   AC_SUBST(BONOBO_CFLAGS)
586   AC_SUBST(BONOBO_LIBS)
587   rm -f conf.bonobotest
588 ])
589
590 AC_DEFUN([BONOBO_CHECK], [
591         AM_PATH_BONOBO(0.1.0,,[AC_MSG_ERROR(BONOBO not found)])
592 ])
593
594 # gnome-common.m4
595
596 # This only for packages that are not in the GNOME CVS tree.
597
598 dnl GNOME_COMMON_INIT
599
600 AC_DEFUN([GNOME_COMMON_INIT],
601 [
602         GNOME_ACLOCAL_DIR=`$ACLOCAL --print-ac-dir`/gnome
603         AC_SUBST(GNOME_ACLOCAL_DIR)
604
605         ACLOCAL="$ACLOCAL -I $GNOME_ACLOCAL_DIR"
606 ])
607
608 dnl
609 dnl GNOME_FILEUTILS_CHECKS
610 dnl
611 dnl checks that are needed for the diskusage applet.
612 dnl
613
614 AC_DEFUN([GNOME_FILEUTILS_CHECKS],
615 [       
616 AC_CHECK_HEADERS(fcntl.h sys/param.h sys/statfs.h sys/fstyp.h \
617 mnttab.h mntent.h sys/statvfs.h sys/vfs.h sys/mount.h \
618 sys/filsys.h sys/fs_types.h sys/fs/s5param.h)
619
620 AC_CHECK_FUNCS(bcopy endgrent endpwent fchdir ftime ftruncate \
621 getcwd getmntinfo gettimeofday isascii lchown \
622 listmntent memcpy mkfifo strchr strerror strrchr vprintf)
623
624 dnl Set some defaults when cross-compiling
625
626 if test x$cross_compiling = xyes ; then
627         case "$host_os" in
628         linux*)
629           fu_cv_sys_mounted_getmntent1=yes
630           fu_cv_sys_stat_statfs2_bsize=yes
631           ;;
632         sunos*)
633           fu_cv_sys_stat_statfs4=yes
634           ;;
635         freebsd*)
636           fu_cv_sys_stat_statfs2_bsize=yes
637           ;;
638         osf*)
639           fu_cv_sys_stat_statfs3_osf1=yes
640           ;;
641         esac
642 fi
643
644 # Determine how to get the list of mounted filesystems.
645 list_mounted_fs=
646
647 # If the getmntent function is available but not in the standard library,
648 # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
649 AC_FUNC_GETMNTENT
650
651 # This test must precede the ones for getmntent because Unicos-9 is
652 # reported to have the getmntent function, but its support is incompatible
653 # with other getmntent implementations.
654
655 # NOTE: Normally, I wouldn't use a check for system type as I've done for
656 # `CRAY' below since that goes against the whole autoconf philosophy.  But
657 # I think there is too great a chance that some non-Cray system has a
658 # function named listmntent to risk the false positive.
659
660 if test -z "$list_mounted_fs"; then
661 # Cray UNICOS 9
662 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
663 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent,
664 [fu_cv_sys_mounted_cray_listmntent=no
665 AC_EGREP_CPP(yes,
666 [#ifdef _CRAY
667 yes
668 #endif
669 ], [test $ac_cv_func_listmntent = yes \
670 && fu_cv_sys_mounted_cray_listmntent=yes]
671 )
672 ]
673 )
674 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent)
675 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
676 list_mounted_fs=found
677 AC_DEFINE(MOUNTED_LISTMNTENT)
678 fi
679 fi
680
681 if test $ac_cv_func_getmntent = yes; then
682
683 # This system has the getmntent function.
684 # Determine whether it's the one-argument variant or the two-argument one.
685
686 if test -z "$list_mounted_fs"; then
687 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
688 AC_MSG_CHECKING([for one-argument getmntent function])
689 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
690 [test $ac_cv_header_mntent_h = yes \
691 && fu_cv_sys_mounted_getmntent1=yes \
692 || fu_cv_sys_mounted_getmntent1=no])
693 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1)
694 if test $fu_cv_sys_mounted_getmntent1 = yes; then
695 list_mounted_fs=found
696 AC_DEFINE(MOUNTED_GETMNTENT1)
697 fi
698 fi
699
700 if test -z "$list_mounted_fs"; then
701 # SVR4
702 AC_MSG_CHECKING([for two-argument getmntent function])
703 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
704 [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
705 fu_cv_sys_mounted_getmntent2=yes,
706 fu_cv_sys_mounted_getmntent2=no)])
707 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2)
708 if test $fu_cv_sys_mounted_getmntent2 = yes; then
709 list_mounted_fs=found
710 AC_DEFINE(MOUNTED_GETMNTENT2)
711 fi
712 fi
713
714 if test -z "$list_mounted_fs"; then
715 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
716 fi
717
718 fi
719
720 if test -z "$list_mounted_fs"; then
721 # DEC Alpha running OSF/1.
722 AC_MSG_CHECKING([for getfsstat function])
723 AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
724 [AC_TRY_LINK([
725 #include <sys/types.h>
726 #include <sys/mount.h>
727 #include <sys/fs_types.h>],
728 [struct statfs *stats;
729 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
730 fu_cv_sys_mounted_getsstat=yes,
731 fu_cv_sys_mounted_getsstat=no)])
732 AC_MSG_RESULT($fu_cv_sys_mounted_getsstat)
733 if test $fu_cv_sys_mounted_getsstat = yes; then
734 list_mounted_fs=found
735 AC_DEFINE(MOUNTED_GETFSSTAT)
736 fi
737 fi
738
739 if test -z "$list_mounted_fs"; then
740 # AIX.
741 AC_MSG_CHECKING([for mntctl function and struct vmount])
742 AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
743 [AC_TRY_CPP([#include <fshelp.h>],
744 fu_cv_sys_mounted_vmount=yes,
745 fu_cv_sys_mounted_vmount=no)])
746 AC_MSG_RESULT($fu_cv_sys_mounted_vmount)
747 if test $fu_cv_sys_mounted_vmount = yes; then
748 list_mounted_fs=found
749 AC_DEFINE(MOUNTED_VMOUNT)
750 fi
751 fi
752
753 if test -z "$list_mounted_fs"; then
754 # SVR3
755 AC_MSG_CHECKING([for FIXME existence of three headers])
756 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
757 [AC_TRY_CPP([
758 #include <sys/statfs.h>
759 #include <sys/fstyp.h>
760 #include <mnttab.h>],
761 fu_cv_sys_mounted_fread_fstyp=yes,
762 fu_cv_sys_mounted_fread_fstyp=no)])
763 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp)
764 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
765 list_mounted_fs=found
766 AC_DEFINE(MOUNTED_FREAD_FSTYP)
767 fi
768 fi
769
770 if test -z "$list_mounted_fs"; then
771 # 4.4BSD and DEC OSF/1.
772 AC_MSG_CHECKING([for getmntinfo function])
773 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
774 [
775 ok=
776 if test $ac_cv_func_getmntinfo = yes; then
777 AC_EGREP_HEADER(f_type;, sys/mount.h,
778 ok=yes)
779 fi
780 test -n "$ok" \
781 && fu_cv_sys_mounted_getmntinfo=yes \
782 || fu_cv_sys_mounted_getmntinfo=no
783 ])
784 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
785 if test $fu_cv_sys_mounted_getmntinfo = yes; then
786 list_mounted_fs=found
787 AC_DEFINE(MOUNTED_GETMNTINFO)
788 fi
789 fi
790
791 # FIXME: add a test for netbsd-1.1 here
792
793 if test -z "$list_mounted_fs"; then
794 # Ultrix
795 AC_MSG_CHECKING([for getmnt function])
796 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
797 [AC_TRY_CPP([
798 #include <sys/fs_types.h>
799 #include <sys/mount.h>],
800 fu_cv_sys_mounted_getmnt=yes,
801 fu_cv_sys_mounted_getmnt=no)])
802 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt)
803 if test $fu_cv_sys_mounted_getmnt = yes; then
804 list_mounted_fs=found
805 AC_DEFINE(MOUNTED_GETMNT)
806 fi
807 fi
808
809 if test -z "$list_mounted_fs"; then
810 # SVR2
811 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
812 AC_CACHE_VAL(fu_cv_sys_mounted_fread,
813 [AC_TRY_CPP([#include <mnttab.h>],
814 fu_cv_sys_mounted_fread=yes,
815 fu_cv_sys_mounted_fread=no)])
816 AC_MSG_RESULT($fu_cv_sys_mounted_fread)
817 if test $fu_cv_sys_mounted_fread = yes; then
818 list_mounted_fs=found
819 AC_DEFINE(MOUNTED_FREAD)
820 fi
821 fi
822
823 if test -z "$list_mounted_fs"; then
824 AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
825 # FIXME -- no need to abort building the whole package
826 # Can't build mountlist.c or anything that needs its functions
827 fi
828
829 AC_CHECKING(how to get filesystem space usage)
830 space=no
831
832 # Perform only the link test since it seems there are no variants of the
833 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
834 # because that got a false positive on SCO OSR5.  Adding the declaration
835 # of a `struct statvfs' causes this test to fail (as it should) on such
836 # systems.  That system is reported to work fine with STAT_STATFS4 which
837 # is what it gets when this test fails.
838 if test $space = no; then
839 # SVR4
840 AC_CACHE_CHECK([statvfs function (SVR4)], fu_cv_sys_stat_statvfs,
841 [AC_TRY_LINK([#include <sys/types.h>
842 #include <sys/statvfs.h>],
843 [struct statvfs fsd; statvfs (0, &fsd);],
844 fu_cv_sys_stat_statvfs=yes,
845 fu_cv_sys_stat_statvfs=no)])
846 if test $fu_cv_sys_stat_statvfs = yes; then
847 space=yes
848 AC_DEFINE(STAT_STATVFS)
849 fi
850 fi
851
852 if test $space = no; then
853 # DEC Alpha running OSF/1
854 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
855 AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
856 [AC_TRY_RUN([
857 #include <sys/param.h>
858 #include <sys/types.h>
859 #include <sys/mount.h>
860 main ()
861 {
862 struct statfs fsd;
863 fsd.f_fsize = 0;
864 exit (statfs (".", &fsd, sizeof (struct statfs)));
865 }],
866 fu_cv_sys_stat_statfs3_osf1=yes,
867 fu_cv_sys_stat_statfs3_osf1=no,
868 fu_cv_sys_stat_statfs3_osf1=no)])
869 AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
870 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
871 space=yes
872 AC_DEFINE(STAT_STATFS3_OSF1)
873 fi
874 fi
875
876 if test $space = no; then
877 # AIX
878 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
879 member (AIX, 4.3BSD)])
880 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
881 [AC_TRY_RUN([
882 #ifdef HAVE_SYS_PARAM_H
883 #include <sys/param.h>
884 #endif
885 #ifdef HAVE_SYS_MOUNT_H
886 #include <sys/mount.h>
887 #endif
888 #ifdef HAVE_SYS_VFS_H
889 #include <sys/vfs.h>
890 #endif
891 main ()
892 {
893 struct statfs fsd;
894 fsd.f_bsize = 0;
895 exit (statfs (".", &fsd));
896 }],
897 fu_cv_sys_stat_statfs2_bsize=yes,
898 fu_cv_sys_stat_statfs2_bsize=no,
899 fu_cv_sys_stat_statfs2_bsize=no)])
900 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize)
901 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
902 space=yes
903 AC_DEFINE(STAT_STATFS2_BSIZE)
904 fi
905 fi
906
907 if test $space = no; then
908 # SVR3
909 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
910 AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
911 [AC_TRY_RUN([#include <sys/types.h>
912 #include <sys/statfs.h>
913 main ()
914 {
915 struct statfs fsd;
916 exit (statfs (".", &fsd, sizeof fsd, 0));
917 }],
918 fu_cv_sys_stat_statfs4=yes,
919 fu_cv_sys_stat_statfs4=no,
920 fu_cv_sys_stat_statfs4=no)])
921 AC_MSG_RESULT($fu_cv_sys_stat_statfs4)
922 if test $fu_cv_sys_stat_statfs4 = yes; then
923 space=yes
924 AC_DEFINE(STAT_STATFS4)
925 fi
926 fi
927
928 if test $space = no; then
929 # 4.4BSD and NetBSD
930 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
931 member (4.4BSD and NetBSD)])
932 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
933 [AC_TRY_RUN([#include <sys/types.h>
934 #ifdef HAVE_SYS_PARAM_H
935 #include <sys/param.h>
936 #endif
937 #ifdef HAVE_SYS_MOUNT_H
938 #include <sys/mount.h>
939 #endif
940 main ()
941 {
942 struct statfs fsd;
943 fsd.f_fsize = 0;
944 exit (statfs (".", &fsd));
945 }],
946 fu_cv_sys_stat_statfs2_fsize=yes,
947 fu_cv_sys_stat_statfs2_fsize=no,
948 fu_cv_sys_stat_statfs2_fsize=no)])
949 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize)
950 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
951 space=yes
952 AC_DEFINE(STAT_STATFS2_FSIZE)
953 fi
954 fi
955
956 if test $space = no; then
957 # Ultrix
958 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
959 AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
960 [AC_TRY_RUN([#include <sys/types.h>
961 #ifdef HAVE_SYS_PARAM_H
962 #include <sys/param.h>
963 #endif
964 #ifdef HAVE_SYS_MOUNT_H
965 #include <sys/mount.h>
966 #endif
967 #ifdef HAVE_SYS_FS_TYPES_H
968 #include <sys/fs_types.h>
969 #endif
970 main ()
971 {
972 struct fs_data fsd;
973 /* Ultrix's statfs returns 1 for success,
974 0 for not mounted, -1 for failure.  */
975 exit (statfs (".", &fsd) != 1);
976 }],
977 fu_cv_sys_stat_fs_data=yes,
978 fu_cv_sys_stat_fs_data=no,
979 fu_cv_sys_stat_fs_data=no)])
980 AC_MSG_RESULT($fu_cv_sys_stat_fs_data)
981 if test $fu_cv_sys_stat_fs_data = yes; then
982 space=yes
983 AC_DEFINE(STAT_STATFS2_FS_DATA)
984 fi
985 fi
986
987 if test $space = no; then
988 # SVR2
989 AC_TRY_CPP([#include <sys/filsys.h>],
990 AC_DEFINE(STAT_READ_FILSYS) space=yes)
991 fi
992
993 if test -n "$list_mounted_fs" && test $space != no; then
994 DF_PROG="df"
995 # LIBOBJS="$LIBOBJS fsusage.o"
996 # LIBOBJS="$LIBOBJS mountlist.o"
997 fi
998
999 # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
1000 # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
1001 # enable the work-around code in fsusage.c.
1002 AC_MSG_CHECKING([for statfs that truncates block counts])
1003 AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
1004 [AC_TRY_COMPILE([
1005 #if !defined(sun) && !defined(__sun)
1006 choke -- this is a workaround for a Sun-specific problem
1007 #endif
1008 #include <sys/types.h>
1009 #include <sys/vfs.h>],
1010 [struct statfs t; long c = *(t.f_spare);],
1011 fu_cv_sys_truncating_statfs=yes,
1012 fu_cv_sys_truncating_statfs=no,
1013 )])
1014 if test $fu_cv_sys_truncating_statfs = yes; then
1015 AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS)
1016 fi
1017 AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
1018
1019 AC_CHECKING(for AFS)
1020 test -d /afs && AC_DEFINE(AFS)
1021 ])
1022 AC_DEFUN([GNOME_GHTTP_CHECK],[
1023         AC_REQUIRE([GNOME_INIT_HOOK])
1024         GHTTP_LIB=
1025         AC_CHECK_FUNC(connect,,[
1026           AC_CHECK_LIB(socket,connect,
1027                 GHTTP_LIB="-lsocket $GHTTP_LIB",,$GHTTP_LIB)])
1028         AC_CHECK_FUNC(gethostbyname,,[
1029           AC_CHECK_LIB(nsl,gethostbyname,
1030                 GHTTP_LIB="-lnsl $GHTTP_LIB",,$GHTTP_LIB)])
1031         AC_CHECK_LIB(ghttp, ghttp_request_new, 
1032                 GHTTP_LIB="-lghttp $GHTTP_LIB",GHTTP_LIB="",-L$gnome_prefix $GHTTP_LIB)
1033         AC_SUBST(GHTTP_LIB)
1034         AC_PROVIDE([GNOME_GHTTP_CHECK])
1035 ])
1036 dnl
1037 dnl GNOME_GNORBA_HOOK (script-if-gnorba-found, failflag)
1038 dnl
1039 dnl if failflag is "failure" it aborts if gnorba is not found.
1040 dnl
1041
1042 AC_DEFUN([GNOME_GNORBA_HOOK],[
1043         GNOME_ORBIT_HOOK([],$2)
1044         AC_CACHE_CHECK([for gnorba libraries],gnome_cv_gnorba_found,[
1045                 gnome_cv_gnorba_found=no
1046                 if test x$gnome_cv_orbit_found = xyes; then
1047                         GNORBA_CFLAGS="`gnome-config --cflags gnorba gnomeui`"
1048                         GNORBA_LIBS="`gnome-config --libs gnorba gnomeui`"
1049                         if test -n "$GNORBA_LIBS"; then
1050                                 gnome_cv_gnorba_found=yes
1051                         fi
1052                 fi
1053         ])
1054         AM_CONDITIONAL(HAVE_GNORBA, test x$gnome_cv_gnorba_found = xyes)
1055         if test x$gnome_cv_orbit_found = xyes; then
1056                 $1
1057                 GNORBA_CFLAGS="`gnome-config --cflags gnorba gnomeui`"
1058                 GNORBA_LIBS="`gnome-config --libs gnorba gnomeui`"
1059                 AC_SUBST(GNORBA_CFLAGS)
1060                 AC_SUBST(GNORBA_LIBS)
1061         else
1062                 if test x$2 = xfailure; then
1063                         AC_MSG_ERROR(gnorba library not installed or installation problem)
1064                 fi
1065         fi
1066 ])
1067
1068 AC_DEFUN([GNOME_GNORBA_CHECK], [
1069         GNOME_GNORBA_HOOK([],failure)
1070 ])
1071 dnl
1072 dnl GNOME_CHECK_GUILE (failflag)
1073 dnl
1074 dnl if failflag is "fail" then GNOME_CHECK_GUILE will abort if guile is not found.
1075 dnl
1076
1077 AC_DEFUN([GNOME_CHECK_GUILE],
1078 [
1079         saved_ldflags="$LDFLAGS"
1080         saved_cppflags="$CPPFLAGS"
1081         LDFLAGS="$LDFLAGS $GNOME_LIBDIR"
1082
1083         AC_CHECK_LIB(qthreads,qt_null,[
1084                 QTTHREADS_LIB="-lqthreads"
1085         ],[
1086                 AC_CHECK_LIB(qt, qt_null, QTTHREADS_LIB="-lqt")
1087         ],$LIBS)
1088         AC_SUBST(QTTHREADS_LIB)
1089
1090         AC_CHECK_LIB(termcap,main,TERMCAP_LIB="-ltermcap")
1091         AC_CHECK_LIB(readline,main,READLINE_LIB="-lreadline",,$TERMCAP_LIB)
1092
1093         AC_SUBST(TERMCAP_LIB)
1094         AC_SUBST(READLINE_LIB)
1095
1096         if test "x$cross_compiling" = "xyes" ; then
1097           name_build_guile="$target_alias-guile-config"
1098         else
1099           name_build_guile="guile-config"
1100         fi
1101
1102         AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
1103
1104         if test "x$BUILD_GUILE" = "xyes"; then
1105             AC_MSG_CHECKING(whether $name_build_guile works)
1106             if test x`$name_build_guile --version >/dev/null 2>&1 || \
1107                 echo no` = xno; then
1108                 BUILD_GUILE=no
1109             fi
1110             AC_MSG_RESULT($BUILD_GUILE)
1111         else
1112
1113             if test "x$cross_compiling" = "xyes" ; then
1114                 name_build_guile="$target_alias-build-guile"
1115             else        
1116                 name_build_guile="build-guile"
1117             fi
1118
1119             AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
1120
1121             if test "x$BUILD_GUILE" = "xyes"; then
1122                 AC_MSG_CHECKING(whether $name_build_guile works)
1123                 if test x`$name_build_guile --version >/dev/null 2>&1 || \
1124                     echo no` = xno; then
1125                     BUILD_GUILE=no
1126                 fi
1127                 AC_MSG_RESULT($BUILD_GUILE)
1128             fi
1129         fi
1130
1131         AC_CHECK_LIB(m, sin)
1132
1133         if test "x$BUILD_GUILE" = "xyes"; then
1134                 AC_MSG_CHECKING(for guile libraries)
1135                 GUILE_LIBS="`$name_build_guile link`"
1136                 AC_MSG_RESULT($GUILE_LIBS)
1137                 AC_MSG_CHECKING(for guile headers)
1138                 GUILE_INCS="`$name_build_guile compile`"
1139                 AC_MSG_RESULT($GUILE_INCS)
1140         else
1141                 GUILE_LIBS="$GNOME_LIBDIR"
1142                 GUILE_INCS="$GNOME_INCLUDEDIR"
1143                 AC_CHECK_LIB(rx, main, GUILE_LIBS="-lrx $GUILE_LIBS")
1144                 AC_CHECK_LIB(qt, qt_null, GUILE_LIBS="-lqt $GUILE_LIBS")
1145                 AC_CHECK_LIB(dl, dlopen, GUILE_LIBS="-ldl $GUILE_LIBS")
1146                 AC_CHECK_LIB(nsl, t_accept, GUILE_LIBS="$GUILE_LIBS -lnsl")
1147                 AC_CHECK_LIB(socket, socket, GUILE_LIBS="$GUILE_LIBS -lsocket")
1148                 GUILE_LIBS="-lguile $GUILE_LIBS $QTTHREADS_LIB $READLINE_LIB $TERMCAP_LIB"
1149         fi
1150
1151         AC_SUBST(GUILE_LIBS)
1152         AC_SUBST(GUILE_INCS)
1153
1154         saved_LIBS="$LIBS"
1155         LIBS="$LIBS $GUILE_LIBS"
1156         CPPFLAGS="$saved_cppflags $GUILE_INCS"
1157
1158         AC_MSG_CHECKING(whether guile works)
1159         AC_TRY_LINK([
1160                 #include <libguile.h>
1161                 #include <guile/gh.h>
1162         ],[
1163                 gh_eval_str("(newline)");
1164                 scm_boot_guile(0,NULL,NULL,NULL);
1165         ],[
1166                 ac_cv_guile_found=yes
1167                 AC_DEFINE(HAVE_GUILE)
1168         ],[
1169                 ac_cv_guile_found=no
1170         ])
1171         AC_MSG_RESULT($ac_cv_guile_found)
1172
1173         if test x$ac_cv_guile_found = xno ; then
1174                 if test x$1 = xfail ; then
1175                   AC_MSG_ERROR(Can not find Guile on this system)
1176                 else
1177                   AC_MSG_WARN(Can not find Guile on this system)
1178                 fi
1179                 ac_cv_guile_found=no
1180                 GUILE_LIBS= GUILE_INCS=
1181         fi
1182
1183         LIBS="$saved_LIBS"
1184         LDFLAGS="$saved_ldflags"
1185         CPPFLAGS="$saved_cppflags"
1186
1187         AC_SUBST(GUILE_LIBS)
1188         AM_CONDITIONAL(GUILE, test x$ac_cv_guile_found = xyes)
1189 ])
1190 dnl
1191 dnl LIBGTOP_CHECK_TYPE
1192 dnl
1193 dnl Improved version of AC_CHECK_TYPE which takes into account
1194 dnl that we need to #include some other header files on some
1195 dnl systems to get some types.
1196
1197 dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT)
1198 AC_DEFUN(AC_LIBGTOP_CHECK_TYPE,
1199 [AC_REQUIRE([AC_HEADER_STDC])dnl
1200 AC_MSG_CHECKING(for $1)
1201 AC_CACHE_VAL(ac_cv_type_$1,
1202 [AC_EGREP_CPP(dnl
1203 changequote(<<,>>)dnl
1204 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
1205 changequote([,]), [#include <sys/types.h>
1206 #if STDC_HEADERS
1207 #include <stdlib.h>
1208 #include <stddef.h>
1209 #endif
1210
1211 /* For Tru64 */
1212 #ifdef HAVE_SYS_BITYPES_H
1213 #include <sys/bitypes.h>
1214 #endif
1215 ], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
1216 AC_MSG_RESULT($ac_cv_type_$1)
1217 if test $ac_cv_type_$1 = no; then
1218   AC_DEFINE($1, $2)
1219 fi
1220 ])
1221
1222 dnl
1223 dnl GNOME_LIBGTOP_TYPES
1224 dnl
1225 dnl some typechecks for libgtop.
1226 dnl
1227
1228 AC_DEFUN([GNOME_LIBGTOP_TYPES],
1229 [
1230         AC_CHECK_HEADERS(sys/bitypes.h)
1231         AC_LIBGTOP_CHECK_TYPE(u_int64_t, unsigned long long int)
1232         AC_LIBGTOP_CHECK_TYPE(int64_t, signed long long int)
1233 ])
1234
1235 dnl
1236 dnl GNOME_LIBGTOP_HOOK (minversion, script-if-libgtop-enabled, failflag)
1237 dnl
1238 dnl if failflag is "fail" then GNOME_LIBGTOP_HOOK will abort if LibGTop
1239 dnl is not found. 
1240 dnl
1241
1242 AC_DEFUN([GNOME_LIBGTOP_HOOK],
1243 [       
1244         AC_REQUIRE([GNOME_LIBGTOP_TYPES])
1245
1246         AC_SUBST(LIBGTOP_LIBDIR)
1247         AC_SUBST(LIBGTOP_INCLUDEDIR)
1248         AC_SUBST(LIBGTOP_EXTRA_LIBS)
1249         AC_SUBST(LIBGTOP_LIBS)
1250         AC_SUBST(LIBGTOP_INCS)
1251         AC_SUBST(LIBGTOP_NAMES_LIBS)
1252         AC_SUBST(LIBGTOP_NAMES_INCS)
1253         AC_SUBST(LIBGTOP_MAJOR_VERSION)
1254         AC_SUBST(LIBGTOP_MINOR_VERSION)
1255         AC_SUBST(LIBGTOP_MICRO_VERSION)
1256         AC_SUBST(LIBGTOP_VERSION)
1257         AC_SUBST(LIBGTOP_VERSION_CODE)
1258         AC_SUBST(LIBGTOP_SERVER_VERSION)
1259         AC_SUBST(LIBGTOP_INTERFACE_AGE)
1260         AC_SUBST(LIBGTOP_BINARY_AGE)
1261         AC_SUBST(LIBGTOP_BINDIR)
1262         AC_SUBST(LIBGTOP_SERVER)
1263
1264         dnl Get the cflags and libraries from the libgtop-config script
1265         dnl
1266         AC_ARG_WITH(libgtop,
1267         [  --with-libgtop=PFX      Prefix where LIBGTOP is installed (optional)],
1268         libgtop_config_prefix="$withval", libgtop_config_prefix="")
1269         AC_ARG_WITH(libgtop-exec,
1270         [  --with-libgtop-exec=PFX Exec prefix where LIBGTOP is installed (optional)],
1271         libgtop_config_exec_prefix="$withval", libgtop_config_exec_prefix="")
1272
1273         if test x$libgtop_config_exec_prefix != x ; then
1274           libgtop_config_args="$libgtop_config_args --exec-prefix=$libgtop_config_exec_prefix"
1275           if test x${LIBGTOP_CONFIG+set} != xset ; then
1276             LIBGTOP_CONFIG=$libgtop_config_exec_prefix/bin/libgtop-config
1277           fi
1278         fi
1279         if test x$libgtop_config_prefix != x ; then
1280           libgtop_config_args="$libgtop_config_args --prefix=$libgtop_config_prefix"
1281           if test x${LIBGTOP_CONFIG+set} != xset ; then
1282             LIBGTOP_CONFIG=$libgtop_config_prefix/bin/libgtop-config
1283           fi
1284         fi
1285
1286         AC_PATH_PROG(LIBGTOP_CONFIG, libgtop-config, no)
1287         dnl IMPORTANT NOTICE:
1288         dnl   If you increase this number here, this means that *ALL*
1289         dnl   modules will require the new version, even if they explicitly
1290         dnl   give a lower number in their `configure.in' !!!
1291         real_min_libgtop_version=1.0.0
1292         min_libgtop_version=ifelse([$1], ,$real_min_libgtop_version,$1)
1293         dnl I know, the following code looks really ugly, but if you want
1294         dnl to make changes, please test it with a brain-dead /bin/sh and
1295         dnl with a brain-dead /bin/test (not all shells/tests support the
1296         dnl `<' operator to compare strings, that's why I convert everything
1297         dnl into numbers and test them).
1298         min_libgtop_major=`echo $min_libgtop_version | \
1299           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1300         min_libgtop_minor=`echo $min_libgtop_version | \
1301           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1302         min_libgtop_micro=`echo $min_libgtop_version | \
1303           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1304         test x$min_libgtop_micro = x && min_libgtop_micro=0
1305         real_min_libgtop_major=`echo $real_min_libgtop_version | \
1306           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1307         real_min_libgtop_minor=`echo $real_min_libgtop_version | \
1308           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1309         real_min_libgtop_micro=`echo $real_min_libgtop_version | \
1310           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1311         test x$real_min_libgtop_micro = x && real_min_libgtop_micro=0
1312         dnl You cannot require a version less then $real_min_libgtop_version,
1313         dnl so you don't need to update each `configure.in' when it's increased.
1314         if test $real_min_libgtop_major -gt $min_libgtop_major ; then
1315           min_libgtop_major=$real_min_libgtop_major
1316           min_libgtop_minor=$real_min_libgtop_minor
1317           min_libgtop_micro=$real_min_libgtop_micro
1318         elif test $real_min_libgtop_major = $min_libgtop_major ; then
1319           if test $real_min_libgtop_minor -gt $min_libgtop_minor ; then
1320             min_libgtop_minor=$real_min_libgtop_minor
1321             min_libgtop_micro=$real_min_libgtop_micro
1322           elif test $real_min_libgtop_minor = $min_libgtop_minor ; then
1323             if test $real_min_libgtop_micro -gt $min_libgtop_micro ; then
1324               min_libgtop_micro=$real_min_libgtop_micro
1325             fi
1326           fi
1327         fi
1328         min_libgtop_version="$min_libgtop_major.$min_libgtop_minor.$min_libgtop_micro"
1329         AC_MSG_CHECKING(for libgtop - version >= $min_libgtop_version)
1330         no_libgtop=""
1331         if test "$LIBGTOP_CONFIG" = "no" ; then
1332           no_libgtop=yes
1333         else
1334           configfile=`$LIBGTOP_CONFIG --config`
1335           libgtop_major_version=`$LIBGTOP_CONFIG --version | \
1336             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1337           libgtop_minor_version=`$LIBGTOP_CONFIG --version | \
1338             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1339           libgtop_micro_version=`$LIBGTOP_CONFIG --version | \
1340             sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1341           if test $libgtop_major_version != $min_libgtop_major ; then 
1342             no_libgtop=mismatch
1343           else 
1344             test $libgtop_minor_version -lt $min_libgtop_minor && no_libgtop=yes
1345             if test $libgtop_minor_version = $min_libgtop_minor ; then
1346               test $libgtop_micro_version -lt $min_libgtop_micro && no_libgtop=yes
1347             fi
1348           fi
1349           . $configfile
1350         fi
1351         if test x$no_libgtop = x ; then
1352           AC_DEFINE(HAVE_LIBGTOP)
1353           AC_DEFINE_UNQUOTED(LIBGTOP_VERSION, "$LIBGTOP_VERSION")
1354           AC_DEFINE_UNQUOTED(LIBGTOP_VERSION_CODE, $LIBGTOP_VERSION_CODE)
1355           AC_DEFINE_UNQUOTED(LIBGTOP_MAJOR_VERSION, $LIBGTOP_MAJOR_VERSION)
1356           AC_DEFINE_UNQUOTED(LIBGTOP_MINOR_VERSION, $LIBGTOP_MINOR_VERSION)
1357           AC_DEFINE_UNQUOTED(LIBGTOP_MICRO_VERSION, $LIBGTOP_MICRO_VERSION)
1358           AC_DEFINE_UNQUOTED(LIBGTOP_SERVER_VERSION, $LIBGTOP_SERVER_VERSION)
1359           AC_MSG_RESULT(yes)
1360           dnl Note that an empty true branch is not valid sh syntax.
1361           ifelse([$2], [], :, [$2])
1362         else
1363           AC_MSG_RESULT(no)
1364           if test "$no_libgtop"x = mismatchx; then
1365             AC_MSG_ERROR(LibGTop major version mismatch $libgtop_major_version != $min_libgtop_major)
1366           fi
1367           if test "x$3" = "xfail"; then
1368             AC_MSG_ERROR(LibGTop >= $min_libgtop_version not found)
1369           else
1370             AC_MSG_WARN(LibGTop >= $min_libgtop_version not found)
1371           fi
1372         fi
1373
1374         AM_CONDITIONAL(HAVE_LIBGTOP, test x$no_libgtop != xyes)
1375 ])
1376
1377 AC_DEFUN([GNOME_INIT_LIBGTOP],[
1378         GNOME_LIBGTOP_HOOK($1,[ifelse([$3], [], :, [$3])],$2)
1379 ])
1380
1381 dnl
1382 dnl GNOME_LIBGTOP_DOCU
1383 dnl
1384 dnl checks whether the documentation of LibGTop is installed
1385 dnl
1386
1387 AC_DEFUN([GNOME_LIBGTOP_DOCU],
1388 [
1389         AC_REQUIRE([GNOME_LIBGTOP_HOOK])
1390
1391         helpdir="$LIBGTOP_DATADIR/gnome/help/libgtop"
1392
1393         AC_MSG_CHECKING(whether you have the LibGTop Documentation)
1394
1395         if test -f "$helpdir/C/topic.dat" ; then
1396           have_libgtop_docu=yes
1397           AC_DEFINE(HAVE_LIBGTOP_DOCU)
1398         else
1399           have_libgtop_docu=no
1400         fi
1401
1402         AC_MSG_RESULT($have_libgtop_docu)
1403
1404         AM_CONDITIONAL(HAVE_LIBGTOP_DOCU, test x$have_libgtop_docu = xyes)
1405 ])
1406
1407 AC_DEFUN([GNOME_CHECK_OBJC],
1408 [
1409 dnl Look for an ObjC compiler.
1410 dnl FIXME: extend list of possible names of ObjC compilers.
1411   AC_CHECK_PROGS(OBJC, $OBJC egcs, "")
1412   if test "x$OBJC" = "x" ; then
1413     AC_CHECK_PROGS(OBJC, $OBJC egcc, "")
1414     if test "x$OBJC" = "x" ; then
1415       AC_CHECK_PROGS(OBJC, $OBJC gcc, "")
1416     fi
1417   fi
1418
1419   AC_REQUIRE([GNOME_PTHREAD_CHECK])
1420
1421   OBJC_LIBS="-lobjc $PTHREAD_LIB"
1422   AC_CHECK_FUNC(sched_yield,,[
1423     AC_CHECK_LIB(rt,sched_yield,
1424       OBJC_LIBS="$OBJC_LIBS -lrt",[
1425       AC_CHECK_LIB(posix4,sched_yield,
1426         OBJC_LIBS="$OBJC_LIBS -lposix4",, 
1427         $OBJC_LIBS)],
1428       $OBJC_LIBS)])
1429   AC_SUBST(OBJC_LIBS)
1430
1431   AC_CACHE_CHECK([if Objective C compiler ($OBJC) works],
1432                  ac_cv_prog_objc_works, [
1433     if test -n "$OBJC"; then
1434       cat > conftest.m <<EOF
1435 #include <objc/Object.h>
1436 @interface myRandomObj : Object
1437 {
1438 }
1439 @end
1440 @implementation myRandomObj
1441 @end
1442 int main () {
1443   /* No, you are not seeing double.  Remember that square brackets
1444      are the autoconf m4 quotes.  */
1445   id myid = [[myRandomObj alloc]];
1446   [[myid free]];
1447   return 0;
1448 }
1449 EOF
1450
1451       $OBJC $CFLAGS -o conftest $LDFLAGS conftest.m $OBJC_LIBS 1>&AC_FD_CC 2>&1
1452       result=$?
1453       rm -f conftest*
1454
1455       if test $result -eq 0; then
1456         ac_cv_prog_objc_works=yes
1457       fi
1458     else
1459       ac_cv_prog_objc_works=no
1460     fi
1461   ])
1462
1463   AM_CONDITIONAL(OBJECTIVE_C, test x$ac_cv_prog_objc_works = xyes)
1464   dnl Also set the shell variable OBJECTIVE_C to "yes" or "no".
1465   OBJECTIVE_C=$ac_cv_prog_objc_works
1466 ])
1467
1468 AC_DEFUN([GNOME_INIT_OBJC],
1469 [
1470         AC_MSG_CHECKING(for an obGnomeConf.sh)
1471         my_gnome_libdir=`$GNOME_CONFIG --libdir`
1472         if test -f $my_gnome_libdir/obGnomeConf.sh; then
1473             . $my_gnome_libdir/obGnomeConf.sh
1474             AC_MSG_RESULT(found $my_gnome_libdir)
1475             ac_cv_have_gnome_objc=yes
1476         else
1477             AC_MSG_RESULT(not found)
1478             AC_MSG_WARN(Could not find the obGnomeConf.sh file that is generated by gnome-objc install)
1479             ac_cv_have_gnome_objc=no
1480         fi
1481         
1482         dnl Add a conditional on whether or not we have gnome-objc
1483         AM_CONDITIONAL(HAVE_GNOME_OBJC, test x$ac_cv_have_gnome_objc = xyes)
1484         HAVE_GNOME_OBJC=$ac_cv_have_gnome_objc
1485
1486         AC_SUBST(OBGNOME_INCLUDEDIR)
1487         AC_SUBST(OBGNOME_LIBS)
1488         AC_SUBST(OBGTK_LIBS)
1489 ])
1490 dnl
1491 dnl GNOME_ORBIT_HOOK (script-if-orbit-found, failflag)
1492 dnl
1493 dnl if failflag is "failure" it aborts if orbit is not found.
1494 dnl
1495
1496 AC_DEFUN([GNOME_ORBIT_HOOK],[
1497         AC_PATH_PROG(ORBIT_CONFIG,orbit-config,no)
1498         AC_PATH_PROG(ORBIT_IDL,orbit-idl,no)
1499         AC_CACHE_CHECK([for working ORBit environment],gnome_cv_orbit_found,[
1500                 if test x$ORBIT_CONFIG = xno -o x$ORBIT_IDL = xno; then
1501                         gnome_cv_orbit_found=no
1502                 else
1503                         gnome_cv_orbit_found=yes
1504                 fi
1505         ])
1506         AM_CONDITIONAL(HAVE_ORBIT, test x$gnome_cv_orbit_found = xyes)
1507         if test x$gnome_cv_orbit_found = xyes; then
1508                 $1
1509                 ORBIT_CFLAGS=`orbit-config --cflags client server`
1510                 ORBIT_LIBS=`orbit-config --use-service=name --libs client server`
1511                 AC_SUBST(ORBIT_CFLAGS)
1512                 AC_SUBST(ORBIT_LIBS)
1513         else
1514                 if test x$2 = xfailure; then
1515                         AC_MSG_ERROR(ORBit not installed or installation problem)
1516                 fi
1517         fi
1518 ])
1519
1520 AC_DEFUN([GNOME_ORBIT_CHECK], [
1521         GNOME_ORBIT_HOOK([],failure)
1522 ])
1523 # Configure paths for GNOME-PRINT
1524 # Chris Lahey   99-2-5
1525 # stolen from Manish Singh again
1526 # stolen back from Frank Belew
1527 # stolen from Manish Singh
1528 # Shamelessly stolen from Owen Taylor
1529
1530 dnl AM_PATH_GNOME_PRINT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1531 dnl Test for GNOME-PRINT, and define GNOME_PRINT_CFLAGS and GNOME_PRINT_LIBS
1532 dnl
1533 AC_DEFUN(AM_PATH_GNOME_PRINT,
1534 [dnl 
1535 dnl Get the cflags and libraries from the gnome-config script
1536 dnl
1537 AC_ARG_WITH(gnome-print-prefix,[  --with-gnome-print-prefix=PFX   Prefix where GNOME-PRINT is installed (optional)],
1538             gnome_print_prefix="$withval", gnome_print_prefix="")
1539 AC_ARG_WITH(gnome-print-exec-prefix,[  --with-gnome-print-exec-prefix=PFX Exec prefix where GNOME-PRINT is installed (optional)],
1540             gnome_print_exec_prefix="$withval", gnome_print_exec_prefix="")
1541 AC_ARG_ENABLE(gnome-printtest, [  --disable-gnome-printtest       Do not try to compile and run a test GNOME-PRINT program],
1542                     , enable_gnome_printtest=yes)
1543
1544   if test x$gnome_print_exec_prefix != x ; then
1545      gnome_print_args="$gnome_print_args --exec-prefix=$gnome_print_exec_prefix"
1546      if test x${GNOME_CONFIG+set} != xset ; then
1547         GNOME_CONFIG=$gnome_print_exec_prefix/bin/gnome-config
1548      fi
1549   fi
1550   if test x$gnome_print_prefix != x ; then
1551      gnome_print_args="$gnome_print_args --prefix=$gnome_print_prefix"
1552      if test x${GNOME_CONFIG+set} != xset ; then
1553         GNOME_CONFIG=$gnome_print_prefix/bin/gnome-config
1554      fi
1555   fi
1556
1557   AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
1558   min_gnome_print_version=ifelse([$1], ,0.1.0,$1)
1559   AC_MSG_CHECKING(for GNOME-PRINT - version >= $min_gnome_print_version)
1560   no_gnome_print=""
1561   if test "$GNOME_CONFIG" = "no" ; then
1562     no_gnome_print=yes
1563   else
1564     GNOME_PRINT_CFLAGS=`$GNOME_CONFIG $gnome_printconf_args --cflags print`
1565     GNOME_PRINT_LIBS=`$GNOME_CONFIG $gnome_printconf_args --libs print`
1566
1567     gnome_print_major_version=`$GNOME_CONFIG $gnome_print_args --version | \
1568            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1569     gnome_print_minor_version=`$GNOME_CONFIG $gnome_print_args --version | \
1570            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1571     gnome_print_micro_version=`$GNOME_CONFIG $gnome_print_config_args --version | \
1572            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1573     if test "x$enable_gnome_printtest" = "xyes" ; then
1574       ac_save_CFLAGS="$CFLAGS"
1575       ac_save_LIBS="$LIBS"
1576       CFLAGS="$CFLAGS $GNOME_PRINT_CFLAGS"
1577       LIBS="$LIBS $GNOME_PRINT_LIBS"
1578 dnl
1579 dnl Now check if the installed GNOME-PRINT is sufficiently new. (Also sanity
1580 dnl checks the results of gnome-config to some extent
1581 dnl
1582       rm -f conf.gnome_printtest
1583       AC_TRY_RUN([
1584 #include <stdio.h>
1585 #include <stdlib.h>
1586 #include <string.h>
1587 #include <libgnomeprint/gnome-print.h>
1588
1589 static char*
1590 my_strdup (char *str)
1591 {
1592   char *new_str;
1593   
1594   if (str)
1595     {
1596       new_str = malloc ((strlen (str) + 1) * sizeof(char));
1597       strcpy (new_str, str);
1598     }
1599   else
1600     new_str = NULL;
1601   
1602   return new_str;
1603 }
1604
1605 int main ()
1606 {
1607   int major, minor, micro;
1608   char *tmp_version;
1609
1610   system ("touch conf.gnome_printtest");
1611
1612   /* HP/UX 9 (%@#!) writes to sscanf strings */
1613   tmp_version = my_strdup("$min_gnome_print_version");
1614   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
1615      printf("%s, bad version string\n", "$min_gnome_print_version");
1616      exit(1);
1617    }
1618   return 0;
1619 #if 0
1620    if (($gnome_print_major_version > major) ||
1621       (($gnome_print_major_version == major) && ($gnome_print_minor_version > minor)) ||
1622       (($gnome_print_major_version == major) && ($gnome_print_minor_version == minor) && ($gnome_print_micro_version >= micro)))
1623     {
1624       return 0;
1625     }
1626   else
1627     {
1628       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);
1629       printf("*** of GNOME-PRINT required is %d.%d.%d. If gnome-config is correct, then it is\n", major, minor, micro);
1630       printf("*** best to upgrade to the required version.\n");
1631       printf("*** If gnome-config was wrong, set the environment variable GNOME_CONFIG\n");
1632       printf("*** to point to the correct copy of gnome-config, and remove the file\n");
1633       printf("*** config.cache before re-running configure\n");
1634       return 1;
1635     }
1636 #endif
1637 }
1638
1639 ],, no_gnome_print=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1640        CFLAGS="$ac_save_CFLAGS"
1641        LIBS="$ac_save_LIBS"
1642      fi
1643   fi
1644   if test "x$no_gnome_print" = x ; then
1645      AC_MSG_RESULT(yes)
1646      ifelse([$2], , :, [$2])     
1647   else
1648      AC_MSG_RESULT(no)
1649      if test "$GNOME_CONFIG" = "no" ; then
1650        echo "*** The gnome-config script installed by GNOME-LIBS could not be found"
1651        echo "*** If GNOME-PRINT was installed in PREFIX, make sure PREFIX/bin is in"
1652        echo "*** your path, or set the GNOME_CONFIG environment variable to the"
1653        echo "*** full path to gnome-config."
1654      else
1655        if test -f conf.gnome_printtest ; then
1656         :
1657        else
1658           echo "*** Could not run GNOME-PRINT test program, checking why..."
1659           CFLAGS="$CFLAGS $GNOME_PRINT_CFLAGS"
1660           LIBS="$LIBS $GNOME_PRINT_LIBS"
1661           AC_TRY_LINK([
1662 #include <stdio.h>
1663 #include <libgnomeprint/gnome-print.h>
1664 ],      [ return 0; ],
1665         [ echo "*** The test program compiled, but did not run. This usually means"
1666           echo "*** that the run-time linker is not finding GNOME-PRINT or finding the wrong"
1667           echo "*** version of GNOME-PRINT. If it is not finding GNOME-PRINT, you'll need to set your"
1668           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
1669           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
1670           echo "*** is required on your system"
1671           echo "***"
1672           echo "*** If you have an old version installed, it is best to remove it, although"
1673           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
1674         [ echo "*** The test program failed to compile or link. See the file config.log for the"
1675           echo "*** exact error that occured. This usually means GNOME-PRINT was incorrectly installed"
1676           echo "*** or that you have moved GNOME-PRINT since it was installed. In the latter case, you"
1677           echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ])
1678           CFLAGS="$ac_save_CFLAGS"
1679           LIBS="$ac_save_LIBS"
1680        fi
1681      fi
1682      GNOME_PRINT_CFLAGS=""
1683      GNOME_PRINT_LIBS=""
1684      ifelse([$3], , :, [$3])
1685   fi
1686   AC_SUBST(GNOME_PRINT_CFLAGS)
1687   AC_SUBST(GNOME_PRINT_LIBS)
1688   rm -f conf.gnome_printtest
1689 ])
1690
1691 AC_DEFUN([GNOME_PRINT_CHECK], [
1692         AM_PATH_GNOME_PRINT(0.1.0,,[AC_MSG_ERROR(GNOME-PRINT not found)])
1693 ])
1694 dnl
1695 dnl And better, use gthreads instead...
1696 dnl
1697
1698 AC_DEFUN([GNOME_PTHREAD_CHECK],[
1699         PTHREAD_LIB=""
1700         AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIB="-lpthread",
1701                 [AC_CHECK_LIB(pthreads, pthread_create, PTHREAD_LIB="-lpthreads",
1702                     [AC_CHECK_LIB(c_r, pthread_create, PTHREAD_LIB="-lc_r",
1703                         [AC_CHECK_FUNC(pthread_create)]
1704                     )]
1705                 )]
1706         )
1707         AC_SUBST(PTHREAD_LIB)
1708         AC_PROVIDE([GNOME_PTHREAD_CHECK])
1709 ])
1710 dnl GNOME_SUPPORT_CHECKS
1711 dnl    Check for various support functions needed by the standard
1712 dnl    Gnome libraries.  Sets LIBOBJS, might define some macros.
1713 dnl    This should only be used when building the Gnome libs; 
1714 dnl    Gnome clients should not need this macro.
1715 AC_DEFUN([GNOME_SUPPORT_CHECKS],[
1716   # we need an `awk' to build `gnomesupport.h'
1717   AC_REQUIRE([AC_PROG_AWK])
1718
1719   # this should go away soon
1720   need_gnome_support=yes
1721
1722   save_LIBOBJS="$LIBOBJS"
1723   LIBOBJS=
1724
1725   AC_CHECK_FUNCS(getopt_long,,LIBOBJS="$LIBOBJS getopt.o getopt1.o")
1726
1727   # for `scandir'
1728   AC_HEADER_DIRENT
1729
1730   # copied from `configure.in' of `libiberty'
1731   vars="program_invocation_short_name program_invocation_name sys_errlist"
1732   for v in $vars; do
1733     AC_MSG_CHECKING([for $v])
1734     AC_CACHE_VAL(gnome_cv_var_$v,
1735       [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
1736                    [eval "gnome_cv_var_$v=yes"],
1737                    [eval "gnome_cv_var_$v=no"])])
1738     if eval "test \"`echo '$gnome_cv_var_'$v`\" = yes"; then
1739       AC_MSG_RESULT(yes)
1740       n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
1741       AC_DEFINE_UNQUOTED($n)
1742     else
1743       AC_MSG_RESULT(no)
1744     fi
1745   done
1746
1747   AC_REPLACE_FUNCS(memmove mkstemp scandir strcasecmp strerror strndup strnlen)
1748   AC_REPLACE_FUNCS(strtok_r strtod strtol strtoul vasprintf vsnprintf)
1749
1750   AC_CHECK_FUNCS(realpath,,LIBOBJS="$LIBOBJS canonicalize.o")
1751
1752   # to include `error.c' error.c has some HAVE_* checks
1753   AC_CHECK_FUNCS(vprintf doprnt strerror_r)
1754   AM_FUNC_ERROR_AT_LINE
1755
1756   # This is required if we declare setreuid () and setregid ().
1757   AC_TYPE_UID_T
1758
1759   # see if we need to declare some functions.  Solaris is notorious for
1760   # putting functions into the `libc' but not listing them in the headers
1761   AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h dirent.h)
1762   GCC_NEED_DECLARATIONS(gethostname setreuid setregid getpagesize)
1763   GCC_NEED_DECLARATION(scandir,[
1764 #ifdef HAVE_DIRENT_H
1765 #include <dirent.h>
1766 #endif
1767 ])
1768
1769   # Turn our LIBOBJS into libtool objects.  This is gross, but it
1770   # requires changes to autoconf before it goes away.
1771   LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'`
1772   AC_SUBST(need_gnome_support)
1773   AC_SUBST(LTLIBOBJS)
1774
1775   LIBOBJS="$save_LIBOBJS"
1776   AM_CONDITIONAL(BUILD_GNOME_SUPPORT, test "$need_gnome_support" = yes)
1777 ])
1778 dnl GNOME_UNDELFS_CHECKS
1779 dnl    Check for ext2fs undel support.
1780 dnl    Set shell variable ext2fs_undel to "yes" if we have it,
1781 dnl    "no" otherwise.  May define USE_EXT2FSLIB for cpp.
1782 dnl    Will set EXT2FS_UNDEL_LIBS to required libraries.
1783
1784 AC_DEFUN([GNOME_UNDELFS_CHECKS], [
1785   AC_CHECK_HEADERS(ext2fs/ext2fs.h linux/ext2_fs.h)
1786   ext2fs_undel=no
1787   EXT2FS_UNDEL_LIBS=
1788   if test x$ac_cv_header_ext2fs_ext2fs_h = xyes
1789   then
1790     if test x$ac_cv_header_linux_ext2_fs_h = xyes
1791     then
1792       AC_DEFINE(USE_EXT2FSLIB)
1793       ext2fs_undel=yes
1794       EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err"
1795     fi
1796   fi
1797 ])
1798 dnl GNOME_VFS_CHECKS
1799 dnl   Check for various functions needed by libvfs.
1800 dnl   This has various effects:
1801 dnl     Sets GNOME_VFS_LIBS to libraries required
1802 dnl     Sets termnet  to true or false depending on whether it is required.
1803 dnl        If yes, defines USE_TERMNET.
1804 dnl     Sets vfs_flags to "pretty" list of vfs implementations we include.
1805 dnl     Sets shell variable use_vfs to yes (default, --with-vfs) or
1806 dnl        "no" (--without-vfs).
1807 dnl     Calls AC_SUBST(mcserv), which is either empty or "mcserv".
1808
1809 dnl Private define
1810 AC_DEFUN([GNOME_WITH_VFS],[
1811   dnl FIXME: network checks should probably be in their own macro.
1812   AC_CHECK_LIB(nsl, t_accept)
1813   AC_CHECK_LIB(socket, socket)
1814
1815   have_socket=no
1816   AC_CHECK_FUNCS(socket, have_socket=yes)
1817   if test $have_socket = no; then
1818     # socket is not in the default libraries.  See if it's in some other.
1819     for lib in bsd socket inet; do
1820       AC_CHECK_LIB($lib, socket, [
1821           LIBS="$LIBS -l$lib"
1822           have_socket=yes
1823           AC_DEFINE(HAVE_SOCKET)
1824           break])
1825     done
1826   fi
1827
1828   have_gethostbyname=no
1829   AC_CHECK_FUNC(gethostbyname, have_gethostbyname=yes)
1830   if test $have_gethostbyname = no; then
1831     # gethostbyname is not in the default libraries.  See if it's in some other.
1832     for lib in bsd socket inet; do
1833       AC_CHECK_LIB($lib, gethostbyname, [LIBS="$LIBS -l$lib"; have_gethostbyname=yes; break])
1834     done
1835   fi
1836
1837   vfs_flags="tarfs"
1838   use_net_code=false
1839   if test $have_socket = yes; then
1840       AC_STRUCT_LINGER
1841       AC_CHECK_FUNCS(pmap_set, , [
1842          AC_CHECK_LIB(rpc, pmap_set, [
1843            LIBS="-lrpc $LIBS"
1844           AC_DEFINE(HAVE_PMAP_SET)
1845           ])])
1846       AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport)
1847       dnl add for source routing support setsockopt
1848       AC_CHECK_HEADERS(rpc/pmap_clnt.h)
1849       vfs_flags="$vfs_flags, mcfs, ftpfs, fish"
1850       use_net_code=true
1851   fi
1852
1853   dnl
1854   dnl Samba support
1855   dnl
1856   smbfs=""
1857   SAMBAFILES=""
1858   AC_ARG_WITH(samba,
1859           [--with-samba             Support smb virtual file system],[
1860           if test "x$withval != xno"; then
1861                   AC_DEFINE(WITH_SMBFS)
1862                   vfs_flags="$vfs_flags, smbfs"
1863                   smbfs="smbfs.o"
1864                   SAMBAFILES="\$(SAMBAFILES)"
1865           fi
1866   ])
1867   AC_SUBST(smbfs)
1868   AC_SUBST(SAMBAFILES)
1869   
1870   dnl
1871   dnl The termnet support
1872   dnl
1873   termnet=false
1874   AC_ARG_WITH(termnet,
1875           [--with-termnet             If you want a termified net support],[
1876           if test x$withval = xyes; then
1877                   AC_DEFINE(USE_TERMNET)
1878                   termnet=true          
1879           fi
1880   ])
1881
1882   TERMNET=""
1883   AC_DEFINE(USE_VFS)
1884   if $use_net_code; then
1885      AC_DEFINE(USE_NETCODE)
1886   fi
1887   mcserv=
1888   if test $have_socket = yes; then
1889      mcserv="mcserv"
1890      if $termnet; then
1891         TERMNET="-ltermnet"
1892      fi
1893   fi
1894
1895   AC_SUBST(TERMNET)
1896   AC_SUBST(mcserv)
1897
1898 dnl FIXME:
1899 dnl GNOME_VFS_LIBS=
1900
1901 ])
1902
1903 AC_DEFUN([GNOME_VFS_CHECKS],[
1904         use_vfs=yes
1905         AC_ARG_WITH(vfs,
1906                 [--with-vfs                Compile with the VFS code],
1907                 use_vfs=$withval
1908         )
1909         case $use_vfs in
1910                 yes)    GNOME_WITH_VFS;;
1911                 no)     use_vfs=no;;
1912                 *)      use_vfs=no;;
1913                         dnl Should we issue a warning?
1914         esac
1915 ])
1916
1917
1918 dnl GNOME_X_CHECKS
1919 dnl
1920 dnl Basic X11 related checks for X11.  At the end, the following will be
1921 dnl defined/changed:
1922 dnl   GTK_{CFLAGS,LIBS}      From AM_PATH_GTK
1923 dnl   CPPFLAGS               Will include $X_CFLAGS
1924 dnl   GNOME_HAVE_SM          `true' or `false' depending on whether session
1925 dnl                          management is available.  It is available if
1926 dnl                          both -lSM and X11/SM/SMlib.h exist.  (Some
1927 dnl                          Solaris boxes have the library but not the header)
1928 dnl   XPM_LIBS               -lXpm if Xpm library is present, otherwise ""
1929 dnl
1930 dnl The following configure cache variables are defined (but not used):
1931 dnl   gnome_cv_passdown_{x_libs,X_LIBS,X_CFLAGS}
1932 dnl
1933 AC_DEFUN([GNOME_X_CHECKS],
1934 [
1935         AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(GTK not installed, or gtk-config not in path))
1936         dnl Hope that GTK_CFLAGS have only -I and -D.  Otherwise, we could
1937         dnl   test -z "$x_includes" || CPPFLAGS="$CPPFLAGS -I$x_includes"
1938         dnl
1939         dnl Use CPPFLAGS instead of CFLAGS because AC_CHECK_HEADERS uses
1940         dnl CPPFLAGS, not CFLAGS
1941         CPPFLAGS="$CPPFLAGS $GTK_CFLAGS"
1942
1943         saved_ldflags="$LDFLAGS"
1944         LDFLAGS="$LDFLAGS $GTK_LIBS"
1945
1946         gnome_cv_passdown_x_libs="$GTK_LIBS"
1947         gnome_cv_passdown_X_LIBS="$GTK_LIBS"
1948         gnome_cv_passdown_X_CFLAGS="$GTK_CFLAGS"
1949         gnome_cv_passdown_GTK_LIBS="$GTK_LIBS"
1950
1951         LDFLAGS="$saved_ldflags $GTK_LIBS"
1952
1953 dnl We are requiring GTK >= 1.1.1, which means this will be fine anyhow.
1954         USE_DEVGTK=true
1955
1956 dnl     AC_MSG_CHECKING([whether to use features from (unstable) GTK+ 1.1.x])
1957 dnl     AC_EGREP_CPP(answer_affirmatively,
1958 dnl     [#include <gtk/gtkfeatures.h>
1959 dnl     #ifdef GTK_HAVE_FEATURES_1_1_0
1960 dnl        answer_affirmatively
1961 dnl     #endif
1962 dnl     ], dev_gtk=yes, dev_gtk=no)
1963 dnl     if test "$dev_gtk" = "yes"; then
1964 dnl        USE_DEVGTK=true
1965 dnl     fi
1966 dnl     AC_MSG_RESULT("$dev_gtk")
1967
1968         GNOME_HAVE_SM=true
1969         case "$GTK_LIBS" in
1970          *-lSM*)
1971             dnl Already found it.
1972             ;;
1973          *)
1974             dnl Assume that if we have -lSM then we also have -lICE.
1975             AC_CHECK_LIB(SM, SmcSaveYourselfDone,
1976                 [GTK_LIBS="-lSM -lICE $GTK_LIBS"],GNOME_HAVE_SM=false,
1977                 $x_libs -lICE)
1978             ;;
1979         esac
1980
1981         if test "$GNOME_HAVE_SM" = true; then
1982            AC_CHECK_HEADERS(X11/SM/SMlib.h,,GNOME_HAVE_SM=false)
1983         fi
1984
1985         if test "$GNOME_HAVE_SM" = true; then
1986            AC_DEFINE(HAVE_LIBSM)
1987         fi
1988
1989         XPM_LIBS=""
1990         AC_CHECK_LIB(Xpm, XpmFreeXpmImage, [XPM_LIBS="-lXpm"], , $x_libs)
1991         AC_SUBST(XPM_LIBS)
1992
1993         AC_REQUIRE([GNOME_PTHREAD_CHECK])
1994         LDFLAGS="$saved_ldflags"
1995
1996         AC_PROVIDE([GNOME_X_CHECKS])
1997 ])
1998 dnl
1999 dnl GNOME_XML_HOOK (script-if-xml-found, failflag)
2000 dnl
2001 dnl If failflag is "failure", script aborts due to lack of XML
2002 dnl 
2003 dnl Check for availability of the libxml library
2004 dnl the XML parser uses libz if available too
2005 dnl
2006
2007 AC_DEFUN([GNOME_XML_HOOK],[
2008         AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
2009         if test "$GNOME_CONFIG" = no; then
2010                 if test x$2 = xfailure; then
2011                         AC_MSG_ERROR(Could not find gnome-config)
2012                 fi
2013         fi
2014         AC_CHECK_LIB(xml, xmlNewDoc, [
2015                 $1
2016                 GNOME_XML_LIB=`$GNOME_CONFIG --libs xml`
2017         ], [
2018                 if test x$2 = xfailure; then 
2019                         AC_MSG_ERROR(Could not link sample xml program)
2020                 fi
2021         ], `$GNOME_CONFIG --libs xml`)
2022         AC_SUBST(GNOME_XML_LIB)
2023 ])
2024
2025 AC_DEFUN([GNOME_XML_CHECK], [
2026         GNOME_XML_HOOK([],failure)
2027 ])
2028 dnl
2029 dnl GNOME_INIT_HOOK (script-if-gnome-enabled, [failflag], [additional-inits])
2030 dnl
2031 dnl if failflag is "fail" then GNOME_INIT_HOOK will abort if gnomeConf.sh
2032 dnl is not found. 
2033 dnl
2034
2035 AC_DEFUN([GNOME_INIT_HOOK],[
2036         AC_SUBST(GNOME_LIBS)
2037         AC_SUBST(GNOMEUI_LIBS)
2038         AC_SUBST(GNOMEGNORBA_LIBS)
2039         AC_SUBST(GTKXMHTML_LIBS)
2040         AC_SUBST(ZVT_LIBS)
2041         AC_SUBST(GNOME_LIBDIR)
2042         AC_SUBST(GNOME_INCLUDEDIR)
2043
2044         AC_ARG_WITH(gnome-includes,
2045         [  --with-gnome-includes   Specify location of GNOME headers],[
2046         CFLAGS="$CFLAGS -I$withval"
2047         ])
2048         
2049         AC_ARG_WITH(gnome-libs,
2050         [  --with-gnome-libs       Specify location of GNOME libs],[
2051         LDFLAGS="$LDFLAGS -L$withval"
2052         gnome_prefix=$withval
2053         ])
2054
2055         AC_ARG_WITH(gnome,
2056         [  --with-gnome            Specify prefix for GNOME files],
2057                 if test x$withval = xyes; then
2058                         want_gnome=yes
2059                         dnl Note that an empty true branch is not
2060                         dnl valid sh syntax.
2061                         ifelse([$1], [], :, [$1])
2062                 else
2063                         if test "x$withval" = xno; then
2064                                 want_gnome=no
2065                         else
2066                                 want_gnome=yes
2067                                 LDFLAGS="$LDFLAGS -L$withval/lib"
2068                                 CFLAGS="$CFLAGS -I$withval/include"
2069                                 gnome_prefix=$withval/lib
2070                         fi
2071                 fi,
2072                 want_gnome=yes)
2073
2074         if test "x$want_gnome" = xyes; then
2075
2076             AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
2077             if test "$GNOME_CONFIG" = "no"; then
2078               no_gnome_config="yes"
2079             else
2080               AC_MSG_CHECKING(if $GNOME_CONFIG works)
2081               if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then
2082                 AC_MSG_RESULT(yes)
2083                 GNOME_GNORBA_HOOK([],$2)
2084                 GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome`"
2085                 GNOMEUI_LIBS="`$GNOME_CONFIG --libs-only-l gnomeui`"
2086                 GNOMEGNORBA_LIBS="`$GNOME_CONFIG --libs-only-l gnorba gnomeui`"
2087                 GTKXMHTML_LIBS="`$GNOME_CONFIG --libs-only-l gtkxmhtml`"
2088                 ZVT_LIBS="`$GNOME_CONFIG --libs-only-l zvt`"
2089                 GNOME_LIBDIR="`$GNOME_CONFIG --libs-only-L gnorba gnomeui`"
2090                 GNOME_INCLUDEDIR="`$GNOME_CONFIG --cflags gnorba gnomeui`"
2091                 $1
2092               else
2093                 AC_MSG_RESULT(no)
2094                 no_gnome_config="yes"
2095               fi
2096             fi
2097
2098             if test x$exec_prefix = xNONE; then
2099                 if test x$prefix = xNONE; then
2100                     gnome_prefix=$ac_default_prefix/lib
2101                 else
2102                     gnome_prefix=$prefix/lib
2103                 fi
2104             else
2105                 gnome_prefix=`eval echo \`echo $libdir\``
2106             fi
2107         
2108             if test "$no_gnome_config" = "yes"; then
2109               AC_MSG_CHECKING(for gnomeConf.sh file in $gnome_prefix)
2110               if test -f $gnome_prefix/gnomeConf.sh; then
2111                 AC_MSG_RESULT(found)
2112                 echo "loading gnome configuration from" \
2113                      "$gnome_prefix/gnomeConf.sh"
2114                 . $gnome_prefix/gnomeConf.sh
2115                 $1
2116               else
2117                 AC_MSG_RESULT(not found)
2118                 if test x$2 = xfail; then
2119                   AC_MSG_ERROR(Could not find the gnomeConf.sh file that is generated by gnome-libs install)
2120                 fi
2121               fi
2122             fi
2123         fi
2124
2125         if test -n "$3"; then
2126           n="$3"
2127           for i in $n; do
2128             AC_MSG_CHECKING(extra library \"$i\")
2129             case $i in 
2130               applets)
2131                 AC_SUBST(GNOME_APPLETS_LIBS)
2132                 GNOME_APPLETS_LIBS=`$GNOME_CONFIG --libs-only-l applets`
2133                 AC_MSG_RESULT($GNOME_APPLETS_LIBS);;
2134               docklets)
2135                 AC_SUBST(GNOME_DOCKLETS_LIBS)
2136                 GNOME_DOCKLETS_LIBS=`$GNOME_CONFIG --libs-only-l docklets`
2137                 AC_MSG_RESULT($GNOME_DOCKLETS_LIBS);;
2138               capplet)
2139                 AC_SUBST(GNOME_CAPPLET_LIBS)
2140                 GNOME_CAPPLET_LIBS=`$GNOME_CONFIG --libs-only-l capplet`
2141                 AC_MSG_RESULT($GNOME_CAPPLET_LIBS);;
2142               *)
2143                 AC_MSG_RESULT(unknown library)
2144             esac
2145           done
2146         fi
2147 ])
2148
2149 dnl
2150 dnl GNOME_INIT ([additional-inits])
2151 dnl
2152
2153 AC_DEFUN([GNOME_INIT],[
2154         GNOME_INIT_HOOK([],fail,$1)
2155 ])
2156 dnl
2157 dnl AC_PROG_GPERF (MINIMUM-VERSION)
2158 dnl
2159 dnl Check for availability of gperf.
2160 dnl Abort if not found or if current version is not up to par.
2161 dnl
2162
2163 AC_DEFUN([AC_PROG_GPERF],[
2164         AC_PATH_PROG(GPERF, gperf, no)
2165         if test "$GPERF" = no; then
2166                 AC_MSG_ERROR(Could not find gperf)
2167         fi
2168         min_gperf_version=ifelse([$1], ,2.7,$1)
2169         AC_MSG_CHECKING(for gperf - version >= $min_gperf_version)
2170         gperf_major_version=`$GPERF --version | \
2171                 sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\1/'`
2172         gperf_minor_version=`$GPERF --version | \
2173                 sed 's/GNU gperf \([[0-9]]*\).\([[0-9]]*\)/\2/'`
2174         no_gperf=""
2175 dnl
2176 dnl Now check if the installed gperf is sufficiently new.
2177 dnl
2178         AC_TRY_RUN([
2179 #include <stdio.h>
2180 #include <stdlib.h>
2181 #include <string.h>
2182
2183 static char*
2184 my_strdup (char *str)
2185 {
2186   char *new_str;
2187   
2188   if (str)
2189     {
2190       new_str = malloc ((strlen (str) + 1) * sizeof(char));
2191       strcpy (new_str, str);
2192     }
2193   else
2194     new_str = NULL;
2195   
2196   return new_str;
2197 }
2198
2199 int 
2200 main ()
2201 {
2202   char  *tmp_version;
2203   
2204   int    major;
2205   int    minor;
2206
2207   /* HP/UX 9 (%@#!) writes to sscanf strings */
2208   tmp_version = my_strdup("$min_gperf_version");
2209   if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
2210     printf ("%s, bad version string\n", "$min_gperf_version");
2211     exit (1);
2212   }
2213
2214   if (($gperf_major_version > major) ||
2215       (($gperf_major_version == major) && ($gperf_minor_version >= minor))) {
2216     return 0;
2217   } else {
2218     printf ("\n");
2219     printf ("*** An old version of gperf ($gperf_major_version.$gperf_minor_version) was found.\n");
2220     printf ("*** You need a version of gperf newer than %d.%d.%d.  The latest version of\n",
2221                major, minor);
2222     printf ("*** gperf is always available from ftp://ftp.gnu.org.\n");
2223     printf ("***\n");
2224     return 1;
2225   }
2226 }
2227 ],,no_gperf=yes,[/bin/true])
2228         if test "x$no_gperf" = x ; then
2229                 AC_MSG_RESULT(yes)
2230         else
2231                 AC_MSG_RESULT(no)
2232         fi
2233
2234 ])
2235 dnl
2236 dnl Check for struct linger
2237 dnl
2238 AC_DEFUN(AC_STRUCT_LINGER, [
2239 av_struct_linger=no
2240 AC_MSG_CHECKING(struct linger is available)
2241 AC_TRY_RUN([
2242 #include <sys/types.h>
2243 #include <sys/socket.h>
2244
2245 struct linger li;
2246
2247 main ()
2248 {
2249     li.l_onoff = 1;
2250     li.l_linger = 120;
2251     exit (0);
2252 }
2253 ],[
2254 AC_DEFINE(HAVE_STRUCT_LINGER)
2255 av_struct_linger=yes
2256 ],[
2257 av_struct_linger=no
2258 ],[
2259 av_struct_linger=no
2260 ])
2261 AC_MSG_RESULT($av_struct_linger)
2262 ])
2263 dnl See whether we need a declaration for a function.
2264 dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
2265 AC_DEFUN(GCC_NEED_DECLARATION,
2266 [AC_MSG_CHECKING([whether $1 must be declared])
2267 AC_CACHE_VAL(gcc_cv_decl_needed_$1,
2268 [AC_TRY_COMPILE([
2269 #include <stdio.h>
2270 #ifdef HAVE_STRING_H
2271 #include <string.h>
2272 #else
2273 #ifdef HAVE_STRINGS_H
2274 #include <strings.h>
2275 #endif
2276 #endif
2277 #ifdef HAVE_STDLIB_H
2278 #include <stdlib.h>
2279 #endif
2280 #ifdef HAVE_UNISTD_H
2281 #include <unistd.h>
2282 #endif
2283 $2],
2284 [char *(*pfn) = (char *(*)) $1],
2285 eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
2286 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
2287   AC_MSG_RESULT(yes)
2288   gcc_need_declarations="$gcc_need_declarations $1"
2289   gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
2290   AC_DEFINE_UNQUOTED($gcc_tr_decl)
2291 else
2292   AC_MSG_RESULT(no)
2293 fi
2294 ])dnl
2295
2296 dnl Check multiple functions to see whether each needs a declaration.
2297 dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
2298 AC_DEFUN(GCC_NEED_DECLARATIONS,
2299 [for ac_func in $1
2300 do
2301 GCC_NEED_DECLARATION($ac_func, $2)
2302 done
2303 ]
2304 )
2305 # Configure paths for GTK+
2306 # Owen Taylor     97-11-3
2307
2308 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
2309 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
2310 dnl
2311 AC_DEFUN(AM_PATH_GTK,
2312 [dnl 
2313 dnl Get the cflags and libraries from the gtk-config script
2314 dnl
2315 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
2316             gtk_config_prefix="$withval", gtk_config_prefix="")
2317 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
2318             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
2319 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
2320                     , enable_gtktest=yes)
2321
2322   for module in . $4
2323   do
2324       case "$module" in
2325          gthread) 
2326              gtk_config_args="$gtk_config_args gthread"
2327          ;;
2328       esac
2329   done
2330
2331   if test x$gtk_config_exec_prefix != x ; then
2332      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
2333      if test x${GTK_CONFIG+set} != xset ; then
2334         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
2335      fi
2336   fi
2337   if test x$gtk_config_prefix != x ; then
2338      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
2339      if test x${GTK_CONFIG+set} != xset ; then
2340         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
2341      fi
2342   fi
2343
2344   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
2345   min_gtk_version=ifelse([$1], ,0.99.7,$1)
2346   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2347   no_gtk=""
2348   if test "$GTK_CONFIG" = "no" ; then
2349     no_gtk=yes
2350   else
2351     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
2352     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
2353     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
2354            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2355     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
2356            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2357     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
2358            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2359     if test "x$enable_gtktest" = "xyes" ; then
2360       ac_save_CFLAGS="$CFLAGS"
2361       ac_save_LIBS="$LIBS"
2362       CFLAGS="$CFLAGS $GTK_CFLAGS"
2363       LIBS="$GTK_LIBS $LIBS"
2364 dnl
2365 dnl Now check if the installed GTK is sufficiently new. (Also sanity
2366 dnl checks the results of gtk-config to some extent
2367 dnl
2368       rm -f conf.gtktest
2369       AC_TRY_RUN([
2370 #include <gtk/gtk.h>
2371 #include <stdio.h>
2372 #include <stdlib.h>
2373
2374 int 
2375 main ()
2376 {
2377   int major, minor, micro;
2378   char *tmp_version;
2379
2380   system ("touch conf.gtktest");
2381
2382   /* HP/UX 9 (%@#!) writes to sscanf strings */
2383   tmp_version = g_strdup("$min_gtk_version");
2384   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2385      printf("%s, bad version string\n", "$min_gtk_version");
2386      exit(1);
2387    }
2388
2389   if ((gtk_major_version != $gtk_config_major_version) ||
2390       (gtk_minor_version != $gtk_config_minor_version) ||
2391       (gtk_micro_version != $gtk_config_micro_version))
2392     {
2393       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
2394              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
2395              gtk_major_version, gtk_minor_version, gtk_micro_version);
2396       printf ("*** was found! If gtk-config was correct, then it is best\n");
2397       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
2398       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
2399       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
2400       printf("*** required on your system.\n");
2401       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
2402       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
2403       printf("*** before re-running configure\n");
2404     } 
2405 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
2406   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
2407            (gtk_minor_version != GTK_MINOR_VERSION) ||
2408            (gtk_micro_version != GTK_MICRO_VERSION))
2409     {
2410       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
2411              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
2412       printf("*** library (version %d.%d.%d)\n",
2413              gtk_major_version, gtk_minor_version, gtk_micro_version);
2414     }
2415 #endif /* defined (GTK_MAJOR_VERSION) ... */
2416   else
2417     {
2418       if ((gtk_major_version > major) ||
2419         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2420         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
2421       {
2422         return 0;
2423        }
2424      else
2425       {
2426         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
2427                gtk_major_version, gtk_minor_version, gtk_micro_version);
2428         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
2429                major, minor, micro);
2430         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
2431         printf("***\n");
2432         printf("*** If you have already installed a sufficiently new version, this error\n");
2433         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
2434         printf("*** being found. The easiest way to fix this is to remove the old version\n");
2435         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
2436         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
2437         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
2438         printf("*** so that the correct libraries are found at run-time))\n");
2439       }
2440     }
2441   return 1;
2442 }
2443 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2444        CFLAGS="$ac_save_CFLAGS"
2445        LIBS="$ac_save_LIBS"
2446      fi
2447   fi
2448   if test "x$no_gtk" = x ; then
2449      AC_MSG_RESULT(yes)
2450      ifelse([$2], , :, [$2])     
2451   else
2452      AC_MSG_RESULT(no)
2453      if test "$GTK_CONFIG" = "no" ; then
2454        echo "*** The gtk-config script installed by GTK could not be found"
2455        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
2456        echo "*** your path, or set the GTK_CONFIG environment variable to the"
2457        echo "*** full path to gtk-config."
2458      else
2459        if test -f conf.gtktest ; then
2460         :
2461        else
2462           echo "*** Could not run GTK test program, checking why..."
2463           CFLAGS="$CFLAGS $GTK_CFLAGS"
2464           LIBS="$LIBS $GTK_LIBS"
2465           AC_TRY_LINK([
2466 #include <gtk/gtk.h>
2467 #include <stdio.h>
2468 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
2469         [ echo "*** The test program compiled, but did not run. This usually means"
2470           echo "*** that the run-time linker is not finding GTK or finding the wrong"
2471           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
2472           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
2473           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
2474           echo "*** is required on your system"
2475           echo "***"
2476           echo "*** If you have an old version installed, it is best to remove it, although"
2477           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
2478           echo "***"
2479           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
2480           echo "*** came with the system with the command"
2481           echo "***"
2482           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
2483         [ echo "*** The test program failed to compile or link. See the file config.log for the"
2484           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
2485           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
2486           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
2487           CFLAGS="$ac_save_CFLAGS"
2488           LIBS="$ac_save_LIBS"
2489        fi
2490      fi
2491      GTK_CFLAGS=""
2492      GTK_LIBS=""
2493      ifelse([$3], , :, [$3])
2494   fi
2495   AC_SUBST(GTK_CFLAGS)
2496   AC_SUBST(GTK_LIBS)
2497   rm -f conf.gtktest
2498 ])