http://ftp.x.org/contrib/applications/xscreensaver-3.18.tar.gz
[xscreensaver] / configure.in
1 # configure.in --- xscreensaver, Copyright (c) 1997 Jamie Zawinski.
2 #
3
4 AC_INIT(driver/subprocs.c)
5 AC_CONFIG_HEADER(config.h)
6
7 echo "current directory: `pwd`"
8 echo "command line was: $0 $@"
9
10
11 # After checking to see that --srcdir is correct (which AC_INIT does)
12 # check for some random other files that come later in the tar file,
13 # to make sure everything is here.
14 #
15 for d in driver utils hacks hacks/glx ; do
16   f=$srcdir/$d/Makefile.in
17   if test \! -r $f ; then
18     echo ""
19     echo "ERROR: The package is incomplete: $f does not exist."
20     echo "       This probably means that your download was truncated."
21     echo ""
22     exit 1
23   fi
24 done
25
26
27 ###############################################################################
28 #
29 #       Function to figure out how to run the compiler.
30 #
31 ###############################################################################
32
33 AC_DEFUN(AC_PROG_CC_ANSI,
34  [AC_PROG_CC
35
36   if test -z "$GCC"; then
37     AC_MSG_CHECKING(how to request ANSI compilation)
38     case "$host" in
39       *-hpux* )
40         AC_MSG_RESULT(HPUX: adding -Ae)
41         CC="$CC -Ae"
42       ;;
43       *-aix* )
44         AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
45         CC="$CC -qlanglvl=ansi -qhalt=e"
46       ;;
47
48       *-dec-* )
49         AC_MSG_RESULT(DEC: adding -std1)
50         CC="$CC -std1"
51       ;;
52
53       *)
54         AC_MSG_RESULT(no idea)
55       ;;
56     esac
57   fi
58
59   AC_MSG_CHECKING([whether the compiler works on ANSI C])
60   AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
61      AC_MSG_RESULT(yes),
62      AC_MSG_RESULT(no)
63      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
64      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
65
66   if test -n "$GCC"; then
67     AC_MSG_RESULT(Turning on gcc compiler warnings.)
68     CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
69   else
70     case "$host" in
71       *-irix5* |*-irix6.[0-3]* )
72         AC_MSG_RESULT(Turning on SGI compiler warnings.)
73         CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
74       ;;
75 #     *-dec-osf* )
76 #       if test -z "$GCC"; then
77 #         AC_MSG_RESULT(Turning on DEC C compiler warnings.)
78 #         CC="$CC -migrate -w0 -verbose -warnprotos"
79 #       fi
80 #     ;;
81     esac
82   fi
83 ])
84
85
86 ###############################################################################
87 #
88 #       Function to figure out how to create directory trees.
89 #
90 ###############################################################################
91
92 AC_DEFUN(AC_PROG_INSTALL_DIRS,
93  [AC_CACHE_CHECK([whether \"\${INSTALL} -d\" creates intermediate directories],
94     ac_cv_install_d_creates_dirs,
95     [ac_cv_install_d_creates_dirs=no
96      rm -rf conftestdir
97      if mkdir conftestdir; then
98        cd conftestdir >&-
99        ${INSTALL} -d `pwd`/dir1/dir2 >&- 2>&-
100        if test -d dir1/dir2/. ; then
101          ac_cv_install_d_creates_dirs=yes
102        fi
103        cd .. >&-
104        rm -rf conftestdir
105      fi
106     ])
107
108   if test "$ac_cv_install_d_creates_dirs" = no ; then
109     AC_CACHE_CHECK([whether \"mkdir -p\" creates intermediate directories],
110       ac_cv_mkdir_p_creates_dirs,
111       [ac_cv_mkdir_p_creates_dirs=no
112        rm -rf conftestdir
113        if mkdir conftestdir; then
114          cd conftestdir >&-
115          mkdir -p dir1/dir2 >&- 2>&-
116          if test -d dir1/dir2/. ; then
117            ac_cv_mkdir_p_creates_dirs=yes
118          fi
119          cd .. >&-
120          rm -rf conftestdir
121        fi
122       ])
123   fi
124
125   if test "$ac_cv_install_d_creates_dirs" = yes ; then
126     INSTALL_DIRS='${INSTALL} -d'
127   elif test "$ac_cv_mkdir_p_creates_dirs" = yes ; then
128     INSTALL_DIRS='mkdir -p'
129   else
130     # any other ideas?
131     INSTALL_DIRS='${INSTALL} -d'
132   fi
133 ])
134
135
136 ###############################################################################
137 #
138 #       Function to check whether gettimeofday() exists, and how to call it.
139 #       This may define HAVE_GETTIMEOFDAY and GETTIMEOFDAY_TWO_ARGS.
140 #
141 ###############################################################################
142
143 AC_DEFUN(AC_GETTIMEOFDAY_ARGS,
144  [AC_MSG_CHECKING(how to call gettimeofday)
145   AC_CACHE_VAL(ac_cv_gettimeofday_args,
146    [AC_TRY_COMPILE([#include <stdlib.h>
147                     #include <sys/time.h>],
148                    [struct timeval tv; struct timezone tzp;
149                     gettimeofday(&tv, &tzp);],
150                    [ac_gettimeofday_args=2],
151                    [AC_TRY_COMPILE([#include <stdlib.h>
152                                     #include <sys/time.h>],
153                                    [struct timeval tv; gettimeofday(&tv);],
154                                    [ac_gettimeofday_args=1],
155                                    [ac_gettimeofday_args=0])])
156     ac_cv_gettimeofday_args=$ac_gettimeofday_args])
157   ac_gettimeofday_args=$ac_cv_gettimeofday_args
158   if test "$ac_gettimeofday_args" = 1 ; then
159     AC_DEFINE(HAVE_GETTIMEOFDAY)
160     AC_MSG_RESULT(one argument)
161   elif test "$ac_gettimeofday_args" = 2 ; then
162     AC_DEFINE(HAVE_GETTIMEOFDAY)
163     AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
164     AC_MSG_RESULT(two arguments)
165   else
166     AC_MSG_RESULT(unknown)
167   fi
168 ])
169
170
171 ###############################################################################
172 #
173 #       Function to find perl5 (defines PERL and PERL_VERSION.)
174 #
175 ###############################################################################
176
177 # M4 sucks!!  perl sucks too!!
178 changequote(X,Y)
179 perl_version_cmd='print $]'
180 changequote([,])
181
182 AC_DEFUN(AC_PROG_PERL,
183  [PERL=''
184   AC_PATH_PROGS(PERL, [perl5 perl],,)
185   if test -z "$PERL" ; then
186     PERL_VERSION=0
187   else
188     AC_CACHE_CHECK([perl version], ac_cv_perl_version,
189                    [ac_cv_perl_version=`$PERL -e "$perl_version_cmd"`])
190     PERL_VERSION=$ac_cv_perl_version
191   fi
192  ])
193
194
195 ###############################################################################
196 #
197 #       Functions to check how to do ICMP PING requests.
198 #
199 ###############################################################################
200
201 AC_DEFUN(AC_CHECK_ICMP,
202  [AC_CACHE_CHECK([for struct icmp], ac_cv_have_icmp,
203   [AC_TRY_COMPILE([#include <stdlib.h>
204                    #include <stdio.h>
205                    #include <math.h>
206                    #include <unistd.h>
207                    #include <limits.h>
208                    #include <signal.h>
209                    #include <fcntl.h>
210                    #include <sys/types.h>
211                    #include <sys/time.h>
212                    #include <sys/ipc.h>
213                    #include <sys/shm.h>
214                    #include <sys/socket.h>
215                    #include <netinet/in_systm.h>
216                    #include <netinet/in.h>
217                    #include <netinet/ip.h>
218                    #include <netinet/ip_icmp.h>
219                    #include <netinet/udp.h>
220                    #include <arpa/inet.h>
221                    #include <netdb.h>],
222                   [struct icmp i;
223                    struct sockaddr s;
224                    struct sockaddr_in si;
225                    struct ip ip;
226                    i.icmp_type = ICMP_ECHO;
227                    i.icmp_code = 0;
228                    i.icmp_cksum = 0;
229                    i.icmp_id = 0;
230                    i.icmp_seq = 0;
231                    si.sin_family = AF_INET;
232                    ip.ip_hl = 0;],
233                   [ac_cv_have_icmp=yes],
234                   [ac_cv_have_icmp=no])])
235  if test "$ac_cv_have_icmp" = yes ; then
236    AC_DEFINE(HAVE_ICMP)
237  fi])
238
239 AC_DEFUN(AC_CHECK_ICMPHDR,
240  [AC_CACHE_CHECK([for struct icmphdr], ac_cv_have_icmphdr,
241   [AC_TRY_COMPILE([#include <stdlib.h>
242                    #include <stdio.h>
243                    #include <math.h>
244                    #include <unistd.h>
245                    #include <limits.h>
246                    #include <signal.h>
247                    #include <fcntl.h>
248                    #include <sys/types.h>
249                    #include <sys/time.h>
250                    #include <sys/ipc.h>
251                    #include <sys/shm.h>
252                    #include <sys/socket.h>
253                    #include <netinet/in_systm.h>
254                    #include <netinet/in.h>
255                    #include <netinet/ip.h>
256                    #include <netinet/ip_icmp.h>
257                    #include <netinet/udp.h>
258                    #include <arpa/inet.h>
259                    #include <netdb.h>],
260                   [struct icmphdr i;
261                    struct sockaddr s;
262                    struct sockaddr_in si;
263                    struct ip ip;
264                    i.type = ICMP_ECHO;
265                    i.code = 0;
266                    i.cksum = 0;
267                    i.un.echo.id = 0;
268                    i.un.echo.sequence = 0;
269                    si.sin_family = AF_INET;
270                    ip.ip_hl = 0;],
271                   [ac_cv_have_icmphdr=yes],
272                   [ac_cv_have_icmphdr=no])])
273  if test "$ac_cv_have_icmphdr" = yes ; then
274    AC_DEFINE(HAVE_ICMPHDR)
275  fi])
276
277
278 ###############################################################################
279 #
280 #       Functions to check for various X11 crap.
281 #
282 ###############################################################################
283
284 # Try and find the app-defaults directory.
285 # It sucks that autoconf doesn't do this already...
286 #
287 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,[
288   rm -fr conftestdir
289   if mkdir conftestdir; then
290     cd conftestdir >&-
291     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
292     cat > Imakefile <<'EOF'
293 acfindx:
294         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
295 EOF
296     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
297       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
298       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
299     fi
300     cd .. >&-
301     rm -fr conftestdir
302   fi])
303
304 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,[
305   # Look for the directory under a standard set of common directories.
306   # Check X11 before X11Rn because it's often a symlink to the current release.
307   for ac_dir in                                 \
308     /usr/X11/lib/app-defaults                   \
309     /usr/X11R6/lib/app-defaults                 \
310     /usr/X11R6/lib/X11/app-defaults             \
311     /usr/X11R5/lib/app-defaults                 \
312     /usr/X11R5/lib/X11/app-defaults             \
313     /usr/X11R4/lib/app-defaults                 \
314     /usr/X11R4/lib/X11/app-defaults             \
315                                                 \
316     /usr/lib/X11/app-defaults                   \
317     /usr/lib/X11R6/app-defaults                 \
318     /usr/lib/X11R5/app-defaults                 \
319     /usr/lib/X11R4/app-defaults                 \
320                                                 \
321     /usr/local/X11/lib/app-defaults             \
322     /usr/local/X11R6/lib/app-defaults           \
323     /usr/local/X11R5/lib/app-defaults           \
324     /usr/local/X11R4/lib/app-defaults           \
325                                                 \
326     /usr/local/lib/X11/app-defaults             \
327     /usr/local/lib/X11R6/app-defaults           \
328     /usr/local/lib/X11R6/X11/app-defaults       \
329     /usr/local/lib/X11R5/app-defaults           \
330     /usr/local/lib/X11R5/X11/app-defaults       \
331     /usr/local/lib/X11R4/app-defaults           \
332     /usr/local/lib/X11R4/X11/app-defaults       \
333                                                 \
334     /usr/X386/lib/X11/app-defaults              \
335     /usr/x386/lib/X11/app-defaults              \
336     /usr/XFree86/lib/X11/app-defaults           \
337                                                 \
338     /usr/lib/X11/app-defaults                   \
339     /usr/local/lib/X11/app-defaults             \
340     /usr/unsupported/lib/X11/app-defaults       \
341     /usr/athena/lib/X11/app-defaults            \
342     /usr/local/x11r5/lib/X11/app-defaults       \
343     /usr/lpp/Xamples/lib/X11/app-defaults       \
344     /lib/usr/lib/X11/app-defaults               \
345                                                 \
346     /usr/openwin/lib/app-defaults               \
347     /usr/openwin/lib/X11/app-defaults           \
348     /usr/openwin/share/lib/app-defaults         \
349     /usr/openwin/share/lib/X11/app-defaults     \
350                                                 \
351     /X11R6/lib/app-defaults                     \
352     /X11R5/lib/app-defaults                     \
353     /X11R4/lib/app-defaults                     \
354     ; \
355   do
356     if test -d "$ac_dir"; then
357       ac_x_app_defaults=$ac_dir
358       break
359     fi
360   done
361 ])
362
363 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
364   [AC_REQUIRE_CPP()
365     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
366      [AC_PATH_X_APP_DEFAULTS_XMKMF
367       if test x"$ac_x_app_defaults" = x; then
368         AC_PATH_X_APP_DEFAULTS_DIRECT
369       fi
370       if test x"$ac_x_app_defaults" = x; then
371         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
372       else
373         # Record where we found app-defaults for the cache.
374         ac_cv_x_app_defaults="$ac_x_app_defaults"
375       fi])
376     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
377
378
379 AC_DEFUN(AC_XPOINTER,
380  [AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
381                  [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
382                                    [XPointer foo = (XPointer) 0;],
383                                    [ac_cv_xpointer=yes],
384                                    [ac_cv_xpointer=no])])
385   if test "$ac_cv_xpointer" != yes; then
386    AC_DEFINE(XPointer,[char*])
387   fi])
388
389
390 # Random special-cases for X on certain pathological OSes.
391 # You know who you are.
392 #
393 AC_DEFUN(AC_X_RANDOM_PATHS,
394  [case "$host" in
395     *-hpux*)
396
397       # The following arcana was gleaned from conversations with
398       # Eric Schwartz <erics@col.hp.com>:
399       #
400       # On HPUX 10.x, the parts of X that HP considers "standard" live in
401       # /usr/{include,lib}/X11R6/.  The parts that HP doesn't consider
402       # "standard", notably, Xaw and Xmu, live in /usr/contrib/X11R6/.
403       # Yet /usr/contrib/X11R6/ comes preinstalled on all HPUX systems.
404       # Also, there are symlinks from /usr/include/ and /usr/lib/ into
405       # /usr/{include,lib}/X11R6/, so that (if you don't use Xmu at all)
406       # you don't need any -I or -L arguments.
407       #
408       # On HPUX 9.x, /usr/{include,lib}/X11R5/ and /usr/contrib/X11R5/
409       # are the same division as 10.x.  However, there are no symlinks to
410       # the X stuff from /usr/include/ and /usr/lib/, so -I and -L
411       # arguments are always necessary.
412       #
413       # However, X11R6 was available on HPUX 9.x as a patch: if that
414       # patch was installed, then all of X11R6 went in to
415       # /usr/contrib/X11R6/ (there was no /usr/{include,lib}/X11R6/.)
416       #
417       # HPUX 8.x was the same as 9.x, but was X11R4 instead (I don't know
418       # whether R5 was available as a patch; R6 undoubtedly was not.)
419       #
420       # So.  We try and use the highest numbered pair of
421       # /usr/{include,lib}/X11R?/ and /usr/contrib/X11R?/{include,lib}/
422       # that are available.  We do not mix and match different versions
423       # of X.
424       #
425       # Question I still don't know the answer to: (do you?)
426       #
427       #   * On HPUX 9.x, where /usr/include/X11R5/ was standard, and
428       #     /usr/contrib/X11R6/ could be installed as a patch, what was in
429       #     that contrib directory?  Did it contain so-called "standard"
430       #     X11R6, or did it include Xaw and Xmu as well?  If the former,
431       #     where did one find Xaw and Xmu on 9.x R6 systems?  Would this
432       #     be a situation where one had to reach into the R5 headers and
433       #     libs to find Xmu?  That is, must both R6 and R5 directories
434       #     be on the -I and -L lists in that case?
435       #
436       for version in X11R6 X11R5 X11R4 ; do
437         # if either pair of directories exists...
438         if test -d /usr/lib/$version || test -d /usr/contrib/$version/lib
439         then
440            # if contrib exists, use it...
441            if test -d /usr/contrib/$version/lib ; then
442              X_CFLAGS="$X_CFLAGS -I/usr/contrib/$version/include"
443              X_LIBS="$X_LIBS -L/usr/contrib/$version/lib"
444            fi
445            # if the "standard" one exists, use it.
446            if test -d /usr/lib/$version ; then
447              X_CFLAGS="$X_CFLAGS -I/usr/include/$version"
448              X_LIBS="$X_LIBS -L/usr/lib/$version"
449            fi
450            # since at least one of the pair exists, go no farther.
451            break
452         fi
453       done
454
455       # Now find Motif.  Thanks for not making xmkmf find this by
456       # default, you losers.
457       #
458       if test -d /usr/lib/Motif1.2 ; then
459         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.2"
460         X_LIBS="$X_LIBS -L/usr/lib/Motif1.2"
461       elif test -d /usr/lib/Motif1.1 ; then
462         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.1"
463         X_LIBS="$X_LIBS -L/usr/lib/Motif1.1"
464       fi
465
466       # Now let's check for the pseudo-standard locations for OpenGL and XPM.
467       #
468       if test -d /opt/Mesa/lib ; then
469         X_CFLAGS="-I/opt/Mesa/include $X_CFLAGS"
470         X_LIBS="-L/opt/Mesa/lib $X_LIBS"
471       fi
472
473       if test -d /opt/xpm/lib/X11 ; then
474         X_CFLAGS="-I/opt/xpm/include $X_CFLAGS"
475         X_LIBS="-L/opt/xpm/lib/X11 $X_LIBS"
476       fi
477
478       # On HPUX, default to installing in /opt/xscreensaver/ instead of
479       # in /usr/local/, unless there is already an xscreensaver in
480       # /usr/local/bin/.  This can be overridden with the --prefix arg
481       # to configure.  I'm not sure this is the right thing to do, but
482       # Richard Lloyd says so...
483       #
484       if test \! -x /usr/local/bin/xscreensaver ; then
485         ac_default_prefix=/opt/xscreensaver
486       fi
487
488     ;;
489     *-solaris*)
490
491       # Thanks for not making xmkmf find this by default, pinheads.
492       # And thanks for moving things around again, too.  Is this
493       # really the standard location now?  What happened to the
494       # joke that this kind of thing went in /opt?
495       # cthomp says "answer: CDE (Common Disorganized Environment)"
496       #
497       if test -f /usr/dt/include/Xm/Xm.h ; then
498         X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
499         X_LIBS="$X_LIBS -L/usr/dt/lib -R:/usr/dt/lib"
500
501         # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
502         AC_CHECK_LIB(gen, regcmp, [X_LIBS="$X_LIBS -lgen"])
503       fi
504     ;;
505   esac])
506
507
508
509 ###############################################################################
510 #
511 #       Some utility functions to make checking for X things easier.
512 #
513 ###############################################################################
514
515 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
516 #
517 AC_DEFUN(AC_CHECK_X_HEADER, [
518   ac_save_CPPFLAGS="$CPPFLAGS"
519   if test \! -z "$includedir" ; then 
520     CPPFLAGS="$CPPFLAGS -I$includedir"
521   fi
522   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
523   AC_CHECK_HEADER([$1], [$2])
524   CPPFLAGS="$ac_save_CPPFLAGS"])
525
526 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
527 #
528 AC_DEFUN(AC_EGREP_X_HEADER, [
529   ac_save_CPPFLAGS="$CPPFLAGS"
530   if test \! -z "$includedir" ; then 
531     CPPFLAGS="$CPPFLAGS -I$includedir"
532   fi
533   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
534   AC_EGREP_HEADER([$1], [$2], [$3], [$4])
535   CPPFLAGS="$ac_save_CPPFLAGS"])
536
537 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
538 #
539 AC_DEFUN(AC_TRY_X_COMPILE, [
540   ac_save_CPPFLAGS="$CPPFLAGS"
541   if test \! -z "$includedir" ; then 
542     CPPFLAGS="$CPPFLAGS -I$includedir"
543   fi
544   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
545   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
546   CPPFLAGS="$ac_save_CPPFLAGS"])
547
548
549 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
550 # Use this sparingly; it probably doesn't work very well on X programs.
551 #
552 AC_DEFUN(AC_CHECK_X_LIB, [
553   ac_save_CPPFLAGS="$CPPFLAGS"
554   ac_save_LDFLAGS="$LDFLAGS"
555 #  ac_save_LIBS="$LIBS"
556
557   if test \! -z "$includedir" ; then 
558     CPPFLAGS="$CPPFLAGS -I$includedir"
559   fi
560   # note: $X_CFLAGS includes $x_includes
561   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
562
563   if test \! -z "$libdir" ; then
564     LDFLAGS="$LDFLAGS -L$libdir"
565   fi
566   # note: $X_LIBS includes $x_libraries
567   LDFLAGS="$LDFLAGS $X_LIBS"
568
569   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
570   CPPFLAGS="$ac_save_CPPFLAGS"
571   LDFLAGS="$ac_save_LDFLAGS"
572 #  LIBS="$ac_save_LIBS"
573   ])
574
575 # Like AC_TRY_RUN, but it uses the already-computed -I directories.
576 # (But not the -L directories!)
577 #
578 AC_DEFUN(AC_TRY_X_RUN, [
579   ac_save_CPPFLAGS="$CPPFLAGS"
580   if test \! -z "$includedir" ; then 
581     CPPFLAGS="$CPPFLAGS -I$includedir"
582   fi
583   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
584   AC_TRY_RUN([$1], [$2], [$3], [$4])
585   CPPFLAGS="$ac_save_CPPFLAGS"])
586
587
588
589 # Usage: HANDLE_X_PATH_ARG([variable_name],
590 #                          [--command-line-option],
591 #                          [descriptive string])
592 #
593 # All of the --with options take three forms:
594 #
595 #   --with-foo (or --with-foo=yes)
596 #   --without-foo (or --with-foo=no)
597 #   --with-foo=/DIR
598 #
599 # This function, HANDLE_X_PATH_ARG, deals with the /DIR case.  When it sees
600 # a directory (string beginning with a slash) it checks to see whether
601 # /DIR/include and /DIR/lib exist, and adds them to $X_CFLAGS and $X_LIBS
602 # as appropriate.
603 #
604 AC_DEFUN(HANDLE_X_PATH_ARG, [
605    case "$[$1]" in
606     yes) ;;
607     no)  ;;
608
609     /*)
610      AC_MSG_CHECKING([for [$3] headers])
611      d=$[$1]/include
612      if test -d $d; then
613        X_CFLAGS="-I$d $X_CFLAGS"
614        AC_MSG_RESULT($d)
615      else
616        AC_MSG_RESULT(not found ($d: no such directory))
617      fi
618
619      AC_MSG_CHECKING([for [$3] libs])
620      d=$[$1]/lib
621      if test -d $d; then
622        X_LIBS="-L$d $X_LIBS"
623        AC_MSG_RESULT($d)
624      else
625        AC_MSG_RESULT(not found ($d: no such directory))
626      fi
627
628      # replace the directory string with "yes".
629      [$1]_req="yes"
630      [$1]=$[$1]_req
631      ;;
632
633     *)
634      echo ""
635      echo "error: argument to [$2] must be \"yes\", \"no\", or a directory."
636      echo "       If it is a directory, then \`DIR/include' will be added to"
637      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
638      exit 1
639      ;;
640    esac
641   ])
642
643
644
645 ###############################################################################
646 ###############################################################################
647 #
648 #       End of function definitions.  Now start actually executing stuff.
649 #
650 ###############################################################################
651 ###############################################################################
652
653 # random compiler setup
654 AC_CANONICAL_HOST
655 AC_PROG_CC_ANSI
656 AC_PROG_CPP
657 AC_C_CONST
658 AC_C_INLINE
659
660 # stuff for Makefiles
661 AC_PROG_INSTALL
662 AC_PROG_INSTALL_DIRS
663 AC_PROG_MAKE_SET
664
665 # random libc stuff
666 AC_HEADER_STDC
667 AC_CHECK_HEADERS(unistd.h)
668 AC_TYPE_MODE_T
669 AC_TYPE_PID_T
670 AC_TYPE_SIZE_T
671 AC_TYPE_SIGNAL
672 AC_HEADER_TIME
673 AC_HEADER_SYS_WAIT
674 AC_HEADER_DIRENT
675 AC_GETTIMEOFDAY_ARGS
676 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv)
677
678 AC_CHECK_FUNCS(sigaction syslog realpath)
679 AC_CHECK_ICMP
680 AC_CHECK_ICMPHDR
681 AC_CHECK_HEADERS(crypt.h sys/select.h)
682 AC_PROG_PERL
683
684 if test -z "$PERL" ; then
685   # don't let it be blank...
686   PERL=/usr/local/bin/perl5
687 fi
688
689 AC_PATH_XTRA
690
691 if test "$have_x" != yes; then
692   AC_MSG_ERROR(Couldn't find X11 headers/libs.  Try \`$0 --help'.)
693 fi
694
695 AC_PATH_X_APP_DEFAULTS
696 AC_X_RANDOM_PATHS
697 AC_XPOINTER
698
699
700
701 ###############################################################################
702 #
703 #       Check for -lXmu (some fucked up vendors don't ship it...)
704 #
705 ###############################################################################
706
707 have_xmu=no
708 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
709 if test "$have_xmu" = no ; then
710   XMU_SRCS='$(UTILS_SRC)/xmu.c'
711   XMU_OBJS='$(UTILS_BIN)/xmu.o'
712 else
713   XMU_SRCS=''
714   XMU_OBJS=''
715   SAVER_LIBS="-lXmu $SAVER_LIBS"
716   HACK_LIBS="-lXmu $HACK_LIBS"
717   MOTIF_LIBS="-lXmu $MOTIF_LIBS"
718   GTK_LIBS="-lXmu $GTK_LIBS"
719   ATHENA_LIBS="-lXmu $ATHENA_LIBS"
720   ATHENA3D_LIBS="-lXmu $ATHENA3D_LIBS"
721   AC_DEFINE(HAVE_XMU)
722 fi
723
724
725 ###############################################################################
726 #
727 #       Check for the SunOS 4.1.x _get_wmShellWidgetClass bug.
728 #       See comp.windows.x FAQ question 124.  The right fix is to
729 #       get OpenWindows 3.0 patches 100512-02 and 100573-03.
730 #
731 ###############################################################################
732
733 if test "$have_xmu" = yes ; then
734   case "$host" in
735     *-sunos4*)
736     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
737                    ac_cv_sunos_xmu_bug,
738                    [ac_save_LDFLAGS="$LDFLAGS"
739                     if test \! -z "$x_libraries" ; then
740                       LDFLAGS="$LDFLAGS -L$x_libraries"
741                     fi
742                     # Note: this trick never works!  (Generally.)
743                     # We're only getting away with using AC_TRY_LINK
744                     # with X libraries because we know it's SunOS.
745                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
746                     AC_TRY_LINK(,,
747                                 [ac_cv_sunos_xmu_bug=no],
748                                 [ac_cv_sunos_xmu_bug=yes])
749                     LDFLAGS="$ac_save_LDFLAGS"])
750     if test "$ac_cv_sunos_xmu_bug" = yes ; then
751       AC_CACHE_CHECK([whether the compiler understands -static], 
752                      ac_cv_ld_static,
753                      [ac_save_LDFLAGS="$LDFLAGS"
754                       LDFLAGS="$LDFLAGS -static"
755                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
756                     LDFLAGS="$ac_save_LDFLAGS"])
757       if test "$ac_cv_ld_static" = yes ; then
758         LDFLAGS="$LDFLAGS -static"
759       else
760         LDFLAGS="$LDFLAGS -Bstatic"
761       fi
762     fi
763     ;;
764   esac
765 fi
766
767
768 ###############################################################################
769 #
770 #       Handle the --enable-subdir option
771 #
772 ###############################################################################
773
774 AC_ARG_ENABLE(subdir,[
775 Installation options:
776
777   --enable-subdir=DIR     Put the demo programs in a subdirectory of \`bindir',
778                           instead of putting them in bindir itself.  You can
779                           specify the name of the subdirectory.  For example,
780                           \`--exec-prefix=/usr/local --enable-subdir=demos'
781                           would put xscreensaver in /usr/local/bin/, and would
782                           put the demos in /usr/local/bin/demos/.  (If DIR
783                           begins with /, then bindir will not be prepended.)
784
785   --disable-subdir        Just put the demos in \`bindir' (this is the default.)
786 ],
787   [enable_subdir="$enableval"],[enable_subdir=no])
788 if test x"$enable_subdir" = xno; then
789   HACKDIR='${bindir}'
790 elif test x"$enable_subdir" = xyes -o x"$enable_subdir" = x ; then
791   echo "error: must be a subdirectory name: --enable-subdir=$enable_subdir"
792   exit 1
793 else
794   # there must be a better way than this...
795   if test -z "`echo $enable_subdir | sed 's@^/.*@@'`" ; then
796     # absolute path
797     HACKDIR=$enable_subdir
798   else
799     # relative path
800     HACKDIR='${bindir}/'$enable_subdir
801   fi
802 fi
803
804 # canonicalize slashes.
805 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
806
807
808 ###############################################################################
809 #
810 #       Check for the SGI SCREEN_SAVER server extension.
811 #
812 ###############################################################################
813
814 have_sgi=no
815 with_sgi_req=unspecified
816 AC_ARG_WITH(sgi-ext,
817 [Except where noted, all of the --with options below can also take a
818 directory argument: for example, \`--with-motif=/opt/Motif'.  That would
819 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
820 to be added to the -L list, assuming those directories exist.  
821
822 By default, support for each of these options will be built in, if the
823 relevant library routines exist.  At run time, they will then be used
824 only if the X server being used supports them.  Each --with option has
825 a corresponding --without option, to override building support for them
826 at all.
827
828 Screen blanking and idle-detection options:
829
830   --with-sgi-ext          Include support for the SGI SCREEN_SAVER extension.],
831   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
832
833 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
834
835 if test "$with_sgi" = yes; then
836   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
837                     [have_sgi=yes
838                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
839
840 elif test "$with_sgi" != no; then
841   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
842   exit 1
843 fi
844
845
846 ###############################################################################
847 #
848 #       Check for the MIT-SCREEN-SAVER server extension.
849 #
850 ###############################################################################
851
852 have_mit=no
853 with_mit_req=unspecified
854 AC_ARG_WITH(mit-ext,
855 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER extension.],
856   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
857
858 HANDLE_X_PATH_ARG(with_mit, --with-mit-ext, MIT-SCREEN-SAVER)
859
860 if test "$with_mit" = yes; then
861   AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
862
863   # Now check to see if it's really in the library; XF86Free-3.3 ships
864   # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
865   #
866   if test "$have_mit" = yes; then
867     AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [true], [have_mit=no], -lm)
868
869     if test "$have_mit" = no; then
870       # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
871       # of in Xext.  Thank you master, may I have another.
872       AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
873                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
874                      [true], -lX11 -lXext -lm)
875     fi
876
877     if test "$have_mit" = no; then
878       # Double fuck!  Looks like some versions of XFree86 (whichever version
879       # it is that comes with RedHat Linux 2.0 -- I can't find a version 
880       # number) put this garbage in Xss instead of Xext.  Thank you master,
881       #  may I have another.
882       AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
883                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
884                      [true], -lX11 -lXext -lm)
885     fi
886
887   if test "$have_mit" = yes; then
888     AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
889   fi
890
891   fi
892
893 elif test "$with_mit" != no; then
894   echo "error: must be yes or no: --with-mit-ext=$with_mit"
895   exit 1
896 fi
897
898
899 ###############################################################################
900 #
901 #       Check for the XIDLE server extension.
902 #
903 ###############################################################################
904
905 have_xidle=no
906 with_xidle_req=unspecified
907 AC_ARG_WITH(xidle-ext,
908 [  --with-xidle-ext        Include support for the XIDLE extension.],
909   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
910
911 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
912
913 if test "$with_xidle" = yes; then
914   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
915                     [have_xidle=yes
916                      AC_DEFINE(HAVE_XIDLE_EXTENSION)])
917 elif test "$with_xidle" != no; then
918   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
919   exit 1
920 fi
921
922
923 ###############################################################################
924 #
925 #       Check for the SGI-VIDEO-CONTROL server extension.
926 #
927 ###############################################################################
928
929 have_sgivc=no
930 with_sgivc_req=unspecified
931 AC_ARG_WITH(sgivc-ext,
932 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension.],
933   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
934
935 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
936
937 if test "$with_sgivc" = yes; then
938
939   # first check for XSGIvc.h
940   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes])
941
942   # if that succeeded, then check for the -lXsgivc
943   if test "$have_sgivc" = yes; then
944     have_sgivc=no
945     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
946                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [true],
947                   -lXext -lX11)
948   fi
949
950   # if that succeeded, then we've really got it.
951   if test "$have_sgivc" = yes; then
952     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
953   fi
954
955 elif test "$with_sgivc" != no; then
956   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
957   exit 1
958 fi
959
960
961 ###############################################################################
962 #
963 #       Check for the DPMS server extension.
964 #
965 ###############################################################################
966
967 have_dpms=no
968 with_dpms_req=unspecified
969 AC_ARG_WITH(dpms-ext,
970 [  --with-dpms-ext         Include support for the DPMS extension.],
971   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
972
973 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
974
975 if test "$with_dpms" = yes; then
976
977   # first check for dpms.h
978   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
979
980   # if that succeeded, then check for the -lXdpms
981   if test "$have_dpms" = yes; then
982     have_dpms=no
983     AC_CHECK_X_LIB(Xdpms, DPMSInfo,
984                   [have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"], [true],
985                   -lXext -lX11)
986   fi
987
988   # if that succeeded, then we've really got it.
989   if test "$have_dpms" = yes; then
990     AC_DEFINE(HAVE_DPMS_EXTENSION)
991   fi
992
993 elif test "$with_dpms" != no; then
994   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
995   exit 1
996 fi
997
998
999 ###############################################################################
1000 #
1001 #       Check for the XF86VMODE server extension.
1002 #
1003 ###############################################################################
1004
1005 have_xf86vmode=no
1006 with_xf86vmode_req=unspecified
1007 AC_ARG_WITH(xf86vmode-ext,
1008 [  --with-xf86vmode-ext    Include support for XFree86 virtual screens.],
1009   [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
1010   [with_xf86vmode=yes])
1011
1012 HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
1013
1014 if test "$with_xf86vmode" = yes; then
1015
1016   # first check for xf86vmode.h
1017   AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes])
1018
1019   # if that succeeded, then check for the -lXxf86vm
1020   if test "$have_xf86vmode" = yes; then
1021     have_xf86vmode=no
1022     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
1023                   [have_xf86vmode=yes; SAVER_LIBS="$SAVER_LIBS -lXxf86vm"],
1024                    [true], -lXext -lX11)
1025   fi
1026
1027   # if that succeeded, then we've really got it.
1028   if test "$have_xf86vmode" = yes; then
1029     AC_DEFINE(HAVE_XF86VMODE)
1030   fi
1031
1032 elif test "$with_xf86vmode" != no; then
1033   echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
1034   exit 1
1035 fi
1036
1037
1038 ###############################################################################
1039 #
1040 #       Check for HP XHPDisableReset and XHPEnableReset.
1041 #
1042 ###############################################################################
1043
1044 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
1045                   [AC_DEFINE(HAVE_XHPDISABLERESET)
1046                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
1047
1048
1049 ###############################################################################
1050 #
1051 #       Check for /proc/interrupts.
1052 #
1053 ###############################################################################
1054
1055 have_proc_interrupts=no
1056 with_proc_interrupts_req=unspecified
1057 AC_ARG_WITH(proc-interrupts,
1058 [  --with-proc-interrupts  Include support for consulting the /proc/interrupts
1059                           file to notice keyboard activity.],
1060   [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
1061   [with_proc_interrupts=yes])
1062
1063 if test "$with_proc_interrupts" = yes; then
1064
1065    AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
1066     ac_cv_have_proc_interrupts,
1067     [ac_cv_have_proc_interrupts=no
1068      if grep keyboard /proc/interrupts >/dev/null 2>&1 ; then
1069        ac_cv_have_proc_interrupts=yes
1070      fi
1071     ])
1072    have_proc_interrupts=$ac_cv_have_proc_interrupts
1073
1074   if test "$have_proc_interrupts" = yes; then
1075     AC_DEFINE(HAVE_PROC_INTERRUPTS)
1076   fi
1077
1078 elif test "$with_proc_interrupts" != no; then
1079   echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
1080   exit 1
1081 fi
1082
1083
1084 ###############################################################################
1085 #
1086 #       The --enable-locking option
1087 #
1088 ###############################################################################
1089
1090 AC_ARG_ENABLE(locking,[
1091 Screen locking options:
1092
1093   --enable-locking        Compile in support for locking the display.
1094   --disable-locking       Do not allow locking at all.
1095 ],
1096   [enable_locking="$enableval"],[enable_locking=yes])
1097 if test "$enable_locking" = yes; then
1098   true
1099 elif test "$enable_locking" = no; then
1100   AC_DEFINE(NO_LOCKING)
1101 else
1102   echo "error: must be yes or no: --enable-locking=$enable_locking"
1103   exit 1
1104 fi
1105
1106
1107
1108 ###############################################################################
1109 #
1110 #       The --enable-vt-locking option
1111 #
1112 ###############################################################################
1113
1114 #ac_vt_lockswitch=no
1115 #AC_ARG_ENABLE(vt-locking,[
1116 #  --enable-vt-locking     Compile in support for locking Virtual Terminals.
1117 #                          This is the default if the system supports it, and
1118 #                          if locking support is included (--enable-locking.)
1119 #  --disable-vt-locking    Do not allow locking of VTs, even if locking is
1120 #                          enabled.],
1121 #  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1122 #if test "$enable_vt_locking" = yes; then
1123 #
1124 #  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
1125 #   [AC_TRY_COMPILE([#include <fcntl.h>
1126 #                   #include <sys/ioctl.h>
1127 #                   #include <sys/vt.h>],
1128 #                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1129 #                  [ac_cv_vt_lockswitch=yes],
1130 #                  [ac_cv_vt_lockswitch=no])])
1131 #  ac_vt_lockswitch=$ac_cv_vt_lockswitch
1132 #
1133 #elif test "$enable_vt_locking" = no; then
1134 #  true
1135 #else
1136 #  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1137 #  exit 1
1138 #fi
1139 #
1140 #if test "$ac_vt_lockswitch" = yes; then
1141 #  AC_DEFINE(HAVE_VT_LOCKSWITCH)
1142 #  # the VT_LOCKSWITCH ioctl can only be used when running as root.
1143 #  # #### but it doesn't work yet, so don't worry about that for now.
1144 ##  need_setuid=yes
1145 #fi
1146
1147
1148
1149 ###############################################################################
1150 #
1151 #       Check for PAM.
1152 #
1153 ###############################################################################
1154
1155 case "$host" in
1156   *-solaris*)
1157    # Solaris systems tend to come with PAM misconfigured.
1158    #  Don't build it by default, even if the headers exist.
1159    with_pam_default=no
1160    ;;
1161   *)
1162    # Default to building PAM support on all other systems, if it exists.
1163    with_pam_default=yes
1164   ;;
1165 esac
1166
1167 have_pam=no
1168 with_pam_req=unspecified
1169
1170 AC_ARG_WITH(pam,
1171 [  --with-pam              Include support for PAM (Pluggable Auth Modules.)],
1172   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
1173
1174 HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1175
1176 if test "$enable_locking" = yes -a "$with_pam" = yes; then
1177   AC_CACHE_CHECK([for PAM], ac_cv_pam,
1178                  [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1179                                    [ac_cv_pam=yes],
1180                                    [ac_cv_pam=no])])
1181   if test "$ac_cv_pam" = yes ; then
1182     have_pam=yes
1183     AC_DEFINE(HAVE_PAM)
1184     PASSWD_LIBS="${PASSWD_LIBS} -lpam"
1185
1186     # libpam typically requires dlopen and dlsym.  On FreeBSD,
1187     # those are in libc.  On Linux and Solaris, they're in libdl.
1188     AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
1189
1190     AC_MSG_CHECKING(how to call pam_strerror)
1191     AC_CACHE_VAL(ac_cv_pam_strerror_args,
1192      [AC_TRY_COMPILE([#include <stdio.h>
1193                       #include <stdlib.h>
1194                       #include <security/pam_appl.h>],
1195                      [pam_handle_t *pamh = 0;
1196                       char *s = pam_strerror(pamh, PAM_SUCCESS);],
1197                      [ac_pam_strerror_args=2],
1198                      [AC_TRY_COMPILE([#include <stdio.h>
1199                                       #include <stdlib.h>
1200                                       #include <security/pam_appl.h>],
1201                                      [char *s =
1202                                        pam_strerror(PAM_SUCCESS);],
1203                                      [ac_pam_strerror_args=1],
1204                                      [ac_pam_strerror_args=0])])
1205       ac_cv_pam_strerror_args=$ac_pam_strerror_args])
1206     ac_pam_strerror_args=$ac_cv_pam_strerror_args
1207     if test "$ac_pam_strerror_args" = 1 ; then
1208       AC_MSG_RESULT(one argument)
1209     elif test "$ac_pam_strerror_args" = 2 ; then
1210       AC_DEFINE(PAM_STRERROR_TWO_ARGS)
1211       AC_MSG_RESULT(two arguments)
1212     else
1213       AC_MSG_RESULT(unknown)
1214     fi
1215   fi
1216 fi
1217
1218
1219 ###############################################################################
1220 #
1221 #       Check for Kerberos.
1222 #
1223 ###############################################################################
1224
1225 have_kerberos=no
1226 with_kerberos_req=unspecified
1227
1228 AC_ARG_WITH(kerberos, 
1229 [  --with-kerberos         Include support for Kerberos authentication.],
1230   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1231
1232 HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1233
1234 if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
1235   AC_CACHE_CHECK([for Kerberos], ac_cv_kerberos,
1236                  [AC_TRY_X_COMPILE([#include <krb.h>],,
1237                                    [ac_cv_kerberos=yes],
1238                                    [ac_cv_kerberos=no])])
1239   if test "$ac_cv_kerberos" = yes ; then
1240     have_kerberos=yes
1241     AC_DEFINE(HAVE_KERBEROS)
1242
1243     # from Tim Showalter <tjs+@andrew.cmu.edu>
1244     PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes"
1245     AC_CHECK_FUNC(res_search,,
1246       AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1247         AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1248       ))
1249
1250   fi
1251 fi
1252
1253
1254 ###############################################################################
1255 #
1256 #       Check for the nine billion variants of shadow passwords...
1257 #
1258 ###############################################################################
1259
1260 need_setuid=no
1261
1262 have_shadow=no
1263 with_shadow_req=unspecified
1264
1265 AC_ARG_WITH(shadow,
1266 [  --with-shadow           Include support for shadow password authentication.],
1267   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1268
1269 HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1270
1271 if test "$enable_locking" = no ; then
1272   with_shadow_req=no
1273   with_shadow=no
1274 fi
1275
1276
1277 ###############################################################################
1278 #
1279 #       Check for Sun "adjunct" passwords.
1280 #
1281 ###############################################################################
1282
1283 if test "$with_shadow" = yes ; then
1284   AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1285                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1286                                     #include <unistd.h>
1287                                     #include <sys/types.h>
1288                                     #include <sys/label.h>
1289                                     #include <sys/audit.h>
1290                                     #include <pwdadj.h>],
1291                       [struct passwd_adjunct *p = getpwanam("nobody");
1292                        const char *pw = p->pwa_passwd;],
1293                       [ac_cv_sun_adjunct=yes],
1294                       [ac_cv_sun_adjunct=no])])
1295   if test "$ac_cv_sun_adjunct" = yes; then
1296     have_shadow_adjunct=yes
1297     have_shadow=yes
1298     need_setuid=yes
1299   fi
1300 fi
1301
1302
1303 ###############################################################################
1304 #
1305 #       Check for DEC and SCO so-called "enhanced" security.
1306 #
1307 ###############################################################################
1308
1309 if test "$with_shadow" = yes ; then
1310   AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1311                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1312                                     #include <unistd.h>
1313                                     #include <sys/types.h>
1314                                     #include <pwd.h>
1315                                     #include <sys/security.h>
1316                                     #include <prot.h>],
1317                       [struct pr_passwd *p;
1318                        const char *pw;
1319                        set_auth_parameters(0, 0);
1320                        check_auth_parameters();
1321                        p = getprpwnam("nobody");
1322                        pw = p->ufld.fd_encrypt;],
1323                       [ac_cv_enhanced_passwd=yes],
1324                       [ac_cv_enhanced_passwd=no])])
1325   if test $ac_cv_enhanced_passwd = yes; then
1326     have_shadow_enhanced=yes
1327     have_shadow=yes
1328     need_setuid=yes
1329
1330     # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1331     # (I'm told it needs -lcurses too, but I don't understand why.)
1332     # But on DEC, it's in -lsecurity.
1333     #
1334     AC_CHECK_LIB(prot, getprpwnam, 
1335                  [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1336                  [AC_CHECK_LIB(security, getprpwnam, 
1337                                [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1338                  [-lx])
1339   fi
1340 fi
1341
1342 ###############################################################################
1343 #
1344 #       Check for HP's entry in the "Not Invented Here" Sweepstakes.
1345 #
1346 ###############################################################################
1347
1348 if test "$with_shadow" = yes ; then
1349   AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1350                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1351                                     #include <unistd.h>
1352                                     #include <sys/types.h>
1353                                     #include <pwd.h>
1354                                     #include <hpsecurity.h>
1355                                     #include <prot.h>],
1356                       [struct s_passwd *p = getspwnam("nobody");
1357                        const char *pw = p->pw_passwd;],
1358                       [ac_cv_hpux_passwd=yes],
1359                       [ac_cv_hpux_passwd=no])])
1360   if test "$ac_cv_hpux_passwd" = yes; then
1361     have_shadow_hpux=yes
1362     have_shadow=yes
1363     need_setuid=yes
1364
1365     # on HPUX, bigcrypt is in -lsec
1366     AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1367   fi
1368 fi
1369
1370
1371 ###############################################################################
1372 #
1373 #       Check for FreeBSD-style shadow passwords.
1374 #
1375 #       On FreeBSD, getpwnam() and friends work just like on non-shadow-
1376 #       password systems -- except you only get stuff in the pw_passwd field
1377 #       if the running program is setuid.  So, guess that we've got this
1378 #       lossage to contend with if /etc/master.passwd exists, and default to
1379 #       a setuid installation.
1380 #
1381 ###############################################################################
1382
1383 if test "$with_shadow" = yes ; then
1384   AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1385                  [if test -f /etc/master.passwd ; then
1386                     ac_cv_master_passwd=yes
1387                   else
1388                     ac_cv_master_passwd=no
1389                   fi])
1390   if test "$ac_cv_master_passwd" = yes; then
1391     need_setuid=yes
1392   fi
1393 fi
1394
1395
1396 ###############################################################################
1397 #
1398 #       Check for traditional (ha!) shadow passwords.
1399 #
1400 ###############################################################################
1401
1402 if test "$with_shadow" = yes ; then
1403   AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1404                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1405                                     #include <unistd.h>
1406                                     #include <sys/types.h>
1407                                     #include <pwd.h>
1408                                     #include <shadow.h>],
1409                       [struct spwd *p = getspnam("nobody");
1410                        const char *pw = p->sp_pwdp;],
1411                       [ac_cv_shadow=yes],
1412                       [ac_cv_shadow=no])])
1413   if test "$ac_cv_shadow" = yes; then
1414     have_shadow=yes
1415     need_setuid=yes
1416
1417     # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1418     have_getspnam=no
1419     AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1420     if test "$have_getspnam" = no ; then
1421       AC_CHECK_LIB(gen, getspnam,
1422                    [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1423     fi
1424   fi
1425 fi
1426
1427
1428 ###############################################################################
1429 #
1430 #       Check for other libraries needed for non-shadow passwords.
1431 #
1432 ###############################################################################
1433
1434 if test "$enable_locking" = yes ; then
1435
1436   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1437   have_crypt=no
1438   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1439   if test "$have_crypt" = no ; then
1440     AC_CHECK_LIB(crypt, crypt,
1441                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1442   fi
1443 fi
1444
1445
1446 # Most of the above shadow mechanisms will have set need_setuid to yes,
1447 # if they were found.  But, on some systems, we need setuid even when
1448 # using plain old vanilla passwords.
1449 #
1450 if test "$enable_locking" = yes ; then
1451   case "$host" in
1452     *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1453       need_setuid=yes
1454     ;;
1455   esac
1456 fi
1457
1458
1459 if test "$have_shadow_adjunct" = yes ; then
1460   AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1461 elif test "$have_shadow_enhanced" = yes ; then
1462   AC_DEFINE(HAVE_ENHANCED_PASSWD)
1463 elif test "$have_shadow_hpux" = yes ; then
1464   AC_DEFINE(HAVE_HPUX_PASSWD)
1465 elif test "$have_shadow" = yes ; then
1466   AC_DEFINE(HAVE_SHADOW_PASSWD)
1467 fi
1468
1469
1470 ###############################################################################
1471 #
1472 #       Check for -lXm.
1473 #
1474 ###############################################################################
1475
1476 have_motif=no
1477 with_motif_req=unspecified
1478 AC_ARG_WITH(motif,[
1479 User interface options:
1480
1481   --with-motif            Use the Motif toolkit for the user interface.],
1482   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=yes])
1483
1484 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
1485
1486 if test "$with_motif" != yes -a "$with_motif" != no ; then
1487   echo "error: must be yes or no: --with-motif=$with_motif"
1488   exit 1
1489 fi
1490
1491 if test "$with_motif" = yes; then
1492   have_motif=no
1493   AC_CHECK_X_HEADER(Xm/Xm.h,
1494                     [have_motif=yes
1495                      AC_DEFINE(HAVE_MOTIF)
1496                      MOTIF_LIBS="$MOTIF_LIBS -lXm"])
1497 fi
1498
1499
1500 ###############################################################################
1501 #
1502 #       Check for -lgtk.
1503 #
1504 ###############################################################################
1505
1506 have_gtk=no
1507 with_gtk_req=unspecified
1508 AC_ARG_WITH(gtk,
1509 [  --with-gtk              Use the Gtk toolkit for the user interface.],
1510   [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
1511
1512 # if --with-gtk=/directory/ was specified, remember that directory so that
1513 # we can also look for the `gtk-config' program in that directory.
1514 case "$with_gtk" in
1515   /*)
1516     gtk_dir="$with_gtk"
1517     ;;
1518   *)
1519     gtk_dir=""
1520     ;;
1521 esac
1522
1523 HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
1524
1525 if test "$with_gtk" != yes -a "$with_gtk" != no ; then
1526   echo "error: must be yes or no: --with-gtk=$with_gtk"
1527   exit 1
1528 fi
1529
1530 jurassic_gtk=no
1531 if test "$with_gtk" = yes; then
1532   have_gtk=no
1533   
1534   # if the user specified --with-gtk=/foo/ then look in /foo/bin/
1535   # for glib-config and gtk-config.
1536   #
1537   gtk_path="$PATH"
1538
1539   if test ! -z "$gtk_dir"; then
1540     # canonicalize slashes.
1541     gtk_dir=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
1542     gtk_path="$gtk_dir:$gtk_dir:$gtk_path"
1543   fi
1544
1545   AC_PATH_PROGS(glib_config, glib-config,, $gtk_path)
1546   AC_PATH_PROGS(gtk_config,  gtk-config,,  $gtk_path)
1547
1548   if test -n "$glib_config" -a  -n "gtk_config" ; then
1549     have_gtk=yes
1550   fi
1551   if test "$have_gtk" = yes; then
1552     AC_CACHE_CHECK([Gtk version number], ac_cv_gtk_version_string,
1553                    [ac_cv_gtk_version_string=`$glib_config --version`])
1554     ac_gtk_version_string=$ac_cv_gtk_version_string
1555     # M4 sucks!!
1556     changequote(X,Y)
1557     maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
1558     min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
1559     changequote([,])
1560     ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
1561     if test -z "$ac_gtk_version"; then
1562       ac_gtk_version=unknown
1563       ac_gtk_version_string=unknown
1564     fi
1565     if test "$ac_gtk_version" = "unknown" || test "$ac_gtk_version" -lt 1002
1566     then
1567       have_gtk=no
1568       jurassic_gtk=yes
1569     fi
1570   fi
1571   if test "$have_gtk" = yes; then
1572     AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
1573                    [ac_cv_gtk_config_cflags=`$gtk_config --cflags`])
1574     AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
1575                    [ac_cv_gtk_config_libs=`$gtk_config --libs`])
1576     INCLUDES="$INCLUDES $ac_cv_gtk_config_cflags"
1577     GTK_LIBS="$GTK_LIBS $ac_cv_gtk_config_libs"
1578     AC_DEFINE(HAVE_GTK)
1579   fi
1580 fi
1581
1582
1583 ###############################################################################
1584 #
1585 #       Check for -lXaw and -lXaw3d.
1586 #
1587 ###############################################################################
1588
1589 have_athena=no
1590 have_athena3d=no
1591 with_athena_req=unspecified
1592 AC_ARG_WITH(athena,
1593 [  --with-athena           Use the Athena toolkit for the user interface.],
1594   [with_athena="$withval"; with_athena_req="$withval"],[with_athena=yes])
1595
1596 HANDLE_X_PATH_ARG(with_athena, --with-athena, Athena)
1597
1598
1599 if test "$with_athena" != yes -a "$with_athena" != no ; then
1600   echo "error: must be yes or no: --with-athena=$with_athena"
1601   exit 1
1602 fi
1603
1604
1605 if test "$with_athena" = yes; then
1606   have_athena=no
1607   AC_CHECK_X_HEADER(X11/Xaw/Dialog.h, [have_athena=yes])
1608   if test "$have_athena" = yes; then
1609     AC_CHECK_X_LIB(Xaw3d, Xaw3dComputeTopShadowRGB,
1610                   [have_athena=yes; have_athena3d=yes], [true],
1611                   -lXt -lXmu -lXext -lX11)
1612   fi
1613 fi
1614
1615 if test "$have_athena" = yes; then
1616   AC_DEFINE(HAVE_ATHENA)
1617   ATHENA_LIBS="-lXaw $ATHENA_LIBS"
1618 fi
1619
1620 if test "$have_athena3d" = yes; then
1621   ATHENA3D_LIBS="-lXaw3d $ATHENA3D_LIBS"
1622 fi
1623
1624
1625 # If we have Athena, check whether it's a version that includes
1626 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
1627 if test "$have_athena" = yes ; then
1628   AC_CACHE_CHECK([for XawViewportSetCoordinates in Viewport.h], 
1629                  ac_cv_have_XawViewportSetCoordinates,
1630                  [ac_cv_have_XawViewportSetCoordinates=no
1631                   AC_EGREP_X_HEADER(XawViewportSetCoordinates, 
1632                                     X11/Xaw/Viewport.h,
1633                                     ac_cv_have_XawViewportSetCoordinates=yes)])
1634   if test "$ac_cv_have_XawViewportSetCoordinates" = yes ; then
1635     AC_DEFINE(HAVE_XawViewportSetCoordinates)
1636   fi
1637 fi
1638
1639
1640 ###############################################################################
1641 #
1642 #       Checking whether Motif is really Lesstif.
1643 #
1644 ###############################################################################
1645
1646 have_lesstif=no
1647 if test "$have_motif" = yes ; then
1648   AC_CACHE_CHECK([whether Motif is really LessTif], 
1649                  ac_cv_have_lesstif,
1650                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
1651                                    [long vers = LesstifVersion;],
1652                                    [ac_cv_have_lesstif=yes],
1653                                    [ac_cv_have_lesstif=no])])
1654   have_lesstif=$ac_cv_have_lesstif
1655 fi
1656
1657
1658 lesstif_version=unknown
1659 lesstif_version_string=unknown
1660
1661 if test "$have_lesstif" = yes ; then
1662   ltv=unknown
1663   echo unknown > conftest-lt
1664   AC_CACHE_CHECK([LessTif version number],
1665                  ac_cv_lesstif_version_string,
1666       [AC_TRY_X_RUN([#include <stdio.h>
1667                      #include <Xm/Xm.h>
1668                      int main() {
1669                        FILE *f = fopen("conftest-lt", "w");
1670                        if (!f) exit(1);
1671                        fprintf(f, "%d %d.%d\n", LesstifVersion,
1672                           LESSTIF_VERSION, LESSTIF_REVISION);
1673                        fclose(f);
1674                        exit(0);
1675                      }],
1676                     [ltv=`cat conftest-lt`
1677                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
1678                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
1679                     [ac_cv_lesstif_version=unknown
1680                      ac_cv_lesstif_version_string=unknown],
1681                     [ac_cv_lesstif_version=unknown
1682                      ac_cv_lesstif_version_string=unknown])])
1683   rm -f conftest-lt
1684   lesstif_version=$ac_cv_lesstif_version
1685   lesstif_version_string=$ac_cv_lesstif_version_string
1686
1687 fi
1688
1689
1690 if test "$have_motif" = yes ; then
1691   mtv=unknown
1692   echo unknown > conftest-mt
1693   AC_CACHE_CHECK([Motif version number],
1694                  ac_cv_motif_version_string,
1695       [AC_TRY_X_RUN([#include <stdio.h>
1696                      #include <Xm/Xm.h>
1697                      int main() {
1698                        FILE *f = fopen("conftest-mt", "w");
1699                        if (!f) exit(1);
1700                        fprintf(f, "%d %d.%d\n", XmVersion,
1701                           XmVERSION, XmREVISION);
1702                        fclose(f);
1703                        exit(0);
1704                      }],
1705                     [mtv=`cat conftest-mt`
1706                      ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
1707                      ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
1708                     [ac_cv_motif_version=unknown
1709                      ac_cv_motif_version_string=unknown],
1710                     [ac_cv_motif_version=unknown
1711                      ac_cv_motif_version_string=unknown])])
1712   rm -f conftest-mt
1713   motif_version=$ac_cv_motif_version
1714   motif_version_string=$ac_cv_motif_version_string
1715
1716 fi
1717
1718
1719 ###############################################################################
1720 #
1721 #       Checking whether Motif requires -lXpm.
1722 #
1723 #       If this is Motif 2.x, and we have XPM, then link against XPM as well.
1724 #       The deal is, Motif 2.x requires XPM -- but it's a compilation option
1725 #       of the library whether to build the XPM code into libXm, or whether
1726 #       to rely on an external libXm.  So the only way to tell whether XPM is
1727 #       a link-time requirement is to examine libXm.a, which is very
1728 #       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
1729 #       always link against XPM if the XPM lib exists (and this will be a
1730 #       no-op if libXm happens to already have the XPM code in it.)
1731 #
1732 ###############################################################################
1733
1734 motif_requires_xpm=no
1735 if test "$have_motif" = yes ; then
1736    AC_MSG_CHECKING(whether Motif requires XPM)
1737    if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
1738    then
1739      motif_requires_xpm=yes
1740      AC_MSG_RESULT(maybe)
1741    else
1742      AC_MSG_RESULT(no)
1743    fi
1744 fi
1745
1746
1747 ###############################################################################
1748 #
1749 #       Checking whether Motif requires -lXp.
1750 #
1751 #       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
1752 #       Extension".   Why this extension isn't in -lXext with all the others,
1753 #       I have no idea.
1754 #
1755 ###############################################################################
1756
1757 have_xp_ext=no
1758 if test "$have_motif" = yes ; then
1759    have_xp_ext=no
1760    AC_CHECK_X_LIB(Xp, XpQueryExtension,
1761                   [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
1762                   [true], -lX11 -lXext -lm)
1763 fi
1764
1765
1766 ###############################################################################
1767 #
1768 #       Checking whether Motif requires -lXintl (for _Xsetlocale.)
1769 #
1770 ###############################################################################
1771
1772 have_xintl=no
1773 if test "$have_motif" = yes ; then
1774   AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
1775                  -lX11 -lXext -lm)
1776   if test "$have_xintl" = yes; then
1777     MOTIF_LIBS="$MOTIF_LIBS -lXintl"
1778   fi
1779 fi
1780
1781
1782 ###############################################################################
1783 #
1784 #       Check for -lGL or -lMesa.
1785 #
1786 ###############################################################################
1787
1788 have_gl=no
1789 ac_have_mesa_gl=no
1790 with_gl_req=unspecified
1791 AC_ARG_WITH(gl,[
1792 Graphics options:
1793
1794   --with-gl               Build those demos which depend on OpenGL.],
1795   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
1796
1797 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
1798
1799 ac_mesagl_version=unknown
1800 ac_mesagl_version_string=unknown
1801
1802 if test "$with_gl" = yes; then
1803   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
1804   if test "$have_gl" = yes ; then
1805     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
1806   fi
1807
1808   # If we have the headers, try and figure out which vendor it's from.
1809   #
1810   if test "$have_gl" = yes ; then
1811
1812     # We need to know whether it's MesaGL so that we know which libraries
1813     # to link against.
1814     #
1815     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
1816       [ac_cv_have_mesa_gl=no
1817        AC_EGREP_X_HEADER(Mesa, GL/glx.h, [ac_cv_have_mesa_gl=yes])
1818       ])
1819     ac_have_mesa_gl=$ac_cv_have_mesa_gl
1820  
1821
1822     # If we have Mesa headers, check to see if we can link against -lMesaGL.
1823     # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
1824     # Else, warn that GL is busted.  (We have the headers, but no libs.)
1825     #
1826     gl_lib_1=""
1827     GL_LIBS=""
1828
1829     if test "$ac_have_mesa_gl" = yes ; then
1830       AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
1831                      [gl_lib_1="MesaGL"
1832                       GL_LIBS="-lMesaGL -lMesaGLU"],
1833                      [], -lMesaGLU -lX11 -lXext -lm)
1834     fi
1835
1836     if test "$gl_lib_1" = "" ; then
1837       AC_CHECK_X_LIB(GL, glXCreateContext, 
1838                      [gl_lib_1="GL"
1839                       GL_LIBS="-lGL -lGLU"],
1840                      [], -lGLU -lX11 -lXext -lm)
1841     fi
1842
1843     if test "$gl_lib_1" = "" ; then
1844       # we have headers, but no libs -- bail.
1845       have_gl=no
1846       ac_have_mesa_gl=no
1847     else
1848       # linking works -- we can build the GL hacks.
1849       AC_DEFINE(HAVE_GL)
1850       if test "$ac_have_mesa_gl" = yes ; then
1851         AC_DEFINE(HAVE_MESA_GL)
1852       fi
1853     fi
1854   fi
1855
1856
1857   # Now that we know we have GL headers and libs, do some more GL testing.
1858   #
1859
1860   if test "$have_gl" = yes ; then
1861     # If it's MesaGL, we'd like to issue a warning if the version number
1862     # is less than or equal to 2.6, because that version had a security bug.
1863     #
1864     if test "$ac_have_mesa_gl" = yes; then
1865
1866       AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
1867         [cat > conftest.$ac_ext <<EOF
1868 #line __oline__ "configure"
1869 #include "confdefs.h"
1870 #include <GL/gl.h>
1871 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
1872 EOF
1873
1874          ac_save_CPPFLAGS="$CPPFLAGS"
1875          if test \! -z "$includedir" ; then 
1876            CPPFLAGS="$CPPFLAGS -I$includedir"
1877          fi
1878          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1879
1880           # M4 sucks!!
1881          changequote(X,Y)
1882          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
1883               's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
1884          changequote([,])
1885
1886          rm -f conftest.$ac_ext
1887
1888          CPPFLAGS="$ac_save_CPPFLAGS"
1889
1890          if test "$mglv" = ""; then
1891            ac_mesagl_version=unknown
1892            ac_mesagl_version_string=unknown
1893          else
1894            ac_mesagl_version_string=$mglv
1895            maj=`echo $mglv | sed -n 's/\..*//p'`
1896            min=`echo $mglv | sed -n 's/.*\.//p'`
1897            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
1898            if test -z "$ac_mesagl_version"; then
1899              ac_mesagl_version=unknown
1900              ac_mesagl_version_string=unknown
1901            fi
1902          fi
1903          ac_cv_mesagl_version=$ac_mesagl_version
1904          ac_cv_mesagl_version_string=$ac_mesagl_version_string
1905       ])
1906       ac_mesagl_version=$ac_cv_mesagl_version
1907       ac_mesagl_version_string=$ac_cv_mesagl_version_string
1908     fi
1909
1910
1911     # If it's MesaGL, check to see if it requires -lpthread.
1912     #
1913     have_pthread=no
1914     mesa_requires_pthread=no
1915     if test "$ac_have_mesa_gl" = yes; then
1916
1917       AC_CHECK_LIB(pthread, pthread_create, [have_pthread=yes], [],)
1918       if test "$have_pthread" = yes; then
1919         AC_CHECK_X_LIB($gl_lib_1, gl_get_thread_context,
1920                        [mesa_requires_pthread=yes], [true],
1921                        $GL_LIBS -lpthread -lX11 -lXext -lm)
1922       fi
1923
1924       if test "$mesa_requires_pthread" = yes; then
1925         GL_LIBS="$GL_LIBS -lpthread"
1926       fi
1927     fi
1928
1929     # Check for OpenGL 1.1 features.
1930     #
1931     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
1932                    [true], $GL_LIBS -lX11 -lXext -lm)
1933
1934
1935     # Check whether the `xscreensaver' executable should link against GL.
1936     # See comments in utils/visual-gl.c for why this is sometimes necessary.
1937     #
1938     AC_MSG_CHECKING(whether drastic GL measures must be taken)
1939     case "$host" in
1940       *-sgi*)
1941         AC_MSG_RESULT([yes -- hello, SGI.])
1942         AC_DEFINE(DAEMON_USE_GL)
1943         SAVER_GL_SRCS='$(UTILS_SRC)/visual-gl.c'
1944         SAVER_GL_OBJS='$(UTILS_BIN)/visual-gl.o'
1945         SAVER_GL_LIBS="$GL_LIBS"
1946       ;;
1947       *)
1948         AC_MSG_RESULT([no -- non-SGI.])
1949         SAVER_GL_SRCS=''
1950         SAVER_GL_OBJS=''
1951         SAVER_GL_LIBS=''
1952       ;;
1953     esac
1954
1955   fi
1956
1957 elif test "$with_gl" != no; then
1958   echo "error: must be yes or no: --with-gl=$with_gl"
1959   exit 1
1960 fi
1961
1962
1963 ###############################################################################
1964 #
1965 #       Check for -lXpm.
1966 #
1967 ###############################################################################
1968
1969 have_xpm=no
1970 with_xpm_req=unspecified
1971 AC_ARG_WITH(xpm,
1972 [  --with-xpm              Include support for XPM files in some demos.],
1973   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
1974
1975 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
1976
1977 if test "$with_xpm" = yes; then
1978   AC_CHECK_X_HEADER(X11/xpm.h,
1979                    [have_xpm=yes
1980                     AC_DEFINE(HAVE_XPM)
1981                     XPM_LIBS="-lXpm"])
1982 elif test "$with_xpm" != no; then
1983   echo "error: must be yes or no: --with-xpm=$with_xpm"
1984   exit 1
1985 fi
1986
1987 # See comment near $motif_requires_xpm, above.
1988 # Need to do this here, after both Motif and XPM have been checked for.
1989 #
1990 if test "$have_motif" = yes -a "$have_xpm" = yes ; then
1991   if test "$motif_requires_xpm" = yes ; then
1992     MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
1993   fi
1994 fi
1995
1996
1997 ###############################################################################
1998 #
1999 #       Check for the XSHM server extension.
2000 #
2001 ###############################################################################
2002
2003 have_xshm=no
2004 with_xshm_req=unspecified
2005 AC_ARG_WITH(xshm-ext,
2006 [  --with-xshm-ext         Include support for the XSHM extension.],
2007   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
2008
2009 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
2010
2011 if test "$with_xshm" = yes; then
2012
2013   # first check for Xshm.h.
2014   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes])
2015
2016   # if that succeeded, then check for sys/ipc.h.
2017   if test "$have_xshm" = yes; then
2018     have_xshm=no
2019     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
2020   fi
2021
2022   # if that succeeded, then check for sys/shm.h.
2023   if test "$have_xshm" = yes; then
2024     have_xshm=no
2025     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
2026   fi
2027
2028   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
2029   # to exist, but the library code to not exist.  And even better, the library
2030   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
2031   # lib doesn't exist, give up.  (This lib gets added to X_EXTRA_LIBS, and
2032   # that's not quite right, but close enough.)
2033   #
2034   case "$host" in
2035     *-aix*)
2036       have_xshm=no
2037       AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
2038                      [have_xshm=yes; X_EXTRA_LIBS="$X_EXTRA_LIBS -lXextSam"],
2039                      [true], -lX11 -lXext -lm)
2040     ;;
2041   esac
2042
2043   # if that succeeded, then we've really got it.
2044   if test "$have_xshm" = yes; then
2045     AC_DEFINE(HAVE_XSHM_EXTENSION)
2046   fi
2047
2048 elif test "$with_xshm" != no; then
2049   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
2050   exit 1
2051 fi
2052
2053
2054 ###############################################################################
2055 #
2056 #       Check for the DOUBLE-BUFFER server extension.
2057 #
2058 ###############################################################################
2059
2060 have_xdbe=no
2061 with_xdbe_req=unspecified
2062 AC_ARG_WITH(xdbe-ext,
2063 [  --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension.],
2064   [with_xdbe="$withval"; with_xdbe_req="$withval"],[with_xdbe=yes])
2065
2066 HANDLE_X_PATH_ARG(with_xdbe, --with-xdbe-ext, DOUBLE-BUFFER)
2067
2068 if test "$with_xdbe" = yes; then
2069
2070   AC_CHECK_X_HEADER(X11/extensions/Xdbe.h, [have_xdbe=yes])
2071   if test "$have_xdbe" = yes; then
2072     AC_DEFINE(HAVE_DOUBLE_BUFFER_EXTENSION)    
2073   fi
2074
2075 elif test "$with_xdbe" != no; then
2076   echo "error: must be yes or no: --with-xdbe-ext=$with_xshm"
2077   exit 1
2078 fi
2079
2080
2081 ###############################################################################
2082 #
2083 #       Check for the SGI XReadDisplay server extension.
2084 #
2085 #       Note: this has to be down here, rather than up with the other server
2086 #       extension tests, so that the output of `configure --help' is in the
2087 #       right order.  Arrgh!
2088 #
2089 ###############################################################################
2090
2091 have_readdisplay=no
2092 with_readdisplay_req=unspecified
2093 AC_ARG_WITH(readdisplay,
2094 [  --with-readdisplay      Include support for the XReadDisplay extension.],
2095   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
2096   [with_readdisplay=yes])
2097
2098 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
2099
2100 if test "$with_readdisplay" = yes; then
2101   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
2102                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
2103 elif test "$with_readdisplay" != no; then
2104   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
2105   exit 1
2106 fi
2107
2108
2109 ###############################################################################
2110 #
2111 #       Check for the SGI Iris Video Library.
2112 #
2113 ###############################################################################
2114
2115 have_sgivideo=no
2116 with_sgivideo_req=unspecified
2117 AC_ARG_WITH(sgivideo,
2118 [  --with-sgivideo         Include support for SGI's Iris Video Library.],
2119   [with_sgivideo="$withval"; with_sgivideo_req="$withval"],
2120   [with_sgivideo=yes])
2121
2122 HANDLE_X_PATH_ARG(with_sgivideo, --with-sgivideo, Iris Video)
2123
2124 if test "$with_sgivideo" = yes; then
2125   AC_CHECK_X_HEADER(dmedia/vl.h, have_sgivideo=yes)
2126   if test "$have_sgivideo" = yes; then
2127     have_sgivideo=no
2128     AC_CHECK_LIB(vl, vlOpenVideo, [have_sgivideo=yes])
2129     if test "$have_sgivideo" = yes; then
2130       SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
2131       SGI_VIDEO_LIBS="-lvl"
2132       AC_DEFINE(HAVE_SGI_VIDEO)
2133     fi
2134   fi
2135 elif test "$with_sgivideo" != no; then
2136   echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
2137   exit 1
2138 fi
2139
2140
2141 ###############################################################################
2142 #
2143 #       Check for a program to generate random text.
2144 #
2145 #       Zippy is funnier than the idiocy generally spat out by `fortune',
2146 #       so try to find that, by invoking Emacs and asking it where its 
2147 #       libexec directory is ("yow" lives in there.)
2148 #
2149 #       If that doesn't work, see if fortune, zippy, or yow are on $PATH,
2150 #       and if so, use them.
2151 #
2152 #       If that doesn't work, look in /usr/games, and if it's there, use
2153 #       the full pathname.
2154 #
2155 ###############################################################################
2156
2157 with_zippy_req=""
2158 AC_ARG_WITH(zippy,[
2159   --with-zippy=PROGRAM    Some demos are able to run an external program and
2160                           display its text; this names the program to use by
2161                           default (though it can be overridden with X
2162                           resources.)  If you don't specify this, the default
2163                           is to use \"yow\" from the Emacs distribution (if you
2164                           have it) or else to use \"fortune\".
2165 ],
2166   [with_zippy_req="$withval"; with_zippy="$withval"],[with_zippy=yes])
2167
2168 if test "$with_zippy" = no || test "$with_zippy" = yes ; then
2169   with_zippy=""
2170   with_zippy_req=""
2171 fi
2172
2173 if test -n "$with_zippy_req" ; then
2174   ac_cv_zippy_program=""
2175   case "$with_zippy_req" in
2176     /*)
2177       AC_MSG_CHECKING([for $with_zippy_req])
2178       if test -x "$with_zippy_req" ; then
2179         AC_MSG_RESULT(yes)
2180       else
2181         AC_MSG_RESULT(no)
2182         with_zippy=""
2183       fi
2184     ;;
2185     *)
2186       # don't cache
2187       unset ac_cv_path_zip2
2188       AC_PATH_PROG(zip2, $with_zippy_req, [])
2189       if test "$zip2" = ""; then
2190         with_zippy=""
2191       fi
2192     ;;
2193   esac
2194   ac_cv_zippy_program="$with_zippy"
2195
2196 elif test -n "$ac_cv_zippy_program"; then
2197   AC_MSG_RESULT([checking for zippy... (cached) $ac_cv_zippy_program])
2198 fi
2199
2200 if test ! -n "$ac_cv_zippy_program"; then
2201
2202   AC_CHECK_PROGS(emacs_exe, emacs)
2203   AC_CHECK_PROGS(xemacs_exe, xemacs)
2204
2205   ac_cv_zippy_program=""
2206   eargs='-batch -q -nw --eval'
2207
2208   if test -n "$emacs_exe" ; then
2209     AC_MSG_CHECKING([for emacs yow])
2210     #
2211     # get emacs to tell us where the libexec directory is.
2212     #
2213     dir=`$emacs_exe $eargs '(princ (concat exec-directory "\n"))' \
2214          2>/dev/null | tail -1`
2215     dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
2216     #
2217     # try running libexec/yow and see if it exits without error.
2218     #
2219     if test x"$dir" != x -a -x "$dir/yow" ; then
2220       if $dir/yow >&- 2>&- ; then
2221         ac_cv_zippy_program="$dir/yow"
2222         AC_MSG_RESULT($ac_cv_zippy_program)
2223       else
2224         AC_MSG_RESULT(no)
2225       fi
2226     fi
2227   fi
2228
2229   if test -z "$ac_cv_zippy_program" ; then
2230     AC_MSG_CHECKING([for xemacs yow])
2231     if test -n "$xemacs_exe" ; then
2232       #
2233       # get xemacs to tell us where the libexec directory is.
2234       #
2235       dir=`$xemacs_exe $eargs '(princ (concat exec-directory "\n"))' \
2236            2>/dev/null | tail -1`
2237       dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
2238       #
2239       # try running libexec/yow and see if it exits without error.
2240       #
2241       if test x"$dir" != x -a -x "$dir/yow" ; then
2242         if $dir/yow >&- 2>&- ; then
2243           ac_cv_zippy_program="$dir/yow"
2244           AC_MSG_RESULT($ac_cv_zippy_program)
2245         else
2246           #
2247           # in some xemacs installations, the pathname of the yow.lines file
2248           # isn't hardcoded into the yow executable, and must be passed on 
2249           # the command line.  See if it's in libexec/../etc/.
2250
2251           # M4 sucks!!
2252           changequote(X,Y)
2253           dir_up=`echo "$dir" | sed 's@/[^/]*$@@'`
2254           changequote([,])
2255
2256           yowlines="$dir_up/etc/yow.lines"
2257           if $dir/yow -f $yowlines >&- 2>&- ; then
2258             ac_cv_zippy_program="$dir/yow -f $yowlines"
2259             AC_MSG_RESULT($ac_cv_zippy_program)
2260           else
2261             #
2262             # In newer XEmacs releases, yow.lines is in a different place,
2263             # and the easiest way to get it is by calling the new function
2264             # `locate-data-file'.
2265             #
2266             yowlines=`$xemacs_exe $eargs \
2267               '(princ (concat (locate-data-file "yow.lines") "\n"))' \
2268               2>/dev/null | tail -1`
2269             if $dir/yow -f $yowlines >&- 2>&- ; then
2270               ac_cv_zippy_program="$dir/yow -f $yowlines"
2271               AC_MSG_RESULT($ac_cv_zippy_program)
2272             else
2273               AC_MSG_RESULT(no)
2274             fi
2275           fi
2276         fi
2277       fi
2278     fi
2279   fi
2280
2281   # if that didn't work, try for some other programs...
2282   if test -z "$ac_cv_zippy_program" ; then
2283     fortune=''
2284     AC_CHECK_PROGS(fortune, [fortune zippy yow])
2285     # if that didn't work, try for those programs in /usr/games...
2286     if test -z "$fortune" ; then
2287       AC_PATH_PROGS(fortune, [fortune zippy yow], fortune,
2288                     /usr/games:/usr/local/games:$PATH)
2289     fi
2290   fi
2291 fi
2292
2293 if test -z "$ac_cv_zippy_program" ; then
2294   ac_cv_zippy_program=fortune
2295 fi
2296
2297 AC_DEFINE_UNQUOTED(ZIPPY_PROGRAM, "$ac_cv_zippy_program")
2298
2299
2300 ###############################################################################
2301 #
2302 #       Done testing.  Now, set up the various -I and -L variables,
2303 #       and decide which GUI program to build by default.
2304 #
2305 ###############################################################################
2306
2307 DEPEND=makedepend
2308 DEPEND_FLAGS=
2309 DEPEND_DEFINES=
2310
2311
2312 if test \! -z "$includedir" ; then 
2313   INCLUDES="$INCLUDES -I$includedir"
2314 fi
2315
2316 if test \! -z "$libdir" ; then
2317   LDFLAGS="$LDFLAGS -L$libdir"
2318 fi
2319
2320
2321 ALL_DEMO_PROGRAMS=
2322 if test "$have_athena3d" = yes; then
2323   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xaw3d
2324   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2325 fi
2326 if test "$have_athena" = yes; then
2327   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xaw
2328   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2329 fi
2330 if test "$have_gtk" = yes; then
2331   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
2332   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2333 fi
2334 if test "$have_motif" = yes; then
2335   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
2336   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2337 fi
2338
2339
2340 if test "$have_kerberos" = yes; then
2341   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
2342   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
2343 fi
2344 if test "$have_pam" = yes; then
2345   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
2346   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
2347   INSTALL_PAM="install-pam"
2348 fi
2349   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
2350   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
2351
2352
2353 if test "$enable_locking" = yes; then
2354   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
2355   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
2356 else
2357   LOCK_SRCS=''
2358   LOCK_OBJS=''
2359 fi
2360
2361 if test "$need_setuid" = yes; then
2362   NEED_SETUID=yes
2363   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
2364 else
2365   NEED_SETUID=no
2366   INSTALL_SETUID='$(INSTALL_PROGRAM)'
2367 fi
2368
2369 tab='   '
2370 if test "$have_gl" = yes; then
2371   GL_EXES='$(GL_EXES)'
2372   GL_MEN='$(GL_MEN)'
2373   GL_KLUDGE="${tab}  "
2374 else
2375   GL_KLUDGE="  -${tab}  "
2376 fi
2377
2378
2379 ###############################################################################
2380 #
2381 #       Perform substitutions and write Makefiles.
2382 #
2383 ###############################################################################
2384
2385 AC_SUBST(INCLUDES)
2386
2387 AC_SUBST(PREFERRED_DEMO_PROGRAM)
2388 AC_SUBST(ALL_DEMO_PROGRAMS)
2389 AC_SUBST(SAVER_LIBS)
2390 AC_SUBST(MOTIF_LIBS)
2391 AC_SUBST(GTK_LIBS)
2392 AC_SUBST(ATHENA_LIBS)
2393 AC_SUBST(ATHENA3D_LIBS)
2394 AC_SUBST(HACK_LIBS)
2395 AC_SUBST(XPM_LIBS)
2396 AC_SUBST(GL_LIBS)
2397 AC_SUBST(PASSWD_LIBS)
2398 AC_SUBST(INSTALL_SETUID)
2399 AC_SUBST(INSTALL_DIRS)
2400 AC_SUBST(NEED_SETUID)
2401 AC_SUBST(INSTALL_PAM)
2402 AC_SUBST(SGI_VIDEO_OBJS)
2403 AC_SUBST(SGI_VIDEO_LIBS)
2404
2405 AC_SUBST(PASSWD_SRCS)
2406 AC_SUBST(PASSWD_OBJS)
2407 AC_SUBST(XMU_SRCS)
2408 AC_SUBST(XMU_OBJS)
2409 AC_SUBST(SAVER_GL_SRCS)
2410 AC_SUBST(SAVER_GL_OBJS)
2411 AC_SUBST(SAVER_GL_LIBS)
2412 AC_SUBST(LOCK_SRCS)
2413 AC_SUBST(LOCK_OBJS)
2414 AC_SUBST(GL_EXES)
2415 AC_SUBST(GL_MEN)
2416 AC_SUBST(GL_KLUDGE)
2417 AC_SUBST(HACKDIR)
2418
2419 APPDEFAULTS=$ac_x_app_defaults
2420 AC_SUBST(APPDEFAULTS)
2421
2422 AC_SUBST(DEPEND)
2423 AC_SUBST(DEPEND_FLAGS)
2424 AC_SUBST(DEPEND_DEFINES)
2425 AC_SUBST(PERL)
2426
2427 AC_OUTPUT(Makefile
2428           utils/Makefile
2429           driver/Makefile
2430           hacks/Makefile
2431           hacks/glx/Makefile
2432           driver/XScreenSaver.ad)
2433
2434 ###############################################################################
2435 #
2436 #       Print some warnings at the end.
2437 #
2438 ###############################################################################
2439
2440 warn_prefix_1="    Warning:"
2441 warn_prefix_2="       Note:"
2442 warn_prefix="$warn_prefix_1"
2443
2444 warning=no
2445 warnsep='    #################################################################'
2446
2447 warnpre() {
2448   if test "$warning" = no ; then
2449     echo '' ; echo "$warnsep" ; echo ''
2450     warning=yes
2451   fi
2452 }
2453
2454 warn() {
2455   warnpre
2456   if test "$warning" = long ; then echo '' ; fi
2457   warning=yes
2458   echo "$warn_prefix $@"
2459 }
2460
2461 warnL() {
2462   was=$warning
2463   warnpre
2464   warning=yes
2465   if test "$was" != no ; then echo '' ; fi
2466   echo "$warn_prefix $@"
2467 }
2468
2469 warn2() {
2470   echo "             $@"
2471   warning=long
2472 }
2473
2474 note() {
2475   warn_prefix="$warn_prefix_2"
2476   warn $@
2477   warn_prefix="$warn_prefix_1"
2478 }
2479
2480 noteL() {
2481   warn_prefix="$warn_prefix_2"
2482   warnL $@
2483   warn_prefix="$warn_prefix_1"
2484 }
2485
2486
2487 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
2488   warn 'The SGI saver extension was requested, but was not found.'
2489 fi
2490
2491 if test "$with_mit_req" = yes -a "$have_mit" = no ; then
2492   warn 'The MIT saver extension was requested, but was not found.'
2493 fi
2494
2495 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
2496   warn 'The XIdle extension was requested, but was not found.'
2497 fi
2498
2499 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
2500   warn 'The XSHM extension was requested, but was not found.'
2501 fi
2502
2503 if test "$with_xdbe_req" = yes -a "$have_xdbe" = no ; then
2504   warn 'The DOUBLE-BUFFER extension was requested, but was not found.'
2505 fi
2506
2507 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
2508   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
2509 fi
2510
2511 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
2512   warn 'The DPMS extension was requested, but was not found.'
2513 fi
2514
2515 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
2516   warn 'The XF86VMODE extension was requested, but was not found.'
2517 fi
2518
2519 if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
2520   warn "Checking of /proc/interrupts was requested, but it's bogus."
2521 fi
2522
2523
2524 if test "$have_motif" = no -a "$have_gtk" = no -a "$have_athena" = no ; then
2525   warnL "None of Motif, Gtk, or Athena widgets seem to be available;"
2526   warn2 "the \`xscreensaver-demo' program requires one of these."
2527
2528 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
2529   warnL "Use of Motif was requested, but it wasn't found;"
2530   if test "$have_gtk" = yes; then
2531     warn2 "Gtk will be used instead."
2532   else
2533     warn2 "Athena will be used instead."
2534   fi
2535
2536 elif test "$jurassic_gtk" = yes ; then
2537
2538   pref_gtk=1.2
2539
2540   v="$ac_gtk_version_string"
2541   if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
2542     warnL "Use of Gtk was requested, but its version number is unknown;"
2543   elif test "$with_gtk_req" = yes ; then
2544     warnL "Use of Gtk was requested, but it is version $v;"
2545   else
2546     warnL "Gtk was found on this system, but it is version $v;"
2547   fi
2548
2549   if test "$have_motif" = yes; then
2550     which="Motif"
2551   else
2552     which="Athena"
2553   fi
2554
2555   warn2 "Gtk $pref_gtk or newer is required.  $which will be used instead."
2556
2557 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
2558   warnL "Use of Gtk was requested, but it wasn't found;"
2559   if test "$have_motif" = yes; then
2560     warn2 "Motif will be used instead."
2561   else
2562     warn2 "Athena will be used instead."
2563   fi
2564
2565 elif test "$with_athena_req" = yes -a "$have_athena" = no ; then
2566   warnL "Use of Athena was requested, but it wasn't found;"
2567   if test "$have_gtk" = yes; then
2568     warn2 "Gtk will be used instead."
2569   else
2570     warn2 "Motif will be used instead."
2571   fi
2572 fi
2573
2574
2575 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
2576
2577   preferred_lesstif=0.86
2578
2579   if test "$lesstif_version" = unknown; then
2580     warnL "Unable to determine the LessTif version number!"
2581     warn2 "Make sure you are using version $preferred_lesstif or newer."
2582     warn2 "See <http://www.lesstif.org/>."
2583
2584   elif test \! $lesstif_version -gt 82; then
2585     warnL "LessTif version $lesstif_version_string is being used."
2586     warn2 "LessTif versions 0.82 and earlier are too buggy to"
2587     warn2 "use with XScreenSaver; it is strongly recommended"
2588     warn2 "that you upgrade to at least version $preferred_lesstif!"
2589     warn2 "See <http://www.lesstif.org/>."
2590   fi
2591 fi
2592
2593 if test "$have_athena" = yes -a "$have_motif" = no -a "$have_gtk" = no; then
2594     warnL "Athena widgets are being used instead of Motif or Gtk."
2595     warn2 "The \`xscreensaver-demo' program looks much better"
2596     warn2 "with Motif or Gtk.  Wouldn't you rather be using Motif?"
2597     warn2 "Motif is shipped by every commercial Unix vendor,"
2598     warn2 "and there is a free implementation available as"
2599     warn2 "well: see <http://www.lesstif.org/>.  Gtk is shipped"
2600     warn2 "with most Linux and BSD distributions."
2601 fi
2602
2603
2604 if test "$have_xpm" = no ; then
2605   if test "$with_xpm_req" = yes ; then
2606     warnL 'Use of XPM was requested, but it was not found.'
2607   elif test "$with_xpm_req" = no ; then
2608     noteL 'The XPM library is not being used.'
2609   else
2610     noteL 'The XPM library was not found.'
2611   fi
2612
2613   echo ''
2614   warn2 'Some of the demos will not be as colorful as they'
2615   warn2 'could be.  You might want to consider installing XPM'
2616   warn2 'and re-running configure.  (Remember to delete the'
2617   warn2 'config.cache file first.)  You can find XPM at most'
2618   warn2 'X11 archive sites, such as <http://sunsite.unc.edu/>.'
2619 fi
2620
2621
2622 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
2623   preferred_mesagl=3.0
2624
2625   if test "$ac_mesagl_version" = unknown; then
2626     warnL "Unable to determine the MesaGL version number!"
2627     warn2 "Make sure you are using version $preferred_mesagl or newer."
2628
2629   elif test \! "$ac_mesagl_version" -gt 2006; then
2630     warnL "MesaGL version $ac_mesagl_version_string is being used."
2631     warn2 "MesaGL versions 2.6 and earlier have a security bug."
2632     warn2 "It is strongly recommended that you upgrade to at"
2633     warn2 "least version $preferred_mesagl."
2634   fi
2635 fi
2636
2637
2638 if test "$have_gl" = no ; then
2639   if test "$with_gl_req" = yes ; then
2640     warnL 'Use of GL was requested, but it was not found.'
2641   elif test "$with_gl_req" = no ; then
2642     noteL 'The OpenGL 3D library is not being used.'
2643   else
2644     noteL 'The OpenGL 3D library was not found.'
2645   fi
2646
2647   echo ''
2648   warn2 'Those demos which use 3D will not be built or installed.'
2649   warn2 'You might want to consider installing OpenGL and'
2650   warn2 're-running configure.  (Remember to delete the'
2651   warn2 "config.cache file first.)  If your vendor doesn't ship"
2652   warn2 'their own implementation of OpenGL, you can get a free'
2653   warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
2654   warn2 'info, see <http://www.opengl.org/>.'
2655
2656 fi
2657
2658 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
2659   warn 'Use of XReadDisplay was requested, but it was not found.'
2660 fi
2661
2662 if test "$with_sgivideo_req" = yes -a "$have_sgivideo" = no ; then
2663   warn 'Use of the Iris Video Library was requested, but it was not found.'
2664 fi
2665
2666 if test -n "$with_zippy_req"; then
2667   if test "$with_zippy_req" != "$ac_cv_zippy_program" ; then
2668     warnL "$with_zippy_req was requested as the Zippy program,"
2669     warn2 "but was not found.  The default will be used instead."
2670   fi
2671 fi
2672
2673 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
2674   warn 'Use of Kerberos was requested, but it was not found.'
2675 fi
2676
2677 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
2678   warn 'Use of PAM was requested, but it was not found.'
2679 fi
2680
2681 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
2682   warn 'Use of shadow passwords was requested, but they were not found.'
2683 fi
2684
2685
2686 # You are in a twisty maze of namespaces and syntaxes, all alike.
2687 # Fuck the skull of Unix.
2688 #
2689 eval bindir=${bindir}
2690 eval bindir=${bindir}
2691 eval bindir=${bindir}
2692 eval bindir=${bindir}
2693 eval bindir=${bindir}
2694 eval bindir=${bindir}
2695 eval HACKDIR=${HACKDIR}
2696 eval HACKDIR=${HACKDIR}
2697 eval HACKDIR=${HACKDIR}
2698 eval HACKDIR=${HACKDIR}
2699 eval HACKDIR=${HACKDIR}
2700 eval HACKDIR=${HACKDIR}
2701
2702 # canonicalize slashes.
2703 bindir=`echo  "${bindir}"  | sed 's@/$@@;s@//*@/@g'`
2704 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
2705
2706
2707 # Sanity check the subdir
2708 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
2709   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
2710     echo ""
2711     AC_MSG_ERROR([\"--enable-subdir=${bindir}/${bad_choice}\" won't work.
2712                    There will be an executable installed with that name, so
2713                    that can't be the name of a directory as well.  Please
2714                    re-configure with a different directory name.])
2715   fi
2716 done
2717
2718
2719 do_dir_warning=no
2720
2721 # Now let's see if there's a previous RPM version already installed.  Blargh!
2722
2723 # M4 sucks!!
2724 changequote(X,Y)
2725 rpmv=`(rpm -qv xscreensaver) 2>&- | \
2726       sed 's/^xscreensaver-\([0-9][0-9]*[.][0-9][0-9]*\)-[0-9][0-9]*$/\1/'`
2727 changequote([,])
2728
2729 if test \! -z "$rpmv" ; then
2730   rpmbdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/xscreensaver-demo$@\1@p'`
2731   rpmhdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/attraction$@\1@p'`
2732
2733   warning=no
2734   warnL "There is already an installed RPM of xscreensaver $rpmv"
2735   warn2 "on this system.  You might want to remove it (with"
2736   warn2 '"rpm -ve xscreensaver") before running "make install"'
2737   warn2 "from this directory."
2738   echo ""
2739   warn2 "Alternately, you could build this version of xscreensaver"
2740   warn2 'as an RPM, and then install that.  An "xscreensaver.spec"'
2741   warn2 "file is included.  See the RPM documentation for more info."
2742   echo ""
2743
2744   if test "$rpmbdir" = "$rpmhdir" ; then
2745     warn2 "The RPM version was installed in $rpmbdir."
2746   else
2747     warn2 "The RPM version was installed in $rpmbdir,"
2748     warn2 "with demos in $rpmhdir."
2749   fi
2750
2751   do_dir_warning=yes
2752 fi
2753
2754
2755 # Warn about egregious GNOME bogosity.
2756 #
2757 if (rpm -qv control-center) >&- 2>&- ; then
2758   warning=no
2759   warnL "The Gnome Control Center seems to be installed."
2760   echo  ""
2761   warn2 "Note that simply installing this version of xscreensaver"
2762   warn2 "will not cause GNOME to know about the newly-added display"
2763   warn2 "modes -- GNOME is just lame that way.  Instead of using the"
2764   warn2 "Control Center, try using the \`xscreensaver-demo' command."
2765 fi
2766
2767
2768 if test "${bindir}" = "${HACKDIR}" ; then
2769   do_dir_warning=yes
2770 fi
2771
2772 if test "$do_dir_warning" = yes; then
2773   echo ""
2774   echo "$warnsep"
2775   echo ""
2776   echo '      When you run "make install", the "xscreensaver",'
2777   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
2778   echo "      will be installed in ${bindir}."
2779   echo ""
2780   echo "      The various graphics demos (100+ different executables) will"
2781   echo "      also be installed in ${HACKDIR}."
2782   echo ""
2783   echo "      If you would prefer the demos to be installed elsewhere"
2784   echo "      (for example, in a dedicated directory) you should re-run"
2785   echo "      configure with the --enable-subdir=DIR option.  For more"
2786   echo "      information, run $0 --help."
2787   warning=yes
2788 fi
2789
2790 if test "$warning" != no; then
2791   echo '' ; echo "$warnsep" ; echo ''
2792 fi