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