http://ftp.x.org/contrib/applications/xscreensaver-3.06.tar.gz
[xscreensaver] / configure.in
1 # configure.in --- xscreensaver, Copyright (c) 1997 Jamie Zawinski.
2 #
3
4 AC_INIT(driver/subprocs.c)
5
6 echo "current directory: `pwd`"
7 echo "command line was: $0 $@"
8
9 AC_CONFIG_HEADER(config.h)
10 AC_CANONICAL_HOST
11
12 AC_PROG_CC
13
14 if test -z "$GCC"; then
15   AC_MSG_CHECKING(how to request ANSI compilation)
16   case "$host" in
17     *-hpux*)
18       AC_MSG_RESULT(HPUX: adding -Ae)
19       CC="$CC -Ae"
20     ;;
21     *-aix*)
22       AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
23       CC="$CC -qlanglvl=ansi -qhalt=e"
24     ;;
25
26     *-dec-*)
27       AC_MSG_RESULT(DEC: adding -std1)
28       CC="$CC -std1"
29     ;;
30
31     *)
32       AC_MSG_RESULT(no idea)
33     ;;
34   esac
35 fi
36
37
38 AC_MSG_CHECKING([whether the compiler works on ANSI C])
39 AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
40    AC_MSG_RESULT(yes),
41    AC_MSG_RESULT(no)
42    AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
43    AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
44
45 case "$host" in
46   *-irix5* |*-irix6.[0-3]* )
47     if test -n "$GCC"; then
48       AC_MSG_RESULT(Turning on gcc compiler warnings.)
49       CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
50     else
51       # not gcc
52       AC_MSG_RESULT(Turning on SGI compiler warnings.)
53       CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
54     fi
55   ;;
56
57     *-linux-*)
58       AC_MSG_RESULT(Turning on gcc compiler warnings.)
59       CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
60   ;;
61
62 #  *-dec-osf*)
63 #    if test -z "$GCC"; then
64 #      AC_MSG_RESULT(Turning on DEC C compiler warnings.)
65 #      CC="$CC -migrate -w0 -verbose -warnprotos"
66 #    fi
67 #  ;;
68
69 esac
70
71
72 # Try and determine whether ${INSTALL} can create intermediate directories,
73 # and if not, whether "mkdir -p" works instead.  This sets ${INSTALL_DIRS}.
74 # (But autoconf should earn its keep and do this for us!)
75 #
76 AC_DEFUN(AC_PROG_INSTALL_DIRS,
77   [INSTALL_DIRS='${INSTALL} -d'
78    AC_MSG_CHECKING(whether \"\${INSTALL} -d\" creates intermediate directories)
79    rm -rf conftestdir
80    if mkdir conftestdir; then
81       cd conftestdir >&-
82
83       ${INSTALL} -d `pwd`/dir1/dir2 >&- 2>&-
84       if test -d dir1/dir2 ; then
85         AC_MSG_RESULT(yes)
86       else
87         AC_MSG_RESULT(no)
88         AC_MSG_CHECKING(whether \"mkdir -p\" creates intermediate directories)
89         rm -rf dir1
90         mkdir -p dir1/dir2 >&- 2>&-
91         if test -d dir1/dir2/. ; then
92           AC_MSG_RESULT(yes)
93           INSTALL_DIRS='mkdir -p'
94         else
95           AC_MSG_RESULT(no)
96         fi
97       fi
98       cd .. >&-
99       rm -rf conftestdir
100    fi
101 ])
102
103
104 AC_PROG_CPP
105 AC_PROG_INSTALL
106 AC_PROG_INSTALL_DIRS
107 AC_PROG_MAKE_SET
108
109 AC_C_CONST
110 AC_C_INLINE
111
112 AC_HEADER_STDC
113 AC_HEADER_TIME
114 AC_HEADER_SYS_WAIT
115 AC_HEADER_DIRENT
116
117 AC_TYPE_MODE_T
118 AC_TYPE_PID_T
119 AC_TYPE_SIZE_T
120 AC_TYPE_SIGNAL
121
122 AC_MSG_CHECKING(how to call gettimeofday)
123 AC_CACHE_VAL(ac_cv_gettimeofday_args,
124  [AC_TRY_COMPILE([#include <stdlib.h>
125                   #include <sys/time.h>],
126                  [struct timeval tv; struct timezone tzp;
127                   gettimeofday(&tv, &tzp);],
128                  [ac_gettimeofday_args=2],
129                  [AC_TRY_COMPILE([#include <stdlib.h>
130                                   #include <sys/time.h>],
131                                  [struct timeval tv; gettimeofday(&tv);],
132                                  [ac_gettimeofday_args=1],
133                                  [ac_gettimeofday_args=0])])
134   ac_cv_gettimeofday_args=$ac_gettimeofday_args])
135 ac_gettimeofday_args=$ac_cv_gettimeofday_args
136 if test "$ac_gettimeofday_args" = 1 ; then
137   AC_DEFINE(HAVE_GETTIMEOFDAY)
138   AC_MSG_RESULT(one argument)
139 elif test "$ac_gettimeofday_args" = 2 ; then
140   AC_DEFINE(HAVE_GETTIMEOFDAY)
141   AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
142   AC_MSG_RESULT(two arguments)
143 else
144   AC_MSG_RESULT(unknown)
145 fi
146
147
148 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv)
149 AC_CHECK_FUNCS(sigaction syslog)
150
151 AC_CHECK_HEADERS(unistd.h crypt.h sys/select.h)
152
153 dnl     /usr/local/src/ssh-1.2.17/putenv.c -- AC_REPLACE_FUNCS(putenv)
154
155
156 AC_ARG_ENABLE(subdir,[
157 Installation options:
158
159   --enable-subdir=DIR     Put the demo programs in a subdirectory of \`bindir',
160                           instead of putting them in bindir itself.  You can
161                           specify the name of the subdirectory.  For example,
162                           --exec-prefix=/usr/local/bin --enable-subdir=demos
163                           would put xscreensaver in /usr/local/bin/, and would
164                           put the demos in /usr/local/bin/demos/.  (If DIR
165                           begins with /, then bindir will not be prepended.)
166
167   --disable-subdir        Just put the demos in \`bindir' (this is the default.)
168 ],
169   [enable_subdir="$enableval"],[enable_subdir=no])
170 if test x"$enable_subdir" = xno; then
171   HACKDIR='${bindir}'
172 elif test x"$enable_subdir" = xyes -o x"$enable_subdir" = x ; then
173   echo "error: must be a subdirectory name: --enable-subdir=$enable_subdir"
174   exit 1
175 else
176   # there must be a better way than this...
177   if test -z "`echo $enable_subdir | sed 's@^/.*@@'`" ; then
178     # absolute path
179     HACKDIR=$enable_subdir
180   else
181     # relative path
182     HACKDIR='${bindir}/'$enable_subdir
183   fi
184 fi
185
186
187 AC_PATH_XTRA
188
189 # Try and find the app-defaults directory.
190 # It sucks that autoconf doesn't do this already...
191 #
192 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,[
193   rm -fr conftestdir
194   if mkdir conftestdir; then
195     cd conftestdir >&-
196     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
197     cat > Imakefile <<'EOF'
198 acfindx:
199         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
200 EOF
201     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
202       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
203       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
204     fi
205     cd .. >&-
206     rm -fr conftestdir
207   fi])
208
209 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,[
210   # Look for the directory under a standard set of common directories.
211   # Check X11 before X11Rn because it's often a symlink to the current release.
212   for ac_dir in                                 \
213     /usr/X11/lib/app-defaults                   \
214     /usr/X11R6/lib/app-defaults                 \
215     /usr/X11R6/lib/X11/app-defaults             \
216     /usr/X11R5/lib/app-defaults                 \
217     /usr/X11R5/lib/X11/app-defaults             \
218     /usr/X11R4/lib/app-defaults                 \
219     /usr/X11R4/lib/X11/app-defaults             \
220                                                 \
221     /usr/lib/X11/app-defaults                   \
222     /usr/lib/X11R6/app-defaults                 \
223     /usr/lib/X11R5/app-defaults                 \
224     /usr/lib/X11R4/app-defaults                 \
225                                                 \
226     /usr/local/X11/lib/app-defaults             \
227     /usr/local/X11R6/lib/app-defaults           \
228     /usr/local/X11R5/lib/app-defaults           \
229     /usr/local/X11R4/lib/app-defaults           \
230                                                 \
231     /usr/local/lib/X11/app-defaults             \
232     /usr/local/lib/X11R6/app-defaults           \
233     /usr/local/lib/X11R6/X11/app-defaults       \
234     /usr/local/lib/X11R5/app-defaults           \
235     /usr/local/lib/X11R5/X11/app-defaults       \
236     /usr/local/lib/X11R4/app-defaults           \
237     /usr/local/lib/X11R4/X11/app-defaults       \
238                                                 \
239     /usr/X386/lib/X11/app-defaults              \
240     /usr/x386/lib/X11/app-defaults              \
241     /usr/XFree86/lib/X11/app-defaults           \
242                                                 \
243     /usr/lib/X11/app-defaults                   \
244     /usr/local/lib/X11/app-defaults             \
245     /usr/unsupported/lib/X11/app-defaults       \
246     /usr/athena/lib/X11/app-defaults            \
247     /usr/local/x11r5/lib/X11/app-defaults       \
248     /usr/lpp/Xamples/lib/X11/app-defaults       \
249     /lib/usr/lib/X11/app-defaults               \
250                                                 \
251     /usr/openwin/lib/app-defaults               \
252     /usr/openwin/lib/X11/app-defaults           \
253     /usr/openwin/share/lib/app-defaults         \
254     /usr/openwin/share/lib/X11/app-defaults     \
255                                                 \
256     /X11R6/lib/app-defaults                     \
257     /X11R5/lib/app-defaults                     \
258     /X11R4/lib/app-defaults                     \
259     ; \
260   do
261     if test -d "$ac_dir"; then
262       ac_x_app_defaults=$ac_dir
263       break
264     fi
265   done
266 ])
267
268
269 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
270   [AC_REQUIRE_CPP()
271     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
272      [AC_PATH_X_APP_DEFAULTS_XMKMF
273       if test x"$ac_x_app_defaults" = x; then
274         AC_PATH_X_APP_DEFAULTS_DIRECT
275       fi
276       if test x"$ac_x_app_defaults" = x; then
277         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
278       else
279         # Record where we found app-defaults for the cache.
280         ac_cv_x_app_defaults="$ac_x_app_defaults"
281       fi])
282     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
283
284 AC_PATH_X_APP_DEFAULTS
285
286 APPDEFAULTS=$ac_x_app_defaults
287
288
289 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
290 #
291 AC_DEFUN(AC_CHECK_X_HEADER, [
292   ac_save_CPPFLAGS="$CPPFLAGS"
293   if test \! -z "$includedir" ; then 
294     CPPFLAGS="$CPPFLAGS -I$includedir"
295   fi
296   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
297   AC_CHECK_HEADER([$1], [$2])
298   CPPFLAGS="$ac_save_CPPFLAGS"])
299
300 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
301 #
302 AC_DEFUN(AC_EGREP_X_HEADER, [
303   ac_save_CPPFLAGS="$CPPFLAGS"
304   if test \! -z "$includedir" ; then 
305     CPPFLAGS="$CPPFLAGS -I$includedir"
306   fi
307   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
308   AC_EGREP_HEADER([$1], [$2], [$3], [$4])
309   CPPFLAGS="$ac_save_CPPFLAGS"])
310
311 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
312 #
313 AC_DEFUN(AC_TRY_X_COMPILE, [
314   ac_save_CPPFLAGS="$CPPFLAGS"
315   if test \! -z "$includedir" ; then 
316     CPPFLAGS="$CPPFLAGS -I$includedir"
317   fi
318   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
319   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
320   CPPFLAGS="$ac_save_CPPFLAGS"])
321
322
323 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
324 # Use this sparingly; it probably doesn't work very well on X programs.
325 #
326 AC_DEFUN(AC_CHECK_X_LIB, [
327   ac_save_CPPFLAGS="$CPPFLAGS"
328   ac_save_LDFLAGS="$LDFLAGS"
329
330   if test \! -z "$includedir" ; then 
331     CPPFLAGS="$CPPFLAGS -I$includedir"
332   fi
333   # note: $X_CFLAGS includes $x_includes
334   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
335
336   if test \! -z "$libdir" ; then
337     LDFLAGS="$LDFLAGS -L$libdir"
338   fi
339   # note: $X_LIBS includes $x_libraries
340   LDFLAGS="$LDFLAGS $X_LIBS"
341
342   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
343   CPPFLAGS="$ac_save_CPPFLAGS"
344   LDFLAGS="$ac_save_LDFLAGS"])
345
346 # Like AC_TRY_RUN, but it uses the already-computed -I directories.
347 # (But not the -L directories!)
348 #
349 AC_DEFUN(AC_TRY_X_RUN, [
350   ac_save_CPPFLAGS="$CPPFLAGS"
351   if test \! -z "$includedir" ; then 
352     CPPFLAGS="$CPPFLAGS -I$includedir"
353   fi
354   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
355   AC_TRY_RUN([$1], [$2], [$3], [$4])
356   CPPFLAGS="$ac_save_CPPFLAGS"])
357
358
359
360 # Usage: HANDLE_X_PATH_ARG([variable_name],
361 #                          [--command-line-option],
362 #                          [descriptive string])
363 #
364 # All of the --with options take three forms:
365 #
366 #   --with-foo (or --with-foo=yes)
367 #   --without-foo (or --with-foo=no)
368 #   --with-foo=/DIR
369 #
370 # This function, HANDLE_X_PATH_ARG, deals with the /DIR case.  When it sees
371 # a directory (string beginning with a slash) it checks to see whether
372 # /DIR/include and /DIR/lib exist, and adds them to $X_CFLAGS and $X_LIBS
373 # as appropriate.
374 #
375 AC_DEFUN(HANDLE_X_PATH_ARG, [
376    case "$[$1]" in
377     yes) ;;
378     no)  ;;
379
380     /*)
381      AC_MSG_CHECKING([for [$3] headers])
382      d=$[$1]/include
383      if test -d $d; then
384        X_CFLAGS="-I$d $X_CFLAGS"
385        AC_MSG_RESULT($d)
386      else
387        AC_MSG_RESULT(not found ($d: no such directory))
388      fi
389
390      AC_MSG_CHECKING([for [$3] libs])
391      d=$[$1]/lib
392      if test -d $d; then
393        X_LIBS="-L$d $X_LIBS"
394        AC_MSG_RESULT($d)
395      else
396        AC_MSG_RESULT(not found ($d: no such directory))
397      fi
398
399      # replace the directory string with "yes".
400      [$1]_req="yes"
401      [$1]=$[$1]_req
402      ;;
403
404     *)
405      echo ""
406      echo "error: argument to [$2] must be \"yes\", \"no\", or a directory."
407      echo "       If it is a directory, then \`DIR/include' will be added to"
408      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
409      exit 1
410      ;;
411    esac
412
413    # why is this necessary?
414    # if we don't do this, then "./configure --with-motif=/usr/local/lesstif"
415    # behaves as if "--with-zippy=/usr/local/lesstif" was also present!
416    withval=
417   ])
418
419
420
421 # check for the HP XHPDisableReset server extension headers.
422 #
423 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
424                   [AC_DEFINE(HAVE_XHPDISABLERESET)
425                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
426
427
428 # Check for the availability of the XPointer typedef, and define it otherwise.
429 #
430 AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
431                 [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
432                                   [XPointer foo = (XPointer) 0;],
433                                   [ac_cv_xpointer=yes],
434                                   [ac_cv_xpointer=no])])
435 if test "$ac_cv_xpointer" != yes; then
436   AC_DEFINE(XPointer,[char*])
437 fi
438
439
440 # Random special-cases for certain pathological OSes.  You know who you are.
441 #
442 case "$host" in
443   *-hpux*)
444
445     # The following arcana was gleaned from conversations with
446     # Eric Schwartz <erics@col.hp.com>:
447     #
448     # On HPUX 10.x, the parts of X that HP considers "standard" live in
449     # /usr/{include,lib}/X11R6/.  The parts that HP doesn't consider
450     # "standard", notably, Xaw and Xmu, live in /usr/contrib/X11R6/.
451     # Also, there are symlinks from /usr/include/ and /usr/lib/ into
452     # /usr/{include,lib}/X11R6/, so that (if you don't use Xmu at all)
453     # you don't need any -I or -L arguments.
454     #
455     # On HPUX 9.x, /usr/{include,lib}/X11R5/ and /usr/contrib/X11R5/
456     # are the same division as 10.x.  However, there are no symlinks to
457     # the X stuff from /usr/include/ and /usr/lib/, so -I and -L
458     # arguments are always necessary.
459     #
460     # However, X11R6 was available on HPUX 9.x as a patch: if that
461     # patch was installed, then all of X11R6 went in to
462     # /usr/contrib/X11R6/ (there was no /usr/{include,lib}/X11R6/.)
463     #
464     # HPUX 8.x was the same as 9.x, but was X11R4 instead (I don't know
465     # whether R5 was available as a patch; R6 undoubtedly was not.)
466     #
467     # So.  We try and use the highest numbered pair of
468     # /usr/{include,lib}/X11R?/ and /usr/contrib/X11R?/{include,lib}/
469     # that are available.  We do not mix and match different versions
470     # of X.
471     #
472     # Questions I still don't know the answers to: (do you?)
473     #
474     #   * Does HPUX 10.x come with /usr/contrib/X11R6/ standard?  
475     #     Or does that need to be installed separately?
476     #
477     #   * On HPUX 9.x, where /usr/include/X11R5/ was standard, and
478     #     /usr/contrib/X11R6/ could be installed as a patch, what was in
479     #     that contrib directory?  Did it contain so-called "standard"
480     #     X11R6, or did it include Xaw and Xmu as well?  If the former,
481     #     where did one find Xaw and Xmu on 9.x R6 systems?  Would this
482     #     be a situation where one had to reach into the R5 headers and
483     #     libs to find Xmu?  That is, must both R6 and R5 directories
484     #     be on the -I and -L lists in that case?
485     #
486     for version in X11R6 X11R5 X11R4 ; do
487       # if either pair of directories exists...
488       if test -d /usr/lib/$version || test -d /usr/contrib/$version/lib ; then
489          # if contrib exists, use it...
490          if test -d /usr/contrib/$version/lib ; then
491            X_CFLAGS="$X_CFLAGS -I/usr/contrib/$version/include"
492            X_LIBS="$X_LIBS -L/usr/contrib/$version/lib"
493          fi
494          # if the "standard" one exists, use it.
495          if test -d /usr/lib/$version ; then
496            X_CFLAGS="$X_CFLAGS -I/usr/include/$version"
497            X_LIBS="$X_LIBS -L/usr/lib/$version"
498          fi
499          # since at least one of the pair exists, go no farther.
500          break
501       fi
502     done
503
504     # Now find Motif.  Thanks for not making xmkmf find this by
505     # default, you losers.
506     #
507     if test -d /usr/lib/Motif1.2 ; then
508       X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.2"
509       X_LIBS="$X_LIBS -L/usr/lib/Motif1.2"
510     elif test -d /usr/lib/Motif1.1 ; then
511       X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.1"
512       X_LIBS="$X_LIBS -L/usr/lib/Motif1.1"
513     fi
514
515     # Now let's check for the pseudo-standard locations for OpenGL and XPM.
516     #
517     if test -d /opt/Mesa/lib ; then
518       X_CFLAGS="-I/opt/Mesa/include $X_CFLAGS"
519       X_LIBS="-L/opt/Mesa/lib $X_LIBS"
520     fi
521
522     if test -d /opt/xpm/lib/X11 ; then
523       X_CFLAGS="-I/opt/xpm/include $X_CFLAGS"
524       X_LIBS="-L/opt/xpm/lib/X11 $X_LIBS"
525     fi
526
527     # On HPUX, default to installing in /opt/xscreensaver/ instead of
528     # in /usr/local/, unless there is already an xscreensaver in
529     # /usr/local/bin/.  This can be overridden with the --prefix arg
530     # to configure.  I'm not sure this is the right thing to do, but
531     # Richard Lloyd says so...
532     #
533     if test \! -x /usr/local/bin/xscreensaver ; then
534       ac_default_prefix=/opt/xscreensaver
535     fi
536
537   ;;
538   *-solaris*)
539
540     # Thanks for not making xmkmf find this by default, pinheads.
541     # And thanks for moving things around again, too.  Is this
542     # really the standard location now?  What happened to the
543     # joke that this kind of thing went in /opt?
544     # cthomp says "answer: CDE (Common Disorganized Environment)"
545     #
546     if test -f /usr/dt/include/Xm/Xm.h ; then
547       X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
548       X_LIBS="$X_LIBS -L/usr/dt/lib -R:/usr/dt/lib"
549
550       # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
551       AC_CHECK_LIB(gen, regcmp, [X_LIBS="$X_LIBS -lgen"])
552     fi
553   ;;
554 esac
555
556
557
558 # Check for Xmu (some fucked up vendors don't ship it...)
559 #
560 have_xmu=no
561 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
562 if test "$have_xmu" = no ; then
563   XMU_SRCS='$(UTILS_SRC)/xmu.c'
564   XMU_OBJS='$(UTILS_BIN)/xmu.o'
565 else
566   XMU_SRCS=''
567   XMU_OBJS=''
568   SAVER_LIBS="-lXmu $SAVER_LIBS"
569   HACK_LIBS="-lXmu $HACK_LIBS"
570   AC_DEFINE(HAVE_XMU)
571 fi
572
573
574 # See comp.windows.x FAQ question 124 about _get_wmShellWidgetClass on 4.1.x.
575 # The right fix is to get OpenWindows 3.0 patches 100512-02 and 100573-03.
576 #
577 if test "$have_xmu" = yes ; then
578   case "$host" in
579     *-sunos4*)
580     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
581                    ac_cv_sunos_xmu_bug,
582                    [ac_save_LDFLAGS="$LDFLAGS"
583                     if test \! -z "$x_libraries" ; then
584                       LDFLAGS="$LDFLAGS -L$x_libraries"
585                     fi
586                     # Note: this trick never works!  (Generally.)
587                     # We're only getting away with using AC_TRY_LINK
588                     # with X libraries because we know it's SunOS.
589                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
590                     AC_TRY_LINK(,,
591                                 [ac_cv_sunos_xmu_bug=no],
592                                 [ac_cv_sunos_xmu_bug=yes])
593                     LDFLAGS="$ac_save_LDFLAGS"])
594     if test "$ac_cv_sunos_xmu_bug" = yes ; then
595       AC_CACHE_CHECK([whether the compiler understands -static], 
596                      ac_cv_ld_static,
597                      [ac_save_LDFLAGS="$LDFLAGS"
598                       LDFLAGS="$LDFLAGS -static"
599                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
600                     LDFLAGS="$ac_save_LDFLAGS"])
601       if test "$ac_cv_ld_static" = yes ; then
602         LDFLAGS="$LDFLAGS -static"
603       else
604         LDFLAGS="$LDFLAGS -Bstatic"
605       fi
606     fi
607     ;;
608   esac
609 fi
610
611
612 # Check for the SGI SCREEN_SAVER server extension header.
613 #
614 have_sgi=no
615 with_sgi_req=unspecified
616 AC_ARG_WITH(sgi-ext,
617 [Except where noted, all of the --with options below can also take a
618 directory argument: for example, --with-motif=/opt/Motif.  That would
619 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
620 to be added to the -L list, assuming those directories exist.
621
622 X Server Extension options:
623
624   --with-sgi-ext          Include support for the SGI SCREEN_SAVER
625                           server extension, if possible (this is the default).
626   --without-sgi-ext       Do not compile in support for this extension.],
627   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
628
629 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
630
631 if test "$with_sgi" = yes; then
632   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
633                     [have_sgi=yes
634                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
635
636 elif test "$with_sgi" != no; then
637   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
638   exit 1
639 fi
640
641 # Check for the MIT-SCREEN-SAVER server extension header,
642 # unless the SGI extension has already been found.
643 #
644 have_mit=no
645 with_mit_req=unspecified
646 AC_ARG_WITH(mit-ext,
647 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER
648                           server extension, if possible (this is the default).
649   --without-mit-ext       Do not compile in support for this extension.],
650   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
651
652 HANDLE_X_PATH_ARG(with_mit, --with-mit-ext, MIT-SCREEN-SAVER)
653
654 if test "$have_sgi" != yes; then
655   if test "$with_mit" = yes; then
656     AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
657
658     # Now check to see if it's really in the library; XF86Free-3.3 ships
659     # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
660     #
661     if test "$have_mit" = yes; then
662       AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [], [have_mit=no], -lm)
663
664       if test "$have_mit" = no; then
665         # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
666         # of in Xext.  Thank you master, may I have another.
667         AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
668                        [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
669                        [], -lX11 -lXext -lm)
670       fi
671
672       if test "$have_mit" = no; then
673         # Double fuck!  Looks like some versions of XFree86 (whichever version
674         # it is that comes with RedHat Linux 2.0 -- I can't find a version 
675         # number) put this garbage in Xss instead of Xext.  Thank you master,
676         #  may I have another.
677         AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
678                        [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
679                        [], -lX11 -lXext -lm)
680       fi
681
682     if test "$have_mit" = yes; then
683       AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
684     fi
685
686     fi
687
688   elif test "$with_mit" != no; then
689     echo "error: must be yes or no: --with-mit-ext=$with_mit"
690     exit 1
691   fi
692 fi
693
694
695 # Check for the XIDLE server extension header.
696 #
697 have_xidle=no
698 with_xidle_req=unspecified
699 AC_ARG_WITH(xidle-ext,
700 [  --with-xidle-ext        Include support for the XIDLE server extension,
701                           if possible (this is the default).
702   --without-xidle-ext     Do not compile in support for this extension.],
703   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
704
705 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
706
707 if test "$with_xidle" = yes; then
708   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
709                     [have_xidle=yes
710                      AC_DEFINE(HAVE_XIDLE_EXTENSION)])
711 elif test "$with_xidle" != no; then
712   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
713   exit 1
714 fi
715
716
717 # Check for the XSHM server extension header.
718 #
719 have_xshm=no
720 with_xshm_req=unspecified
721 AC_ARG_WITH(xshm-ext,
722 [  --with-xshm-ext         Include support for the XSHM (Shared Memory) server
723                           extension, if possible (this is the default).
724   --without-xshm-ext      Do not compile in support for this extension.],
725   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
726
727 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
728
729 if test "$with_xshm" = yes; then
730
731   # first check for Xshm.h.
732   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes])
733
734   # if that succeeded, then check for sys/ipc.h.
735   if test "$have_xshm" = yes; then
736     have_xshm=no
737     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
738   fi
739
740   # if that succeeded, then check for sys/shm.h.
741   if test "$have_xshm" = yes; then
742     have_xshm=no
743     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
744   fi
745
746   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
747   # to exist, but the library code to not exist.  And even better, the library
748   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
749   # lib doesn't exist, give up.
750   #
751   case "$host" in
752     *-aix*)
753       have_xshm=no
754       AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
755                      [have_xshm=yes; SAVER_LIBS="$SAVER_LIBS -lXextSam"],
756                        [], -lX11 -lXext -lm)
757     ;;
758   esac
759
760   # if that succeeded, then we've really got it.
761   if test "$have_xshm" = yes; then
762     AC_DEFINE(HAVE_XSHM_EXTENSION)
763   fi
764
765 elif test "$with_xshm" != no; then
766   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
767   exit 1
768 fi
769
770
771 # Check for the SGI-VIDEO-CONTROL server extension header.
772 #
773 have_sgivc=no
774 with_sgivc_req=unspecified
775 AC_ARG_WITH(sgivc-ext,
776 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL server
777                           extension, if possible (this is the default).
778   --without-sgivc-ext     Do not compile in support for this extension.],
779   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
780
781 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
782
783 if test "$with_sgivc" = yes; then
784
785   # first check for XSGIvc.h
786   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes])
787
788   # if that succeeded, then check for the -lXsgivc
789   if test "$have_sgivc" = yes; then
790     have_sgivc=no
791     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
792                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [],
793                   -lXext -lX11)
794   fi
795
796   # if that succeeded, then we've really got it.
797   if test "$have_sgivc" = yes; then
798     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
799   fi
800
801 elif test "$with_sgivc" != no; then
802   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
803   exit 1
804 fi
805
806
807 # Check for the DPMS server extension header.
808 #
809 have_dpms=no
810 with_dpms_req=unspecified
811 AC_ARG_WITH(dpms-ext,
812 [  --with-dpms-ext         Include support for the DPMS server extension,
813                           if possible (this is the default).
814   --without-dpms-ext      Do not compile in support for this extension.],
815   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
816
817 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
818
819 if test "$with_dpms" = yes; then
820
821   # first check for dpms.h
822   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
823
824   # if that succeeded, then check for the -lXdpms
825   if test "$have_dpms" = yes; then
826     have_dpms=no
827     AC_CHECK_X_LIB(Xdpms, DPMSInfo,
828                   [have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"], [],
829                   -lXext -lX11)
830   fi
831
832   # if that succeeded, then we've really got it.
833   if test "$have_dpms" = yes; then
834     AC_DEFINE(HAVE_DPMS_EXTENSION)
835   fi
836
837 elif test "$with_dpms" != no; then
838   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
839   exit 1
840 fi
841
842
843
844 # Check for Motif and Athena --with and --without arguments.
845 #
846 have_motif=no
847 have_athena=no
848 have_athena3d=no
849 with_motif_req=unspecified
850 with_athena_req=unspecified
851
852 AC_ARG_WITH(motif,[
853 X Client Toolkit options:
854
855   --with-motif            Use the Motif toolkit for the user interface, if
856                           possible (this is the default).
857   --without-motif         Do not use Motif.],
858   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
859
860 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
861
862 AC_ARG_WITH(athena,
863 [  --with-athena           Use the Athena toolkit for the user interface, if
864                           possible (this is the default if Motif isn't used.)
865   --without-athena        Do not use Athena.],
866   [with_athena="$withval"; with_athena_req="$withval"],[with_athena=no])
867
868 HANDLE_X_PATH_ARG(with_athena, --with-athena, Athena)
869
870 if test "$with_motif" != yes -a "$with_motif" != no ; then
871   echo "error: must be yes or no: --with-motif=$with_motif"
872   exit 1
873 fi
874
875 if test "$with_athena" != yes -a "$with_athena" != no ; then
876   echo "error: must be yes or no: --with-athena=$with_athena"
877   exit 1
878 fi
879
880
881 # Saying --without-motif is the same as saying --with-athena.
882 if test "$with_motif_req" = no ; then
883   with_athena_req=yes
884   with_athena=yes
885 fi
886
887 # Saying --without-athena is the same as saying --with-motif.
888 if test "$with_athena_req" = no ; then
889   with_motif_req=yes
890   with_motif=yes
891 fi
892
893 # Check for Motif and Athena headers.
894
895 check_motif() {
896   AC_CHECK_X_HEADER(Xm/Xm.h,
897                     [have_motif=yes
898                      AC_DEFINE(HAVE_MOTIF)
899                      TOOLKIT_LIBS="-lXm $TOOLKIT_LIBS"])
900 }
901
902 check_athena() {
903   have_athena=no
904   have_athena3d=no
905   AC_CHECK_X_HEADER(X11/Xaw/Dialog.h, [have_athena=yes])
906   if test "$have_athena" = yes; then
907     AC_CHECK_X_LIB(Xaw3d, Xaw3dComputeTopShadowRGB,
908                    [have_athena=yes; have_athena3d=yes], [],
909                    -lXt -lXmu -lXext -lX11)
910   fi
911
912   if test "$have_athena3d" = yes; then
913     TOOLKIT_LIBS="-lXaw3d $TOOLKIT_LIBS"
914   elif test "$have_athena" = yes; then
915     TOOLKIT_LIBS="-lXaw $TOOLKIT_LIBS"
916   fi
917 }
918
919
920 # If they asked for both motif and athena, check motif then athena.
921 # If they asked for only motif, check motif then athena.
922 # If they asked for only athena, check athena then motif.
923 # If they asked for neither, check motif then athena.
924
925 proselytize_motif=yes
926 if test "$with_motif" = yes; then
927   # asked for both, or for motif only
928   check_motif
929   if test "$have_motif" = yes; then
930     with_athena=no
931     with_athena_req=no
932   else
933     check_athena
934   fi
935
936 elif test "$with_athena" = yes; then
937   # asked for athena only
938   check_athena
939   if test "$have_athena" = yes; then
940     with_motif=no
941     proselytize_motif=no
942   else
943     check_motif
944   fi
945
946 else
947   # asked for neither
948   check_motif
949   if test "$have_motif" = yes; then
950     with_athena=no
951   else
952     check_athena
953   fi
954
955 fi
956
957 if test "$have_motif" = yes; then
958   proselytize_motif=no
959 fi
960
961 # If we have Athena, check whether it's a version that includes
962 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
963 if test "$have_athena" = yes ; then
964   AC_CACHE_CHECK([for XawViewportSetCoordinates in Viewport.h], 
965                  ac_cv_have_XawViewportSetCoordinates,
966                  [ac_cv_have_XawViewportSetCoordinates=no
967                   AC_EGREP_X_HEADER(XawViewportSetCoordinates, 
968                                     X11/Xaw/Viewport.h,
969                                     ac_cv_have_XawViewportSetCoordinates=yes)])
970   if test "$ac_cv_have_XawViewportSetCoordinates" = yes ; then
971     AC_DEFINE(HAVE_XawViewportSetCoordinates)
972   fi
973 fi
974
975
976 # If we have Motif, check whether it's really LessTif.
977 #
978 have_lesstif=no
979 if test "$have_motif" = yes ; then
980   AC_CACHE_CHECK([whether Motif is really LessTif], 
981                  ac_cv_have_lesstif,
982                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
983                                    [long vers = LesstifVersion;],
984                                    [ac_cv_have_lesstif=yes],
985                                    [ac_cv_have_lesstif=no])])
986   have_lesstif=$ac_cv_have_lesstif
987 fi
988
989 # don't cache these
990 unset ac_cv_lesstif_version
991 unset ac_cv_lesstif_version_string
992
993 lesstif_version=unknown
994 lesstif_version_string=unknown
995
996 if test "$have_lesstif" = yes ; then
997   ltv=unknown
998   echo unknown > conftest-lt
999   AC_CACHE_CHECK([LessTif version number],
1000                  ac_cv_lesstif_version_string,
1001       [AC_TRY_X_RUN([#include <stdio.h>
1002                      #include <Xm/Xm.h>
1003                      int main() {
1004                        FILE *f = fopen("conftest-lt", "w");
1005                        if (!f) exit(1);
1006                        fprintf(f, "%d %d.%d\n", LesstifVersion,
1007                           LESSTIF_VERSION, LESSTIF_REVISION);
1008                        fclose(f);
1009                        exit(0);
1010                      }],
1011                     [ltv=`cat conftest-lt`
1012                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
1013                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
1014                     [ac_cv_lesstif_version=unknown
1015                      ac_cv_lesstif_version_string=unknown],
1016                     [ac_cv_lesstif_version=unknown
1017                      ac_cv_lesstif_version_string=unknown])])
1018   rm -f conftest-lt
1019   lesstif_version=$ac_cv_lesstif_version
1020   lesstif_version_string=$ac_cv_lesstif_version_string
1021
1022 fi
1023
1024
1025 # Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
1026 # Extension".   Why this extension isn't in -lXext with all the others,
1027 # I have no idea.
1028 #
1029 have_xp_ext=no
1030 if test "$have_motif" = yes ; then
1031    have_xp_ext=no
1032    AC_CHECK_X_LIB(Xp, XpQueryExtension,
1033                   [have_xp_ext=yes; TOOLKIT_LIBS="$TOOLKIT_LIBS -lXp"],
1034                   [], -lX11 -lXext -lm)
1035 fi
1036
1037
1038 # check for XPM header.
1039 #
1040 have_xpm=no
1041 with_xpm_req=unspecified
1042 AC_ARG_WITH(xpm,[
1043 Graphics Demo options:
1044
1045   --with-xpm              Include support for XPM files in some demos,
1046                           if possible (this is the default).
1047   --without-xpm           Do not compile in support for XPM files.],
1048   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
1049
1050 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
1051
1052 if test "$with_xpm" = yes; then
1053   AC_CHECK_X_HEADER(X11/xpm.h,
1054                    [have_xpm=yes
1055                     AC_DEFINE(HAVE_XPM)
1056                     XPM_LIBS="-lXpm"])
1057 elif test "$with_xpm" != no; then
1058   echo "error: must be yes or no: --with-xpm=$with_xpm"
1059   exit 1
1060 fi
1061
1062
1063 # check for the GL header
1064 #
1065 have_gl=no
1066 ac_have_mesa_gl=no
1067 with_gl_req=unspecified
1068 AC_ARG_WITH(gl,
1069 [  --with-gl               Build those demos which depend on OpenGL,
1070                           if possible (this is the default).
1071   --without-gl            Do not build the OpenGL demos.],
1072   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
1073
1074 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
1075
1076 ac_mesagl_version=unknown
1077 ac_mesagl_version_string=unknown
1078
1079 if test "$with_gl" = yes; then
1080   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
1081   if test "$have_gl" = yes ; then
1082     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
1083   fi
1084
1085   # If we have the headers, try and figure out which vendor it's from.
1086   #
1087   if test "$have_gl" = yes ; then
1088
1089     AC_DEFINE(HAVE_GL)
1090
1091     # We need to know whether it's MesaGL so that we know which libraries
1092     # to link against.
1093     #
1094     AC_MSG_CHECKING(whether GL is really MesaGL)
1095     AC_CACHE_VAL(ac_cv_have_mesa_gl,
1096       [ac_cv_have_mesa_gl=no
1097        AC_EGREP_X_HEADER(Mesa, GL/glx.h, [ac_cv_have_mesa_gl=yes])
1098       ])
1099     ac_have_mesa_gl=$ac_cv_have_mesa_gl
1100     AC_MSG_RESULT($ac_have_mesa_gl)
1101
1102     if test "$ac_have_mesa_gl" = no ; then
1103       gl_lib_1="GL"
1104       GL_LIBS="-lGL -lGLU"
1105     else
1106       AC_DEFINE(HAVE_MESA_GL)
1107       gl_lib_1="MesaGL"
1108       GL_LIBS="-lMesaGL -lMesaGLU"
1109     fi
1110
1111
1112     # If it's MesaGL, we'd like to issue a warning if the version number
1113     # is less than or equal to 2.6, because that version had a security bug.
1114     #
1115     if test "$ac_have_mesa_gl" = yes; then
1116
1117       # don't cache these.
1118       unset ac_cv_mesagl_version
1119       unset ac_cv_mesagl_version_string
1120
1121       AC_MSG_CHECKING(MesaGL version number)
1122       AC_CACHE_VAL(ac_cv_mesagl_version_string,
1123         [cat > conftest.$ac_ext <<EOF
1124 #line __oline__ "configure"
1125 #include "confdefs.h"
1126 #include <GL/gl.h>
1127 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
1128 EOF
1129
1130          ac_save_CPPFLAGS="$CPPFLAGS"
1131          if test \! -z "$includedir" ; then 
1132            CPPFLAGS="$CPPFLAGS -I$includedir"
1133          fi
1134          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1135
1136           # M4 sucks!!
1137          changequote(X,Y)
1138          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
1139               's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
1140          changequote([,])
1141
1142          rm -f conftest.$ac_ext
1143
1144          CPPFLAGS="$ac_save_CPPFLAGS"
1145
1146          if test "$mglv" = ""; then
1147            ac_mesagl_version=unknown
1148            ac_mesagl_version_string=unknown
1149          else
1150            ac_mesagl_version_string=$mglv
1151            maj=`echo $mglv | sed -n 's/\..*//p'`
1152            min=`echo $mglv | sed -n 's/.*\.//p'`
1153            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
1154            if test -z "$ac_mesagl_version"; then
1155              ac_mesagl_version=unknown
1156              ac_mesagl_version_string=unknown
1157            fi
1158          fi
1159          ac_cv_mesagl_version=$ac_mesagl_version
1160          ac_cv_mesagl_version_string=$ac_mesagl_version_string
1161       ])
1162       ac_mesagl_version=$ac_cv_mesagl_version
1163       ac_mesagl_version_string=$ac_cv_mesagl_version_string
1164       AC_MSG_RESULT($ac_cv_mesagl_version_string)
1165     fi
1166
1167
1168     # Check for OpenGL 1.1 features.
1169     #
1170     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
1171                    [], $GL_LIBS -lX11 -lXext -lm)
1172
1173   fi
1174
1175 elif test "$with_gl" != no; then
1176   echo "error: must be yes or no: --with-gl=$with_gl"
1177   exit 1
1178 fi
1179
1180
1181 # check for SGI XReadDisplay server extension header.
1182 #
1183 have_readdisplay=no
1184 with_readdisplay_req=unspecified
1185 AC_ARG_WITH(readdisplay,
1186 [  --with-readdisplay      Include support for the XReadDisplay server
1187                           extension if possible (this is the default).
1188   --without-readdisplay   Do not compile in support for this extension.],
1189   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
1190   [with_readdisplay=yes])
1191
1192 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
1193
1194 if test "$with_readdisplay" = yes; then
1195   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
1196                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
1197 elif test "$with_readdisplay" != no; then
1198   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
1199   exit 1
1200 fi
1201
1202
1203 # check for SGI's Iris Video Library header.
1204 #
1205 have_sgivideo=no
1206 with_sgivideo_req=unspecified
1207 AC_ARG_WITH(sgivideo,
1208 [  --with-sgivideo         Include support for SGI's Iris Video Library
1209                           if possible (this is the default).
1210   --without-sgivideo       Do not compile in support for this library.],
1211   [with_sgivideo="$withval"; with_sgivideo_req="$withval"],
1212   [with_sgivideo=yes])
1213
1214 HANDLE_X_PATH_ARG(with_sgivideo, --with-sgivideo, Iris Video)
1215
1216 if test "$with_sgivideo" = yes; then
1217   AC_CHECK_X_HEADER(dmedia/vl.h, have_sgivideo=yes)
1218   if test "$have_sgivideo" = yes; then
1219     have_sgivideo=no
1220     AC_CHECK_LIB(vl, vlOpenVideo, have_sgivideo=yes)
1221     if test "$have_sgivideo" = yes; then
1222       SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
1223       SGI_VIDEO_LIBS="-lvl"
1224       AC_DEFINE(HAVE_SGI_VIDEO)
1225     fi
1226   fi
1227 elif test "$with_sgivideo" != no; then
1228   echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
1229   exit 1
1230 fi
1231
1232
1233
1234 # Try to find a program to generate random text.
1235 #
1236 # Zippy is funnier than the idiocy generally spat out by `fortune',
1237 # so try to find that, by invoking Emacs and asking it where its 
1238 # libexec directory is ("yow" lives in there.)
1239 #
1240 # If that doesn't work, see if fortune, zippy, or yow are on $PATH,
1241 # and if so, use them.
1242 #
1243 # If that doesn't work, look in /usr/games, and if it's there, use
1244 # the full pathname.
1245 #
1246 with_zippy_req=""
1247 AC_ARG_WITH(zippy,
1248 [  --with-zippy=PROGRAM    Some demos are able to run an external program and
1249                           display its text; this names the program to use by
1250                           default (though it can be overridden with X
1251                           resources.)  If you don't specify this, the default
1252                           is to use \"yow\" from the Emacs distribution (if you
1253                           have it) or else to use \"fortune\".],
1254   [ with_zippy_req="$withval"; with_zippy="$withval" ],
1255   [ with_zippy_req="$withval"; with_zippy="$withval" ])
1256
1257 if test "$with_zippy" = no || test "$with_zippy" = yes ; then
1258   with_zippy=""
1259   with_zippy_req=""
1260 fi
1261
1262 if test -n "$with_zippy_req" ; then
1263   ac_cv_zippy_program=""
1264   case "$with_zippy_req" in
1265     /*)
1266       AC_MSG_CHECKING([for $with_zippy_req])
1267       if test -x "$with_zippy_req" ; then
1268         AC_MSG_RESULT(yes)
1269       else
1270         AC_MSG_RESULT(no)
1271         with_zippy=""
1272       fi
1273     ;;
1274     *)
1275       # don't cache
1276       unset ac_cv_path_zip2
1277       AC_PATH_PROG(zip2, $with_zippy_req, [])
1278       if test "$zip2" = ""; then
1279         with_zippy=""
1280       fi
1281     ;;
1282   esac
1283   ac_cv_zippy_program="$with_zippy"
1284
1285 elif test -n "$ac_cv_zippy_program"; then
1286   AC_MSG_RESULT([checking for zippy... (cached) $ac_cv_zippy_program])
1287 fi
1288
1289 if test ! -n "$ac_cv_zippy_program"; then
1290
1291   AC_CHECK_PROGS(emacs_exe, emacs)
1292   AC_CHECK_PROGS(xemacs_exe, xemacs)
1293
1294   ac_cv_zippy_program=""
1295   eargs='-batch -q -nw --eval'
1296
1297   if test -n "$emacs_exe" ; then
1298     AC_MSG_CHECKING([for emacs yow])
1299     #
1300     # get emacs to tell us where the libexec directory is.
1301     #
1302     dir=`$emacs_exe $eargs '(princ (concat exec-directory "\n"))' \
1303          2>/dev/null | tail -1`
1304     dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
1305     #
1306     # try running libexec/yow and see if it exits without error.
1307     #
1308     if test x"$dir" != x -a -x "$dir/yow" ; then
1309       if $dir/yow >&- 2>&- ; then
1310         ac_cv_zippy_program="$dir/yow"
1311         AC_MSG_RESULT($ac_cv_zippy_program)
1312       else
1313         AC_MSG_RESULT(no)
1314       fi
1315     fi
1316   fi
1317
1318   if test -z "$ac_cv_zippy_program" ; then
1319     AC_MSG_CHECKING([for xemacs yow])
1320     if test -n "$xemacs_exe" ; then
1321       #
1322       # get xemacs to tell us where the libexec directory is.
1323       #
1324       dir=`$xemacs_exe $eargs '(princ (concat exec-directory "\n"))' \
1325            2>/dev/null | tail -1`
1326       dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
1327       #
1328       # try running libexec/yow and see if it exits without error.
1329       #
1330       if test x"$dir" != x -a -x "$dir/yow" ; then
1331         if $dir/yow >&- 2>&- ; then
1332           ac_cv_zippy_program="$dir/yow"
1333           AC_MSG_RESULT($ac_cv_zippy_program)
1334         else
1335           #
1336           # in some xemacs installations, the pathname of the yow.lines file
1337           # isn't hardcoded into the yow executable, and must be passed on 
1338           # the command line.  See if it's in libexec/../etc/.
1339
1340           # M4 sucks!!
1341           changequote(X,Y)
1342           dir_up=`echo "$dir" | sed 's@/[^/]*$@@'`
1343           changequote([,])
1344
1345           yow="yow -f $dir_up/etc/yow.lines"
1346           if $dir/$yow >&- 2>&- ; then
1347             ac_cv_zippy_program="$dir/$yow"
1348             AC_MSG_RESULT($ac_cv_zippy_program)
1349           else
1350             AC_MSG_RESULT(no)
1351           fi
1352         fi
1353       fi
1354     fi
1355   fi
1356
1357   # if that didn't work, try for some other programs...
1358   if test -z "$ac_cv_zippy_program" ; then
1359     fortune=''
1360     AC_CHECK_PROGS(fortune, [fortune zippy yow])
1361     # if that didn't work, try for those programs in /usr/games...
1362     if test -z "$fortune" ; then
1363       AC_PATH_PROGS(fortune, [fortune zippy yow], fortune,
1364                     /usr/games:/usr/local/games)
1365     fi
1366   fi
1367 fi
1368
1369 if test -z "$ac_cv_zippy_program" ; then
1370   ac_cv_zippy_program=fortune
1371 fi
1372
1373 AC_DEFINE_UNQUOTED(ZIPPY_PROGRAM, "$ac_cv_zippy_program")
1374
1375
1376
1377
1378 # Allow locking to be disabled at compile-time.
1379 #
1380 have_kerberos=no
1381 with_kerberos_req=unspecified
1382 have_shadow=no
1383 with_shadow_req=unspecified
1384 have_pam=no
1385 with_pam_req=unspecified
1386 need_setuid=no
1387
1388 AC_ARG_ENABLE(locking,[
1389 Screen Locking options:
1390
1391   --enable-locking        Compile in support for locking the display
1392                           (this is the default.)
1393   --disable-locking       Do not allow locking at all.],
1394   [enable_locking="$enableval"],[enable_locking=yes])
1395 if test "$enable_locking" = yes; then
1396   true
1397 elif test "$enable_locking" = no; then
1398   AC_DEFINE(NO_LOCKING)
1399 else
1400   echo "error: must be yes or no: --enable-locking=$enable_locking"
1401   exit 1
1402 fi
1403
1404
1405
1406 # Check to see if we can lock Virtual-Terminal switching, but allow that 
1407 # to be disabled at compile-time.
1408 #
1409 ac_vt_lockswitch=no
1410 AC_ARG_ENABLE(vt-locking,[
1411   --enable-vt-locking     Compile in support for locking Virtual Terminals.
1412                           This is the default if the system supports it, and
1413                           if locking support is included (--enable-locking.)
1414   --disable-vt-locking    Do not allow locking of VTs, even if locking is
1415                           enabled.],
1416   [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1417 if test "$enable_vt_locking" = yes; then
1418
1419   AC_MSG_CHECKING(for the VT_LOCKSWITCH ioctl)
1420   AC_CACHE_VAL(ac_cv_vt_lockswitch,
1421    [AC_TRY_COMPILE([#include <fcntl.h>
1422                     #include <sys/ioctl.h>
1423                     #include <sys/vt.h>],
1424                    [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1425                    [ac_cv_vt_lockswitch=yes],
1426                    [ac_cv_vt_lockswitch=no])])
1427   ac_vt_lockswitch=$ac_cv_vt_lockswitch
1428   AC_MSG_RESULT($ac_vt_lockswitch)
1429
1430 elif test "$enable_locking" = no; then
1431   true
1432 else
1433   echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1434   exit 1
1435 fi
1436
1437 if test "$ac_vt_lockswitch" = yes; then
1438   AC_DEFINE(HAVE_VT_LOCKSWITCH)
1439   # the VT_LOCKSWITCH ioctl can only be used when running as root.
1440   # #### but it doesn't work yet, so don't worry about that for now.
1441 #  need_setuid=yes
1442 fi
1443
1444
1445
1446 if test "$enable_locking" = yes; then
1447
1448   # Check for Kerberos.
1449   #
1450   AC_ARG_WITH(kerberos, [
1451   --with-kerberos         Include support for Kerberos authentication,
1452                           if possible (this is the default.)
1453   --without-kerberos      Do not compile in support for Kerberos.],
1454   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1455
1456   HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1457
1458   if test "$with_kerberos" = yes; then
1459     AC_CACHE_CHECK([for Kerberos], ac_cv_kerberos,
1460                    [AC_TRY_X_COMPILE([#include <krb.h>],,
1461                                      [ac_cv_kerberos=yes],
1462                                      [ac_cv_kerberos=no])])
1463     if test "$ac_cv_kerberos" = yes ; then
1464       have_kerberos=yes
1465       AC_DEFINE(HAVE_KERBEROS)
1466
1467       # from Tim Showalter <tjs+@andrew.cmu.edu>
1468       PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes"
1469       AC_CHECK_FUNC(res_search,,
1470         AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1471           AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1472         ))
1473
1474     fi
1475   elif test "$with_kerberos" != no; then
1476     echo "error: must be yes or no: --with-kerberos=$with_kerberos"
1477     exit 1
1478   fi
1479   
1480   # Check for PAM.
1481   AC_ARG_WITH(pam,
1482 [  --with-pam              Include support for PAM (Pluggable Authentication
1483                           Modules) if possible (this is the default.)
1484   --without-pam           Do not compile in support for PAM.],
1485   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=no])
1486 #### Leave PAM off by default for now, since it's buggy on Solaris
1487 #### (and probably Linux, but it's so hard to tell...)
1488
1489   HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1490
1491   if test "$with_pam" = yes; then
1492     AC_CACHE_CHECK([for PAM], ac_cv_pam,
1493                    [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1494                                      [ac_cv_pam=yes],
1495                                      [ac_cv_pam=no])])
1496     if test "$ac_cv_pam" = yes ; then
1497           have_pam=yes
1498           AC_DEFINE(HAVE_PAM)
1499           PASSWD_LIBS="${PASSWD_LIBS} -lpam -ldl"
1500     fi
1501   elif test "$with_pam" != no; then
1502         echo "error: must be yes or no: --with-pam=$with_pam"
1503         exit 1
1504   fi
1505
1506   # Next, check for the nine billion variants of shadow passwords...
1507
1508   pwent_cruft_done=no
1509   AC_ARG_WITH(shadow,
1510 [  --with-shadow           Include support for shadow password authentication,
1511                           if possible (this is the default, if no Kerberos or
1512                           PAM.)
1513   --without-shadow        Do not compile in support for shadow passwords.
1514 ],
1515   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1516
1517   HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1518
1519   if test "$with_shadow" = no; then
1520     pwent_cruft_done=yes
1521   elif test "$with_shadow" != yes; then
1522     echo "error: must be yes or no: --with-shadow=$with_shadow"
1523     exit 1
1524   fi
1525
1526
1527   # Sun's "adjunct" passwords.
1528   #
1529   if test "$pwent_cruft_done" = no ; then
1530     AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1531                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1532                                       #include <unistd.h>
1533                                       #include <sys/types.h>
1534                                       #include <sys/label.h>
1535                                       #include <sys/audit.h>
1536                                       #include <pwdadj.h>],
1537                         [struct passwd_adjunct *p = getpwanam("nobody");
1538                          const char *pw = p->pwa_passwd;],
1539                         [ac_cv_sun_adjunct=yes],
1540                         [ac_cv_sun_adjunct=no])])
1541     if test "$ac_cv_sun_adjunct" = yes; then
1542       have_shadow=yes
1543       need_setuid=yes
1544       pwent_cruft_done=yes
1545       AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1546     fi
1547   fi
1548
1549   # DEC and SCO so-called "enhanced" security.
1550   #
1551   if test "$pwent_cruft_done" = no ; then
1552     AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1553                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1554                                       #include <unistd.h>
1555                                       #include <sys/types.h>
1556                                       #include <pwd.h>
1557                                       #include <sys/security.h>
1558                                       #include <prot.h>],
1559                         [struct pr_passwd *p;
1560                          const char *pw;
1561                          set_auth_parameters(0, 0);
1562                          check_auth_parameters();
1563                          p = getprpwnam("nobody");
1564                          pw = p->ufld.fd_encrypt;],
1565                         [ac_cv_enhanced_passwd=yes],
1566                         [ac_cv_enhanced_passwd=no])])
1567     if test $ac_cv_enhanced_passwd = yes; then
1568       have_shadow=yes
1569       need_setuid=yes
1570       pwent_cruft_done=yes
1571       AC_DEFINE(HAVE_ENHANCED_PASSWD)
1572
1573       # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1574       # (I'm told it needs -lcurses too, but I don't understand why.)
1575       AC_CHECK_LIB(prot, getprpwnam, 
1576                    [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1577                    [# On DEC, getprpwnam() is in -lsecurity
1578                     AC_CHECK_LIB(security, getprpwnam, 
1579                                  [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1580                    [-lx])
1581     fi
1582   fi
1583
1584   # HP's entry in the "Not Invented Here" Sweepstakes.
1585   #
1586   if test "$pwent_cruft_done" = no ; then
1587     AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1588                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1589                                       #include <unistd.h>
1590                                       #include <sys/types.h>
1591                                       #include <pwd.h>
1592                                       #include <hpsecurity.h>
1593                                       #include <prot.h>],
1594                         [struct s_passwd *p = getspwnam("nobody");
1595                          const char *pw = p->pw_passwd;],
1596                         [ac_cv_hpux_passwd=yes],
1597                         [ac_cv_hpux_passwd=no])])
1598     if test "$ac_cv_hpux_passwd" = yes; then
1599       have_shadow=yes
1600       need_setuid=yes
1601       pwent_cruft_done=yes
1602       AC_DEFINE(HAVE_HPUX_PASSWD)
1603
1604       # on HPUX, bigcrypt is in -lsec
1605       AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1606     fi
1607   fi
1608
1609   # Traditional (ha!) shadow passwords.
1610   #
1611   if test "$pwent_cruft_done" = no ; then
1612     AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1613                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1614                                       #include <unistd.h>
1615                                       #include <sys/types.h>
1616                                       #include <pwd.h>
1617                                       #include <shadow.h>],
1618                         [struct spwd *p = getspnam("nobody");
1619                          const char *pw = p->sp_pwdp;],
1620                         [ac_cv_shadow=yes],
1621                         [ac_cv_shadow=no])])
1622     if test "$ac_cv_shadow" = yes; then
1623       have_shadow=yes
1624       need_setuid=yes
1625       pwent_cruft_done=yes
1626       AC_DEFINE(HAVE_SHADOW_PASSWD)
1627
1628       # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1629       have_getspnam=no
1630       AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1631       if test "$have_getspnam" = no ; then
1632         AC_CHECK_LIB(gen, getspnam,
1633                      [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1634       fi
1635     fi
1636   fi
1637
1638   # On FreeBSD, getpwnam() and friends work just like on non-shadow-password
1639   # systems -- except you only get stuff in the pw_passwd field if the running
1640   # program is setuid.  So, guess that we've got this lossage to contend with
1641   # if /etc/master.passwd exists, and default to a setuid installation.
1642   #
1643   if test "$pwent_cruft_done" = no ; then
1644     AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1645                    [if test -f /etc/master.passwd ; then
1646                       ac_cv_master_passwd=yes
1647                     else
1648                       ac_cv_master_passwd=no
1649                     fi])
1650     if test "$ac_cv_master_passwd" = yes; then
1651       need_setuid=yes
1652       pwent_cruft_done=yes
1653     fi
1654   fi
1655
1656   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1657   have_crypt=no
1658   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1659   if test "$have_crypt" = no ; then
1660     AC_CHECK_LIB(crypt, crypt,
1661                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1662   fi
1663
1664
1665   # Most of the above shadow mechanisms will have set need_setuid to yes,
1666   # if they were found.  But, on some systems, we need setuid even when
1667   # using plain old vanilla passwords.
1668   #
1669   if test "$need_setuid" = no ; then
1670     case "$host" in
1671       *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1672         need_setuid=yes
1673       ;;
1674     esac
1675   fi
1676
1677 fi
1678
1679
1680 if test \! -z "$includedir" ; then 
1681   INCLUDES="-I$includedir"
1682 fi
1683
1684 if test \! -z "$libdir" ; then
1685   LDFLAGS="$LDFLAGS -L$libdir"
1686 fi
1687
1688
1689 ##### should have options to override the DEPEND crap, I guess...
1690 DEPEND=makedepend
1691 DEPEND_FLAGS=
1692 DEPEND_DEFINES=
1693
1694
1695 # Done testing things -- now substitute in some stuff for the Makefiles.
1696 #
1697 if test "$have_motif" = yes; then
1698   AC_DEFINE(HAVE_MOTIF)
1699   TOOLKIT_SRCS='$(MOTIF_SRCS)'
1700   TOOLKIT_OBJS='$(MOTIF_OBJS)'
1701 elif test "$have_athena" = yes; then
1702   AC_DEFINE(HAVE_ATHENA)
1703   TOOLKIT_SRCS='$(ATHENA_SRCS)'
1704   TOOLKIT_OBJS='$(ATHENA_OBJS)'
1705 else
1706   TOOLKIT_SRCS=''
1707   TOOLKIT_OBJS=''
1708 fi
1709
1710 if test "$have_kerberos" = yes; then
1711   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
1712   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
1713 fi
1714 if test "$have_pam" = yes; then
1715   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
1716   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
1717   INSTALL_PAM="install-pam"
1718 fi
1719   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
1720   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
1721
1722
1723 if test "$enable_locking" = yes; then
1724   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
1725   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
1726 else
1727   LOCK_SRCS=''
1728   LOCK_OBJS=''
1729 fi
1730
1731 if test "$need_setuid" = yes; then
1732   NEED_SETUID=yes
1733   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
1734 else
1735   NEED_SETUID=no
1736   INSTALL_SETUID='$(INSTALL_PROGRAM)'
1737 fi
1738
1739 tab='   '
1740 if test "$have_gl" = yes; then
1741   GL_EXES='$(GL_EXES)'
1742   GL_KLUDGE=${tab}
1743 else
1744   GL_KLUDGE='  -'${tab}
1745 fi
1746
1747 AC_SUBST(INCLUDES)
1748
1749 AC_SUBST(SAVER_LIBS)
1750 AC_SUBST(TOOLKIT_LIBS)
1751 AC_SUBST(HACK_LIBS)
1752 AC_SUBST(XPM_LIBS)
1753 AC_SUBST(GL_LIBS)
1754 AC_SUBST(PASSWD_LIBS)
1755 AC_SUBST(INSTALL_SETUID)
1756 AC_SUBST(INSTALL_DIRS)
1757 AC_SUBST(NEED_SETUID)
1758 AC_SUBST(INSTALL_PAM)
1759 AC_SUBST(SGI_VIDEO_OBJS)
1760 AC_SUBST(SGI_VIDEO_LIBS)
1761
1762 AC_SUBST(TOOLKIT_SRCS)
1763 AC_SUBST(TOOLKIT_OBJS)
1764 AC_SUBST(PASSWD_SRCS)
1765 AC_SUBST(PASSWD_OBJS)
1766 AC_SUBST(XMU_SRCS)
1767 AC_SUBST(XMU_OBJS)
1768 AC_SUBST(LOCK_SRCS)
1769 AC_SUBST(LOCK_OBJS)
1770 AC_SUBST(GL_EXES)
1771 AC_SUBST(GL_KLUDGE)
1772 AC_SUBST(HACKDIR)
1773 AC_SUBST(APPDEFAULTS)
1774
1775 AC_SUBST(DEPEND)
1776 AC_SUBST(DEPEND_FLAGS)
1777 AC_SUBST(DEPEND_DEFINES)
1778
1779 # Print some warnings before emitting the Makefiles.
1780 #
1781 warn_prefix_1="    Warning:"
1782 warn_prefix_2="       Note:"
1783 warn_prefix="$warn_prefix_1"
1784
1785 warning=no
1786 warnsep='    #################################################################'
1787
1788 warnpre() {
1789   if test "$warning" = no ; then
1790     echo '' ; echo "$warnsep" ; echo ''
1791     warning=yes
1792   fi
1793 }
1794
1795 warn() {
1796   warnpre
1797   if test "$warning" = long ; then echo '' ; fi
1798   warning=yes
1799   echo "$warn_prefix $@"
1800 }
1801
1802 warnL() {
1803   was=$warning
1804   warnpre
1805   warning=yes
1806   if test "$was" != no ; then echo '' ; fi
1807   echo "$warn_prefix $@"
1808 }
1809
1810 warn2() {
1811   echo "             $@"
1812   warning=long
1813 }
1814
1815 note() {
1816   warn_prefix="$warn_prefix_2"
1817   warn $@
1818   warn_prefix="$warn_prefix_1"
1819 }
1820
1821 noteL() {
1822   warn_prefix="$warn_prefix_2"
1823   warnL $@
1824   warn_prefix="$warn_prefix_1"
1825 }
1826
1827
1828 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
1829   warn 'The SGI saver extension was requested, but was not found.'
1830 fi
1831
1832 if test "$with_mit_req" = yes -a "$have_mit" = no ; then
1833   warn 'The MIT saver extension was requested, but was not found.'
1834 fi
1835
1836 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
1837   warn 'The XIdle extension was requested, but was not found.'
1838 fi
1839
1840 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
1841   warn 'The XSHM extension was requested, but was not found.'
1842 fi
1843
1844 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
1845   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
1846 fi
1847
1848 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
1849   warn 'The DPMS extension was requested, but was not found.'
1850 fi
1851
1852 if test "$have_motif" = no -a "$have_athena" = no ; then
1853   warnL "Neither Motif nor Athena widgets seem to be available;"
1854   warn2 "the \`xscreensaver-demo' program requires one or the"
1855   warn2 "other."
1856   proselytize_motif=no
1857
1858 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
1859   warnL "Use of Motif was requested, but it wasn't found;"
1860   warn2 "Athena will be used instead."
1861
1862 elif test "$with_athena_req" = yes -a "$have_athena" = no ; then
1863   warnL "Use of Athena was requested, but it wasn't found;"
1864   warn2 "Motif will be used instead."
1865 fi
1866
1867 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
1868
1869   preferred_lesstif=0.86
1870
1871   if test "$lesstif_version" = unknown; then
1872     warnL "Unable to determine the LessTif version number!"
1873     warn2 "Make sure you are using version $preferred_lesstif or newer."
1874     warn2 "See <http://www.lesstif.org/>."
1875
1876   elif test \! $lesstif_version -gt 82; then
1877     warnL "LessTif version $lesstif_version_string is being used."
1878     warn2 "LessTif versions 0.82 and earlier are too buggy to"
1879     warn2 "use with XScreenSaver; it is strongly recommended"
1880     warn2 "that you upgrade to at least version $preferred_lesstif!"
1881     warn2 "See <http://www.lesstif.org/>."
1882   fi
1883 fi
1884
1885 if test "$proselytize_motif" = yes ; then
1886     warnL "Athena widgets are being used instead of Motif."
1887     warn2 "The \`xscreensaver-demo' program looks much better"
1888     warn2 "with Motif.  Wouldn't you rather be using Motif?"
1889     warn2 "It is shipped by every commercial Unix vendor;"
1890     warn2 "and there is a free implementation available as"
1891     warn2 "well: see <http://www.lesstif.org/>."
1892 fi
1893
1894
1895 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
1896   preferred_mesagl=2.7
1897
1898   if test "$ac_mesagl_version" = unknown; then
1899     warnL "Unable to determine the MesaGL version number!"
1900     warn2 "Make sure you are using version $preferred_mesagl or newer."
1901
1902   elif test \! "$ac_mesagl_version" -gt 2006; then
1903     warnL "MesaGL version $ac_mesagl_version_string is being used."
1904     warn2 "MesaGL versions 2.6 and earlier have a security bug."
1905     warn2 "It is strongly recommended that you upgrade to at"
1906     warn2 "least version $preferred_mesagl."
1907   fi
1908 fi
1909
1910
1911 if test "$have_xpm" = no ; then
1912   if test "$with_xpm_req" = yes ; then
1913     warnL 'Use of XPM was requested, but it was not found.'
1914   elif test "$with_xpm_req" = no ; then
1915     noteL 'The XPM library is not being used.'
1916   else
1917     noteL 'The XPM library was not found.'
1918   fi
1919
1920   echo ''
1921   warn2 'Some of the demos will not be as colorful as they'
1922   warn2 'could be.  You might want to consider installing XPM'
1923   warn2 'and re-running configure.  (Remember to delete the'
1924   warn2 'config.cache file first.)  You can find XPM at most'
1925   warn2 'X11 archive sites, such as <http://sunsite.unc.edu/>.'
1926 fi
1927
1928 if test "$have_gl" = no ; then
1929   if test "$with_gl_req" = yes ; then
1930     warnL 'Use of GL was requested, but it was not found.'
1931   elif test "$with_gl_req" = no ; then
1932     noteL 'The OpenGL 3D library is not being used.'
1933   else
1934     noteL 'The OpenGL 3D library was not found.'
1935   fi
1936
1937   echo ''
1938   warn2 'Those demos which use 3D will not be built or installed.'
1939   warn2 'You might want to consider installing OpenGL and'
1940   warn2 're-running configure.  (Remember to delete the'
1941   warn2 "config.cache file first.)  If your vendor doesn't ship"
1942   warn2 'their own implementation of OpenGL, you can get a free'
1943   warn2 'version at <http://www.ssec.wisc.edu/~brianp/Mesa.html>.'
1944   warn2 'For general OpenGL info, see <http://www.opengl.org/>.'
1945
1946 fi
1947
1948 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
1949   warn 'Use of XReadDisplay was requested, but it was not found.'
1950 fi
1951
1952 if test "$with_sgivideo_req" = yes -a "$have_sgivideo" = no ; then
1953   warn 'Use of the Iris Video Library was requested, but it was not found.'
1954 fi
1955
1956 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
1957   warn 'Use of Kerberos was requested, but it was not found.'
1958 fi
1959
1960 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
1961   warn 'Use of PAM was requested, but it was not found.'
1962 fi
1963
1964 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
1965   warn 'Use of shadow passwords was requested, but they were not found.'
1966 fi
1967
1968 if test -n "$with_zippy_req"; then
1969   if test "$with_zippy_req" != "$ac_cv_zippy_program" ; then
1970     warnL "$with_zippy_req was requested as the Zippy program,"
1971     warn2 "but was not found.  The default will be used instead."
1972   fi
1973 fi
1974
1975 if test "$warning" != no; then
1976   echo '' ; echo "$warnsep" ; echo ''
1977 fi
1978
1979
1980 AC_OUTPUT(Makefile
1981           utils/Makefile
1982           driver/Makefile
1983           hacks/Makefile
1984           hacks/glx/Makefile
1985           driver/XScreenSaver.ad)
1986
1987 # You are in a twisty maze of namespaces and syntaxes, all alike.
1988 # Fuck the skull of Unix.
1989 #
1990 eval bindir=${bindir}
1991 eval bindir=${bindir}
1992 eval bindir=${bindir}
1993 eval bindir=${bindir}
1994 eval bindir=${bindir}
1995 eval bindir=${bindir}
1996 eval HACKDIR=${HACKDIR}
1997 eval HACKDIR=${HACKDIR}
1998 eval HACKDIR=${HACKDIR}
1999 eval HACKDIR=${HACKDIR}
2000 eval HACKDIR=${HACKDIR}
2001 eval HACKDIR=${HACKDIR}
2002
2003 echo ""
2004 echo "$warnsep"
2005 echo ""
2006 echo '      When you run "make install", the "xscreensaver",'
2007 echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
2008 echo "      will be installed in ${bindir}."
2009 echo ""
2010 echo "      The various graphics demos (80+ different executables) will"
2011 echo "      be installed in ${HACKDIR}."
2012 echo ""
2013 echo "      If you would prefer the demos to be installed elsewhere"
2014 echo "      (for example, in a dedicated directory) you should re-run"
2015 echo "      configure with the --enable-subdir=DIR option.  For more"
2016 echo "      information, run $0 --help."
2017 echo ""
2018 echo "$warnsep"
2019 echo ""