4fd08b644254c2e78c3acd19d8e7ff89dce930b2
[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 AC_CANONICAL_HOST
7
8 AC_PROG_CC
9
10 if test -z "$GCC"; then
11   AC_MSG_CHECKING(how to request ANSI compilation)
12   case "$host" in
13     *-hpux*)
14       AC_MSG_RESULT(HPUX: adding -Ae)
15       CC="$CC -Ae"
16     ;;
17     *-aix*)
18       AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
19       CC="$CC -qlanglvl=ansi -qhalt=e"
20     ;;
21
22 # NOTE:   for Digital, need to add -std1 to get ANSI, but I'm not sure
23 #         yet what $host pattern we should be testing for...
24
25     *)
26       AC_MSG_RESULT(no idea)
27     ;;
28   esac
29 fi
30
31
32 AC_MSG_CHECKING([whether the compiler works on ANSI C])
33 AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
34    AC_MSG_RESULT(yes),
35    AC_MSG_RESULT(no)
36    AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
37    AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
38
39 case "$host" in
40   *-irix*)
41   if test -n "$GCC"; then
42     AC_MSG_RESULT(Turning on gcc compiler warnings.)
43     CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
44   else
45     # not gcc
46     AC_MSG_RESULT(Turning on SGI compiler warnings.)
47     CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
48   fi
49   ;;
50 esac
51
52
53 AC_PROG_CPP
54 AC_PROG_INSTALL
55 AC_PROG_MAKE_SET
56
57 AC_C_CONST
58 AC_C_INLINE
59
60 AC_HEADER_STDC
61 AC_HEADER_TIME
62 AC_HEADER_SYS_WAIT
63 AC_HEADER_DIRENT
64
65 AC_TYPE_MODE_T
66 AC_TYPE_PID_T
67 AC_TYPE_SIZE_T
68 AC_TYPE_SIGNAL
69
70 AC_MSG_CHECKING(how to call gettimeofday)
71 AC_CACHE_VAL(ac_cv_gettimeofday_args,
72  [AC_TRY_COMPILE([#include <stdlib.h>
73                   #include <sys/time.h>],
74                  [struct timeval tv; struct timezone tzp;
75                   gettimeofday(&tv, &tzp);],
76                  [ac_gettimeofday_args=2],
77                  [AC_TRY_COMPILE([#include <stdlib.h>
78                                   #include <sys/time.h>],
79                                  [struct timeval tv; gettimeofday(&tv);],
80                                  [ac_gettimeofday_args=1],
81                                  [ac_gettimeofday_args=0])])
82   ac_cv_gettimeofday_args=$ac_gettimeofday_args])
83 ac_gettimeofday_args=$ac_cv_gettimeofday_args
84 if test $ac_gettimeofday_args = 1 ; then
85   AC_DEFINE(HAVE_GETTIMEOFDAY)
86   AC_MSG_RESULT(one argument)
87 elif test $ac_gettimeofday_args = 2 ; then
88   AC_DEFINE(HAVE_GETTIMEOFDAY)
89   AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
90   AC_MSG_RESULT(two arguments)
91 else
92   AC_MSG_RESULT(unknown)
93 fi
94
95
96 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv)
97 AC_CHECK_FUNCS(sigaction)
98
99 AC_CHECK_HEADERS(unistd.h)
100
101 dnl     /usr/local/src/ssh-1.2.17/putenv.c -- AC_REPLACE_FUNCS(putenv)
102
103
104 AC_ARG_ENABLE(subdir,[
105 Installation options:
106
107   --enable-subdir=DIR     Put the demo programs in a subdirectory of \`bindir',
108                           instead of putting them in bindir itself.  You can
109                           specify the name of the subdirectory.  For example,
110                           --exec-prefix=/usr/local/bin --enable-subdir=demos
111                           would put xscreensaver in /usr/local/bin/, and would
112                           put the demos in /usr/local/bin/demos/.  Note that if
113                           you do this, you must make sure that the directory
114                           is on your \$PATH before xscreensaver is started: the
115                           directory name is not hardcoded into the program.
116                           This merely sets the default installation location.
117
118   --disable-subdir        Just put the demos in \`bindir' (this is the default.)
119 ],
120   [enable_subdir="$enableval"],[enable_subdir=no])
121 if test x"$enable_subdir" = xno; then
122   HACKDIR='${bindir}'
123 elif test x"$enable_subdir" = xyes -o x"$enable_subdir" = x ; then
124   echo "error: must be a subdirectory name: --enable-subdir=$enable_subdir"
125   exit 1
126 else
127   # there must be a better way than this...
128   if test -z "`echo $enable_subdir | sed 's@^/.*@@'`" ; then
129     # absolute path
130     HACKDIR=$enable_subdir
131   else
132     # relative path
133     HACKDIR='${bindir}/'$enable_subdir
134   fi
135 fi
136
137
138 AC_PATH_XTRA
139
140 # Try and find the app-defaults directory.
141 # It sucks that autoconf doesn't do this already...
142 #
143 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,
144   [
145   rm -fr conftestdir
146   if mkdir conftestdir; then
147     cd conftestdir
148     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
149     cat > Imakefile <<'EOF'
150 acfindx:
151         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
152 EOF
153     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
154       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
155       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
156     fi
157     cd ..
158     rm -fr conftestdir
159   fi])
160
161 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,
162 [  # Look for the directory under a standard set of common directories.
163   # Check X11 before X11Rn because it's often a symlink to the current release.
164   for ac_dir in                                 \
165     /usr/X11/lib/app-defaults                   \
166     /usr/X11R6/lib/app-defaults                 \
167     /usr/X11R6/lib/X11/app-defaults             \
168     /usr/X11R5/lib/app-defaults                 \
169     /usr/X11R5/lib/X11/app-defaults             \
170     /usr/X11R4/lib/app-defaults                 \
171     /usr/X11R4/lib/X11/app-defaults             \
172                                                 \
173     /usr/lib/X11/app-defaults                   \
174     /usr/lib/X11R6/app-defaults                 \
175     /usr/lib/X11R5/app-defaults                 \
176     /usr/lib/X11R4/app-defaults                 \
177                                                 \
178     /usr/local/X11/lib/app-defaults             \
179     /usr/local/X11R6/lib/app-defaults           \
180     /usr/local/X11R5/lib/app-defaults           \
181     /usr/local/X11R4/lib/app-defaults           \
182                                                 \
183     /usr/local/lib/X11/app-defaults             \
184     /usr/local/lib/X11R6/app-defaults           \
185     /usr/local/lib/X11R6/X11/app-defaults       \
186     /usr/local/lib/X11R5/app-defaults           \
187     /usr/local/lib/X11R5/X11/app-defaults       \
188     /usr/local/lib/X11R4/app-defaults           \
189     /usr/local/lib/X11R4/X11/app-defaults       \
190                                                 \
191     /usr/X386/lib/X11/app-defaults              \
192     /usr/x386/lib/X11/app-defaults              \
193     /usr/XFree86/lib/X11/app-defaults           \
194                                                 \
195     /usr/lib/X11/app-defaults                   \
196     /usr/local/lib/X11/app-defaults             \
197     /usr/unsupported/lib/X11/app-defaults       \
198     /usr/athena/lib/X11/app-defaults            \
199     /usr/local/x11r5/lib/X11/app-defaults       \
200     /usr/lpp/Xamples/lib/X11/app-defaults       \
201     /lib/usr/lib/X11/app-defaults               \
202                                                 \
203     /usr/openwin/lib/app-defaults               \
204     /usr/openwin/lib/X11/app-defaults           \
205     /usr/openwin/share/lib/app-defaults         \
206     /usr/openwin/share/lib/X11/app-defaults     \
207                                                 \
208     /X11R6/lib/app-defaults                     \
209     /X11R5/lib/app-defaults                     \
210     /X11R4/lib/app-defaults                     \
211     ; \
212   do
213     if test -d "$ac_dir"; then
214       ac_x_app_defaults=$ac_dir
215       break
216     fi
217   done
218 ])
219
220
221 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
222   [AC_REQUIRE_CPP()
223     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
224      [AC_PATH_X_APP_DEFAULTS_XMKMF
225       AC_PATH_X_APP_DEFAULTS_DIRECT
226       if test x"$ac_x_app_defaults" = x; then
227         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
228       else
229         # Record where we found app-defaults for the cache.
230         ac_cv_x_app_defaults="$ac_x_app_defaults"
231       fi])
232     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
233
234 AC_PATH_X_APP_DEFAULTS
235
236 APPDEFAULTS=$ac_x_app_defaults
237
238
239 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
240 #
241 AC_DEFUN(AC_CHECK_X_HEADER, [
242   ac_save_CPPFLAGS="$CPPFLAGS"
243   if test \! -z "$includedir" ; then 
244     CPPFLAGS="$CPPFLAGS -I$includedir"
245   fi
246   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
247   AC_CHECK_HEADER([$1], [$2])
248   CPPFLAGS="$ac_save_CPPFLAGS"])
249
250 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
251 #
252 AC_DEFUN(AC_EGREP_X_HEADER, [
253   ac_save_CPPFLAGS="$CPPFLAGS"
254   if test \! -z "$includedir" ; then 
255     CPPFLAGS="$CPPFLAGS -I$includedir"
256   fi
257   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
258   AC_EGREP_HEADER([$1], [$2], [$3], [$4])
259   CPPFLAGS="$ac_save_CPPFLAGS"])
260
261 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
262 #
263 AC_DEFUN(AC_TRY_X_COMPILE, [
264   ac_save_CPPFLAGS="$CPPFLAGS"
265   if test \! -z "$includedir" ; then 
266     CPPFLAGS="$CPPFLAGS -I$includedir"
267   fi
268   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
269   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
270   CPPFLAGS="$ac_save_CPPFLAGS"])
271
272
273 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
274 # Use this sparingly; it probably doesn't work very well on X programs.
275 #
276 AC_DEFUN(AC_CHECK_X_LIB, [
277   ac_save_CPPFLAGS="$CPPFLAGS"
278   ac_save_LDFLAGS="$LDFLAGS"
279   if test \! -z "$includedir" ; then 
280     CPPFLAGS="$CPPFLAGS -I$includedir"
281   fi
282   if test \! -z "$includedir" ; then 
283     CPPFLAGS="$CPPFLAGS -I$includedir"
284   fi
285   if test \! -z "$libdir" ; then
286     LDFLAGS="$LDFLAGS -L$libdir"
287   fi
288   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
289   if test \! -z "$x_libraries" ; then
290     LDFLAGS="$LDFLAGS -L$x_libraries"
291   fi
292   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
293   CPPFLAGS="$ac_save_CPPFLAGS"
294   LDFLAGS="$ac_save_LDFLAGS"])
295
296 # Like AC_TRY_RUN, but it uses the already-computed -I directories.
297 # (But not the -L directories!)
298 #
299 AC_DEFUN(AC_TRY_X_RUN, [
300   ac_save_CPPFLAGS="$CPPFLAGS"
301   if test \! -z "$includedir" ; then 
302     CPPFLAGS="$CPPFLAGS -I$includedir"
303   fi
304   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
305   AC_TRY_RUN([$1], [$2], [$3], [$4])
306   CPPFLAGS="$ac_save_CPPFLAGS"])
307
308
309
310
311
312 # check for the HP XHPDisableReset server extension headers.
313 #
314 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
315                   [AC_DEFINE(HAVE_XHPDISABLERESET)
316                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
317
318
319 # Check for the availability of the XPointer typedef, and define it otherwise.
320 #
321 AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
322                 [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
323                                   [XPointer foo = (XPointer) 0;],
324                                   [ac_cv_xpointer=yes],
325                                   [ac_cv_xpointer=no])])
326 if test $ac_cv_xpointer != yes; then
327   AC_DEFINE(XPointer,[char*])
328 fi
329
330
331 case "$host" in
332   *-hpux*)
333     # Thanks for not making xmkmf find this by default, you losers.
334     if test -d /usr/lib/Motif1.2 ; then
335       X_CFLAGS="-I/usr/include/Motif1.2 $X_CFLAGS"
336       X_LIBS="-L/usr/lib/Motif1.2 $X_LIBS"
337     elif test -d /usr/lib/Motif1.1 ; then
338       X_CFLAGS="-I/usr/include/Motif1.1 $X_CFLAGS"
339       X_LIBS="-L/usr/lib/Motif1.1 $X_LIBS"
340     fi
341
342     # This too.  You losers.
343     if test -d /usr/contrib/X11R6/include ; then
344       X_CFLAGS="-I/usr/contrib/X11R6/include $X_CFLAGS"
345       X_LIBS="-L/usr/contrib/X11R6/lib $X_LIBS"
346     elif test -d /usr/X11R6/include ; then
347       X_CFLAGS="-I/usr/X11R6/include $X_CFLAGS"
348       X_LIBS="-L/usr/X11R6/lib $X_LIBS"
349     elif test -d /usr/contrib/X11R5/include ; then
350       X_CFLAGS="-I/usr/contrib/X11R5/include $X_CFLAGS"
351       X_LIBS="-L/usr/contrib/X11R5/lib $X_LIBS"
352     elif test -d /usr/X11R5/include ; then
353       X_CFLAGS="-I/usr/X11R5/include $X_CFLAGS"
354       X_LIBS="-L/usr/X11R5/lib $X_LIBS"
355     fi
356
357   ;;
358   *-solaris*)
359     # Same to you, pinheads.  (Is this really the standard location now?
360     # What happened to the joke that this kind of thing went in /opt?)
361     # cthomp says "answer: CDE (Common Disorganized Environment)"
362     if test -f /usr/dt/include/Xm/Xm.h ; then
363       X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
364       X_LIBS="$X_LIBS -L/usr/dt/lib -R:/usr/dt/lib"
365
366       # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
367       AC_CHECK_LIB(gen, regcmp, [X_LIBS="$X_LIBS -lgen"])
368     fi
369   ;;
370 esac
371
372
373
374 # Check for Xmu (some fucked up vendors don't ship it...)
375 #
376 have_xmu=no
377 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
378 if test $have_xmu = no ; then
379   XMU_SRCS='$(UTILS_SRC)/xmu.c'
380   XMU_OBJS='$(UTILS_BIN)/xmu.o'
381 else
382   XMU_SRCS=''
383   XMU_OBJS=''
384   SAVER_LIBS="-lXmu $SAVER_LIBS"
385   HACK_LIBS="-lXmu $HACK_LIBS"
386   AC_DEFINE(HAVE_XMU)
387 fi
388
389
390 # See comp.windows.x FAQ question 124 about _get_wmShellWidgetClass on 4.1.x.
391 # The right fix is to get OpenWindows 3.0 patches 100512-02 and 100573-03.
392 #
393 if test $have_xmu = yes ; then
394   case "$host" in
395     *-sunos4*)
396     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
397                    ac_cv_sunos_xmu_bug,
398                    [ac_save_LDFLAGS="$LDFLAGS"
399                     if test \! -z "$x_libraries" ; then
400                       LDFLAGS="$LDFLAGS -L$x_libraries"
401                     fi
402                     # Note: this trick never works!  (Generally.)
403                     # We're only getting away with using AC_TRY_LINK
404                     # with X libraries because we know it's SunOS.
405                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
406                     AC_TRY_LINK(,,
407                                 [ac_cv_sunos_xmu_bug=no],
408                                 [ac_cv_sunos_xmu_bug=yes])
409                     LDFLAGS="$ac_save_LDFLAGS"])
410     if test $ac_cv_sunos_xmu_bug = yes ; then
411       AC_CACHE_CHECK([whether the compiler understands -static], 
412                      ac_cv_ld_static,
413                      [ac_save_LDFLAGS="$LDFLAGS"
414                       LDFLAGS="$LDFLAGS -static"
415                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
416                     LDFLAGS="$ac_save_LDFLAGS"])
417       if test $ac_cv_ld_static = yes ; then
418         LDFLAGS="$LDFLAGS -static"
419       else
420         LDFLAGS="$LDFLAGS -Bstatic"
421       fi
422     fi
423     ;;
424   esac
425 fi
426
427
428 # Check for the SGI SCREEN_SAVER server extension header.
429 #
430 have_sgi=no
431 with_sgi_req=unspecified
432 AC_ARG_WITH(sgi-ext,[
433 Server options:
434
435   --with-sgi-ext          Include support for the SGI SCREEN_SAVER
436                           server extension, if possible (this is the default).
437   --without-sgi-ext       Do not compile in support for this extension.],
438   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
439 if test $with_sgi = yes; then
440   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
441                     [have_sgi=yes
442                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
443
444 elif test $with_sgi != no; then
445   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
446   exit 1
447 fi
448
449 # Check for the MIT-SCREEN-SAVER server extension header,
450 # unless the SGI extension has already been found.
451 #
452 have_mit=no
453 with_mit_req=unspecified
454 AC_ARG_WITH(mit-ext,
455 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER
456                           server extension, if possible (this is the default).
457   --without-mit-ext       Do not compile in support for this extension.],
458   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
459 if test $have_sgi != yes; then
460   if test $with_mit = yes; then
461     AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
462
463     # Now check to see if it's really in the library; XF86Free-3.3 ships
464     # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
465     #
466     if test $have_mit = yes; then
467       AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [], [have_mit=no], -lm)
468
469       if test $have_mit = no; then
470         # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
471         # of in Xext.  Thank you master, may I have another.
472         AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
473                        [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
474                        [], -lX11 -lXext -lm)
475       fi
476
477       if test $have_mit = no; then
478         # Double fuck!  Looks like some versions of XFree86 (whichever version
479         # it is that comes with RedHat Linux 2.0 -- I can't find a version 
480         # number) put this garbage in Xss instead of Xext.  Thank you master,
481         #  may I have another.
482         AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
483                        [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
484                        [], -lX11 -lXext -lm)
485       fi
486
487     if test $have_mit = yes; then
488       AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
489     fi
490
491     fi
492
493   elif test $with_mit != no; then
494     echo "error: must be yes or no: --with-mit-ext=$with_mit"
495     exit 1
496   fi
497 fi
498
499
500 # Check for the XIDLE server extension header.
501 #
502 have_xidle=no
503 with_xidle_req=unspecified
504 AC_ARG_WITH(xidle-ext,
505 [  --with-xidle-ext        Include support for the XIDLE server extension,
506                           if possible (this is the default).
507   --without-xidle-ext     Do not compile in support for this extension.],
508   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
509 if test $with_xidle = yes; then
510   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
511                     [have_xidle=yes
512                      AC_DEFINE(HAVE_XIDLE_EXTENSION)])
513 elif test $with_xidle != no; then
514   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
515   exit 1
516 fi
517
518
519 # Check for the XSHM server extension header.
520 #
521 have_xshm=no
522 with_xshm_req=unspecified
523 AC_ARG_WITH(xshm-ext,
524 [  --with-xshm-ext         Include support for the XSHM (Shared Memory) server
525                           extension, if possible (this is the default).
526   --without-xshm-ext      Do not compile in support for this extension.],
527   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
528 if test $with_xshm = yes; then
529
530   # first check for Xshm.h.
531   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes])
532
533   # if that succeeded, then check for sys/ipc.h.
534   if test $have_xshm = yes; then
535     have_xshm=no
536     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
537   fi
538
539   # if that succeeded, then check for sys/shm.h.
540   if test $have_xshm = yes; then
541     have_xshm=no
542     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
543   fi
544
545   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
546   # to exist, but the library code to not exist.  And even better, the library
547   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
548   # lib doesn't exist, give up.
549   #
550   case "$host" in
551     *-aix*)
552       have_xshm=no
553       AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
554                      [have_xshm=yes; SAVER_LIBS="$SAVER_LIBS -lXextSam"],
555                        [], -lX11 -lXext -lm)
556     ;;
557   esac
558
559   # if that succeeded, then we've really got it.
560   if test $have_xshm = yes; then
561     AC_DEFINE(HAVE_XSHM_EXTENSION)
562   fi
563
564 elif test $with_xshm != no; then
565   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
566   exit 1
567 fi
568
569
570 # Check for the SGI-VIDEO-CONTROL server extension header.
571 #
572 have_sgivc=no
573 with_sgivc_req=unspecified
574 AC_ARG_WITH(sgivc-ext,
575 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL server
576                           extension, if possible (this is the default).
577   --without-sgivc-ext     Do not compile in support for this extension.],
578   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
579 if test $with_sgivc = yes; then
580
581   # first check for XSGIvc.h
582   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes])
583
584   # if that succeeded, then check for the -lXsgivc
585   if test $have_sgivc = yes; then
586     have_sgivc=no
587     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
588                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [],
589                   -lXext -lX11)
590   fi
591
592   # if that succeeded, then we've really got it.
593   if test $have_sgivc = yes; then
594     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
595   fi
596
597 elif test $with_sgivc != no; then
598   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
599   exit 1
600 fi
601
602
603 # Check for the DPMS server extension header.
604 #
605 have_dpms=no
606 with_dpms_req=unspecified
607 AC_ARG_WITH(dpms-ext,
608 [  --with-dpms-ext         Include support for the DPMS server extension,
609                           if possible (this is the default).
610   --without-dpms-ext      Do not compile in support for this extension.],
611   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
612 if test $with_dpms = yes; then
613
614   # first check for dpms.h
615   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
616
617   # if that succeeded, then check for the -lXdpms
618   if test $have_dpms = yes; then
619     have_dpms=no
620     AC_CHECK_X_LIB(Xdpms, DPMSInfo,
621                   [have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"], [],
622                   -lXext -lX11)
623   fi
624
625   # if that succeeded, then we've really got it.
626   if test $have_dpms = yes; then
627     AC_DEFINE(HAVE_DPMS_EXTENSION)
628   fi
629
630 elif test $with_dpms != no; then
631   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
632   exit 1
633 fi
634
635
636
637 # Check for Motif and Athena --with and --without arguments.
638 #
639 have_motif=no
640 have_athena=no
641 have_athena3d=no
642 with_motif_req=unspecified
643 with_athena_req=unspecified
644
645 AC_ARG_WITH(motif,[
646 Toolkit options:
647
648   --with-motif            Use the Motif toolkit for the user interface,
649                           if possible (this is the default).
650   --without-motif         Do not use Motif.],
651   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
652
653 AC_ARG_WITH(athena,
654 [  --with-athena           Use the Athena toolkit for the user interface, if
655                           possible (this is the default if Motif isn't used.)
656   --without-athena        Do not use Athena.],
657   [with_athena="$withval"; with_athena_req="$withval"],[with_athena=no])
658
659 if test $with_motif != yes -a $with_motif != no ; then
660   echo "error: must be yes or no: --with-motif=$with_motif"
661   exit 1
662 fi
663
664 if test $with_athena != yes -a $with_athena != no ; then
665   echo "error: must be yes or no: --with-athena=$with_athena"
666   exit 1
667 fi
668
669
670 # Saying --without-motif is the same as saying --with-athena.
671 if test $with_motif_req = no ; then
672   with_athena_req=yes
673   with_athena=yes
674 fi
675
676 # Saying --without-athena is the same as saying --with-motif.
677 if test $with_athena_req = no ; then
678   with_motif_req=yes
679   with_motif=yes
680 fi
681
682 # Check for Motif and Athena headers.
683
684 check_motif() {
685   AC_CHECK_X_HEADER(Xm/Xm.h,
686                     [have_motif=yes
687                      AC_DEFINE(HAVE_MOTIF)
688                      SAVER_LIBS="-lXm $SAVER_LIBS"])
689 }
690
691 check_athena() {
692   have_athena=no
693   have_athena3d=no
694   AC_CHECK_X_HEADER(X11/Xaw/Dialog.h, [have_athena=yes])
695   AC_CHECK_X_LIB(Xaw3d, Xaw3dComputeTopShadowRGB,
696                  [have_athena=yes; have_athena3d=yes], [],
697                  -lXt -lXmu -lXext -lX11)
698
699   if test $have_athena3d = yes; then
700     SAVER_LIBS="-lXaw3d $SAVER_LIBS"
701   elif test $have_athena = yes; then
702     SAVER_LIBS="-lXaw $SAVER_LIBS"
703   fi
704 }
705
706
707 # If they asked for both motif and athena, check motif then athena.
708 # If they asked for only motif, check motif then athena.
709 # If they asked for only athena, check athena then motif.
710 # If they asked for neither, check motif then athena.
711
712 proselytize_motif=yes
713 if test $with_motif = yes; then
714   # asked for both, or for motif only
715   check_motif
716   if test $have_motif = yes; then
717     with_athena=no
718     with_athena_req=no
719   else
720     check_athena
721   fi
722
723 elif test $with_athena = yes; then
724   # asked for athena only
725   check_athena
726   if test $have_athena = yes; then
727     with_motif=no
728     proselytize_motif=no
729   else
730     check_motif
731   fi
732
733 else
734   # asked for neither
735   check_motif
736   if test $have_motif = yes; then
737     with_athena=no
738   else
739     check_athena
740   fi
741
742 fi
743
744 if test $have_motif = yes; then
745   proselytize_motif=no
746 fi
747
748 # If we have Athena, check whether it's a version that includes
749 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
750 if test $have_athena = yes ; then
751   AC_CACHE_CHECK([for XawViewportSetCoordinates in Viewport.h], 
752                  ac_cv_have_XawViewportSetCoordinates,
753                  [ac_cv_have_XawViewportSetCoordinates=no
754                   AC_EGREP_X_HEADER(XawViewportSetCoordinates, 
755                                     X11/Xaw/Viewport.h,
756                                     ac_cv_have_XawViewportSetCoordinates=yes)])
757   if test $ac_cv_have_XawViewportSetCoordinates = yes ; then
758     AC_DEFINE(HAVE_XawViewportSetCoordinates)
759   fi
760 fi
761
762
763 # If we have Motif, check whether it's really LessTif.
764 #
765 have_lesstif=no
766 if test $have_motif = yes ; then
767   AC_CACHE_CHECK([whether Motif is really LessTif], 
768                  ac_cv_have_lesstif,
769                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
770                                    [long vers = LesstifVersion;],
771                                    [ac_cv_have_lesstif=yes],
772                                    [ac_cv_have_lesstif=no])])
773   have_lesstif=$ac_cv_have_lesstif
774 fi
775
776 # don't cache this
777 unset ac_cv_good_lesstif
778
779 good_lesstif=no
780 if test $have_lesstif = yes ; then
781   # It must be at least "GNU Lesstif 0.82".
782   # #### If you change this, also sync the warning message lower down.
783   AC_CACHE_CHECK([whether LessTif is of a recent enough vintage],
784                  ac_cv_good_lesstif,
785                  [AC_TRY_X_RUN([#include <Xm/Xm.h>
786                                 int main() { exit(LesstifVersion < 82); }],
787                                [ac_cv_good_lesstif=yes],
788                                [ac_cv_good_lesstif=no],
789                                # cross compiling?  Make an ass out of umption.
790                                [ac_cv_good_lesstif=yes])])
791   good_lesstif=$ac_cv_good_lesstif
792 fi
793
794
795 # Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
796 # Extension".   Why this extension isn't in -lXext with all the others,
797 # I have no idea.
798 #
799 have_xp_ext=no
800 if test $have_motif = yes ; then
801    have_xp_ext=no
802    AC_CHECK_X_LIB(Xp, XpQueryExtension,
803                   [have_xp_ext=yes; SAVER_LIBS="$SAVER_LIBS -lXp"],
804                   [], -lX11 -lXext -lm)
805 fi
806
807
808 # check for XPM header.
809 #
810 have_xpm=no
811 with_xpm_req=unspecified
812 AC_ARG_WITH(xpm,[
813 Demo options:
814
815   --with-xpm              Include support for XPM files in some demos,
816                           if possible (this is the default).
817   --without-xpm           Do not compile in support for XPM files.],
818   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
819 if test $with_xpm = yes; then
820   AC_CHECK_X_HEADER(X11/xpm.h,
821                    [have_xpm=yes
822                     AC_DEFINE(HAVE_XPM)
823                     XPM_LIBS="-lXpm"])
824 elif test $with_xpm != no; then
825   echo "error: must be yes or no: --with-xpm=$with_xpm"
826   exit 1
827 fi
828
829
830 # check for the GL header
831 #
832 have_gl=no
833 with_gl_req=unspecified
834 AC_ARG_WITH(gl,
835 [  --with-gl               Build those demos which depend on OpenGL,
836                           if possible (this is the default).
837   --without-gl            Do not build the OpenGL demos.],
838   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
839
840 if test $with_gl = yes; then
841   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
842   if test $have_gl = yes ; then
843     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
844   fi
845
846   # If we have the headers, try and figure out which vendor it's from.
847   #
848   if test $have_gl = yes ; then
849
850     AC_DEFINE(HAVE_GL)
851     have_mesa_gl=no
852     AC_EGREP_X_HEADER(Mesa, GL/glx.h, [have_mesa_gl=yes])
853     if test $have_mesa_gl = no ; then
854       GL_LIBS="-lGL -lGLU"
855     else
856       AC_DEFINE(HAVE_MESA_GL)
857       GL_LIBS="-lMesaGL -lMesaGLU"
858     fi
859   fi
860
861 elif test $with_gl != no; then
862   echo "error: must be yes or no: --with-gl=$with_gl"
863   exit 1
864 fi
865
866
867 # check for SGI XReadDisplay server extension header.
868 #
869 have_readdisplay=no
870 with_readdisplay_req=unspecified
871 AC_ARG_WITH(readdisplay,
872 [  --with-readdisplay      Include support for the XReadDisplay server
873                           extension if possible (this is the default).
874   --without-readdisplay   Do not compile in support for this extension.],
875   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
876   [with_readdisplay=yes])
877 if test $with_readdisplay = yes; then
878   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
879                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
880 elif test $with_readdisplay != no; then
881   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
882   exit 1
883 fi
884
885
886 # check for SGI's Iris Video Library header.
887 #
888 have_sgivideo=no
889 with_sgivideo_req=unspecified
890 AC_ARG_WITH(sgivideo,
891 [  --with-sgivideo         Include support for SGI's Iris Video Library
892                           if possible (this is the default).
893   --without-sgivideo       Do not compile in support for this library.],
894   [with_sgivideo="$withval"; with_sgivideo_req="$withval"],
895   [with_sgivideo=yes])
896 if test $with_sgivideo = yes; then
897   AC_CHECK_X_HEADER(dmedia/vl.h, have_sgivideo=yes)
898   if test $have_sgivideo = yes; then
899     have_sgivideo=no
900     AC_CHECK_LIB(vl, vlOpenVideo, have_sgivideo=yes)
901     if test $have_sgivideo = yes; then
902       SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
903       SGI_VIDEO_LIBS="-lvl"
904       AC_DEFINE(HAVE_SGI_VIDEO)
905     fi
906   fi
907 elif test $with_sgivideo != no; then
908   echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
909   exit 1
910 fi
911
912
913
914 # Try to find a program to generate random text.
915 #
916 # Zippy is funnier than the idiocy generally spat out by `fortune',
917 # so try to find that, by invoking Emacs and asking it where its 
918 # libexec directory is ("yow" lives in there.)
919 #
920 # If that doesn't work, see if fortune, zippy, or yow are on $PATH,
921 # and if so, use them.
922 #
923 # If that doesn't work, look in /usr/games, and if it's there, use
924 # the full pathname.
925 #
926 with_zippy_req=""
927 AC_ARG_WITH(zippy,
928 [  --with-zippy=PROGRAM    Some demos are able to run an external program and
929                           display its text; this names the program to use by
930                           default (though it can be overridden with X
931                           resources.)  If you don't specify this, the default
932                           is to use \"yow\" from the Emacs distribution (if you
933                           have it) or else to use \"fortune\".],
934   [ with_zippy_req="$withval"; with_zippy="$withval" ],
935   [ with_zippy_req="$withval"; with_zippy="$withval" ])
936
937 if test "$with_zippy" = no || test "$with_zippy" = yes ; then
938   with_zippy=""
939   with_zippy_req=""
940 fi
941
942 if test -n "$with_zippy_req" ; then
943   ac_cv_zippy_program=""
944   case "$with_zippy_req" in
945     /*)
946       AC_MSG_CHECKING([for $with_zippy_req])
947       if test -x "$with_zippy_req" ; then
948         AC_MSG_RESULT(yes)
949       else
950         AC_MSG_RESULT(no)
951         with_zippy=""
952       fi
953     ;;
954     *)
955       # don't cache
956       unset ac_cv_path_zip2
957       AC_PATH_PROG(zip2, $with_zippy_req, [])
958       if test "$zip2" = ""; then
959         with_zippy=""
960       fi
961     ;;
962   esac
963   ac_cv_zippy_program="$with_zippy"
964
965 elif test -n "$ac_cv_zippy_program"; then
966   AC_MSG_RESULT([checking for zippy... (cached) $ac_cv_zippy_program])
967 fi
968
969 if test ! -n "$ac_cv_zippy_program"; then
970
971   AC_CHECK_PROGS(emacs_exe, emacs)
972   AC_CHECK_PROGS(xemacs_exe, xemacs)
973
974   ac_cv_zippy_program=""
975   eargs='-batch -q -nw --eval'
976
977   if test -n "$emacs_exe" ; then
978     AC_MSG_CHECKING([for emacs yow])
979     #
980     # get emacs to tell us where the libexec directory is.
981     #
982     dir=`$emacs_exe $eargs '(princ (concat exec-directory "\n"))' \
983          2>/dev/null | tail -1`
984     dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
985     #
986     # try running libexec/yow and see if it exits without error.
987     #
988     if test x"$dir" != x -a -x $dir/yow ; then
989       if $dir/yow >&- 2>&- ; then
990         ac_cv_zippy_program="$dir/yow"
991         AC_MSG_RESULT($ac_cv_zippy_program)
992       else
993         AC_MSG_RESULT(no)
994       fi
995     fi
996   fi
997
998   if test -z "$ac_cv_zippy_program" ; then
999     AC_MSG_CHECKING([for xemacs yow])
1000     if test -n "$xemacs_exe" ; then
1001       #
1002       # get xemacs to tell us where the libexec directory is.
1003       #
1004       dir=`$xemacs_exe $eargs '(princ (concat exec-directory "\n"))' \
1005            2>/dev/null | tail -1`
1006       dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
1007       #
1008       # try running libexec/yow and see if it exits without error.
1009       #
1010       if test x"$dir" != x -a -x $dir/yow ; then
1011         if $dir/yow >&- 2>&- ; then
1012           ac_cv_zippy_program="$dir/yow"
1013           AC_MSG_RESULT($ac_cv_zippy_program)
1014         else
1015           #
1016           # in some xemacs installations, the pathname of the yow.lines file
1017           # isn't hardcoded into the yow executable, and must be passed on 
1018           # the command line.  See if it's in libexec/../etc/.
1019
1020           # M4 sucks!!
1021           changequote(X,Y)
1022           dir_up=`echo "$dir" | sed 's@/[^/]*$@@'`
1023           changequote([,])
1024
1025           yow="yow -f $dir_up/etc/yow.lines"
1026           if $dir/$yow >&- 2>&- ; then
1027             ac_cv_zippy_program="$dir/$yow"
1028             AC_MSG_RESULT($ac_cv_zippy_program)
1029           else
1030             AC_MSG_RESULT(no)
1031           fi
1032         fi
1033       fi
1034     fi
1035   fi
1036
1037   # if that didn't work, try for some other programs...
1038   if test -z "$ac_cv_zippy_program" ; then
1039     fortune=''
1040     AC_CHECK_PROGS(fortune, [fortune zippy yow])
1041     # if that didn't work, try for those programs in /usr/games...
1042     if test -z "$fortune" ; then
1043       AC_PATH_PROGS(fortune, [fortune zippy yow], fortune,
1044                     /usr/games:/usr/local/games)
1045     fi
1046   fi
1047 fi
1048
1049 if test -z "$ac_cv_zippy_program" ; then
1050   ac_cv_zippy_program=fortune
1051 fi
1052
1053 AC_DEFINE_UNQUOTED(ZIPPY_PROGRAM, "$ac_cv_zippy_program")
1054
1055
1056
1057
1058 # Allow locking to be disabled at compile-time.
1059 #
1060 have_locking=yes
1061 have_kerberos=no
1062 with_kerberos_req=unspecified
1063 have_shadow=no
1064 with_shadow_req=unspecified
1065 need_setuid=no
1066
1067 AC_ARG_ENABLE(locking,[
1068 Locking options:
1069
1070   --enable-locking        Compile in support for locking the display
1071                           (this is the default.)
1072   --disable-locking       Do not allow locking at all.],
1073   [enable_locking="$enableval"],[enable_locking=yes])
1074 if test $enable_locking = yes; then
1075
1076   # Check for Kerberos.
1077   #
1078   AC_ARG_WITH(kerberos, [
1079   --with-kerberos         Include support for Kerberos authentication,
1080                           if possible (this is the default.)
1081   --without-kerberos      Do not compile in support for Kerberos.],
1082   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1083   if test $with_kerberos = yes; then
1084     AC_CACHE_CHECK([for Kerberos], ac_cv_kerberos,
1085                    [AC_TRY_X_COMPILE([#include <krb.h>],,
1086                                      [ac_cv_kerberos=yes],
1087                                      [ac_cv_kerberos=no])])
1088     if test $ac_cv_kerberos = yes ; then
1089       have_kerberos=yes
1090       AC_DEFINE(HAVE_KERBEROS)
1091       PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lnsl -lsocket"
1092     fi
1093   elif test $with_kerberos != no; then
1094     echo "error: must be yes or no: --with-kerberos=$with_kerberos"
1095     exit 1
1096   fi
1097
1098   # Next, check for the nine billion variants of shadow passwords...
1099
1100   passwd_cruft_done=no
1101   AC_ARG_WITH(shadow,
1102 [  --with-shadow           Include support for shadow password authentication,
1103                           if possible (this is the default, if no Kerberos.)
1104   --without-shadow        Do not compile in support for shadow passwords.
1105 ],
1106   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1107   if test $with_shadow = no; then
1108     passwd_cruft_done=yes
1109   elif test $with_shadow != yes; then
1110     echo "error: must be yes or no: --with-shadow=$with_shadow"
1111     exit 1
1112   fi
1113
1114
1115   # Sun's "adjunct" passwords.
1116   #
1117   if test $passwd_cruft_done = no ; then
1118     AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1119                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1120                                       #include <unistd.h>
1121                                       #include <sys/types.h>
1122                                       #include <sys/label.h>
1123                                       #include <sys/audit.h>
1124                                       #include <pwdadj.h>],
1125                         [struct passwd_adjunct *p = getpwanam("nobody");
1126                          const char *pw = p->pwa_passwd;],
1127                         [ac_cv_sun_adjunct=yes],
1128                         [ac_cv_sun_adjunct=no])])
1129     if test $ac_cv_sun_adjunct = yes; then
1130       have_shadow=yes
1131       need_setuid=yes
1132       passwd_cruft_done=yes
1133       AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1134     fi
1135   fi
1136
1137   # DEC and SCO so-called "enhanced" security.
1138   #
1139   if test $passwd_cruft_done = no ; then
1140     AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1141                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1142                                       #include <unistd.h>
1143                                       #include <sys/types.h>
1144                                       #include <pwd.h>
1145                                       #include <sys/security.h>
1146                                       #include <prot.h>],
1147                         [struct pr_passwd *p;
1148                          const char *pw;
1149                          set_auth_parameters(0, 0);
1150                          check_auth_parameters();
1151                          p = getprpwnam("nobody");
1152                          pw = p->ufld.fd_encrypt;],
1153                         [ac_cv_enhanced_passwd=yes],
1154                         [ac_cv_enhanced_passwd=no])])
1155     if test $ac_cv_enhanced_passwd = yes; then
1156       have_shadow=yes
1157       need_setuid=yes
1158       passwd_cruft_done=yes
1159       AC_DEFINE(HAVE_ENHANCED_PASSWD)
1160
1161       # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1162       # (I'm told it needs -lcurses too, but I don't understand why.)
1163       AC_CHECK_LIB(prot, getprpwnam, 
1164                    [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1165                    [# On DEC, getprpwnam() is in -lsecurity
1166                     AC_CHECK_LIB(security, getprpwnam, 
1167                                  [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1168                    [-lx])
1169     fi
1170   fi
1171
1172   # HP's entry in the "Not Invented Here" Sweepstakes.
1173   #
1174   if test $passwd_cruft_done = no ; then
1175     AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1176                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1177                                       #include <unistd.h>
1178                                       #include <sys/types.h>
1179                                       #include <pwd.h>
1180                                       #include <hpsecurity.h>
1181                                       #include <prot.h>],
1182                         [struct s_passwd *p = getspwnam("nobody");
1183                          const char *pw = p->pw_passwd;],
1184                         [ac_cv_hpux_passwd=yes],
1185                         [ac_cv_hpux_passwd=no])])
1186     if test $ac_cv_hpux_passwd = yes; then
1187       have_shadow=yes
1188       need_setuid=yes
1189       passwd_cruft_done=yes
1190       AC_DEFINE(HAVE_HPUX_PASSWD)
1191
1192       # on HPUX, bigcrypt is in -lsec
1193       AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1194     fi
1195   fi
1196
1197   # Traditional (ha!) shadow passwords.
1198   #
1199   if test $passwd_cruft_done = no ; then
1200     AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1201                    [AC_TRY_X_COMPILE([#include <stdlib.h>
1202                                       #include <unistd.h>
1203                                       #include <sys/types.h>
1204                                       #include <pwd.h>
1205                                       #include <shadow.h>],
1206                         [struct spwd *p = getspnam("nobody");
1207                          const char *pw = p->sp_pwdp;],
1208                         [ac_cv_shadow=yes],
1209                         [ac_cv_shadow=no])])
1210     if test $ac_cv_shadow = yes; then
1211       have_shadow=yes
1212       need_setuid=yes
1213       passwd_cruft_done=yes
1214       AC_DEFINE(HAVE_SHADOW_PASSWD)
1215
1216       # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1217       have_getspnam=no
1218       AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1219       if test $have_getspnam = no ; then
1220         AC_CHECK_LIB(gen, getspnam,
1221                      [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1222       fi
1223     fi
1224   fi
1225
1226   # On FreeBSD, getpwnam() and friends work just like on non-shadow-password
1227   # systems -- except you only get stuff in the pw_passwd field if the running
1228   # program is setuid.  So, guess that we've got this lossage to contend with
1229   # if /etc/master.passwd exists, and default to a setuid installation.
1230   #
1231   if test $passwd_cruft_done = no ; then
1232     AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1233                    [if test -f /etc/master.passwd ; then
1234                       ac_cv_master_passwd=yes
1235                     else
1236                       ac_cv_master_passwd=no
1237                     fi])
1238     if test $ac_cv_master_passwd = yes; then
1239       need_setuid=yes
1240       passwd_cruft_done=yes
1241     fi
1242   fi
1243
1244   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1245   have_crypt=no
1246   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1247   if test $have_crypt = no ; then
1248     AC_CHECK_LIB(crypt, crypt,
1249                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1250   fi
1251
1252
1253   # Most of the above shadow mechanisms will have set need_setuid to yes,
1254   # if they were found.  But, on some systems, we need setuid even when
1255   # using plain old vanilla passwords.
1256   #
1257   if test $need_setuid = no ; then
1258     case "$host" in
1259       *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1260         need_setuid=yes
1261       ;;
1262     esac
1263   fi
1264
1265 elif test $enable_locking = no; then
1266   AC_DEFINE(NO_LOCKING)
1267 else
1268   echo "error: must be yes or no: --enable-locking=$enable_locking"
1269   exit 1
1270 fi
1271
1272
1273
1274 if test \! -z "$includedir" ; then 
1275   INCLUDES="-I$includedir"
1276 fi
1277
1278 if test \! -z "$libdir" ; then
1279   LDFLAGS="$LDFLAGS -L$libdir"
1280 fi
1281
1282
1283 ##### should have options to override the DEPEND crap, I guess...
1284 DEPEND=makedepend
1285 DEPEND_FLAGS=
1286 DEPEND_DEFINES=
1287
1288
1289 # Autoconf doesn't seem to have an INSTALL_DIRS, so let's define our own...
1290 INSTALL_DIRS='$(INSTALL) -d'
1291
1292 # Done testing things -- now substitute in some stuff for the Makefiles.
1293 #
1294 if test $have_motif = yes; then
1295   AC_DEFINE(HAVE_MOTIF)
1296   DIALOG_SRCS='$(MOTIF_SRCS)'
1297   DIALOG_OBJS='$(MOTIF_OBJS)'
1298 elif test $have_athena = yes; then
1299   AC_DEFINE(HAVE_ATHENA)
1300   DIALOG_SRCS='$(ATHENA_SRCS)'
1301   DIALOG_OBJS='$(ATHENA_OBJS)'
1302 else
1303   DIALOG_SRCS=''
1304   DIALOG_OBJS=''
1305 fi
1306
1307 if test $have_kerberos = yes; then
1308   PASSWD_SRCS='$(KERBEROS_SRCS)'
1309   PASSWD_OBJS='$(KERBEROS_OBJS)'
1310 else
1311   PASSWD_SRCS='$(PWENT_SRCS)'
1312   PASSWD_OBJS='$(PWENT_OBJS)'
1313 fi
1314
1315 if test $enable_locking = yes; then
1316   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
1317   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
1318 else
1319   LOCK_SRCS=''
1320   LOCK_OBJS=''
1321 fi
1322
1323 if test $need_setuid = yes; then
1324   NEED_SETUID=yes
1325   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
1326 else
1327   NEED_SETUID=no
1328   INSTALL_SETUID='$(INSTALL_PROGRAM)'
1329 fi
1330
1331 tab='   '
1332 if test $have_gl = yes; then
1333   GL_EXES='$(GL_EXES)'
1334   GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'  \'
1335   GL_KLUDGE_2=${tab}
1336 else
1337   GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'\n'
1338   GL_KLUDGE_2='!'${tab}
1339 fi
1340
1341 AC_SUBST(INCLUDES)
1342
1343 AC_SUBST(SAVER_LIBS)
1344 AC_SUBST(HACK_LIBS)
1345 AC_SUBST(XPM_LIBS)
1346 AC_SUBST(GL_LIBS)
1347 AC_SUBST(PASSWD_LIBS)
1348 AC_SUBST(INSTALL_SETUID)
1349 AC_SUBST(INSTALL_DIRS)
1350 AC_SUBST(NEED_SETUID)
1351 AC_SUBST(SGI_VIDEO_OBJS)
1352 AC_SUBST(SGI_VIDEO_LIBS)
1353
1354 AC_SUBST(DIALOG_SRCS)
1355 AC_SUBST(DIALOG_OBJS)
1356 AC_SUBST(PASSWD_SRCS)
1357 AC_SUBST(PASSWD_OBJS)
1358 AC_SUBST(XMU_SRCS)
1359 AC_SUBST(XMU_OBJS)
1360 AC_SUBST(LOCK_SRCS)
1361 AC_SUBST(LOCK_OBJS)
1362 AC_SUBST(GL_EXES)
1363 AC_SUBST(GL_KLUDGE_1)
1364 AC_SUBST(GL_KLUDGE_2)
1365 AC_SUBST(HACKDIR)
1366 AC_SUBST(APPDEFAULTS)
1367
1368 AC_SUBST(DEPEND)
1369 AC_SUBST(DEPEND_FLAGS)
1370 AC_SUBST(DEPEND_DEFINES)
1371
1372 # Print some warnings before emitting the Makefiles.
1373 #
1374 warning=no
1375 warnsep='    #################################################################'
1376 warnpre() {
1377   if test $warning = no ; then
1378     echo '' ; echo "$warnsep" ; echo ''
1379     warning=yes
1380   fi
1381 }
1382
1383 warn() {
1384   warnpre
1385   if test $warning = long ; then echo '' ; fi
1386   warning=yes
1387   echo "    Warning: $@"
1388 }
1389
1390 warnL() {
1391   was=$warning
1392   warnpre
1393   warning=yes
1394   if test $was != no ; then echo '' ; fi
1395   echo "    Warning: $@"
1396 }
1397
1398 warn2() {
1399   echo "             $@"
1400   warning=long
1401 }
1402
1403 if test $with_sgi_req = yes -a $have_sgi = no ; then
1404   warn 'The SGI saver extension was requested, but was not found.'
1405 fi
1406
1407 if test $with_mit_req = yes -a $have_mit = no ; then
1408   warn 'The MIT saver extension was requested, but was not found.'
1409 fi
1410
1411 if test $with_xidle_req = yes -a $have_xidle = no ; then
1412   warn 'The XIdle extension was requested, but was not found.'
1413 fi
1414
1415 if test $with_xshm_req = yes -a $have_xshm = no ; then
1416   warn 'The XSHM extension was requested, but was not found.'
1417 fi
1418
1419 if test $with_sgivc_req = yes -a $have_sgivc = no ; then
1420   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
1421 fi
1422
1423 if test $with_dpms_req = yes -a $have_dpms = no ; then
1424   warn 'The DPMS extension was requested, but was not found.'
1425 fi
1426
1427 if test $have_motif = no -a $have_athena = no ; then
1428   warnL "Neither Motif nor Athena widgets seem to be available;"
1429   warn2 "one or the other is required."
1430   proselytize_motif=no
1431
1432 elif test $with_motif_req = yes -a $have_motif = no ; then
1433   warnL "Use of Motif was requested, but it wasn't found;"
1434   warn2 "Athena will be used instead."
1435
1436 elif test $with_athena_req = yes -a $have_athena = no ; then
1437   warnL "Use of Athena was requested, but it wasn't found;"
1438   warn2 "Motif will be used instead."
1439 fi
1440
1441 if test $have_motif = yes -a $have_lesstif = yes ; then
1442   if test $good_lesstif != yes ; then
1443     warnL "Motif is being used, but it appears to actually be"
1444     warn2 "LessTif, and the version number is less than 0.82!"
1445     warn2 "Such old versions of LessTif are too buggy to use"
1446     warn2 "with XScreenSaver; it is strongly recommended that"
1447     warn2 "you upgrade!  See <http://www.lesstif.org/>."
1448   fi
1449 fi
1450
1451 if test $proselytize_motif = yes ; then
1452     warnL "Athena widgets are being used instead of Motif."
1453     warn2 "XScreenSaver looks much better with Motif, and has"
1454     warn2 "a few extra features as well.  Wouldn't you rather"
1455     warn2 "be using Motif?  It is shipped by every commercial"
1456     warn2 "Unix vendor; and there is a free implementation"
1457     warn2 "available as well: see <http://www.lesstif.org/>."
1458 fi
1459
1460 if test $with_xpm_req = yes -a $have_xpm = no ; then
1461   warn 'Use of XPM was requested, but it was not found.'
1462 fi
1463
1464 if test $with_gl_req = yes -a $have_gl = no ; then
1465   warn 'Use of GL was requested, but it was not found.'
1466 fi
1467
1468 if test $with_readdisplay_req = yes -a $have_readdisplay = no ; then
1469   warn 'Use of XReadDisplay was requested, but it was not found.'
1470 fi
1471
1472 if test $with_sgivideo_req = yes -a $have_sgivideo = no ; then
1473   warn 'Use of the Iris Video Library was requested, but it was not found.'
1474 fi
1475
1476 if test $with_kerberos_req = yes -a $have_kerberos = no ; then
1477   warn 'Use of Kerberos was requested, but it was not found.'
1478 fi
1479
1480 if test $with_shadow_req = yes -a $have_shadow = no ; then
1481   warn 'Use of shadow passwords was requested, but they were not found.'
1482 fi
1483
1484 if test -n "$with_zippy_req"; then
1485   if test "$with_zippy_req" != "$ac_cv_zippy_program" ; then
1486     warnL "$with_zippy_req was requested as the Zippy program,"
1487     warn2 "but was not found.  The default will be used instead."
1488   fi
1489 fi
1490
1491 if test $warning != no; then
1492   echo '' ; echo "$warnsep" ; echo ''
1493 fi
1494
1495
1496 AC_OUTPUT(Makefile
1497           utils/Makefile
1498           driver/Makefile
1499           hacks/Makefile
1500           hacks/glx/Makefile
1501           driver/XScreenSaver.ad)
1502
1503 # You are in a twisty maze of namespaces and syntaxes, all alike.
1504 # Fuck the skull of Unix.
1505 #
1506 eval bindir=${bindir}
1507 eval bindir=${bindir}
1508 eval bindir=${bindir}
1509 eval bindir=${bindir}
1510 eval bindir=${bindir}
1511 eval bindir=${bindir}
1512 eval HACKDIR=${HACKDIR}
1513 eval HACKDIR=${HACKDIR}
1514 eval HACKDIR=${HACKDIR}
1515 eval HACKDIR=${HACKDIR}
1516 eval HACKDIR=${HACKDIR}
1517 eval HACKDIR=${HACKDIR}
1518
1519 echo ""
1520 echo "$warnsep"
1521 echo ""
1522 echo '      When you run "make install", the "xscreensaver" and'
1523 echo '      "xscreensaver-command" executables will be installed in'
1524 echo "      ${bindir}."
1525 echo ""
1526 echo "      The various graphics demos (60+ different executables) will"
1527 echo "      be installed in ${HACKDIR}."
1528 echo ""
1529 echo "      If you would prefer the demos to be installed elsewhere"
1530 echo "      (for example, in a dedicated directory) you should re-run"
1531 echo "      configure with the --enable-subdir=DIR option.  For more"
1532 echo "      information, run $0 --help."
1533 echo ""
1534 echo "$warnsep"
1535 echo ""