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