http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.02.tar.gz
[xscreensaver] / configure.in
1 # configure.in --- xscreensaver, Copyright (c) 1997-2000 Jamie Zawinski.
2 #
3
4 AC_PREREQ(2.13)
5 AC_INIT(driver/subprocs.c)
6 AC_CONFIG_HEADER(config.h)
7
8 echo "current directory: `pwd`"
9 echo "command line was: $0 $@"
10
11
12 # After checking to see that --srcdir is correct (which AC_INIT does)
13 # check for some random other files that come later in the tar file,
14 # to make sure everything is here.
15 #
16 for d in driver utils hacks hacks/glx ; do
17   f=$srcdir/$d/Makefile.in
18   if test \! -r $f ; then
19     echo ""
20     echo "ERROR: The package is incomplete: $f does not exist."
21     echo "       This probably means that your download was truncated."
22     echo ""
23     exit 1
24   fi
25 done
26
27
28 ###############################################################################
29 #
30 #       Function to figure out how to run the compiler.
31 #
32 ###############################################################################
33
34 AC_DEFUN(AC_PROG_CC_ANSI,
35  [AC_PROG_CC
36
37   if test -z "$GCC"; then
38     AC_MSG_CHECKING(how to request ANSI compilation)
39     case "$host" in
40       *-hpux* )
41         AC_MSG_RESULT(HPUX: adding -Ae)
42         CC="$CC -Ae"
43       ;;
44       *-aix* )
45         AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
46         CC="$CC -qlanglvl=ansi -qhalt=e"
47       ;;
48
49       *-dec-* )
50         AC_MSG_RESULT(DEC: adding -std1 -ieee)
51         CC="$CC -std1"
52       ;;
53
54       *)
55         AC_MSG_RESULT(no idea)
56       ;;
57     esac
58   fi
59
60   AC_MSG_CHECKING([whether the compiler works on ANSI C])
61   AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
62      AC_MSG_RESULT(yes),
63      AC_MSG_RESULT(no)
64      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
65      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
66
67   if test -n "$GCC"; then
68     AC_MSG_RESULT(Turning on gcc compiler warnings.)
69     CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
70   else
71     case "$host" in
72       *-irix5* |*-irix6.[0-3]* )
73         AC_MSG_RESULT(Turning on SGI compiler warnings.)
74         CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
75       ;;
76 #     *-dec-osf* )
77 #       if test -z "$GCC"; then
78 #         AC_MSG_RESULT(Turning on DEC C compiler warnings.)
79 #         CC="$CC -migrate -w0 -verbose -warnprotos"
80 #       fi
81 #     ;;
82     esac
83   fi
84 ])
85
86
87 ###############################################################################
88 #
89 #       Functions to figure out how to disable // comments in ANSI C code.
90 #
91 #       (With recent gcc, this is done with "-std=c89".  With older gcc, this
92 #       is done by passing "-lang-c89" to cpp, by passing "-Wp,-lang-c89" to
93 #       gcc.  Old gcc doesn't support -std, and new gcc doesn't support -lang.
94 #       so much for compatibility!)
95 #
96 ###############################################################################
97
98 AC_DEFUN(AC_GCC_ACCEPTS_STD,
99  [if test -n "$GCC"; then
100    AC_CACHE_CHECK([whether gcc accepts -std],
101      ac_cv_gcc_accepts_std,
102     [if ( gcc -E -std=c89 - </dev/null 2>&1 >/dev/null | \
103           grep unrecognized >/dev/null ); then
104        ac_cv_gcc_accepts_std=no
105      else
106        ac_cv_gcc_accepts_std=yes
107      fi])
108    ac_gcc_accepts_std="$ac_cv_gcc_accepts_std"
109   fi
110 ])
111
112 AC_DEFUN(AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE,
113  [if test -n "$GCC"; then
114    AC_GCC_ACCEPTS_STD
115    AC_MSG_RESULT(Disabling C++ comments in ANSI C code.)
116    #
117    # The reason that // comments are banned from xscreensaver is that gcc is
118    # basically the only compiler in the world that supports them in C code.
119    # All other vendors support them only in their C++ compilers, not in their
120    # ANSI C compilers.  This means that it's a portability problem: every time
121    # these comments have snuck into the xscreensaver source code, I've gotten
122    # complaints about it the next day.  So we turn off support for them in gcc
123    # as well to prevent them from accidentially slipping in.
124    #
125    if test "$ac_gcc_accepts_std" = yes ; then
126      #
127      # -std=c89 defines __STRICT_ANSI__, which we don't want.
128      # (That appears to be the only additional preprocessor symbol
129      # it defines, in addition to the syntax changes it makes.)
130      #
131      # -std=gnu89 is no good, because // comments were a GNU extension
132      # before they were in the ANSI C 99 spec...  (gcc 2.96 permits //
133      # with -std=gnu89 but not with -std=c89.)
134      #
135      CC="$CC -std=c89 -U__STRICT_ANSI__"
136    else
137      # The old way:
138      CC="$CC -Wp,-lang-c89"
139    fi
140   fi
141 ])
142
143
144 ###############################################################################
145 #
146 #       Function to figure out how to create directory trees.
147 #
148 ###############################################################################
149
150 AC_DEFUN(AC_PROG_INSTALL_DIRS,
151  [AC_CACHE_CHECK([whether \"\${INSTALL} -d\" creates intermediate directories],
152     ac_cv_install_d_creates_dirs,
153     [ac_cv_install_d_creates_dirs=no
154      rm -rf conftestdir
155      if mkdir conftestdir; then
156        cd conftestdir >&-
157        ${INSTALL} -d `pwd`/dir1/dir2 >&- 2>&-
158        if test -d dir1/dir2/. ; then
159          ac_cv_install_d_creates_dirs=yes
160        fi
161        cd .. >&-
162        rm -rf conftestdir
163      fi
164     ])
165
166   if test "$ac_cv_install_d_creates_dirs" = no ; then
167     AC_CACHE_CHECK([whether \"mkdir -p\" creates intermediate directories],
168       ac_cv_mkdir_p_creates_dirs,
169       [ac_cv_mkdir_p_creates_dirs=no
170        rm -rf conftestdir
171        if mkdir conftestdir; then
172          cd conftestdir >&-
173          mkdir -p dir1/dir2 >&- 2>&-
174          if test -d dir1/dir2/. ; then
175            ac_cv_mkdir_p_creates_dirs=yes
176          fi
177          cd .. >&-
178          rm -rf conftestdir
179        fi
180       ])
181   fi
182
183   if test "$ac_cv_install_d_creates_dirs" = yes ; then
184     INSTALL_DIRS='${INSTALL} -d'
185   elif test "$ac_cv_mkdir_p_creates_dirs" = yes ; then
186     INSTALL_DIRS='mkdir -p'
187   else
188     # any other ideas?
189     INSTALL_DIRS='${INSTALL} -d'
190   fi
191 ])
192
193
194 ###############################################################################
195 #
196 #       Function to check whether gettimeofday() exists, and how to call it.
197 #       This may define HAVE_GETTIMEOFDAY and GETTIMEOFDAY_TWO_ARGS.
198 #
199 ###############################################################################
200
201 AC_DEFUN(AC_GETTIMEOFDAY_ARGS,
202  [AC_MSG_CHECKING(how to call gettimeofday)
203   AC_CACHE_VAL(ac_cv_gettimeofday_args,
204    [AC_TRY_COMPILE([#include <stdlib.h>
205                     #include <sys/time.h>],
206                    [struct timeval tv; struct timezone tzp;
207                     gettimeofday(&tv, &tzp);],
208                    [ac_gettimeofday_args=2],
209                    [AC_TRY_COMPILE([#include <stdlib.h>
210                                     #include <sys/time.h>],
211                                    [struct timeval tv; gettimeofday(&tv);],
212                                    [ac_gettimeofday_args=1],
213                                    [ac_gettimeofday_args=0])])
214     ac_cv_gettimeofday_args=$ac_gettimeofday_args])
215   ac_gettimeofday_args=$ac_cv_gettimeofday_args
216   if test "$ac_gettimeofday_args" = 1 ; then
217     AC_DEFINE(HAVE_GETTIMEOFDAY)
218     AC_MSG_RESULT(one argument)
219   elif test "$ac_gettimeofday_args" = 2 ; then
220     AC_DEFINE(HAVE_GETTIMEOFDAY)
221     AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
222     AC_MSG_RESULT(two arguments)
223   else
224     AC_MSG_RESULT(unknown)
225   fi
226 ])
227
228
229 ###############################################################################
230 #
231 #       Function to find perl5 (defines PERL and PERL_VERSION.)
232 #
233 ###############################################################################
234
235 # M4 sucks!!  perl sucks too!!
236 changequote(X,Y)
237 perl_version_cmd='print $]'
238 changequote([,])
239
240 AC_DEFUN(AC_PROG_PERL,
241  [AC_PATH_PROGS(PERL, [perl5 perl],,)
242   if test -z "$PERL" ; then
243     PERL_VERSION=0
244   else
245     AC_CACHE_CHECK([perl version], ac_cv_perl_version,
246                    [ac_cv_perl_version=`$PERL -e "$perl_version_cmd"`])
247     PERL_VERSION=$ac_cv_perl_version
248   fi
249  ])
250
251
252 ###############################################################################
253 #
254 #       Function to demand "bc".  Losers.
255 #
256 ###############################################################################
257
258 AC_DEFUN(AC_DEMAND_BC,
259  [ac_bc_result=`echo 6+9 | bc 2>/dev/null`
260   AC_MSG_CHECKING([for bc])
261   if test "$ac_bc_result" = "15" ; then
262     AC_MSG_RESULT(yes)
263   else
264     AC_MSG_RESULT(no)
265     echo ''
266     AC_MSG_ERROR([Your system doesn't have \"bc\", which has been a standard
267                   part of Unix since the 1970s.  Come back when your vendor
268                   has grown a clue.])
269   fi
270  ])
271
272 ###############################################################################
273 #
274 #       Functions to check how to do ICMP PING requests.
275 #
276 ###############################################################################
277
278 AC_DEFUN(AC_CHECK_ICMP,
279  [AC_CACHE_CHECK([for struct icmp], ac_cv_have_icmp,
280   [AC_TRY_COMPILE([#include <stdlib.h>
281                    #include <stdio.h>
282                    #include <math.h>
283                    #include <unistd.h>
284                    #include <limits.h>
285                    #include <signal.h>
286                    #include <fcntl.h>
287                    #include <sys/types.h>
288                    #include <sys/time.h>
289                    #include <sys/ipc.h>
290                    #include <sys/shm.h>
291                    #include <sys/socket.h>
292                    #include <netinet/in_systm.h>
293                    #include <netinet/in.h>
294                    #include <netinet/ip.h>
295                    #include <netinet/ip_icmp.h>
296                    #include <netinet/udp.h>
297                    #include <arpa/inet.h>
298                    #include <netdb.h>],
299                   [struct icmp i;
300                    struct sockaddr s;
301                    struct sockaddr_in si;
302                    struct ip ip;
303                    i.icmp_type = ICMP_ECHO;
304                    i.icmp_code = 0;
305                    i.icmp_cksum = 0;
306                    i.icmp_id = 0;
307                    i.icmp_seq = 0;
308                    si.sin_family = AF_INET;
309                    #if defined(__DECC) || defined(_IP_VHL)
310                    ip.ip_vhl = 0;
311                    #else
312                    ip.ip_hl = 0;
313                    #endif
314                    ],
315                   [ac_cv_have_icmp=yes],
316                   [ac_cv_have_icmp=no])])
317  if test "$ac_cv_have_icmp" = yes ; then
318    AC_DEFINE(HAVE_ICMP)
319  fi])
320
321 AC_DEFUN(AC_CHECK_ICMPHDR,
322  [AC_CACHE_CHECK([for struct icmphdr], ac_cv_have_icmphdr,
323   [AC_TRY_COMPILE([#include <stdlib.h>
324                    #include <stdio.h>
325                    #include <math.h>
326                    #include <unistd.h>
327                    #include <limits.h>
328                    #include <signal.h>
329                    #include <fcntl.h>
330                    #include <sys/types.h>
331                    #include <sys/time.h>
332                    #include <sys/ipc.h>
333                    #include <sys/shm.h>
334                    #include <sys/socket.h>
335                    #include <netinet/in_systm.h>
336                    #include <netinet/in.h>
337                    #include <netinet/ip.h>
338                    #include <netinet/ip_icmp.h>
339                    #include <netinet/udp.h>
340                    #include <arpa/inet.h>
341                    #include <netdb.h>],
342                   [struct icmphdr i;
343                    struct sockaddr s;
344                    struct sockaddr_in si;
345                    struct ip ip;
346                    i.type = ICMP_ECHO;
347                    i.code = 0;
348                    i.checksum = 0;
349                    i.un.echo.id = 0;
350                    i.un.echo.sequence = 0;
351                    si.sin_family = AF_INET;
352                    ip.ip_hl = 0;],
353                   [ac_cv_have_icmphdr=yes],
354                   [ac_cv_have_icmphdr=no])])
355  if test "$ac_cv_have_icmphdr" = yes ; then
356    AC_DEFINE(HAVE_ICMPHDR)
357  fi])
358
359
360 ###############################################################################
361 #
362 #       Functions to check for various X11 crap.
363 #
364 ###############################################################################
365
366 # Try and find the app-defaults directory.
367 # It sucks that autoconf doesn't do this already...
368 #
369 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,[
370   rm -fr conftestdir
371   if mkdir conftestdir; then
372     cd conftestdir >&-
373     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
374     cat > Imakefile <<'EOF'
375 acfindx:
376         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
377 EOF
378     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
379       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
380       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
381     fi
382     cd .. >&-
383     rm -fr conftestdir
384   fi])
385
386 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,[
387   # Look for the directory under a standard set of common directories.
388   # Check X11 before X11Rn because it's often a symlink to the current release.
389   for ac_dir in                                 \
390     /usr/X11/lib/app-defaults                   \
391     /usr/X11R6/lib/app-defaults                 \
392     /usr/X11R6/lib/X11/app-defaults             \
393     /usr/X11R5/lib/app-defaults                 \
394     /usr/X11R5/lib/X11/app-defaults             \
395     /usr/X11R4/lib/app-defaults                 \
396     /usr/X11R4/lib/X11/app-defaults             \
397                                                 \
398     /usr/lib/X11/app-defaults                   \
399     /usr/lib/X11R6/app-defaults                 \
400     /usr/lib/X11R5/app-defaults                 \
401     /usr/lib/X11R4/app-defaults                 \
402                                                 \
403     /usr/local/X11/lib/app-defaults             \
404     /usr/local/X11R6/lib/app-defaults           \
405     /usr/local/X11R5/lib/app-defaults           \
406     /usr/local/X11R4/lib/app-defaults           \
407                                                 \
408     /usr/local/lib/X11/app-defaults             \
409     /usr/local/lib/X11R6/app-defaults           \
410     /usr/local/lib/X11R6/X11/app-defaults       \
411     /usr/local/lib/X11R5/app-defaults           \
412     /usr/local/lib/X11R5/X11/app-defaults       \
413     /usr/local/lib/X11R4/app-defaults           \
414     /usr/local/lib/X11R4/X11/app-defaults       \
415                                                 \
416     /usr/X386/lib/X11/app-defaults              \
417     /usr/x386/lib/X11/app-defaults              \
418     /usr/XFree86/lib/X11/app-defaults           \
419                                                 \
420     /usr/lib/X11/app-defaults                   \
421     /usr/local/lib/X11/app-defaults             \
422     /usr/unsupported/lib/X11/app-defaults       \
423     /usr/athena/lib/X11/app-defaults            \
424     /usr/local/x11r5/lib/X11/app-defaults       \
425     /usr/lpp/Xamples/lib/X11/app-defaults       \
426     /lib/usr/lib/X11/app-defaults               \
427                                                 \
428     /usr/openwin/lib/app-defaults               \
429     /usr/openwin/lib/X11/app-defaults           \
430     /usr/openwin/share/lib/app-defaults         \
431     /usr/openwin/share/lib/X11/app-defaults     \
432                                                 \
433     /X11R6/lib/app-defaults                     \
434     /X11R5/lib/app-defaults                     \
435     /X11R4/lib/app-defaults                     \
436     ; \
437   do
438     if test -d "$ac_dir"; then
439       ac_x_app_defaults=$ac_dir
440       break
441     fi
442   done
443 ])
444
445 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
446   [AC_REQUIRE_CPP()
447     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
448      [AC_PATH_X_APP_DEFAULTS_XMKMF
449       if test x"$ac_x_app_defaults" = x; then
450         AC_PATH_X_APP_DEFAULTS_DIRECT
451       fi
452       if test x"$ac_x_app_defaults" = x; then
453         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
454       else
455         # Record where we found app-defaults for the cache.
456         ac_cv_x_app_defaults="$ac_x_app_defaults"
457       fi])
458     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
459
460
461 AC_DEFUN(AC_XPOINTER,
462  [AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
463                  [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
464                                    [XPointer foo = (XPointer) 0;],
465                                    [ac_cv_xpointer=yes],
466                                    [ac_cv_xpointer=no])])
467   if test "$ac_cv_xpointer" != yes; then
468    AC_DEFINE(XPointer,[char*])
469   fi])
470
471
472 # Random special-cases for X on certain pathological OSes.
473 # You know who you are.
474 #
475 AC_DEFUN(AC_X_RANDOM_PATHS,
476  [case "$host" in
477     *-hpux*)
478
479       # The following arcana was gleaned from conversations with
480       # Eric Schwartz <erics@col.hp.com>:
481       #
482       # On HPUX 10.x, the parts of X that HP considers "standard" live in
483       # /usr/{include,lib}/X11R6/.  The parts that HP doesn't consider
484       # "standard", notably, Xaw and Xmu, live in /usr/contrib/X11R6/.
485       # Yet /usr/contrib/X11R6/ comes preinstalled on all HPUX systems.
486       # Also, there are symlinks from /usr/include/ and /usr/lib/ into
487       # /usr/{include,lib}/X11R6/, so that (if you don't use Xmu at all)
488       # you don't need any -I or -L arguments.
489       #
490       # On HPUX 9.x, /usr/{include,lib}/X11R5/ and /usr/contrib/X11R5/
491       # are the same division as 10.x.  However, there are no symlinks to
492       # the X stuff from /usr/include/ and /usr/lib/, so -I and -L
493       # arguments are always necessary.
494       #
495       # However, X11R6 was available on HPUX 9.x as a patch: if that
496       # patch was installed, then all of X11R6 went in to
497       # /usr/contrib/X11R6/ (there was no /usr/{include,lib}/X11R6/.)
498       #
499       # HPUX 8.x was the same as 9.x, but was X11R4 instead (I don't know
500       # whether R5 was available as a patch; R6 undoubtedly was not.)
501       #
502       # So.  We try and use the highest numbered pair of
503       # /usr/{include,lib}/X11R?/ and /usr/contrib/X11R?/{include,lib}/
504       # that are available.  We do not mix and match different versions
505       # of X.
506       #
507       # Question I still don't know the answer to: (do you?)
508       #
509       #   * On HPUX 9.x, where /usr/include/X11R5/ was standard, and
510       #     /usr/contrib/X11R6/ could be installed as a patch, what was in
511       #     that contrib directory?  Did it contain so-called "standard"
512       #     X11R6, or did it include Xaw and Xmu as well?  If the former,
513       #     where did one find Xaw and Xmu on 9.x R6 systems?  Would this
514       #     be a situation where one had to reach into the R5 headers and
515       #     libs to find Xmu?  That is, must both R6 and R5 directories
516       #     be on the -I and -L lists in that case?
517       #
518       for version in X11R6 X11R5 X11R4 ; do
519         # if either pair of directories exists...
520         if test -d /usr/include/$version || test -d /usr/contrib/$version/include
521         then
522            # if contrib exists, use it...
523            if test -d /usr/contrib/$version/include ; then
524              X_CFLAGS="$X_CFLAGS -I/usr/contrib/$version/include"
525              X_LIBS="$X_LIBS -L/usr/contrib/$version/lib"
526            fi
527            # if the "standard" one exists, use it.
528            if test -d /usr/include/$version ; then
529              X_CFLAGS="$X_CFLAGS -I/usr/include/$version"
530              X_LIBS="$X_LIBS -L/usr/lib/$version"
531            fi
532            # since at least one of the pair exists, go no farther.
533            break
534         fi
535       done
536
537       # Now find Motif.  Thanks for not making xmkmf find this by
538       # default, you losers.
539       #
540       if test -d /usr/include/Motif2.1 ; then
541         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif2.1"
542         X_LIBS="$X_LIBS -L/usr/lib/Motif2.1"
543       elif test -d /usr/include/Motif1.2 ; then
544         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.2"
545         X_LIBS="$X_LIBS -L/usr/lib/Motif1.2"
546       elif test -d /usr/include/Motif1.1 ; then
547         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.1"
548         X_LIBS="$X_LIBS -L/usr/lib/Motif1.1"
549       fi
550
551       # Now let's check for the pseudo-standard locations for OpenGL and XPM.
552       #
553       if test -d /opt/graphics/OpenGL/include ; then
554         # HP-UX 10.20 puts it here
555         X_CFLAGS="-I/opt/graphics/OpenGL/include $X_CFLAGS"
556         X_LIBS="-L/opt/graphics/OpenGL/lib $X_LIBS"
557       elif test -d /opt/Mesa/lib ; then
558         X_CFLAGS="-I/opt/Mesa/include $X_CFLAGS"
559         X_LIBS="-L/opt/Mesa/lib $X_LIBS"
560       fi
561
562
563       if test -d /opt/xpm/lib/X11 ; then
564         X_CFLAGS="-I/opt/xpm/include $X_CFLAGS"
565         X_LIBS="-L/opt/xpm/lib/X11 $X_LIBS"
566       fi
567
568       # On HPUX, default to installing in /opt/xscreensaver/ instead of
569       # in /usr/local/, unless there is already an xscreensaver in
570       # /usr/local/bin/.  This can be overridden with the --prefix arg
571       # to configure.  I'm not sure this is the right thing to do, but
572       # Richard Lloyd says so...
573       #
574       if test \! -x /usr/local/bin/xscreensaver ; then
575         ac_default_prefix=/opt/xscreensaver
576       fi
577
578     ;;
579     *-solaris*)
580
581       # Thanks for not making xmkmf find this by default, pinheads.
582       # And thanks for moving things around again, too.  Is this
583       # really the standard location now?  What happened to the
584       # joke that this kind of thing went in /opt?
585       # cthomp says "answer: CDE (Common Disorganized Environment)"
586       #
587       if test -f /usr/dt/include/Xm/Xm.h ; then
588         X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
589         X_LIBS="$X_LIBS -L/usr/dt/lib -R:/usr/dt/lib"
590
591         # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
592         AC_CHECK_LIB(gen, regcmp, [X_LIBS="$X_LIBS -lgen"])
593       fi
594     ;;
595   esac])
596
597
598
599 ###############################################################################
600 #
601 #       Some utility functions to make checking for X things easier.
602 #
603 ###############################################################################
604
605 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
606 #
607 AC_DEFUN(AC_CHECK_X_HEADER, [
608   ac_save_CPPFLAGS="$CPPFLAGS"
609   if test \! -z "$includedir" ; then 
610     CPPFLAGS="$CPPFLAGS -I$includedir"
611   fi
612   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
613   AC_CHECK_HEADER([$1], [$2])
614   CPPFLAGS="$ac_save_CPPFLAGS"])
615
616 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
617 #
618 AC_DEFUN(AC_EGREP_X_HEADER, [
619   ac_save_CPPFLAGS="$CPPFLAGS"
620   if test \! -z "$includedir" ; then 
621     CPPFLAGS="$CPPFLAGS -I$includedir"
622   fi
623   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
624   AC_EGREP_HEADER([$1], [$2], [$3], [$4])
625   CPPFLAGS="$ac_save_CPPFLAGS"])
626
627 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
628 #
629 AC_DEFUN(AC_TRY_X_COMPILE, [
630   ac_save_CPPFLAGS="$CPPFLAGS"
631   if test \! -z "$includedir" ; then 
632     CPPFLAGS="$CPPFLAGS -I$includedir"
633   fi
634   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
635   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
636   CPPFLAGS="$ac_save_CPPFLAGS"])
637
638
639 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
640 # Use this sparingly; it probably doesn't work very well on X programs.
641 #
642 AC_DEFUN(AC_CHECK_X_LIB, [
643   ac_save_CPPFLAGS="$CPPFLAGS"
644   ac_save_LDFLAGS="$LDFLAGS"
645 #  ac_save_LIBS="$LIBS"
646
647   if test \! -z "$includedir" ; then 
648     CPPFLAGS="$CPPFLAGS -I$includedir"
649   fi
650   # note: $X_CFLAGS includes $x_includes
651   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
652
653   if test \! -z "$libdir" ; then
654     LDFLAGS="$LDFLAGS -L$libdir"
655   fi
656   # note: $X_LIBS includes $x_libraries
657   LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
658
659   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
660   CPPFLAGS="$ac_save_CPPFLAGS"
661   LDFLAGS="$ac_save_LDFLAGS"
662 #  LIBS="$ac_save_LIBS"
663   ])
664
665 # Like AC_TRY_RUN, but it uses the already-computed -I directories.
666 # (But not the -L directories!)
667 #
668 AC_DEFUN(AC_TRY_X_RUN, [
669   ac_save_CPPFLAGS="$CPPFLAGS"
670   if test \! -z "$includedir" ; then 
671     CPPFLAGS="$CPPFLAGS -I$includedir"
672   fi
673   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
674   AC_TRY_RUN([$1], [$2], [$3], [$4])
675   CPPFLAGS="$ac_save_CPPFLAGS"])
676
677
678
679 # Usage: HANDLE_X_PATH_ARG([variable_name],
680 #                          [--command-line-option],
681 #                          [descriptive string])
682 #
683 # All of the --with options take three forms:
684 #
685 #   --with-foo (or --with-foo=yes)
686 #   --without-foo (or --with-foo=no)
687 #   --with-foo=/DIR
688 #
689 # This function, HANDLE_X_PATH_ARG, deals with the /DIR case.  When it sees
690 # a directory (string beginning with a slash) it checks to see whether
691 # /DIR/include and /DIR/lib exist, and adds them to $X_CFLAGS and $X_LIBS
692 # as appropriate.
693 #
694 AC_DEFUN(HANDLE_X_PATH_ARG, [
695    case "$[$1]" in
696     yes) ;;
697     no)  ;;
698
699     /*)
700      AC_MSG_CHECKING([for [$3] headers])
701      d=$[$1]/include
702      if test -d $d; then
703        X_CFLAGS="-I$d $X_CFLAGS"
704        AC_MSG_RESULT($d)
705      else
706        AC_MSG_RESULT(not found ($d: no such directory))
707      fi
708
709      AC_MSG_CHECKING([for [$3] libs])
710      d=$[$1]/lib
711      if test -d $d; then
712        X_LIBS="-L$d $X_LIBS"
713        AC_MSG_RESULT($d)
714      else
715        AC_MSG_RESULT(not found ($d: no such directory))
716      fi
717
718      # replace the directory string with "yes".
719      [$1]_req="yes"
720      [$1]=$[$1]_req
721      ;;
722
723     *)
724      echo ""
725      echo "error: argument to [$2] must be \"yes\", \"no\", or a directory."
726      echo "       If it is a directory, then \`DIR/include' will be added to"
727      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
728      exit 1
729      ;;
730    esac
731   ])
732
733
734
735 ###############################################################################
736 ###############################################################################
737 #
738 #       End of function definitions.  Now start actually executing stuff.
739 #
740 ###############################################################################
741 ###############################################################################
742
743 # random compiler setup
744 AC_CANONICAL_HOST
745 AC_PROG_CC_ANSI
746 AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE
747 AC_PROG_CPP
748 AC_C_CONST
749 AC_C_INLINE
750 AC_EXEEXT
751 AC_DEMAND_BC
752
753 # stuff for Makefiles
754 AC_PROG_INSTALL
755 AC_PROG_INSTALL_DIRS
756 AC_PROG_MAKE_SET
757
758 # By default, autoconf sets INSTALL_SCRIPT to '${INSTALL_PROGRAM}'.
759 # That's wrong: it should be set to '${INSTALL}', so that one can
760 # implement the "install-strip" target properly (strip executables,
761 # but do not try to strip scripts.)
762 #
763 INSTALL_SCRIPT='${INSTALL}'
764
765 # random libc stuff
766 AC_HEADER_STDC
767 AC_CHECK_HEADERS(unistd.h)
768 AC_TYPE_MODE_T
769 AC_TYPE_PID_T
770 AC_TYPE_SIZE_T
771 AC_TYPE_SIGNAL
772 AC_HEADER_TIME
773 AC_HEADER_SYS_WAIT
774 AC_HEADER_DIRENT
775 AC_GETTIMEOFDAY_ARGS
776 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv sbrk)
777
778 AC_CHECK_FUNCS(sigaction syslog realpath setrlimit)
779 AC_CHECK_ICMP
780 AC_CHECK_ICMPHDR
781 AC_CHECK_HEADERS(crypt.h sys/select.h)
782 AC_PROG_PERL
783
784 if test -z "$PERL" ; then
785   # don't let it be blank...
786   PERL=/usr/bin/perl
787 fi
788
789 AC_PATH_XTRA
790
791 if test "$have_x" != yes; then
792   AC_MSG_ERROR(Couldn't find X11 headers/libs.  Try \`$0 --help'.)
793 fi
794
795 AC_PATH_X_APP_DEFAULTS
796 AC_X_RANDOM_PATHS
797 AC_XPOINTER
798
799
800
801 ###############################################################################
802 #
803 #       Check for -lXmu (some fucked up vendors don't ship it...)
804 #
805 ###############################################################################
806
807 have_xmu=no
808 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
809 if test "$have_xmu" = no ; then
810   XMU_SRCS='$(UTILS_SRC)/xmu.c'
811   XMU_OBJS='$(UTILS_BIN)/xmu.o'
812   XMU_LIBS=''
813 else
814   XMU_SRCS=''
815   XMU_OBJS=''
816   XMU_LIBS='-lXmu'
817   AC_DEFINE(HAVE_XMU)
818 fi
819
820
821 ###############################################################################
822 #
823 #       Check for the SunOS 4.1.x _get_wmShellWidgetClass bug.
824 #       See comp.windows.x FAQ question 124.  The right fix is to
825 #       get OpenWindows 3.0 patches 100512-02 and 100573-03.
826 #
827 ###############################################################################
828
829 if test "$have_xmu" = yes ; then
830   case "$host" in
831     *-sunos4*)
832     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
833                    ac_cv_sunos_xmu_bug,
834                    [ac_save_LDFLAGS="$LDFLAGS"
835                     if test \! -z "$x_libraries" ; then
836                       LDFLAGS="$LDFLAGS -L$x_libraries"
837                     fi
838                     # Note: this trick never works!  (Generally.)
839                     # We're only getting away with using AC_TRY_LINK
840                     # with X libraries because we know it's SunOS.
841                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
842                     AC_TRY_LINK(,,
843                                 [ac_cv_sunos_xmu_bug=no],
844                                 [ac_cv_sunos_xmu_bug=yes])
845                     LDFLAGS="$ac_save_LDFLAGS"])
846     if test "$ac_cv_sunos_xmu_bug" = yes ; then
847       AC_CACHE_CHECK([whether the compiler understands -static], 
848                      ac_cv_ld_static,
849                      [ac_save_LDFLAGS="$LDFLAGS"
850                       LDFLAGS="$LDFLAGS -static"
851                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
852                     LDFLAGS="$ac_save_LDFLAGS"])
853       if test "$ac_cv_ld_static" = yes ; then
854         LDFLAGS="$LDFLAGS -static"
855       else
856         LDFLAGS="$LDFLAGS -Bstatic"
857       fi
858     fi
859     ;;
860   esac
861 fi
862
863
864 ###############################################################################
865 #
866 #       Handle the --with-hackdir option
867 #
868 ###############################################################################
869
870 have_hackdir=yes
871 with_hackdir_req=unspecified
872 AC_ARG_WITH(hackdir,[
873 Installation options:
874
875   --with-hackdir=DIR      Where to install the hundreds of demo executables.
876                           Default: \`PREFIX/lib/xscreensaver/'],
877   [with_hackdir="$withval"; with_hackdir_req="$withval"],[with_hackdir=yes])
878
879 if test x"$with_hackdir" = xyes; then
880   HACKDIR='${exec_prefix}/lib/xscreensaver'
881 elif test x"$with_hackdir" = xno; then
882   HACKDIR='${bindir}'
883 else
884   # there must be a better way than this...
885   if test -z "`echo $with_hackdir | sed 's@^/.*@@'`" ; then
886     # absolute path
887     HACKDIR=$with_hackdir
888   else
889     # relative path
890     HACKDIR="\${exec_prefix}$with_hackdir"
891   fi
892 fi
893
894 # canonicalize slashes.
895 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
896
897 # This option used to be called --enable-subdir; make sure that is no longer
898 # used, since configure brain-damagedly ignores unknown --enable options.
899
900 obsolete_enable=
901 AC_ARG_ENABLE(subdir,,[obsolete_enable=yes])
902 if test -n "$obsolete_enable"; then
903   echo "error: the --enable-subdir option has been replaced with"
904   echo "       the new --with-hackdir option; see \`configure --help'"
905   echo "       for more information."
906   exit 1
907 fi
908
909
910 ###############################################################################
911 #
912 #       Handle the --with-configdir option
913 #
914 ###############################################################################
915
916 have_configdir=yes
917 with_configdir_req=unspecified
918 AC_ARG_WITH(configdir,
919 [  --with-configdir=DIR    Where to install the data files that describe each
920                           of the display modes to the GUI.
921                           Default: \`GNOMEPREFIX/control-center/screensavers/'
922                           or \`PREFIX/lib/xscreensaver/config/', depending on
923                           whether GNOME is available.
924 ],
925   [with_configdir="$withval"; with_configdir_req="$withval"],
926   [with_configdir=yes])
927
928 if test x"$with_configdir" = xyes; then
929   # filled in later...
930   HACK_CONF_DIR=''
931 elif test x"$with_configdir" = xno; then
932   echo "error: must be yes, or a pathname: --with-configdir=$with_configdir"
933   exit 1
934 else
935   # there must be a better way than this...
936   if test -z "`echo $with_configdir | sed 's@^/.*@@'`" ; then
937     # absolute path
938     HACK_CONF_DIR=$with_configdir
939   else
940     # relative path
941     HACK_CONF_DIR="\${exec_prefix}$with_configdir"
942   fi
943 fi
944
945
946
947
948 ###############################################################################
949 #
950 #       Check for the SGI SCREEN_SAVER server extension.
951 #
952 ###############################################################################
953
954 have_sgi=no
955 with_sgi_req=unspecified
956 AC_ARG_WITH(sgi-ext,
957 [Except where noted, all of the --with options below can also take a
958 directory argument: for example, \`--with-motif=/opt/Motif'.  That would
959 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
960 to be added to the -L list, assuming those directories exist.  
961
962 By default, support for each of these options will be built in, if the
963 relevant library routines exist.  At run time, they will then be used
964 only if the X server being used supports them.  Each --with option has
965 a corresponding --without option, to override building support for them
966 at all.
967
968 Screen blanking and idle-detection options:
969
970   --with-sgi-ext          Include support for the SGI SCREEN_SAVER extension.],
971   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
972
973 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
974
975 if test "$with_sgi" = yes; then
976   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
977                     [have_sgi=yes
978                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
979
980 elif test "$with_sgi" != no; then
981   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
982   exit 1
983 fi
984
985
986 ###############################################################################
987 #
988 #       Check for the MIT-SCREEN-SAVER server extension.
989 #
990 ###############################################################################
991
992 have_mit=no
993 with_mit_req=unspecified
994 AC_ARG_WITH(mit-ext,
995 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER extension.],
996   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
997
998 HANDLE_X_PATH_ARG(with_mit, --with-mit-ext, MIT-SCREEN-SAVER)
999
1000 if test "$with_mit" = yes; then
1001   AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
1002
1003   # Now check to see if it's really in the library; XF86Free-3.3 ships
1004   # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
1005   #
1006   if test "$have_mit" = yes; then
1007     AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [true], [have_mit=no], -lm)
1008
1009     if test "$have_mit" = no; then
1010       # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
1011       # of in Xext.  Thank you master, may I have another.
1012       AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
1013                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
1014                      [true], -lX11 -lXext -lm)
1015     fi
1016
1017     if test "$have_mit" = no; then
1018       # Double fuck!  Looks like some versions of XFree86 (whichever version
1019       # it is that comes with RedHat Linux 2.0 -- I can't find a version 
1020       # number) put this garbage in Xss instead of Xext.  Thank you master,
1021       #  may I have another.
1022       AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
1023                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
1024                      [true], -lX11 -lXext -lm)
1025     fi
1026
1027   if test "$have_mit" = yes; then
1028     AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
1029   fi
1030
1031   fi
1032
1033 elif test "$with_mit" != no; then
1034   echo "error: must be yes or no: --with-mit-ext=$with_mit"
1035   exit 1
1036 fi
1037
1038
1039 ###############################################################################
1040 #
1041 #       Check for the XIDLE server extension.
1042 #
1043 ###############################################################################
1044
1045 have_xidle=no
1046 with_xidle_req=unspecified
1047 AC_ARG_WITH(xidle-ext,
1048 [  --with-xidle-ext        Include support for the XIDLE extension.],
1049   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
1050
1051 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
1052
1053 if test "$with_xidle" = yes; then
1054   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
1055                     [have_xidle=yes
1056                      AC_DEFINE(HAVE_XIDLE_EXTENSION)])
1057 elif test "$with_xidle" != no; then
1058   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
1059   exit 1
1060 fi
1061
1062
1063 ###############################################################################
1064 #
1065 #       Check for the SGI-VIDEO-CONTROL server extension.
1066 #
1067 ###############################################################################
1068
1069 have_sgivc=no
1070 with_sgivc_req=unspecified
1071 AC_ARG_WITH(sgivc-ext,
1072 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension.],
1073   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
1074
1075 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
1076
1077 if test "$with_sgivc" = yes; then
1078
1079   # first check for XSGIvc.h
1080   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes])
1081
1082   # if that succeeded, then check for the -lXsgivc
1083   if test "$have_sgivc" = yes; then
1084     have_sgivc=no
1085     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
1086                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [true],
1087                   -lXext -lX11)
1088   fi
1089
1090   # if that succeeded, then we've really got it.
1091   if test "$have_sgivc" = yes; then
1092     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
1093   fi
1094
1095 elif test "$with_sgivc" != no; then
1096   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
1097   exit 1
1098 fi
1099
1100
1101 ###############################################################################
1102 #
1103 #       Check for the DPMS server extension.
1104 #
1105 ###############################################################################
1106
1107 have_dpms=no
1108 with_dpms_req=unspecified
1109 AC_ARG_WITH(dpms-ext,
1110 [  --with-dpms-ext         Include support for the DPMS extension.],
1111   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
1112
1113 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
1114
1115 if test "$with_dpms" = yes; then
1116
1117   # first check for dpms.h
1118   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
1119
1120   # if that succeeded, then check for the DPMS code in the libraries
1121   if test "$have_dpms" = yes; then
1122
1123     # first look in -lXext (this is where it is with XFree86 4.0)
1124     have_dpms=no
1125     AC_CHECK_X_LIB(Xext, DPMSInfo, [have_dpms=yes], [true], -lXext -lX11)
1126
1127     # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
1128     if test "$have_dpms" = no; then
1129       AC_CHECK_X_LIB(Xdpms, DPMSInfo,
1130                     [have_dpms=yes; XDPMS_LIBS="-lXdpms"], [true],
1131                     -lXext -lX11)
1132     fi
1133   fi
1134
1135
1136   # if that succeeded, then we've really got it.
1137   if test "$have_dpms" = yes; then
1138     AC_DEFINE(HAVE_DPMS_EXTENSION)
1139   fi
1140
1141 elif test "$with_dpms" != no; then
1142   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
1143   exit 1
1144 fi
1145
1146
1147 ###############################################################################
1148 #
1149 #       Check for the XINERAMA server extension.
1150 #
1151 ###############################################################################
1152
1153 have_xinerama=no
1154 with_xinerama_req=unspecified
1155 AC_ARG_WITH(xinerama-ext,
1156 [  --with-xinerama-ext     Include support for the XINERAMA extension.],
1157   [with_xinerama="$withval"; with_xinerama_req="$withval"],[with_xinerama=yes])
1158
1159 HANDLE_X_PATH_ARG(with_xinerama, --with-xinerama-ext, XINERAMA)
1160
1161 if test "$with_xinerama" = yes; then
1162
1163   # first check for Xinerama.h
1164   AC_CHECK_X_HEADER(X11/extensions/Xinerama.h, [have_xinerama=yes])
1165
1166   # if that succeeded, then check for the XINERAMA code in the libraries
1167   if test "$have_xinerama" = yes; then
1168
1169     # first look in -lXext
1170     have_xinerama=no
1171     AC_CHECK_X_LIB(Xext, XineramaQueryExtension, [have_xinerama=yes], [true],
1172                   -lXext -lX11)
1173
1174     # if that failed, look in -lXinerama (this is where it is in XFree86 4.1.)
1175     if test "$have_xinerama" = no; then
1176       AC_CHECK_X_LIB(Xinerama, XineramaQueryExtension,
1177                      [have_xinerama=yes; SAVER_LIBS="$SAVER_LIBS -lXinerama"],
1178                      [true], -lXext -lX11)
1179     fi
1180   fi
1181
1182   # if that succeeded, then we've really got it.
1183   if test "$have_xinerama" = yes; then
1184     AC_DEFINE(HAVE_XINERAMA)
1185   fi
1186
1187 elif test "$with_xinerama" != no; then
1188   echo "error: must be yes or no: --with-xinerama-ext=$with_xinerama"
1189   exit 1
1190 fi
1191
1192
1193 ###############################################################################
1194 #
1195 #       Check for the XF86VMODE server extension (for virtual screens.)
1196 #
1197 ###############################################################################
1198
1199 have_xf86vmode=no
1200 with_xf86vmode_req=unspecified
1201 AC_ARG_WITH(xf86vmode-ext,
1202 [  --with-xf86vmode-ext    Include support for XFree86 virtual screens.],
1203   [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
1204   [with_xf86vmode=yes])
1205
1206 HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
1207
1208 if test "$with_xf86vmode" = yes; then
1209
1210   # first check for xf86vmode.h
1211   AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes])
1212
1213   # if that succeeded, then check for the -lXxf86vm
1214   if test "$have_xf86vmode" = yes; then
1215     have_xf86vmode=no
1216     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
1217                   [have_xf86vmode=yes; SAVER_LIBS="$SAVER_LIBS -lXxf86vm"],
1218                    [true], -lXext -lX11)
1219   fi
1220
1221   # if that succeeded, then we've really got it.
1222   if test "$have_xf86vmode" = yes; then
1223     AC_DEFINE(HAVE_XF86VMODE)
1224   fi
1225
1226 elif test "$with_xf86vmode" != no; then
1227   echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
1228   exit 1
1229 fi
1230
1231
1232 ###############################################################################
1233 #
1234 #       Check for the XF86VMODE server extension (for gamma fading.)
1235 #
1236 ###############################################################################
1237
1238 have_xf86gamma=no
1239 have_xf86gamma_ramp=no
1240 with_xf86gamma_req=unspecified
1241 AC_ARG_WITH(xf86gamma-ext,
1242 [  --with-xf86gamma-ext    Include support for XFree86 gamma fading.],
1243   [with_xf86gamma="$withval"; with_xf86gamma_req="$withval"],
1244   [with_xf86gamma=yes])
1245
1246 HANDLE_X_PATH_ARG(with_xf86gamma, --with-xf86gamma-ext, xf86gamma)
1247
1248 if test "$with_xf86gamma" = yes; then
1249
1250   # first check for xf86vmode.h, if we haven't already
1251   if test "$have_xf86vmode" = yes; then
1252     have_xf86gamma=yes
1253   else
1254     AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86gamma=yes])
1255   fi
1256
1257   # if that succeeded, then check for the -lXxf86vm
1258   if test "$have_xf86gamma" = yes; then
1259     have_xf86gamma=no
1260     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGamma,
1261                   [have_xf86gamma=yes],
1262                    [true], -lXext -lX11)
1263   fi
1264
1265   # check for the Ramp versions of the functions too.
1266   if test "$have_xf86gamma" = yes; then
1267     have_xf86gamma_ramp=no
1268     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGammaRamp,
1269                   [have_xf86gamma_ramp=yes],
1270                    [true], -lXext -lX11)
1271   fi
1272
1273   # if those tests succeeded, then we've really got the functions.
1274   if test "$have_xf86gamma" = yes; then
1275     AC_DEFINE(HAVE_XF86VMODE_GAMMA)
1276   fi
1277
1278   if test "$have_xf86gamma_ramp" = yes; then
1279     AC_DEFINE(HAVE_XF86VMODE_GAMMA_RAMP)
1280   fi
1281
1282   # pull in the lib, if we haven't already
1283   if test "$have_xf86gamma" = yes -a "$have_xf86vmode" = no; then
1284     SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
1285   fi
1286
1287 elif test "$with_xf86gamma" != no; then
1288   echo "error: must be yes or no: --with-xf86gamma-ext=$with_xf86vmode"
1289   exit 1
1290 fi
1291
1292
1293 ###############################################################################
1294 #
1295 #       Check for HP XHPDisableReset and XHPEnableReset.
1296 #
1297 ###############################################################################
1298
1299 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
1300                   [AC_DEFINE(HAVE_XHPDISABLERESET)
1301                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
1302
1303
1304 ###############################################################################
1305 #
1306 #       Check for /proc/interrupts.
1307 #
1308 ###############################################################################
1309
1310 have_proc_interrupts=no
1311 with_proc_interrupts_req=unspecified
1312 AC_ARG_WITH(proc-interrupts,
1313 [  --with-proc-interrupts  Include support for consulting the /proc/interrupts
1314                           file to notice keyboard activity.],
1315   [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
1316   [with_proc_interrupts=yes])
1317
1318 if test "$with_proc_interrupts" = yes; then
1319
1320    AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
1321     ac_cv_have_proc_interrupts,
1322     [ac_cv_have_proc_interrupts=no
1323      if grep keyboard /proc/interrupts >/dev/null 2>&1 ; then
1324        ac_cv_have_proc_interrupts=yes
1325      fi
1326     ])
1327    have_proc_interrupts=$ac_cv_have_proc_interrupts
1328
1329   if test "$have_proc_interrupts" = yes; then
1330     AC_DEFINE(HAVE_PROC_INTERRUPTS)
1331   fi
1332
1333 elif test "$with_proc_interrupts" != no; then
1334   echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
1335   exit 1
1336 fi
1337
1338
1339 ###############################################################################
1340 #
1341 #       The --enable-locking option
1342 #
1343 ###############################################################################
1344
1345 AC_ARG_ENABLE(locking,[
1346 Screen locking options:
1347
1348   --enable-locking        Compile in support for locking the display.
1349   --disable-locking       Do not allow locking at all.
1350 ],
1351   [enable_locking="$enableval"],[enable_locking=yes])
1352 if test "$enable_locking" = yes; then
1353   true
1354 elif test "$enable_locking" = no; then
1355   AC_DEFINE(NO_LOCKING)
1356 else
1357   echo "error: must be yes or no: --enable-locking=$enable_locking"
1358   exit 1
1359 fi
1360
1361
1362
1363 ###############################################################################
1364 #
1365 #       The --enable-vt-locking option
1366 #
1367 ###############################################################################
1368
1369 #ac_vt_lockswitch=no
1370 #AC_ARG_ENABLE(vt-locking,[
1371 #  --enable-vt-locking     Compile in support for locking Virtual Terminals.
1372 #                          This is the default if the system supports it, and
1373 #                          if locking support is included (--enable-locking.)
1374 #  --disable-vt-locking    Do not allow locking of VTs, even if locking is
1375 #                          enabled.],
1376 #  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1377 #if test "$enable_vt_locking" = yes; then
1378 #
1379 #  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
1380 #   [AC_TRY_COMPILE([#include <fcntl.h>
1381 #                   #include <sys/ioctl.h>
1382 #                   #include <sys/vt.h>],
1383 #                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1384 #                  [ac_cv_vt_lockswitch=yes],
1385 #                  [ac_cv_vt_lockswitch=no])])
1386 #  ac_vt_lockswitch=$ac_cv_vt_lockswitch
1387 #
1388 #elif test "$enable_vt_locking" = no; then
1389 #  true
1390 #else
1391 #  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1392 #  exit 1
1393 #fi
1394 #
1395 #if test "$ac_vt_lockswitch" = yes; then
1396 #  AC_DEFINE(HAVE_VT_LOCKSWITCH)
1397 #  # the VT_LOCKSWITCH ioctl can only be used when running as root.
1398 #  # #### but it doesn't work yet, so don't worry about that for now.
1399 ##  need_setuid=yes
1400 #fi
1401
1402
1403
1404 ###############################################################################
1405 #
1406 #       Check for PAM.
1407 #
1408 ###############################################################################
1409
1410 case "$host" in
1411   *-solaris*)
1412    # Solaris systems tend to come with PAM misconfigured.
1413    #  Don't build it by default, even if the headers exist.
1414    with_pam_default=no
1415    ;;
1416   *)
1417    # Default to building PAM support on all other systems, if it exists.
1418    with_pam_default=yes
1419   ;;
1420 esac
1421
1422 have_pam=no
1423 with_pam_req=unspecified
1424
1425 AC_ARG_WITH(pam,
1426 [  --with-pam              Include support for PAM (Pluggable Auth Modules.)],
1427   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
1428
1429 HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1430
1431 if test "$enable_locking" = yes -a "$with_pam" = yes; then
1432   AC_CACHE_CHECK([for PAM], ac_cv_pam,
1433                  [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1434                                    [ac_cv_pam=yes],
1435                                    [ac_cv_pam=no])])
1436   if test "$ac_cv_pam" = yes ; then
1437     have_pam=yes
1438     AC_DEFINE(HAVE_PAM)
1439     PASSWD_LIBS="${PASSWD_LIBS} -lpam"
1440
1441     # libpam typically requires dlopen and dlsym.  On FreeBSD,
1442     # those are in libc.  On Linux and Solaris, they're in libdl.
1443     AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
1444
1445     AC_MSG_CHECKING(how to call pam_strerror)
1446     AC_CACHE_VAL(ac_cv_pam_strerror_args,
1447      [AC_TRY_COMPILE([#include <stdio.h>
1448                       #include <stdlib.h>
1449                       #include <security/pam_appl.h>],
1450                      [pam_handle_t *pamh = 0;
1451                       char *s = pam_strerror(pamh, PAM_SUCCESS);],
1452                      [ac_pam_strerror_args=2],
1453                      [AC_TRY_COMPILE([#include <stdio.h>
1454                                       #include <stdlib.h>
1455                                       #include <security/pam_appl.h>],
1456                                      [char *s =
1457                                        pam_strerror(PAM_SUCCESS);],
1458                                      [ac_pam_strerror_args=1],
1459                                      [ac_pam_strerror_args=0])])
1460       ac_cv_pam_strerror_args=$ac_pam_strerror_args])
1461     ac_pam_strerror_args=$ac_cv_pam_strerror_args
1462     if test "$ac_pam_strerror_args" = 1 ; then
1463       AC_MSG_RESULT(one argument)
1464     elif test "$ac_pam_strerror_args" = 2 ; then
1465       AC_DEFINE(PAM_STRERROR_TWO_ARGS)
1466       AC_MSG_RESULT(two arguments)
1467     else
1468       AC_MSG_RESULT(unknown)
1469     fi
1470   fi
1471 fi
1472
1473
1474 ###############################################################################
1475 #
1476 #       Check for Kerberos.
1477 #
1478 ###############################################################################
1479
1480 have_kerberos=no
1481 have_kerberos5=no
1482 with_kerberos_req=unspecified
1483
1484 AC_ARG_WITH(kerberos, 
1485 [  --with-kerberos         Include support for Kerberos authentication.],
1486   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1487
1488 HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1489
1490 if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
1491   AC_CACHE_CHECK([for Kerberos 4], ac_cv_kerberos,
1492                  [AC_TRY_X_COMPILE([#include <krb.h>],,
1493                                    [ac_cv_kerberos=yes],
1494                                    [ac_cv_kerberos=no])])
1495   AC_CACHE_CHECK([for Kerberos 5], ac_cv_kerberos5,
1496                  [AC_TRY_X_COMPILE([#include <kerberosIV/krb.h>],,
1497                                    [ac_cv_kerberos5=yes],
1498                                    [ac_cv_kerberos5=no])])
1499
1500   if test "$ac_cv_kerberos" = yes ; then
1501     have_kerberos=yes
1502     AC_DEFINE(HAVE_KERBEROS)
1503   fi
1504
1505   if test "$ac_cv_kerberos5" = yes ; then
1506     have_kerberos=yes
1507     have_kerberos5=yes
1508     AC_DEFINE(HAVE_KERBEROS)
1509     AC_DEFINE(HAVE_KERBEROS5)
1510   fi
1511
1512   if test "$have_kerberos5" = yes ; then
1513     # from Matt Knopp <mhat@infocalypse.netlag.com>
1514     # (who got it from amu@mit.edu)
1515     PASSWD_LIBS="$PASSWD_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcrypt -lcom_err"
1516   elif test "$have_kerberos" = yes ; then
1517     # from Tim Showalter <tjs@psaux.com> for FreeBSD 4.2
1518     PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lcom_err"
1519   fi
1520
1521   if test "$have_kerberos" = yes ; then
1522     AC_CHECK_FUNC(res_search,,
1523       AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1524         AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1525       ))
1526   fi
1527 fi
1528
1529
1530 ###############################################################################
1531 #
1532 #       Check for the nine billion variants of shadow passwords...
1533 #
1534 ###############################################################################
1535
1536 need_setuid=no
1537
1538 have_shadow=no
1539 with_shadow_req=unspecified
1540
1541 AC_ARG_WITH(shadow,
1542 [  --with-shadow           Include support for shadow password authentication.],
1543   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1544
1545 HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1546
1547 if test "$enable_locking" = no ; then
1548   with_shadow_req=no
1549   with_shadow=no
1550 fi
1551
1552
1553 ###############################################################################
1554 #
1555 #       Check for Sun "adjunct" passwords.
1556 #
1557 ###############################################################################
1558
1559 if test "$with_shadow" = yes ; then
1560   AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1561                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1562                                     #include <unistd.h>
1563                                     #include <sys/types.h>
1564                                     #include <sys/label.h>
1565                                     #include <sys/audit.h>
1566                                     #include <pwdadj.h>],
1567                       [struct passwd_adjunct *p = getpwanam("nobody");
1568                        const char *pw = p->pwa_passwd;],
1569                       [ac_cv_sun_adjunct=yes],
1570                       [ac_cv_sun_adjunct=no])])
1571   if test "$ac_cv_sun_adjunct" = yes; then
1572     have_shadow_adjunct=yes
1573     have_shadow=yes
1574     need_setuid=yes
1575   fi
1576 fi
1577
1578
1579 ###############################################################################
1580 #
1581 #       Check for DEC and SCO so-called "enhanced" security.
1582 #
1583 ###############################################################################
1584
1585 if test "$with_shadow" = yes ; then
1586   AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1587                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1588                                     #include <unistd.h>
1589                                     #include <sys/types.h>
1590                                     #include <pwd.h>
1591                                     #include <sys/security.h>
1592                                     #include <prot.h>],
1593                       [struct pr_passwd *p;
1594                        const char *pw;
1595                        set_auth_parameters(0, 0);
1596                        check_auth_parameters();
1597                        p = getprpwnam("nobody");
1598                        pw = p->ufld.fd_encrypt;],
1599                       [ac_cv_enhanced_passwd=yes],
1600                       [ac_cv_enhanced_passwd=no])])
1601   if test $ac_cv_enhanced_passwd = yes; then
1602     have_shadow_enhanced=yes
1603     have_shadow=yes
1604     need_setuid=yes
1605
1606     # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1607     # (I'm told it needs -lcurses too, but I don't understand why.)
1608     # But on DEC, it's in -lsecurity.
1609     #
1610     AC_CHECK_LIB(prot, getprpwnam, 
1611                  [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1612                  [AC_CHECK_LIB(security, getprpwnam, 
1613                                [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1614                  [-lx])
1615   fi
1616 fi
1617
1618 ###############################################################################
1619 #
1620 #       Check for HP's entry in the "Not Invented Here" Sweepstakes.
1621 #
1622 ###############################################################################
1623
1624 if test "$with_shadow" = yes ; then
1625   AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1626                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1627                                     #include <unistd.h>
1628                                     #include <sys/types.h>
1629                                     #include <pwd.h>
1630                                     #include <hpsecurity.h>
1631                                     #include <prot.h>],
1632                       [struct s_passwd *p = getspwnam("nobody");
1633                        const char *pw = p->pw_passwd;],
1634                       [ac_cv_hpux_passwd=yes],
1635                       [ac_cv_hpux_passwd=no])])
1636   if test "$ac_cv_hpux_passwd" = yes; then
1637     have_shadow_hpux=yes
1638     have_shadow=yes
1639     need_setuid=yes
1640
1641     # on HPUX, bigcrypt is in -lsec
1642     AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1643   fi
1644 fi
1645
1646
1647 ###############################################################################
1648 #
1649 #       Check for FreeBSD-style shadow passwords.
1650 #
1651 #       On FreeBSD, getpwnam() and friends work just like on non-shadow-
1652 #       password systems -- except you only get stuff in the pw_passwd field
1653 #       if the running program is setuid.  So, guess that we've got this
1654 #       lossage to contend with if /etc/master.passwd exists, and default to
1655 #       a setuid installation.
1656 #
1657 ###############################################################################
1658
1659 if test "$with_shadow" = yes ; then
1660   AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1661                  [if test -f /etc/master.passwd ; then
1662                     ac_cv_master_passwd=yes
1663                   else
1664                     ac_cv_master_passwd=no
1665                   fi])
1666   if test "$ac_cv_master_passwd" = yes; then
1667     need_setuid=yes
1668   fi
1669 fi
1670
1671
1672 ###############################################################################
1673 #
1674 #       Check for traditional (ha!) shadow passwords.
1675 #
1676 ###############################################################################
1677
1678 if test "$with_shadow" = yes ; then
1679   AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1680                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1681                                     #include <unistd.h>
1682                                     #include <sys/types.h>
1683                                     #include <pwd.h>
1684                                     #include <shadow.h>],
1685                       [struct spwd *p = getspnam("nobody");
1686                        const char *pw = p->sp_pwdp;],
1687                       [ac_cv_shadow=yes],
1688                       [ac_cv_shadow=no])])
1689   if test "$ac_cv_shadow" = yes; then
1690     have_shadow=yes
1691     need_setuid=yes
1692
1693     # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1694     have_getspnam=no
1695     AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1696     if test "$have_getspnam" = no ; then
1697       AC_CHECK_LIB(gen, getspnam,
1698                    [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1699     fi
1700   fi
1701 fi
1702
1703
1704 ###############################################################################
1705 #
1706 #       Check for other libraries needed for non-shadow passwords.
1707 #
1708 ###############################################################################
1709
1710 if test "$enable_locking" = yes ; then
1711
1712   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1713   have_crypt=no
1714   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1715   if test "$have_crypt" = no ; then
1716     AC_CHECK_LIB(crypt, crypt,
1717                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1718   fi
1719 fi
1720
1721
1722 # Most of the above shadow mechanisms will have set need_setuid to yes,
1723 # if they were found.  But, on some systems, we need setuid even when
1724 # using plain old vanilla passwords.
1725 #
1726 if test "$enable_locking" = yes ; then
1727   case "$host" in
1728     *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1729       need_setuid=yes
1730     ;;
1731   esac
1732 fi
1733
1734
1735 if test "$have_shadow_adjunct" = yes ; then
1736   AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1737 elif test "$have_shadow_enhanced" = yes ; then
1738   AC_DEFINE(HAVE_ENHANCED_PASSWD)
1739 elif test "$have_shadow_hpux" = yes ; then
1740   AC_DEFINE(HAVE_HPUX_PASSWD)
1741 elif test "$have_shadow" = yes ; then
1742   AC_DEFINE(HAVE_SHADOW_PASSWD)
1743 fi
1744
1745
1746 ###############################################################################
1747 #
1748 #       Check for -lXm.
1749 #
1750 ###############################################################################
1751
1752 have_motif=no
1753 with_motif_req=unspecified
1754 AC_ARG_WITH(motif,[
1755 User interface options:
1756
1757   --with-motif            Use the Motif toolkit for the user interface.],
1758   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=yes])
1759
1760 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
1761
1762 if test "$with_motif" != yes -a "$with_motif" != no ; then
1763   echo "error: must be yes or no: --with-motif=$with_motif"
1764   exit 1
1765 fi
1766
1767 if test "$with_motif" = yes; then
1768   have_motif=no
1769   AC_CHECK_X_HEADER(Xm/Xm.h,
1770                     [have_motif=yes
1771                      AC_DEFINE(HAVE_MOTIF)
1772                      MOTIF_LIBS="$MOTIF_LIBS -lXm"])
1773 fi
1774
1775
1776 if test "$have_motif" = yes; then
1777   AC_CHECK_X_HEADER(Xm/ComboBox.h, [AC_DEFINE(HAVE_XMCOMBOBOX)])
1778 fi
1779
1780
1781 ###############################################################################
1782 #
1783 #       Check for -lgtk (and Gnome stuff)
1784 #
1785 ###############################################################################
1786
1787 have_gtk=no
1788 with_gtk_req=unspecified
1789 AC_ARG_WITH(gtk,
1790 [  --with-gtk              Use the Gtk toolkit for the user interface.],
1791   [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
1792
1793 # if --with-gtk=/directory/ was specified, remember that directory so that
1794 # we can also look for the `gtk-config' program in that directory.
1795 case "$with_gtk" in
1796   /*)
1797     gtk_dir="$with_gtk"
1798     ;;
1799   *)
1800     gtk_dir=""
1801     ;;
1802 esac
1803
1804 HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
1805
1806 if test "$with_gtk" != yes -a "$with_gtk" != no ; then
1807   echo "error: must be yes or no: --with-gtk=$with_gtk"
1808   exit 1
1809 fi
1810
1811 have_gnome=no
1812 with_gnome_req=unspecified
1813 AC_ARG_WITH(gnome,
1814 [  --with-gnome            Include support for the Gnome Control Center.],
1815   [with_gnome="$withval"; with_gnome_req="$withval"],[with_gnome=yes])
1816
1817 # if --with-gnome=/directory/ was specified, remember that directory so that
1818 # we can also look for the `gnome-config' program in that directory.
1819 case "$with_gnome" in
1820   /*)
1821     gnome_dir="$with_gnome"
1822     ;;
1823   *)
1824     gnome_dir=""
1825     ;;
1826 esac
1827
1828 HANDLE_X_PATH_ARG(with_gnome, --with-gnome, Gnome)
1829
1830 if test "$with_gnome" != yes -a "$with_gnome" != no ; then
1831   echo "error: must be yes or no: --with-gnome=$with_gnome"
1832   exit 1
1833 fi
1834
1835
1836 jurassic_gtk=no
1837 if test "$with_gtk" = yes; then
1838   have_gtk=no
1839   
1840   # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
1841   # look in /foo/bin/ for glib-config, gtk-config, and gnome-config.
1842   #
1843   gtk_path="$PATH"
1844
1845   if test ! -z "$gtk_dir"; then
1846     # canonicalize slashes.
1847     foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
1848     gtk_path="$foo:$gtk_path"
1849   fi
1850
1851   if test ! -z "$gnome_dir"; then
1852     # canonicalize slashes.
1853     foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
1854     gtk_path="$foo:$gtk_path"
1855   fi
1856
1857   AC_PATH_PROGS(glib_config,  glib12-config glib-config,,  $gtk_path)
1858   AC_PATH_PROGS(gtk_config,   gtk12-config  gtk-config,,   $gtk_path)
1859
1860   if test "$with_gnome" = yes; then
1861     AC_PATH_PROGS(gnome_config, gnome-config,, $gtk_path)
1862   fi
1863
1864   if test -n "$glib_config" -a  -n "$gtk_config" ; then
1865     have_gtk=yes
1866     if test "$with_gnome" = yes -a -n "$gnome_config" ; then
1867       have_gnome=yes
1868     fi
1869   fi
1870
1871   if test "$have_gtk" = yes; then
1872     AC_CACHE_CHECK([Gtk version number], ac_cv_gtk_version_string,
1873                    [ac_cv_gtk_version_string=`$gtk_config --version`])
1874     ac_gtk_version_string=$ac_cv_gtk_version_string
1875     # M4 sucks!!
1876     changequote(X,Y)
1877     maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
1878     min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
1879     changequote([,])
1880     ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
1881     if test -z "$ac_gtk_version"; then
1882       ac_gtk_version=unknown
1883       ac_gtk_version_string=unknown
1884     fi
1885     if test "$ac_gtk_version" = "unknown" || test "$ac_gtk_version" -lt 1002
1886     then
1887       have_gtk=no
1888       have_gnome=no
1889       jurassic_gtk=yes
1890     fi
1891   fi
1892
1893   if test "$have_gtk" = yes; then
1894     AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
1895                    [ac_cv_gtk_config_cflags=`$gtk_config --cflags`])
1896     AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
1897                    [ac_cv_gtk_config_libs=`$gtk_config --libs`])
1898   fi
1899   ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
1900   ac_gtk_config_libs=$ac_cv_gtk_config_libs
1901
1902   # Check for Gnome Capplet support.
1903   #
1904   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1905     gnome_config_libs="gtk capplet gnomeui gdk_pixbuf"
1906     AC_MSG_CHECKING(for Gnome capplet includes)
1907     AC_CACHE_VAL(ac_cv_gnome_config_cflags,
1908       [if ( $gnome_config --cflags $gnome_config_libs 2>&1 >/dev/null | \
1909             grep Unknown >/dev/null ) ; then
1910          ac_cv_gnome_config_cflags=''
1911        else
1912          ac_cv_gnome_config_cflags=`$gnome_config --cflags $gnome_config_libs`
1913        fi])
1914     ac_gnome_config_cflags=$ac_cv_gnome_config_cflags
1915     if test "$ac_gnome_config_cflags" = "" ; then
1916       have_gnome=no
1917       AC_MSG_RESULT(no)
1918     else
1919       AC_MSG_RESULT($ac_gnome_config_cflags)
1920     fi
1921   fi
1922
1923   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1924     AC_MSG_CHECKING(for Gnome capplet libs)
1925     AC_CACHE_VAL(ac_cv_gnome_config_libs,
1926       [if ( $gnome_config --libs $gnome_config_libs 2>&1 >/dev/null |
1927             grep Unknown >/dev/null ) ; then
1928          ac_cv_gnome_config_libs=''
1929        else
1930          ac_cv_gnome_config_libs=`$gnome_config --libs $gnome_config_libs`
1931        fi])
1932     ac_gnome_config_libs=$ac_cv_gnome_config_libs
1933     if test "$ac_gnome_config_libs" = "" ; then
1934       have_gnome=no
1935       AC_MSG_RESULT(no)
1936     else
1937       AC_MSG_RESULT($ac_gnome_config_libs)
1938     fi
1939   fi
1940
1941   GNOME_DATADIR=""
1942   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1943     GNOME_DATADIR=`$gnome_config --datadir`
1944   fi
1945
1946
1947   # If we have Gnome, then override the gtk-config values with 
1948   # the gnome-config values.
1949   #
1950   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1951     ac_gtk_config_cflags=$ac_gnome_config_cflags
1952     ac_gtk_config_libs=$ac_gnome_config_libs
1953     AC_DEFINE(HAVE_CRAPPLET)
1954
1955     # check for this function that was not in libcapplet 1.2.
1956     AC_CHECK_X_LIB(capplet, capplet_widget_changes_are_immediate,
1957                    [AC_DEFINE(HAVE_CRAPPLET_IMMEDIATE)], [true],
1958                    $ac_gnome_config_libs)
1959   fi
1960
1961
1962   if test "$have_gtk" = yes; then
1963     INCLUDES="$INCLUDES $ac_gtk_config_cflags"
1964     GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
1965     AC_DEFINE(HAVE_GTK)
1966   fi
1967
1968 fi
1969
1970
1971 # Check for the Gnome Help Browser.
1972 #
1973 if test "$have_gnome" = yes; then
1974   AC_CHECK_PROG(have_gnome_help, gnome-help-browser, yes, no)
1975 else
1976   have_gnome_help=no
1977 fi
1978
1979
1980 ###############################################################################
1981 #
1982 #       Check for -lxml
1983 #
1984 ###############################################################################
1985
1986 have_xml=no
1987 with_xml_req=unspecified
1988 xml_halfassed=no
1989 AC_ARG_WITH(xml,
1990 [  --with-xml              The XML toolkit is needed for some parts of
1991                           the Gtk interface.],
1992 [with_xml="$withval"; with_xml_req="$withval"],[with_xml=yes])
1993
1994 # if --with-xml=/directory/ was specified, remember that directory so that
1995 # we can also look for the `xml-config' program in that directory.
1996 case "$with_xml" in
1997   /*)
1998     xml_dir="$with_xml"
1999     ;;
2000   *)
2001     xml_dir=""
2002     ;;
2003 esac
2004
2005 HANDLE_X_PATH_ARG(with_xml, --with-xml, XML)
2006
2007 if test "$with_xml" != yes -a "$with_xml" != no ; then
2008   echo "error: must be yes or no: --with-xml=$with_xml"
2009   exit 1
2010 fi
2011
2012 if test "$with_xml" = yes; then
2013   have_xml=no
2014
2015   # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
2016   # look in /foo/bin/ for for xml-config.
2017   #
2018   xml_path="$PATH"
2019
2020   if test ! -z "$gtk_dir"; then
2021     # canonicalize slashes.
2022     foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
2023     xml_path="$foo:$xml_path"
2024   fi
2025
2026   if test ! -z "$gnome_dir"; then
2027     # canonicalize slashes.
2028     foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
2029     xml_path="$foo:$xml_path"
2030   fi
2031
2032   AC_PATH_PROGS(xml_config, xml2-config xml-config,, $xml_path)
2033
2034   # If we found the xml-config program, run it to get flags.
2035   #
2036   if test -n "$xml_config" ; then
2037     AC_CACHE_CHECK([for XML includes], ac_cv_xml_config_cflags,
2038                    [ac_cv_xml_config_cflags=`$xml_config --cflags`])
2039     AC_CACHE_CHECK([for XML libs], ac_cv_xml_config_libs,
2040                    [ac_cv_xml_config_libs=`$xml_config --libs`])
2041     ac_xml_config_cflags=$ac_cv_xml_config_cflags
2042     ac_xml_config_libs=$ac_cv_xml_config_libs
2043   fi
2044
2045   ac_save_xml_CPPFLAGS="$CPPFLAGS"
2046   CPPFLAGS="$CPPFLAGS $ac_xml_config_cflags"
2047   AC_CHECK_X_HEADER(xmlIO.h, [have_xml=yes])
2048   CPPFLAGS="$ac_save_xml_CPPFLAGS"
2049
2050   if test "$have_xml" = yes; then
2051     # we have the header, now check for the library
2052     have_xml=no
2053     xml_halfassed=yes
2054     AC_CHECK_X_LIB(xml, xmlParseChunk,
2055                    [have_xml=yes
2056                     xml_halfassed=no
2057                     XML_LIBS="-lxml"
2058                     AC_DEFINE(HAVE_XML)],
2059                    [true],
2060                    $ac_xml_config_libs)
2061   fi
2062
2063   if test "$have_xml" = yes; then
2064     INCLUDES="$INCLUDES $ac_xml_config_cflags"
2065     GTK_LIBS="$GTK_LIBS $ac_xml_config_libs"
2066     AC_DEFINE(HAVE_XML)
2067   fi
2068
2069 fi
2070
2071
2072 ###############################################################################
2073 #
2074 #       Checking whether Motif is really Lesstif.
2075 #
2076 ###############################################################################
2077
2078 have_lesstif=no
2079 if test "$have_motif" = yes ; then
2080   AC_CACHE_CHECK([whether Motif is really LessTif], 
2081                  ac_cv_have_lesstif,
2082                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
2083                                    [long vers = LesstifVersion;],
2084                                    [ac_cv_have_lesstif=yes],
2085                                    [ac_cv_have_lesstif=no])])
2086   have_lesstif=$ac_cv_have_lesstif
2087 fi
2088
2089
2090 lesstif_version=unknown
2091 lesstif_version_string=unknown
2092
2093 if test "$have_lesstif" = yes ; then
2094   ltv=unknown
2095   echo unknown > conftest-lt
2096   AC_CACHE_CHECK([LessTif version number],
2097                  ac_cv_lesstif_version_string,
2098       [AC_TRY_X_RUN([#include <stdio.h>
2099                      #include <Xm/Xm.h>
2100                      int main() {
2101                        FILE *f = fopen("conftest-lt", "w");
2102                        if (!f) exit(1);
2103                        fprintf(f, "%d %d.%d\n", LesstifVersion,
2104                           LESSTIF_VERSION, LESSTIF_REVISION);
2105                        fclose(f);
2106                        exit(0);
2107                      }],
2108                     [ltv=`cat conftest-lt`
2109                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
2110                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
2111                     [ac_cv_lesstif_version=unknown
2112                      ac_cv_lesstif_version_string=unknown],
2113                     [ac_cv_lesstif_version=unknown
2114                      ac_cv_lesstif_version_string=unknown])])
2115   rm -f conftest-lt
2116   lesstif_version=$ac_cv_lesstif_version
2117   lesstif_version_string=$ac_cv_lesstif_version_string
2118
2119 fi
2120
2121
2122 if test "$have_motif" = yes ; then
2123   mtv=unknown
2124   echo unknown > conftest-mt
2125   AC_CACHE_CHECK([Motif version number],
2126                  ac_cv_motif_version_string,
2127       [AC_TRY_X_RUN([#include <stdio.h>
2128                      #include <Xm/Xm.h>
2129                      int main() {
2130                        FILE *f = fopen("conftest-mt", "w");
2131                        if (!f) exit(1);
2132                        fprintf(f, "%d %d.%d\n", XmVersion,
2133                           XmVERSION, XmREVISION);
2134                        fclose(f);
2135                        exit(0);
2136                      }],
2137                     [mtv=`cat conftest-mt`
2138                      ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
2139                      ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
2140                     [ac_cv_motif_version=unknown
2141                      ac_cv_motif_version_string=unknown],
2142                     [ac_cv_motif_version=unknown
2143                      ac_cv_motif_version_string=unknown])])
2144   rm -f conftest-mt
2145   motif_version=$ac_cv_motif_version
2146   motif_version_string=$ac_cv_motif_version_string
2147
2148 fi
2149
2150
2151 ###############################################################################
2152 #
2153 #       Checking whether Motif requires -lXpm.
2154 #
2155 #       If this is Motif 2.x, and we have XPM, then link against XPM as well.
2156 #       The deal is, Motif 2.x requires XPM -- but it's a compilation option
2157 #       of the library whether to build the XPM code into libXm, or whether
2158 #       to rely on an external libXm.  So the only way to tell whether XPM is
2159 #       a link-time requirement is to examine libXm.a, which is very
2160 #       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
2161 #       always link against XPM if the XPM lib exists (and this will be a
2162 #       no-op if libXm happens to already have the XPM code in it.)
2163 #
2164 ###############################################################################
2165
2166 motif_requires_xpm=no
2167 if test "$have_motif" = yes ; then
2168    AC_MSG_CHECKING(whether Motif requires XPM)
2169    if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
2170    then
2171      motif_requires_xpm=yes
2172      AC_MSG_RESULT(maybe)
2173    else
2174      AC_MSG_RESULT(no)
2175    fi
2176 fi
2177
2178
2179 ###############################################################################
2180 #
2181 #       Checking whether Motif requires -lXp.
2182 #
2183 #       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
2184 #       Extension".   Why this extension isn't in -lXext with all the others,
2185 #       I have no idea.
2186 #
2187 ###############################################################################
2188
2189 have_xp_ext=no
2190 if test "$have_motif" = yes ; then
2191    have_xp_ext=no
2192    AC_CHECK_X_LIB(Xp, XpQueryExtension,
2193                   [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
2194                   [true], -lX11 -lXext -lm)
2195 fi
2196
2197
2198 ###############################################################################
2199 #
2200 #       Checking whether Motif requires -lXintl (for _Xsetlocale.)
2201 #
2202 ###############################################################################
2203
2204 have_xintl=no
2205 if test "$have_motif" = yes ; then
2206   AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
2207                  -lX11 -lXext -lm)
2208   if test "$have_xintl" = yes; then
2209     MOTIF_LIBS="$MOTIF_LIBS -lXintl"
2210   fi
2211 fi
2212
2213
2214 ###############################################################################
2215 #
2216 #       Check for -lGL or -lMesaGL.
2217 #
2218 ###############################################################################
2219
2220 have_gl=no
2221 ac_have_mesa_gl=no
2222 with_gl_req=unspecified
2223 gl_halfassed=no
2224 AC_ARG_WITH(gl,[
2225 Graphics options:
2226
2227   --with-gl               Build those demos which depend on OpenGL.],
2228   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
2229
2230 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
2231
2232 ac_mesagl_version=unknown
2233 ac_mesagl_version_string=unknown
2234
2235 if test "$with_gl" = yes; then
2236   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
2237   if test "$have_gl" = yes ; then
2238     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
2239   fi
2240
2241   # If we have the headers, try and figure out which vendor it's from.
2242   #
2243   if test "$have_gl" = yes ; then
2244
2245     # We need to know whether it's MesaGL so that we know which libraries
2246     # to link against.
2247     #
2248     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
2249       [ac_cv_have_mesa_gl=no
2250        AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
2251       ])
2252     ac_have_mesa_gl=$ac_cv_have_mesa_gl
2253  
2254
2255     gl_lib_1=""
2256     GL_LIBS=""
2257
2258
2259     # Some versions of MesaGL are compiled to require -lpthread.
2260     # So if the Mesa headers exist, and -lpthread exists, then always
2261     # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
2262     #
2263     if test "$ac_have_mesa_gl" = yes; then
2264       AC_CHECK_LIB(pthread, pthread_create, [GL_LIBS="-lpthread"], [],)
2265     fi
2266
2267
2268     # If we have Mesa headers, check to see if we can link against -lMesaGL.
2269     # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
2270     # Else, warn that GL is busted.  (We have the headers, but no libs.)
2271     #
2272
2273     if test "$ac_have_mesa_gl" = yes ; then
2274       AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
2275                      [gl_lib_1="MesaGL"
2276                       GL_LIBS="-lMesaGL -lMesaGLU $GL_LIBS"],
2277                      [], -lMesaGLU $GL_LIBS -lX11 -lXext -lm)
2278     fi
2279
2280     if test "$gl_lib_1" = "" ; then
2281       AC_CHECK_X_LIB(GL, glXCreateContext, 
2282                      [gl_lib_1="GL"
2283                       GL_LIBS="-lGL -lGLU $GL_LIBS"],
2284                      [], -lGLU $GL_LIBS -lX11 -lXext -lm)
2285     fi
2286
2287     if test "$gl_lib_1" = "" ; then
2288       # we have headers, but no libs -- bail.
2289       have_gl=no
2290       ac_have_mesa_gl=no
2291       gl_halfassed=yes
2292     else
2293       # linking works -- we can build the GL hacks.
2294       AC_DEFINE(HAVE_GL)
2295       if test "$ac_have_mesa_gl" = yes ; then
2296         AC_DEFINE(HAVE_MESA_GL)
2297       fi
2298     fi
2299   fi
2300
2301
2302   # Now that we know we have GL headers and libs, do some more GL testing.
2303   #
2304
2305   if test "$have_gl" = yes ; then
2306     # If it's MesaGL, we'd like to issue a warning if the version number
2307     # is less than or equal to 2.6, because that version had a security bug.
2308     #
2309     if test "$ac_have_mesa_gl" = yes; then
2310
2311       AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
2312         [cat > conftest.$ac_ext <<EOF
2313 #line __oline__ "configure"
2314 #include "confdefs.h"
2315 #include <GL/gl.h>
2316 #ifndef MESA_MAJOR_VERSION
2317 # include <GL/xmesa.h>
2318 # define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
2319 # define MESA_MINOR_VERSION XMESA_MINOR_VERSION
2320 #endif
2321 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
2322 EOF
2323
2324          ac_save_CPPFLAGS="$CPPFLAGS"
2325          if test \! -z "$includedir" ; then 
2326            CPPFLAGS="$CPPFLAGS -I$includedir"
2327          fi
2328          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2329
2330           # M4 sucks!!
2331          changequote(X,Y)
2332          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
2333               's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
2334          changequote([,])
2335
2336          rm -f conftest.$ac_ext
2337
2338          CPPFLAGS="$ac_save_CPPFLAGS"
2339
2340          if test "$mglv" = ""; then
2341            ac_mesagl_version=unknown
2342            ac_mesagl_version_string=unknown
2343          else
2344            ac_mesagl_version_string=$mglv
2345            maj=`echo $mglv | sed -n 's/\..*//p'`
2346            min=`echo $mglv | sed -n 's/.*\.//p'`
2347            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
2348            if test -z "$ac_mesagl_version"; then
2349              ac_mesagl_version=unknown
2350              ac_mesagl_version_string=unknown
2351            fi
2352          fi
2353          ac_cv_mesagl_version=$ac_mesagl_version
2354          ac_cv_mesagl_version_string=$ac_mesagl_version_string
2355       ])
2356       ac_mesagl_version=$ac_cv_mesagl_version
2357       ac_mesagl_version_string=$ac_cv_mesagl_version_string
2358     fi
2359
2360
2361     # Check for OpenGL 1.1 features.
2362     #
2363     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
2364                    [true], $GL_LIBS -lX11 -lXext -lm)
2365   fi
2366
2367 elif test "$with_gl" != no; then
2368   echo "error: must be yes or no: --with-gl=$with_gl"
2369   exit 1
2370 fi
2371
2372
2373 ###############################################################################
2374 #
2375 #       Check for -lgle.
2376 #
2377 ###############################################################################
2378
2379 have_gle=no
2380 with_gle_req=unspecified
2381 gle_halfassed=no
2382 AC_ARG_WITH(gle,
2383 [  --with-gle              Build those demos which depend on GLE
2384                           (the OpenGL "extrusion" library.)],
2385   [with_gle="$withval"; with_gle_req="$withval"],[with_gle=yes])
2386
2387 HANDLE_X_PATH_ARG(with_gle, --with-gle, GLE)
2388
2389 GLE_LIBS=""
2390
2391 if test "$with_gle" = yes; then
2392
2393   AC_CHECK_X_HEADER(GL/gle.h, have_gle3=yes, have_gle3=no)
2394   if test "$have_gle3" = yes ; then
2395     have_gle=yes;
2396   else
2397     AC_CHECK_X_HEADER(GL/gutil.h, have_gle=yes, have_gle=no)
2398     if test "$have_gle" = yes ; then
2399       AC_CHECK_X_HEADER(GL/tube.h, have_gle=yes, have_gle=no)
2400     fi
2401   fi
2402
2403   if test "$have_gle" = yes ; then
2404     have_gle=no
2405     gle_halfassed=yes
2406     AC_CHECK_X_LIB(gle, gleCreateGC, 
2407                    [have_gle=yes; gle_halfassed=no; GLE_LIBS="-lgle"],
2408                    [], $GL_LIBS -lX11 -lXext -lm)
2409   fi
2410   if test "$have_gle" = yes ; then
2411     have_gle=no
2412     gle_halfassed=yes
2413
2414     # sometimes the libmatrix stuff is included in libgle.  look there first.
2415 #
2416 # I don't get it.  For some reason, this test passes on SGI, as if
2417 # uview_direction_d() was in libgle -- but it's not, it's in libmatrix.
2418 # Yet the link is succeeding.  Why???
2419 #
2420 #    AC_CHECK_X_LIB(gle, uview_direction_d, 
2421 #                   [have_gle=yes; gle_halfassed=no],
2422 #                   [], $GL_LIBS -lX11 -lXext -lm)
2423
2424     # As of GLE 3 this is in libgle, and has changed name to uview_direction!
2425     # *sigh*
2426     if test "$have_gle3" = yes ; then
2427       AC_CHECK_X_LIB(gle, uview_direction, 
2428                      [have_gle=yes; gle_halfassed=no],
2429                     [], $GL_LIBS -lX11 -lXext -lm)
2430     fi
2431     # if it wasn't in libgle, then look in libmatrix.
2432     if test "$have_gle" = no ; then
2433       AC_CHECK_X_LIB(matrix, uview_direction_d, 
2434                      [have_gle=yes; gle_halfassed=no;
2435                       GLE_LIBS="$GLE_LIBS -lmatrix"],
2436                     [], $GL_LIBS -lX11 -lXext -lm)
2437     fi
2438   fi
2439
2440   if test "$have_gle" = yes ; then
2441     AC_DEFINE(HAVE_GLE)
2442     if test "$have_gle3" = yes ; then
2443       AC_DEFINE(HAVE_GLE3)
2444     fi
2445   fi
2446
2447 elif test "$with_gle" != no; then
2448   echo "error: must be yes or no: --with-gle=$with_gle"
2449   exit 1
2450
2451 fi
2452
2453
2454
2455 ###############################################################################
2456 #
2457 #       Check for -lXpm.
2458 #
2459 ###############################################################################
2460
2461 have_xpm=no
2462 with_xpm_req=unspecified
2463 AC_ARG_WITH(xpm,
2464 [  --with-xpm              Include support for XPM files in some demos.],
2465   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
2466
2467 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
2468
2469 if test "$with_xpm" = yes; then
2470   AC_CHECK_X_HEADER(X11/xpm.h,
2471                    [have_xpm=yes
2472                     AC_DEFINE(HAVE_XPM)
2473                     XPM_LIBS="-lXpm"])
2474 elif test "$with_xpm" != no; then
2475   echo "error: must be yes or no: --with-xpm=$with_xpm"
2476   exit 1
2477 fi
2478
2479 # See comment near $motif_requires_xpm, above.
2480 # Need to do this here, after both Motif and XPM have been checked for.
2481 #
2482 if test "$have_motif" = yes -a "$have_xpm" = yes ; then
2483   if test "$motif_requires_xpm" = yes ; then
2484     MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
2485   fi
2486 fi
2487
2488
2489 ###############################################################################
2490 #
2491 #       Check for -lgdk_pixbuf.
2492 #
2493 ###############################################################################
2494
2495 have_gdk_pixbuf=no
2496 with_gdk_pixbuf_req=unspecified
2497 AC_ARG_WITH(pixbuf,
2498 [  --with-pixbuf           Include support for the GDK-Pixbuf library in some
2499                           demos, which will make it possible for them to read
2500                           GIF, JPEG, and PNG files as well.],
2501   [with_gdk_pixbuf="$withval"; with_gdk_pixbuf_req="$withval"],
2502   [with_gdk_pixbuf=yes])
2503
2504 # if --with-pixbuf=/directory/ was specified, remember that directory so that
2505 # we can also look for the `gdk-pixbuf-config' program in that directory.
2506 case "$with_gdk_pixbuf" in
2507   /*)
2508     gdk_pixbuf_dir="$with_gdk_pixbuf"
2509     ;;
2510   *)
2511     gdk_pixbuf_dir=""
2512     ;;
2513 esac
2514
2515 HANDLE_X_PATH_ARG(with_gdk_pixbuf, --with-pixbuf, GDK_PIXBUF)
2516
2517 if test "$with_gdk_pixbuf" != yes -a "$with_gdk_pixbuf" != no ; then
2518   echo "error: must be yes or no: --with-pixbuf=$with_gdk_pixbuf"
2519   exit 1
2520 fi
2521
2522 if test "$with_gdk_pixbuf" = yes; then
2523   have_gdk_pixbuf=no
2524
2525   # if the user specified --with-gtk=/foo/ or --with-gnome=/foo/ then
2526   # look in /foo/bin/ for for gdk-pixbuf-config.
2527   #
2528   gdk_pixbuf_path="$PATH"
2529
2530   if test ! -z "$gtk_dir"; then
2531     # canonicalize slashes.
2532     foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
2533     gdk_pixbuf_path="$foo:$gdk_pixbuf_path"
2534   fi
2535
2536   if test ! -z "$gnome_dir"; then
2537     # canonicalize slashes.
2538     foo=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
2539     gdk_pixbuf_path="$foo:$gdk_pixbuf_path"
2540   fi
2541
2542   AC_PATH_PROGS(gdk_pixbuf_config, gdk-pixbuf-config,, $gdk_pixbuf_path)
2543
2544   # If we found the gdk-pixbuf-config program, run it to get flags.
2545   #
2546   if test -n "$gdk_pixbuf_config" ; then
2547     AC_CACHE_CHECK([for gdk-pixbuf includes], ac_cv_gdk_pixbuf_config_cflags,
2548                [ac_cv_gdk_pixbuf_config_cflags=`$gdk_pixbuf_config --cflags`])
2549     AC_CACHE_CHECK([for gdk-pixbuf libs], ac_cv_gdk_pixbuf_config_libs,
2550                [ac_cv_gdk_pixbuf_config_libs=`$gdk_pixbuf_config --libs`])
2551     ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
2552     ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
2553   fi
2554
2555   ac_save_gdk_pixbuf_CPPFLAGS="$CPPFLAGS"
2556   CPPFLAGS="$CPPFLAGS $ac_gdk_pixbuf_config_cflags"
2557
2558   # check for header 1...
2559   AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf.h, [have_gdk_pixbuf=yes])
2560
2561   # if that worked, check for header 2...
2562   if test "$have_gdk_pixbuf" = yes; then
2563     have_gdk_pixbuf=no
2564     AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf-xlib.h, [have_gdk_pixbuf=yes])
2565   fi
2566
2567   CPPFLAGS="$ac_save_gdk_pixbuf_CPPFLAGS"
2568
2569   if test "$have_gdk_pixbuf" = yes; then
2570     # we have the headers, now check for the libraries
2571     have_gdk_pixbuf=no
2572     gdk_pixbuf_halfassed=yes
2573     # library 1...
2574     AC_CHECK_X_LIB(gdk_pixbuf, gdk_pixbuf_new_from_file,
2575                    [have_gdk_pixbuf=yes], [true],
2576                    $ac_gdk_pixbuf_config_libs)
2577     # library 2...
2578     if test "$have_gdk_pixbuf" = yes; then
2579       AC_CHECK_X_LIB(gdk_pixbuf_xlib, gdk_pixbuf_xlib_init,
2580                      [have_gdk_pixbuf=yes
2581                       gdk_pixbuf_halfassed=no],
2582                      [true],
2583                      $ac_gdk_pixbuf_config_libs)
2584     fi
2585   fi
2586
2587   if test "$have_gdk_pixbuf" = yes; then
2588     INCLUDES="$INCLUDES $ac_gdk_pixbuf_config_cflags"
2589     XPM_LIBS="$ac_gdk_pixbuf_config_libs -lgdk_pixbuf -lgdk_pixbuf_xlib"
2590     AC_DEFINE(HAVE_GDK_PIXBUF)
2591   fi
2592 fi
2593
2594
2595 ###############################################################################
2596 #
2597 #       Check for -ljpeg
2598 #
2599 ###############################################################################
2600
2601 have_jpeg=no
2602 with_jpeg_req=unspecified
2603 jpeg_halfassed=no
2604 AC_ARG_WITH(jpeg,
2605 [  --with-jpeg             Include support for the JPEG library in some demos,
2606                           which will make it possible for them to read JPEG
2607                           files as well.],
2608   [with_jpeg="$withval"; with_jpeg_req="$withval"],
2609   [with_jpeg=yes])
2610
2611 HANDLE_X_PATH_ARG(with_jpeg, --with-jpeg, JPEG)
2612
2613 if test "$with_jpeg" != yes -a "$with_jpeg" != no ; then
2614   echo "error: must be yes or no: --with-jpeg=$with_jpeg"
2615   exit 1
2616 fi
2617
2618 if test "$with_jpeg" = yes; then
2619
2620   have_jpeg=no
2621   AC_CHECK_X_HEADER(jpeglib.h, [have_jpeg=yes])
2622
2623   if test "$have_jpeg" = yes; then
2624     # we have the header, now check for the library
2625     have_jpeg=no
2626     jpeg_halfassed=yes
2627     AC_CHECK_X_LIB(jpeg, jpeg_start_compress,
2628                    [have_jpeg=yes
2629                     jpeg_halfassed=no
2630                     JPEG_LIBS="-ljpeg"
2631                     AC_DEFINE(HAVE_JPEGLIB)])
2632   fi
2633 fi
2634
2635
2636 ###############################################################################
2637 #
2638 #       Check for the XSHM server extension.
2639 #
2640 ###############################################################################
2641
2642 have_xshm=no
2643 with_xshm_req=unspecified
2644 AC_ARG_WITH(xshm-ext,
2645 [  --with-xshm-ext         Include support for the Shared Memory extension.],
2646   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
2647
2648 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
2649
2650 if test "$with_xshm" = yes; then
2651
2652   # first check for Xshm.h.
2653   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes])
2654
2655   # if that succeeded, then check for sys/ipc.h.
2656   if test "$have_xshm" = yes; then
2657     have_xshm=no
2658     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
2659   fi
2660
2661   # if that succeeded, then check for sys/shm.h.
2662   if test "$have_xshm" = yes; then
2663     have_xshm=no
2664     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
2665   fi
2666
2667   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
2668   # to exist, but the library code to not exist.  And even better, the library
2669   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
2670   # lib doesn't exist, give up.  (This lib gets added to X_EXTRA_LIBS, and
2671   # that's not quite right, but close enough.)
2672   #
2673   case "$host" in
2674     *-aix*)
2675       if [ `uname -v` -eq 3 ]; then
2676         have_xshm=no
2677         AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
2678                        [have_xshm=yes; X_EXTRA_LIBS="$X_EXTRA_LIBS -lXextSam"],
2679                        [true], -lX11 -lXext -lm)
2680       fi
2681     ;;
2682   esac
2683
2684   # if that succeeded, then we've really got it.
2685   if test "$have_xshm" = yes; then
2686     AC_DEFINE(HAVE_XSHM_EXTENSION)
2687   fi
2688
2689 elif test "$with_xshm" != no; then
2690   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
2691   exit 1
2692 fi
2693
2694
2695 ###############################################################################
2696 #
2697 #       Check for the DOUBLE-BUFFER server extension.
2698 #
2699 ###############################################################################
2700
2701 have_xdbe=no
2702 with_xdbe_req=unspecified
2703 AC_ARG_WITH(xdbe-ext,
2704 [  --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension.],
2705   [with_xdbe="$withval"; with_xdbe_req="$withval"],[with_xdbe=yes])
2706
2707 HANDLE_X_PATH_ARG(with_xdbe, --with-xdbe-ext, DOUBLE-BUFFER)
2708
2709 if test "$with_xdbe" = yes; then
2710
2711   AC_CHECK_X_HEADER(X11/extensions/Xdbe.h, [have_xdbe=yes])
2712   if test "$have_xdbe" = yes; then
2713     AC_DEFINE(HAVE_DOUBLE_BUFFER_EXTENSION)    
2714   fi
2715
2716 elif test "$with_xdbe" != no; then
2717   echo "error: must be yes or no: --with-xdbe-ext=$with_xshm"
2718   exit 1
2719 fi
2720
2721
2722 ###############################################################################
2723 #
2724 #       Check for the SGI XReadDisplay server extension.
2725 #
2726 #       Note: this has to be down here, rather than up with the other server
2727 #       extension tests, so that the output of `configure --help' is in the
2728 #       right order.  Arrgh!
2729 #
2730 ###############################################################################
2731
2732 have_readdisplay=no
2733 with_readdisplay_req=unspecified
2734 AC_ARG_WITH(readdisplay,
2735 [  --with-readdisplay      Include support for the XReadDisplay extension.],
2736   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
2737   [with_readdisplay=yes])
2738
2739 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
2740
2741 if test "$with_readdisplay" = yes; then
2742   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
2743                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
2744 elif test "$with_readdisplay" != no; then
2745   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
2746   exit 1
2747 fi
2748
2749
2750 ###############################################################################
2751 #
2752 #       Check for a program to generate random text.
2753 #
2754 #       Zippy is funnier than the idiocy generally spat out by `fortune',
2755 #       so first see if "fortune zippy" works.  Else, use plain "fortune".
2756 #
2757 #       We used to dig around in Emacs to look for the "yow" program, but
2758 #       most people who have Emacs also have "fortune zippy", so nevermind.
2759 #
2760 ###############################################################################
2761
2762 with_fortune_req=""
2763 AC_ARG_WITH(fortune,[
2764   --with-fortune=PROGRAM  Some demos are able to run an external program and
2765                           display its text; this names the program to use by
2766                           default (though it can be overridden with X
2767                           resources.)  Default is \"/usr/games/fortune\".],
2768   [with_fortune_req="$withval"; with_fortune="$withval"],[with_fortune=yes])
2769
2770 if test "$with_fortune" = no || test "$with_fortune" = yes ; then
2771   with_fortune=""
2772   with_fortune_req=""
2773 fi
2774
2775 if test -n "$with_fortune_req" ; then
2776   ac_cv_fortune_program=""
2777   case "$with_fortune_req" in
2778     /*)
2779
2780       set dummy $with_fortune_req ; fortune_tmp=$2
2781       AC_MSG_CHECKING([for $fortune_tmp])
2782       if test -x "$fortune_tmp" ; then
2783         AC_MSG_RESULT(yes)
2784       else
2785         AC_MSG_RESULT(no)
2786         with_fortune=""
2787       fi
2788     ;;
2789     *)
2790       set dummy $with_fortune_req ; fortune_tmp=$2
2791       # don't cache
2792       unset ac_cv_path_fortune_tmp
2793       AC_PATH_PROG(fortune_tmp, $fortune_tmp, [])
2794       if test -z "$fortune_tmp" ; then
2795         with_fortune=""
2796       fi
2797     ;;
2798   esac
2799   ac_cv_fortune_program="$with_fortune"
2800
2801 elif test -n "$ac_cv_fortune_program"; then
2802   AC_MSG_RESULT([checking for fortune... (cached) $ac_cv_fortune_program])
2803 fi
2804
2805 unset ac_cv_path_fortune_tmp
2806 unset fortune_tmp
2807
2808 if test -z "$ac_cv_fortune_program" ; then
2809
2810   # first look for fortune in /usr/games/ (and use absolute path)
2811   AC_PATH_PROGS(fortune_tmp, fortune,, "/usr/games")
2812
2813   # if it's not there, look on $PATH (and don't use absolute path)
2814   if test -z "$fortune_tmp" ; then
2815      AC_CHECK_PROGS(fortune_tmp, fortune)
2816   fi
2817
2818   # if we didn't find anything, then just assume /usr/games/
2819   if test -z "$fortune_tmp" ; then
2820      fortune_tmp="/usr/games/fortune"
2821   fi
2822
2823   ac_cv_fortune_program="$fortune_tmp"
2824
2825   # now check to see whether "fortune zippy" works.
2826   #
2827   fortune_tmp="$fortune_tmp zippy"
2828   AC_MSG_CHECKING([for zippy quotes])
2829   if ( $fortune_tmp >/dev/null 2>&1 ); then
2830     ac_cv_fortune_program="$fortune_tmp"
2831     AC_MSG_RESULT($fortune_tmp)
2832   else
2833     AC_MSG_RESULT(no)
2834   fi
2835
2836 fi
2837
2838 unset ac_cv_path_fortune_tmp
2839 unset fortune_tmp
2840
2841 AC_DEFINE_UNQUOTED(FORTUNE_PROGRAM, "$ac_cv_fortune_program")
2842
2843
2844 ###############################################################################
2845 #
2846 #       Check whether it's ok to install some hacks as setuid (e.g., "sonar")
2847 #       This should be safe, but let's give people the option.
2848 #
2849 ###############################################################################
2850
2851 setuid_hacks_default=no
2852 setuid_hacks="$setuid_hacks_default"
2853 AC_ARG_WITH(setuid-hacks,
2854 [  --with-setuid-hacks     Allow some demos to be installed \`setuid root'
2855                           (which is needed in order to ping other hosts.)
2856 ],
2857   [setuid_hacks="$withval"], [setuid_hacks="$setuid_hacks_default"])
2858
2859 HANDLE_X_PATH_ARG(setuid_hacks, --with-setuid-hacks, setuid hacks)
2860
2861 if test "$setuid_hacks" = yes; then
2862   true
2863 elif test "$setuid_hacks" != no; then
2864   echo "error: must be yes or no: --with-setuid-hacks=$setuid_hacks"
2865   exit 1
2866 fi
2867
2868
2869 ###############################################################################
2870 #
2871 #       Done testing.  Now, set up the various -I and -L variables,
2872 #       and decide which GUI program to build by default.
2873 #
2874 ###############################################################################
2875
2876 DEPEND=makedepend
2877 DEPEND_FLAGS=
2878 DEPEND_DEFINES=
2879
2880
2881 if test \! -z "$includedir" ; then 
2882   INCLUDES="$INCLUDES -I$includedir"
2883 fi
2884
2885 if test \! -z "$libdir" ; then
2886   LDFLAGS="$LDFLAGS -L$libdir"
2887 fi
2888
2889
2890 PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
2891 ALL_DEMO_PROGRAMS=
2892 if test "$have_motif" = yes; then
2893   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
2894   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2895 fi
2896 if test "$have_gtk" = yes; then
2897   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
2898   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2899 fi
2900
2901
2902 if test "$have_kerberos" = yes; then
2903   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
2904   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
2905 fi
2906 if test "$have_pam" = yes; then
2907   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
2908   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
2909   INSTALL_PAM="install-pam"
2910 fi
2911   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
2912   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
2913
2914
2915 if test "$enable_locking" = yes; then
2916   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
2917   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
2918 else
2919   LOCK_SRCS='$(NOLOCK_SRCS_1)'
2920   LOCK_OBJS='$(NOLOCK_OBJS_1)'
2921 fi
2922
2923 INSTALL_SETUID='$(INSTALL_PROGRAM) $(SUID_FLAGS)'
2924
2925 if test "$need_setuid" = yes; then
2926   NEED_SETUID=yes
2927 else
2928   NEED_SETUID=no
2929 fi
2930
2931 if test "$setuid_hacks" = yes; then
2932   SETUID_HACKS=yes
2933 else
2934   SETUID_HACKS=no
2935 fi
2936
2937 tab='   '
2938 if test "$have_gl" = yes; then
2939   GL_EXES='$(GL_EXES)'
2940   GL_UTIL_EXES='$(GL_UTIL_EXES)'
2941   GL_MEN='$(GL_MEN)'
2942   GL_KLUDGE="${tab}  "
2943 else
2944   GL_KLUDGE="-${tab}  "
2945 fi
2946
2947 if test "$have_gle" = yes; then
2948   GLE_EXES='$(GLE_EXES)'
2949   GLE_MEN='$(GLE_MEN)'
2950   GLE_KLUDGE="${tab}   "
2951 else
2952   GLE_KLUDGE="-${tab}   "
2953 fi
2954
2955 if test "$have_jpeg" = yes -a "$have_gdk_pixbuf" = yes; then
2956  JPEG_EXES='$(JPEG_EXES)'
2957 fi
2958
2959
2960 # Another substitution in the XScreenSaver.ad.in file:
2961 #
2962 if test "$have_gnome_help" = yes; then
2963   GNOMEHELP_Y=''
2964   GNOMEHELP_N='!    '
2965 else
2966   GNOMEHELP_Y='!    '
2967   GNOMEHELP_N=''
2968 fi
2969
2970
2971 # Now that we know whether we have Gnome, we can decide where the XML
2972 # config files get installed.
2973 #
2974 if test -z "$HACK_CONF_DIR" ; then
2975   if test -n "$GNOME_DATADIR" ; then
2976     HACK_CONF_DIR='${GNOME_DATADIR}/control-center/screensavers'
2977   else
2978     HACK_CONF_DIR='${prefix}/lib/xscreensaver/config'
2979   fi
2980 fi
2981
2982
2983
2984 # After computing $HACK_CONF_DIR, make sure $GTK_ICONDIR has a value
2985 # so that we know where to install the Gtk pixmaps.
2986 #
2987 if test -n "$GNOME_DATADIR" ; then
2988   GTK_ICONDIR='$(GNOME_DATADIR)/pixmaps'
2989 elif test "$have_gtk" = yes; then
2990   # should this be "$(prefix)/share/pixmaps"? But /usr/X11R6/share/ is wrong...
2991   GTK_ICONDIR='/usr/share/pixmaps'
2992 else
2993   GTK_ICONDIR=''
2994 fi
2995
2996
2997 # canonicalize slashes.
2998 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
2999
3000
3001
3002 ###############################################################################
3003 #
3004 #       Perform substitutions and write Makefiles.
3005 #
3006 ###############################################################################
3007
3008 AC_SUBST(INCLUDES)
3009
3010 AC_SUBST(PREFERRED_DEMO_PROGRAM)
3011 AC_SUBST(ALL_DEMO_PROGRAMS)
3012 AC_SUBST(SAVER_LIBS)
3013 AC_SUBST(MOTIF_LIBS)
3014 AC_SUBST(GTK_LIBS)
3015 AC_SUBST(XML_LIBS)
3016 AC_SUBST(JPEG_LIBS)
3017 AC_SUBST(HACK_LIBS)
3018 AC_SUBST(XPM_LIBS)
3019 AC_SUBST(GL_LIBS)
3020 AC_SUBST(GLE_LIBS)
3021 AC_SUBST(XDPMS_LIBS)
3022 AC_SUBST(PASSWD_LIBS)
3023 AC_SUBST(INSTALL_SETUID)
3024 AC_SUBST(SETUID_HACKS)
3025 AC_SUBST(INSTALL_DIRS)
3026 AC_SUBST(NEED_SETUID)
3027 AC_SUBST(INSTALL_PAM)
3028
3029 AC_SUBST(PASSWD_SRCS)
3030 AC_SUBST(PASSWD_OBJS)
3031 AC_SUBST(XMU_SRCS)
3032 AC_SUBST(XMU_OBJS)
3033 AC_SUBST(XMU_LIBS)
3034 AC_SUBST(SAVER_GL_SRCS)
3035 AC_SUBST(SAVER_GL_OBJS)
3036 AC_SUBST(SAVER_GL_LIBS)
3037 AC_SUBST(LOCK_SRCS)
3038 AC_SUBST(LOCK_OBJS)
3039 AC_SUBST(JPEG_EXES)
3040 AC_SUBST(GL_EXES)
3041 AC_SUBST(GL_UTIL_EXES)
3042 AC_SUBST(GL_MEN)
3043 AC_SUBST(GL_KLUDGE)
3044 AC_SUBST(GLE_EXES)
3045 AC_SUBST(GLE_MEN)
3046 AC_SUBST(GLE_KLUDGE)
3047 AC_SUBST(GNOMEHELP_Y)
3048 AC_SUBST(GNOMEHELP_N)
3049 AC_SUBST(HACKDIR)
3050 AC_SUBST(GNOME_DATADIR)
3051 AC_SUBST(GTK_ICONDIR)
3052 AC_SUBST(HACK_CONF_DIR)
3053
3054 APPDEFAULTS=$ac_x_app_defaults
3055 AC_SUBST(APPDEFAULTS)
3056
3057 AC_SUBST(DEPEND)
3058 AC_SUBST(DEPEND_FLAGS)
3059 AC_SUBST(DEPEND_DEFINES)
3060 AC_SUBST(PERL)
3061
3062 AC_OUTPUT(Makefile
3063           utils/Makefile
3064           driver/Makefile
3065           hacks/Makefile
3066           hacks/glx/Makefile
3067           driver/XScreenSaver.ad)
3068
3069 ###############################################################################
3070 #
3071 #       Print some warnings at the end.
3072 #
3073 ###############################################################################
3074
3075 warn_prefix_1="    Warning:"
3076 warn_prefix_2="       Note:"
3077 warn_prefix="$warn_prefix_1"
3078
3079 warning=no
3080 warnsep='    #################################################################'
3081
3082 warnpre() {
3083   if test "$warning" = no ; then
3084     echo '' ; echo "$warnsep" ; echo ''
3085     warning=yes
3086   fi
3087 }
3088
3089 warn() {
3090   warnpre
3091   if test "$warning" = long ; then echo '' ; fi
3092   warning=yes
3093   rest="$@"
3094   echo "$warn_prefix $rest"
3095 }
3096
3097 warnL() {
3098   was=$warning
3099   warnpre
3100   warning=yes
3101   if test "$was" != no ; then echo '' ; fi
3102   rest="$@"
3103   echo "$warn_prefix $rest"
3104 }
3105
3106 warn2() {
3107   rest="$@"
3108   echo "             $rest"
3109   warning=long
3110 }
3111
3112 note() {
3113   warn_prefix="$warn_prefix_2"
3114   warn $@
3115   warn_prefix="$warn_prefix_1"
3116 }
3117
3118 noteL() {
3119   warn_prefix="$warn_prefix_2"
3120   warnL $@
3121   warn_prefix="$warn_prefix_1"
3122 }
3123
3124
3125 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
3126   warn 'The SGI saver extension was requested, but was not found.'
3127 fi
3128
3129 if test "$with_mit_req" = yes -a "$have_mit" = no ; then
3130   warn 'The MIT saver extension was requested, but was not found.'
3131 fi
3132
3133 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
3134   warn 'The XIdle extension was requested, but was not found.'
3135 fi
3136
3137 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
3138   warn 'The XSHM extension was requested, but was not found.'
3139 fi
3140
3141 if test "$with_xdbe_req" = yes -a "$have_xdbe" = no ; then
3142   warn 'The DOUBLE-BUFFER extension was requested, but was not found.'
3143 fi
3144
3145 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
3146   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
3147 fi
3148
3149 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
3150   warn 'The DPMS extension was requested, but was not found.'
3151 fi
3152
3153 if test "$with_xinerama_req" = yes -a "$have_xinerama" = no ; then
3154   warn 'The Xinerama extension was requested, but was not found.'
3155 fi
3156
3157 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
3158   warn 'The XF86VMODE extension was requested, but was not found.'
3159 fi
3160
3161 if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
3162   warn "Checking of /proc/interrupts was requested, but it's bogus."
3163 fi
3164
3165
3166 if test "$have_motif" = no -a "$have_gtk" = no; then
3167   warnL "Neither Motif nor Gtk seem to be available;"
3168   warn2 "the \`xscreensaver-demo' program requires one of these."
3169
3170 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
3171   warnL "Use of Motif was requested, but it wasn't found;"
3172   warn2 "Gtk will be used instead."
3173
3174 elif test "$jurassic_gtk" = yes ; then
3175
3176   pref_gtk=1.2
3177
3178   v="$ac_gtk_version_string"
3179   if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
3180     warnL "Use of Gtk was requested, but its version number is unknown;"
3181   elif test "$with_gtk_req" = yes ; then
3182     warnL "Use of Gtk was requested, but it is version $v;"
3183   else
3184     warnL "Gtk was found on this system, but it is version $v;"
3185   fi
3186
3187   warn2 "Gtk $pref_gtk or newer is required.  Motif will be used instead."
3188
3189 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
3190   warnL "Use of Gtk was requested, but it wasn't found;"
3191   warn2 "Motif will be used instead."
3192
3193 fi
3194
3195
3196 if test "$with_gnome_req" = yes -a "$have_gnome" = no ; then
3197   warn  'Use of the Gnome Control Panel was requested, but the necessary'
3198   warn2 'headers and/or libraries were not found.'
3199 fi
3200
3201 if test "$have_gtk" = yes ; then
3202   if test "$have_xml" = no ; then
3203     if test "$with_xml_req" = yes ; then
3204       warn  'Use of the XML library was requested, but the necessary'
3205       warn2 'headers and/or libraries were not found.'
3206     else
3207       warn  'GTK is being used, but the XML library was not found.'
3208     fi
3209
3210     if test "$xml_halfassed" = yes ; then
3211       echo ''
3212       warn2 'More specifically, we found the headers, but not the'
3213       warn2 'libraries; so either XML is half-installed on this'
3214       warn2 "system, or something else went wrong.  The \`config.log'"
3215       warn2 'file might contain some clues.'
3216     fi
3217
3218     echo ''
3219     warn2 "Without XML, the per-display-mode \`Settings' dialogs"
3220     warn2 'will not be available.  Specify the location of the XML'
3221     warn2 'library through the --with-xml option to configure.'
3222   fi
3223 fi
3224
3225 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
3226
3227   preferred_lesstif=0.92
3228
3229   if test "$lesstif_version" = unknown; then
3230     warnL "Unable to determine the LessTif version number!"
3231     warn2 "Make sure you are using version $preferred_lesstif or newer."
3232     warn2 "See <http://www.lesstif.org/>."
3233
3234   elif test \! $lesstif_version -gt 82; then
3235     warnL "LessTif version $lesstif_version_string is being used."
3236     warn2 "LessTif versions 0.82 and earlier are too buggy to"
3237     warn2 "use with XScreenSaver; it is strongly recommended"
3238     warn2 "that you upgrade to at least version $preferred_lesstif!"
3239     warn2 "See <http://www.lesstif.org/>."
3240   fi
3241 fi
3242
3243
3244 if test "$have_motif" = yes -a "$have_gtk" = no ; then
3245   warn  'Motif is being used, and GTK is not.'
3246   echo  ''
3247   warn2 'Though the Motif front-end to xscreensaver is still'
3248   warn2 'maintained, it is no longer being updated with new'
3249   warn2 'features: all new development on the xscreensaver-demo'
3250   warn2 'program is happening in the GTK version, and not in the'
3251   warn2 'Motif version.  It is recommended that you build against'
3252   warn2 'GTK instead of Motif.  See <http://www.gtk.org/>.'
3253 fi
3254
3255
3256 if test "$with_xpm_req" = yes -a "$have_xpm" = no; then
3257   warnL 'Use of XPM was requested, but it was not found.'
3258 fi
3259
3260 if test "$with_gdk_pixbuf_req" = yes  -a "$have_gdk_pixbuf" = no; then
3261   warnL 'Use of GDK-Pixbuf was requested, but it was not found.'
3262 fi
3263
3264 if test "$have_xpm" = no -a "$have_gdk_pixbuf" = no; then
3265
3266   if test "$with_xpm_req" = yes ; then
3267     true
3268   elif test "$with_xpm_req" = no ; then
3269     warnL 'The XPM library is not being used.'
3270   else
3271     warnL 'The XPM library was not found.'
3272   fi
3273
3274   if test "$with_gdk_pixbuf_req" = yes ; then
3275     true
3276   elif test "$with_gdk_pixbuf_req" = no ; then
3277     warnL 'The GDK-Pixbuf library is not being used.'
3278   else
3279     warnL 'The GDK-Pixbuf library was not found.'
3280   fi
3281
3282   if test "$gdk_pixbuf_halfassed" = yes ; then
3283     echo ''
3284     warn2 'More specifically, we found the headers, but not the'
3285     warn2 'libraries; so either GDK-Pixbuf is half-installed on this'
3286     warn2 "system, or something else went wrong.  The \`config.log'"
3287     warn2 'file might contain some clues.'
3288   fi
3289
3290   echo ''
3291   warn2 'Some of the demos will not be as colorful as they'
3292   warn2 'could be.  You should consider installing Pixbuf or'
3293   warn2 'XPM and re-running configure.  (Remember to delete'
3294   warn2 'the config.cache file first.)  The Pixbuf library is'
3295   warn2 'a part of GNOME.  The XPM library comes with most'
3296   warn2 'X11 installations; you can also find it at the X11'
3297   warn2 'archive sites, such as <http://sunsite.unc.edu/>.'
3298   echo  ''
3299   warn2 'GDK-Pixbuf is recommended over XPM, as it provides'
3300   warn2 'support for more image formats.'
3301 fi
3302
3303
3304 if test "$have_jpeg" = no ; then
3305   if test "$with_jpeg_req" = yes ; then
3306     warnL 'Use of libjpeg was requested, but it was not found.'
3307   elif test "$with_jpeg_req" = no ; then
3308     noteL 'The JPEG library is not being used.'
3309   else
3310     noteL 'The JPEG library was not found.'
3311   fi
3312
3313   if test "$jpeg_halfassed" = yes ; then
3314     echo ''
3315     warn2 'More specifically, we found the headers, but not the'
3316     warn2 'library; so either JPEG is half-installed on this'
3317     warn2 "system, or something else went wrong.  The \`config.log'"
3318     warn2 'file might contain some clues.'
3319     echo ''
3320   fi
3321
3322   warn2 "This means the \`webcollage' program will be much slower."
3323 fi
3324
3325
3326 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
3327   preferred_mesagl=3.4
3328   mgv="$ac_mesagl_version_string"
3329   pgl="$preferred_mesagl"
3330
3331   if test "$ac_mesagl_version" = unknown; then
3332     warnL "Unable to determine the MesaGL version number!"
3333     warn2 "Make sure you are using version $preferred_mesagl or newer."
3334
3335   elif test \! "$ac_mesagl_version" -gt 2006; then
3336     warnL "MesaGL version $mgv is being used.  MesaGL 2.6 and earlier"
3337     warn2 "have a security bug.  It is strongly recommended that you"
3338     warn2 "upgrade to at least version $preferred_mesagl."
3339
3340   elif test \! "$ac_mesagl_version" -gt 3003; then
3341     warnL "MesaGL version $mgv is being used.  That version has some"
3342     warn2 "bugs; it is recommended that you upgrade to $pgl or newer."
3343   fi
3344 fi
3345
3346 if test "$have_gl" = no ; then
3347   if test "$with_gl_req" = yes ; then
3348     warnL 'Use of GL was requested, but it was not found.'
3349   elif test "$with_gl_req" = no ; then
3350     noteL 'The OpenGL 3D library is not being used.'
3351   else
3352     noteL 'The OpenGL 3D library was not found.'
3353   fi
3354
3355   if test "$gl_halfassed" = yes ; then
3356     echo ''
3357     warn2 'More specifically, we found the headers, but not the'
3358     warn2 'libraries; so either GL is half-installed on this'
3359     warn2 "system, or something else went wrong.  The \`config.log'"
3360     warn2 'file might contain some clues.'
3361   fi
3362
3363   echo ''
3364   warn2 'Those demos which use 3D will not be built or installed.'
3365   warn2 'You might want to consider installing OpenGL and'
3366   warn2 're-running configure.  (Remember to delete the'
3367   warn2 "config.cache file first.)  If your vendor doesn't ship"
3368   warn2 'their own implementation of OpenGL, you can get a free'
3369   warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
3370   warn2 'info, see <http://www.opengl.org/>.'
3371
3372 fi
3373
3374
3375 if test "$have_gl" = yes -a "$have_gle" = no ; then
3376   if test "$with_gle_req" = yes ; then
3377     noteL 'Use of the GLE (GL Extrusion) library was requested, but'
3378     warn2 'it was not found (though the OpenGL library was found, and'
3379     warn2 'is being used.)'
3380   elif test "$with_gle_req" = no ; then
3381     noteL 'The OpenGL Library is being used, but the GLE (GL Extrusion)'
3382     warn2 'library is not.'
3383   else
3384     noteL 'The OpenGL Library was found, but the GLE (GL Extrusion)'
3385     warn2 'was not.'
3386   fi
3387
3388   if test "$gle_halfassed" = yes ; then
3389     echo ''
3390     warn2 'More specifically, we found the headers, but not the'
3391     warn2 'libraries; so either GLE is half-installed on this'
3392     warn2 "system, or something else went wrong.  The \`config.log'"
3393     warn2 'file might contain some clues.'
3394   fi
3395
3396   echo ''
3397   warn2 'Some of the OpenGL (3D) demos (those that depend on GLE)'
3398   warn2 'will not be built or installed.  You might want to consider'
3399   warn2 'installing GLE and re-running configure.  (Remember to delete'
3400   warn2 'the config.cache file first.)  You can find the GLE library'
3401   warn2 'at <http://www.linas.org/gle/>.  For general OpenGL info,'
3402   warn2 'see <http://www.opengl.org/>.'
3403
3404 fi
3405
3406
3407 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
3408   warn 'Use of XReadDisplay was requested, but it was not found.'
3409 fi
3410
3411 if test -n "$with_fortune_req"; then
3412   if test "$with_fortune_req" != "$ac_cv_fortune_program" ; then
3413     warnL "$with_fortune_req was requested as the Fortune program,"
3414     warn2 "but was not found.  The default will be used instead."
3415   fi
3416 fi
3417
3418 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
3419   warn 'Use of Kerberos was requested, but it was not found.'
3420 fi
3421
3422 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
3423   warn 'Use of PAM was requested, but it was not found.'
3424 fi
3425
3426 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
3427   warn 'Use of shadow passwords was requested, but they were not found.'
3428 fi
3429
3430
3431 # You are in a twisty maze of namespaces and syntaxes, all alike.
3432 # Fuck the skull of Unix.
3433 #
3434 eval bindir=${bindir}
3435 eval bindir=${bindir}
3436 eval bindir=${bindir}
3437 eval bindir=${bindir}
3438 eval bindir=${bindir}
3439 eval bindir=${bindir}
3440 eval HACKDIR=${HACKDIR}
3441 eval HACKDIR=${HACKDIR}
3442 eval HACKDIR=${HACKDIR}
3443 eval HACKDIR=${HACKDIR}
3444 eval HACKDIR=${HACKDIR}
3445 eval HACKDIR=${HACKDIR}
3446 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3447 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3448 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3449 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3450 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3451 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3452
3453 # canonicalize slashes.
3454 bindir=`echo  "${bindir}"              | sed 's@/$@@;s@//*@/@g'`
3455 HACKDIR=`echo "${HACKDIR}"             | sed 's@/$@@;s@//*@/@g'`
3456 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
3457
3458
3459 # Sanity check the hackdir
3460 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
3461   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
3462     echo ""
3463     AC_MSG_ERROR([\"--with-hackdir=${bindir}/${bad_choice}\" won't work.
3464                    There will be an executable installed with that name, so
3465                    that can't be the name of a directory as well.  Please
3466                    re-configure with a different directory name.])
3467   fi
3468 done
3469
3470
3471 do_dir_warning=no
3472
3473 # Now let's see if there's a previous RPM version already installed.  Blargh!
3474
3475 # M4 sucks!!
3476 changequote(X,Y)
3477 rpmv=`(rpm -qv xscreensaver) 2>&- | \
3478       sed -n 's/^xscreensaver-\([0-9][0-9]*[.][0-9][0-9]*\)-.*$/\1/p'`
3479 changequote([,])
3480
3481 if test \! -z "$rpmv" ; then
3482   rpmbdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/xscreensaver-demo$@\1@p'`
3483   rpmhdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/attraction$@\1@p'`
3484
3485   warning=no
3486   warnL "There is already an installed RPM of xscreensaver $rpmv"
3487   warn2 "on this system.  You might want to remove it (with"
3488   warn2 '"rpm -ve xscreensaver") before running "make install"'
3489   warn2 "from this directory."
3490   echo ""
3491   warn2 "Alternately, you could build this version of xscreensaver"
3492   warn2 'as an RPM, and then install that.  An "xscreensaver.spec"'
3493   warn2 "file is included.  See the RPM documentation for more info."
3494   echo ""
3495
3496   if test "$rpmbdir" = "$rpmhdir" ; then
3497     warn2 "The RPM version was installed in $rpmbdir/."
3498   else
3499     warn2 "The RPM version was installed in $rpmbdir/,"
3500     warn2 "with demos in $rpmhdir/."
3501   fi
3502
3503   do_dir_warning=yes
3504 fi
3505
3506
3507 if test "${bindir}" = "${HACKDIR}" ; then
3508   do_dir_warning=yes
3509 fi
3510
3511 if test "$do_dir_warning" = yes; then
3512   echo ""
3513   echo "$warnsep"
3514   echo ""
3515   echo '      When you run "make install", the "xscreensaver",'
3516   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
3517   echo "      will be installed in ${bindir}/."
3518   echo ""
3519   echo "      The various graphics demos (140+ different executables) will"
3520   echo "      be installed in ${HACKDIR}/."
3521   echo ""
3522   echo "      If you would prefer the demos to be installed elsewhere,"
3523   echo "      you should re-run configure with the --with-hackdir=DIR"
3524   echo "      option.  For more information, run \`./configure --help'."
3525   warning=yes
3526 fi
3527
3528 if test "$warning" != no; then
3529   echo '' ; echo "$warnsep" ; echo ''
3530 fi
3531
3532 if test "$do_dir_warning" = no; then
3533   if test "$warning" = no; then
3534     echo ''
3535   fi
3536   echo "User programs will be installed in ${bindir}/"
3537   echo "Screen savers will be installed in ${HACKDIR}/"
3538   echo "Configuration will be installed in ${HACK_CONF_DIR}/"
3539   echo ''
3540 fi