ftp://ftp.uni-heidelberg.de/pub/X11/contrib/applications/xscreensaver-2.07.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       AC_MSG_RESULT(no idea)
23     ;;
24   esac
25 fi
26
27
28 AC_MSG_CHECKING([whether the compiler works on ANSI C])
29 AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
30    AC_MSG_RESULT(yes),
31    AC_MSG_RESULT(no)
32    AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
33    AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
34
35 case "$host" in
36   *-irix*)
37   if test -n "$GCC"; then
38     AC_MSG_RESULT(Turning on gcc compiler warnings.)
39     CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
40   else
41     # not gcc
42     AC_MSG_RESULT(Turning on SGI compiler warnings.)
43     CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
44   fi
45   ;;
46 esac
47
48
49 AC_PROG_CPP
50 AC_PROG_INSTALL
51 AC_PROG_MAKE_SET
52
53 AC_C_CONST
54 AC_C_INLINE
55
56 AC_HEADER_STDC
57 AC_HEADER_TIME
58 AC_HEADER_SYS_WAIT
59 AC_HEADER_DIRENT
60
61 AC_TYPE_MODE_T
62 AC_TYPE_PID_T
63 AC_TYPE_SIGNAL
64 AC_TYPE_SIZE_T
65
66
67 AC_MSG_CHECKING(how to call gettimeofday)
68 AC_CACHE_VAL(ac_cv_gettimeofday_args,
69  [AC_TRY_COMPILE([#include <stdlib.h>
70                   #include <sys/time.h>],
71                  [struct timeval tv; gettimeofday(&tv);],
72                  [ac_gettimeofday_args=1],
73                  [AC_TRY_COMPILE([#include <stdlib.h>
74                                   #include <sys/time.h>],
75                                  [struct timeval tv; struct timezone tzp;
76                                   gettimeofday(&tv, &tzp);],
77                                  [ac_gettimeofday_args=2],
78                                  [ac_gettimeofday_args=0])])
79   ac_cv_gettimeofday_args=$ac_gettimeofday_args])
80 ac_gettimeofday_args=$ac_cv_gettimeofday_args
81 if test $ac_gettimeofday_args = 1 ; then
82   AC_DEFINE(HAVE_GETTIMEOFDAY)
83   AC_MSG_RESULT(one argument)
84 elif test $ac_gettimeofday_args = 2 ; then
85   AC_DEFINE(HAVE_GETTIMEOFDAY)
86   AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
87   AC_MSG_RESULT(two arguments)
88 else
89   AC_MSG_RESULT(unknown)
90 fi
91
92
93 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv)
94 AC_CHECK_HEADERS(unistd.h)
95
96 dnl     /usr/local/src/ssh-1.2.17/putenv.c -- AC_REPLACE_FUNCS(putenv)
97
98
99 AC_ARG_ENABLE(subdir,[
100 Installation options:
101
102   --enable-subdir=DIR     Put the demo programs in a subdirectory of \`bindir',
103                           instead of putting them in bindir itself.  You can
104                           specify the name of the subdirectory.  For example,
105                           --exec-prefix=/usr/local/bin --enable-subdir=demos
106                           would put xscreensaver in /usr/local/bin/, and would
107                           put the demos in /usr/local/bin/demos/.  Note that if
108                           you do this, you must make sure that the directory
109                           is on your \$PATH before xscreensaver is started: the
110                           directory name is not hardcoded into the program.
111                           This merely sets the default installation location.
112
113   --disable-subdir        Just put the demos in \`bindir' (this is the default.)
114 ],
115   [enable_subdir="$enableval"],[enable_subdir=no])
116 if test x"$enable_subdir" = xno; then
117   HACKDIR='$(bindir)'
118 elif test x"$enable_subdir" = xyes -o x"$enable_subdir" = x ; then
119   echo "error: must be a subdirectory name: --enable-subdir=$enable_subdir"
120   exit 1
121 else
122   HACKDIR='$(bindir)/'$enable_subdir
123 fi
124
125
126 AC_PATH_XTRA
127
128 # Try and find the app-defaults directory.
129 # It sucks that autoconf doesn't do this already...
130 #
131 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,
132   [
133   rm -fr conftestdir
134   if mkdir conftestdir; then
135     cd conftestdir
136     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
137     cat > Imakefile <<'EOF'
138 acfindx:
139         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
140 EOF
141     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
142       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
143       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
144     fi
145     cd ..
146     rm -fr conftestdir
147   fi])
148
149 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,
150 [  # Look for the directory under a standard set of common directories.
151   # Check X11 before X11Rn because it's often a symlink to the current release.
152   for ac_dir in                                 \
153     /usr/X11/lib/app-defaults                   \
154     /usr/X11R6/lib/app-defaults                 \
155     /usr/X11R6/lib/X11/app-defaults             \
156     /usr/X11R5/lib/app-defaults                 \
157     /usr/X11R5/lib/X11/app-defaults             \
158     /usr/X11R4/lib/app-defaults                 \
159     /usr/X11R4/lib/X11/app-defaults             \
160                                                 \
161     /usr/lib/X11/app-defaults                   \
162     /usr/lib/X11R6/app-defaults                 \
163     /usr/lib/X11R5/app-defaults                 \
164     /usr/lib/X11R4/app-defaults                 \
165                                                 \
166     /usr/local/X11/lib/app-defaults             \
167     /usr/local/X11R6/lib/app-defaults           \
168     /usr/local/X11R5/lib/app-defaults           \
169     /usr/local/X11R4/lib/app-defaults           \
170                                                 \
171     /usr/local/lib/X11/app-defaults             \
172     /usr/local/lib/X11R6/app-defaults           \
173     /usr/local/lib/X11R6/X11/app-defaults       \
174     /usr/local/lib/X11R5/app-defaults           \
175     /usr/local/lib/X11R5/X11/app-defaults       \
176     /usr/local/lib/X11R4/app-defaults           \
177     /usr/local/lib/X11R4/X11/app-defaults       \
178                                                 \
179     /usr/X386/lib/X11/app-defaults              \
180     /usr/x386/lib/X11/app-defaults              \
181     /usr/XFree86/lib/X11/app-defaults           \
182                                                 \
183     /usr/lib/X11/app-defaults                   \
184     /usr/local/lib/X11/app-defaults             \
185     /usr/unsupported/lib/X11/app-defaults       \
186     /usr/athena/lib/X11/app-defaults            \
187     /usr/local/x11r5/lib/X11/app-defaults       \
188     /usr/lpp/Xamples/lib/X11/app-defaults       \
189     /lib/usr/lib/X11/app-defaults               \
190                                                 \
191     /usr/openwin/lib/app-defaults               \
192     /usr/openwin/lib/X11/app-defaults           \
193     /usr/openwin/share/lib/app-defaults         \
194     /usr/openwin/share/lib/X11/app-defaults     \
195                                                 \
196     /X11R6/lib/app-defaults                     \
197     /X11R5/lib/app-defaults                     \
198     /X11R4/lib/app-defaults                     \
199     ; \
200   do
201     if test -d "$ac_dir"; then
202       ac_x_app_defaults=$ac_dir
203       break
204     fi
205   done
206 ])
207
208
209 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
210   [AC_REQUIRE_CPP()
211     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
212      [AC_PATH_X_APP_DEFAULTS_XMKMF
213       AC_PATH_X_APP_DEFAULTS_DIRECT
214       if test x"$ac_x_app_defaults" = x; then
215         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
216       else
217         # Record where we found app-defaults for the cache.
218         ac_cv_x_app_defaults="$ac_x_app_defaults"
219       fi])
220     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
221
222 AC_PATH_X_APP_DEFAULTS
223
224 APPDEFAULTS=$ac_x_app_defaults
225
226
227 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
228 #
229 AC_DEFUN(AC_CHECK_X_HEADER, [
230   ac_save_CPPFLAGS="$CPPFLAGS"
231   if test \! -z "$includedir" ; then 
232     CPPFLAGS="$CPPFLAGS -I$includedir"
233   fi
234   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
235   AC_CHECK_HEADER([$1], [$2])
236   CPPFLAGS="$ac_save_CPPFLAGS"])
237
238 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
239 #
240 AC_DEFUN(AC_EGREP_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_EGREP_HEADER([$1], [$2], [$3], [$4])
247   CPPFLAGS="$ac_save_CPPFLAGS"])
248
249 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
250 #
251 AC_DEFUN(AC_TRY_X_COMPILE, [
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_TRY_COMPILE([$1], [$2], [$3], [$4])
258   CPPFLAGS="$ac_save_CPPFLAGS"])
259
260
261 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
262 # Use this sparingly; it probably doesn't work very well on X programs.
263 #
264 AC_DEFUN(AC_CHECK_X_LIB, [
265   ac_save_CPPFLAGS="$CPPFLAGS"
266   ac_save_LDFLAGS="$LDFLAGS"
267   if test \! -z "$includedir" ; then 
268     CPPFLAGS="$CPPFLAGS -I$includedir"
269   fi
270   if test \! -z "$includedir" ; then 
271     CPPFLAGS="$CPPFLAGS -I$includedir"
272   fi
273   if test \! -z "$libdir" ; then
274     LDFLAGS="$LDFLAGS -L$libdir"
275   fi
276   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
277   LDFLAGS="$LDFLAGS -L$x_libraries"
278   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
279   CPPFLAGS="$ac_save_CPPFLAGS"
280   LDFLAGS="$ac_save_LDFLAGS"])
281
282
283
284
285 # check for the HP XHPDisableReset server extension headers.
286 #
287 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
288                   [AC_DEFINE(HAVE_XHPDISABLERESET)
289                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
290
291
292 # Check for the availability of the XPointer typedef, and define it otherwise.
293 #
294 AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
295                 [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
296                                   [XPointer foo = (XPointer) 0;],
297                                   [ac_cv_xpointer=yes],
298                                   [ac_cv_xpointer=no])])
299 if test $ac_cv_xpointer != yes; then
300   AC_DEFINE(XPointer,[char*])
301 fi
302
303
304 case "$host" in
305   *-hpux*)
306     # Thanks for not making xmkmf find this by default, you losers.
307     if test -d /usr/lib/Motif1.2 ; then
308       X_CFLAGS="-I/usr/include/Motif1.2 $X_CFLAGS"
309       X_LIBS="-L/usr/lib/Motif1.2 $X_LIBS"
310     elif test -d /usr/lib/Motif1.1 ; then
311       X_CFLAGS="-I/usr/include/Motif1.1 $X_CFLAGS"
312       X_LIBS="-L/usr/lib/Motif1.1 $X_LIBS"
313     fi
314
315     # This too.  You losers.
316     if test -d /usr/contrib/X11R6/include ; then
317       X_CFLAGS="-I/usr/contrib/X11R6/include $X_CFLAGS"
318       X_LIBS="-L/usr/contrib/X11R6/lib $X_LIBS"
319     elif test -d /usr/contrib/X11R5/include ; then
320       X_CFLAGS="-I/usr/contrib/X11R5/include $X_CFLAGS"
321       X_LIBS="-L/usr/contrib/X11R5/lib $X_LIBS"
322     fi
323
324   ;;
325   *-solaris*)
326     # Same to you, pinheads.  (Is this really the standard location now?
327     # What happened to the joke that this kind of thing went in /opt?)
328     if test -f /usr/dt/include/Xm/Xm.h ; then
329       X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
330       X_LIBS="$X_LIBS -L/usr/dt/lib -R:/usr/dt/lib"
331
332       # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
333       AC_CHECK_LIB(gen, regcmp, [X_LIBS="$X_LIBS -lgen"])
334     fi
335   ;;
336 esac
337
338
339
340 # Check for Xmu (some fucked up vendors don't ship it...)
341 #
342 have_xmu=no
343 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
344 if test $have_xmu = no ; then
345   XMU_SRCS='$(UTILS_SRC)/xmu.c'
346   XMU_OBJS='$(UTILS_BIN)/xmu.o'
347 else
348   XMU_SRCS=''
349   XMU_OBJS=''
350   SAVER_LIBS="-lXmu $SAVER_LIBS"
351   HACK_LIBS="-lXmu $HACK_LIBS"
352   AC_DEFINE(HAVE_XMU)
353 fi
354
355
356 # See comp.windows.x FAQ question 124 about _get_wmShellWidgetClass on 4.1.x.
357 # The right fix is to get OpenWindows 3.0 patches 100512-02 and 100573-03.
358 #
359 if test $have_xmu = yes ; then
360   case "$host" in
361     *-sunos4*)
362     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
363                    ac_cv_sunos_xmu_bug,
364                    [ac_save_LDFLAGS="$LDFLAGS"
365                     if test \! -z "$x_libraries" ; then
366                       LDFLAGS="$LDFLAGS -L$x_libraries"
367                     fi
368                     # Note: this trick never works!  (Generally.)
369                     # We're only getting away with using AC_TRY_LINK
370                     # with X libraries because we know it's SunOS.
371                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
372                     AC_TRY_LINK(,,
373                                 [ac_cv_sunos_xmu_bug=no],
374                                 [ac_cv_sunos_xmu_bug=yes])
375                     LDFLAGS="$ac_save_LDFLAGS"])
376     if test $ac_cv_sunos_xmu_bug = yes ; then
377       AC_CACHE_CHECK([whether the compiler understands -static], 
378                      ac_cv_ld_static,
379                      [ac_save_LDFLAGS="$LDFLAGS"
380                       LDFLAGS="$LDFLAGS -static"
381                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
382                     LDFLAGS="$ac_save_LDFLAGS"])
383       if test $ac_cv_ld_static = yes ; then
384         LDFLAGS="$LDFLAGS -static"
385       else
386         LDFLAGS="$LDFLAGS -Bstatic"
387       fi
388     fi
389     ;;
390   esac
391 fi
392
393
394 # Check for the SGI SCREEN_SAVER server extension header.
395 #
396 have_sgi=no
397 with_sgi_req=unspecified
398 AC_ARG_WITH(sgi-ext,[
399 Server options:
400
401   --with-sgi-ext          Include support for the SGI SCREEN_SAVER
402                           server extension, if possible (this is the default).
403   --without-sgi-ext       Do not compile in support for this extension.],
404   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
405 if test $with_sgi = yes; then
406   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
407                     [have_sgi=yes
408                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
409
410 elif test $with_sgi != no; then
411   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
412   exit 1
413 fi
414
415 # Check for the MIT-SCREEN-SAVER server extension header,
416 # unless the SGI extension has already been found.
417 #
418 have_mit=no
419 with_mit_req=unspecified
420 AC_ARG_WITH(mit-ext,
421 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER
422                           server extension, if possible (this is the default).
423   --without-mit-ext       Do not compile in support for this extension.],
424   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
425 if test $have_sgi != yes; then
426   if test $with_mit = yes; then
427     AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
428
429     # Now check to see if it's really in the library; XF86Free-3.3 ships
430     # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
431     #
432     if test $have_mit = yes; then
433       AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [], [have_mit=no], -lm)
434
435       if test $have_mit = no; then
436         # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
437         # of in Xext.  Thank you master, may I have another.
438         AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
439                        [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
440                        [], -lX11 -lXext -lm)
441       fi
442
443       if test $have_mit = no; then
444         # Double fuck!  Looks like some versions of XFree86 (whichever version
445         # it is that comes with RedHat Linux 2.0 -- I can't find a version 
446         # number) put this garbage in Xss instead of Xext.  Thank you master,
447         #  may I have another.
448         AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
449                        [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
450                        [], -lX11 -lXext -lm)
451       fi
452
453     if test $have_mit = yes; then
454       AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
455     fi
456
457     fi
458
459   elif test $with_mit != no; then
460     echo "error: must be yes or no: --with-mit-ext=$with_mit"
461     exit 1
462   fi
463 fi
464
465
466 # Check for the XIDLE server extension header,
467 #
468 have_xidle=no
469 with_xidle_req=unspecified
470 AC_ARG_WITH(xidle-ext,
471 [  --with-xidle-ext        Include support for the XIDLE server extension,
472                           if possible (this is the default).
473   --without-xidle-ext     Do not compile in support for this extension.],
474   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
475 if test $with_xidle = yes; then
476   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
477                     [have_xidle=yes
478                      AC_DEFINE(HAVE_XIDLE_EXTENSION)])
479 elif test $with_xidle != no; then
480   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
481   exit 1
482 fi
483
484
485 # Check for Motif and Athena --with and --without arguments.
486 #
487 have_motif=no
488 have_athena=no
489 with_motif_req=unspecified
490 with_athena_req=unspecified
491
492 AC_ARG_WITH(motif,[
493 Toolkit options:
494
495   --with-motif            Use the Motif toolkit for the user interface,
496                           if possible (this is the default).
497   --without-motif         Do not use Motif.],
498   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
499
500 AC_ARG_WITH(athena,
501 [  --with-athena           Use the Athena toolkit for the user interface, if
502                           possible (this is the default if Motif isn't used.)
503   --without-athena        Do not use Athena.],
504   [with_athena="$withval"; with_athena_req="$withval"],[with_athena=no])
505
506 if test $with_motif != yes -a $with_motif != no ; then
507   echo "error: must be yes or no: --with-motif=$with_motif"
508   exit 1
509 fi
510
511 if test $with_athena != yes -a $with_athena != no ; then
512   echo "error: must be yes or no: --with-athena=$with_athena"
513   exit 1
514 fi
515
516
517 # Saying --without-motif is the same as saying --with-athena.
518 if test $with_motif_req = no ; then
519   with_athena_req=yes
520   with_athena=yes
521 fi
522
523 # Saying --without-athena is the same as saying --with-motif.
524 if test $with_athena_req = no ; then
525   with_motif_req=yes
526   with_motif=yes
527 fi
528
529 # Check for Motif and Athena headers.
530
531 check_motif() {
532   AC_CHECK_X_HEADER(Xm/Xm.h,
533                     [have_motif=yes
534                      AC_DEFINE(HAVE_MOTIF)
535                      SAVER_LIBS="-lXm $SAVER_LIBS"])
536 }
537
538 check_athena() {
539   AC_CHECK_X_HEADER(X11/Xaw/Dialog.h,
540                    [have_athena=yes
541                     AC_DEFINE(HAVE_ATHENA)
542                     SAVER_LIBS="-lXaw $SAVER_LIBS"])
543 }
544
545
546 # If they asked for both motif and athena, check motif then athena.
547 # If they asked for only motif, check motif then athena.
548 # If they asked for only athena, check athena then motif.
549 # If they asked for neither, check motif then athena.
550
551 if test $with_motif = yes; then
552   # asked for both, or for motif only
553   check_motif
554   if test $have_motif = yes; then
555     with_athena=no
556     with_athena_req=no
557   else
558     check_athena
559   fi
560
561 elif test $with_athena = yes; then
562   # asked for athena only
563   check_athena
564   if test $have_athena = yes; then
565     with_motif=no
566   else
567     check_motif
568   fi
569
570 else
571   # asked for neither
572   check_motif
573   if test $have_motif = yes; then
574     with_athena=no
575   else
576     check_athena
577   fi
578
579 fi
580
581
582 # If we have Athena, check whether it's a version that includes
583 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
584 if test $have_athena = yes ; then
585   AC_CACHE_CHECK([for XawViewportSetCoordinates in Viewport.h], 
586                  ac_cv_have_XawViewportSetCoordinates,
587                  [ac_cv_have_XawViewportSetCoordinates=no
588                   AC_EGREP_X_HEADER(XawViewportSetCoordinates, 
589                                     X11/Xaw/Viewport.h,
590                                     ac_cv_have_XawViewportSetCoordinates=yes)])
591   if test $ac_cv_have_XawViewportSetCoordinates = yes ; then
592     AC_DEFINE(HAVE_XawViewportSetCoordinates)
593   fi
594 fi
595
596
597 # If we have Motif, check whether it's really LessTif.
598 #
599 if test $have_motif = yes ; then
600   AC_CACHE_CHECK([whether Motif is really LessTif], 
601                  ac_cv_have_lesstif,
602                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
603                                    [long vers = LesstifVersion;],
604                                    [ac_cv_have_lesstif=yes],
605                                    [ac_cv_have_lesstif=no])])
606   have_lesstif=$ac_cv_have_lesstif
607 fi
608
609
610 # check for XPM header.
611 #
612 have_xpm=no
613 with_xpm_req=unspecified
614 AC_ARG_WITH(xpm,[
615 Demo options:
616
617   --with-xpm              Include support for XPM files in some demos,
618                           if possible (this is the default).
619   --without-xpm           Do not compile in support for XPM files.],
620   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
621 if test $with_xpm = yes; then
622   AC_CHECK_X_HEADER(X11/xpm.h,
623                    [have_xpm=yes
624                     AC_DEFINE(HAVE_XPM)
625                     XPM_LIBS="-lXpm"])
626 elif test $with_xpm != no; then
627   echo "error: must be yes or no: --with-xpm=$with_xpm"
628   exit 1
629 fi
630
631
632 # check for the GL header
633 #
634 have_gl=no
635 with_gl_req=unspecified
636 AC_ARG_WITH(gl,
637 [  --with-gl               Build those demos which depend on OpenGL,
638                           if possible (this is the default).
639   --without-gl            Do not build the OpenGL demos.],
640   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
641
642 if test $with_gl = yes; then
643   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
644   if test $have_gl = yes ; then
645     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
646   fi
647
648   # If we have the headers, try and figure out which vendor it's from.
649   #
650   if test $have_gl = yes ; then
651
652     AC_DEFINE(HAVE_GL)
653     have_mesa_gl=no
654     AC_EGREP_X_HEADER(Mesa, GL/glx.h, [have_mesa_gl=yes])
655     if test $have_mesa_gl = no ; then
656       GL_LIBS="-lGL -lGLU"
657     else
658       AC_DEFINE(HAVE_MESA_GL)
659       GL_LIBS="-lMesaGL -lMesaGLU"
660     fi
661   fi
662
663 elif test $with_gl != no; then
664   echo "error: must be yes or no: --with-gl=$with_gl"
665   exit 1
666 fi
667
668
669 # check for SGI XReadDisplay server extension header.
670 #
671 have_readdisplay=no
672 with_readdisplay_req=unspecified
673 AC_ARG_WITH(readdisplay,
674 [  --with-readdisplay      Include support for the XReadDisplay server
675                           extension if possible (this is the default).
676   --without-readdisplay   Do not compile in support for this extension.],
677   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
678   [with_readdisplay=yes])
679 if test $with_readdisplay = yes; then
680   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
681                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
682 elif test $with_readdisplay != no; then
683   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
684   exit 1
685 fi
686
687
688
689 # Try to find a program to generate random text.
690 #
691 # Zippy is funnier than the idiocy generally spat out by `fortune',
692 # so try to find that, by invoking Emacs and asking it where its 
693 # libexec directory is ("yow" lives in there.)
694 #
695 # If that doesn't work, see if fortune, zippy, or yow are on $PATH,
696 # and if so, use them.
697 #
698 # If that doesn't work, look in /usr/games, and if it's there, use
699 # the full pathname.
700 #
701 with_zippy=""
702 AC_ARG_WITH(zippy,
703 [  --with-zippy=PROGRAM    Some demos are able to run an external program and
704                           display its text; this names the program to use by
705                           default (though it can be overridden with X
706                           resources.)  If you don't specify this, the default
707                           is to use \"yow\" from the Emacs distribution (if you
708                           have it) or else to use \"fortune\".],
709   [with_zippy="$withval"])
710
711 if test "$with_zippy" = no || test "$with_zippy" = yes ; then
712   $with_zippy=""
713 fi
714
715 if test -n "$with_zippy" ; then
716   ac_cv_zippy_program="$with_zippy"
717
718 elif test -n "$ac_cv_zippy_program"; then
719   AC_MSG_RESULT([checking for zippy... (cached) $ac_cv_zippy_program])
720
721 else
722
723   AC_CHECK_PROGS(emacs_exe, emacs)
724   AC_CHECK_PROGS(xemacs_exe, xemacs)
725
726   ac_cv_zippy_program=""
727   eargs='-batch -q -nw --eval'
728
729   if test -n "$emacs_exe" ; then
730     AC_MSG_CHECKING([for emacs yow])
731     #
732     # get emacs to tell us where the libexec directory is.
733     #
734     dir=`$emacs_exe $eargs '(princ (concat exec-directory "\n"))' \
735          2>/dev/null | tail -1`
736     dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
737     #
738     # try running libexec/yow and see if it exits without error.
739     #
740     if test x"$dir" != x -a -x $dir/yow ; then
741       if $dir/yow >&- 2>&- ; then
742         ac_cv_zippy_program="$dir/yow"
743         AC_MSG_RESULT($ac_cv_zippy_program)
744       else
745         AC_MSG_RESULT(no)
746       fi
747     fi
748   fi
749
750   if test -z "$ac_cv_zippy_program" ; then
751     AC_MSG_CHECKING([for xemacs yow])
752     if test -n "$xemacs_exe" ; then
753       #
754       # get xemacs to tell us where the libexec directory is.
755       #
756       dir=`$xemacs_exe $eargs '(princ (concat exec-directory "\n"))' \
757            2>/dev/null | tail -1`
758       dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
759       #
760       # try running libexec/yow and see if it exits without error.
761       #
762       if test x"$dir" != x -a -x $dir/yow ; then
763         if $dir/yow >&- 2>&- ; then
764           ac_cv_zippy_program="$dir/yow"
765           AC_MSG_RESULT($ac_cv_zippy_program)
766         else
767           #
768           # in some xemacs installations, the pathname of the yow.lines file
769           # isn't hardcoded into the yow executable, and must be passed on 
770           # the command line.  See if it's in libexec/../etc/.
771
772           # M4 sucks!!
773           changequote(X,Y)
774           dir_up=`echo "$dir" | sed 's@/[^/]*$@@'`
775           changequote([,])
776
777           yow="yow -f $dir_up/etc/yow.lines"
778           if $dir/$yow >&- 2>&- ; then
779             ac_cv_zippy_program="$dir/$yow"
780             AC_MSG_RESULT($ac_cv_zippy_program)
781           else
782             AC_MSG_RESULT(no)
783           fi
784         fi
785       fi
786     fi
787   fi
788
789   # if that didn't work, try for some other programs...
790   if test -z "$ac_cv_zippy_program" ; then
791     fortune=''
792     AC_CHECK_PROGS(fortune, [fortune zippy yow])
793     # if that didn't work, try for those programs in /usr/games...
794     if test -z "$fortune" ; then
795       AC_PATH_PROGS(fortune, [fortune zippy yow], fortune,
796                     /usr/games:/usr/local/games)
797     fi
798   fi
799 fi
800
801 if test -z "$ac_cv_zippy_program" ; then
802   ac_cv_zippy_program=fortune
803 fi
804
805 AC_DEFINE_UNQUOTED(ZIPPY_PROGRAM, "$ac_cv_zippy_program")
806
807
808
809
810 # Allow locking to be disabled at compile-time.
811 #
812 have_locking=yes
813 have_kerberos=no
814 with_kerberos_req=unspecified
815 have_shadow=no
816 with_shadow_req=unspecified
817 need_setuid=no
818
819 AC_ARG_ENABLE(locking,[
820 Locking options:
821
822   --enable-locking        Compile in support for locking the display
823                           (this is the default.)
824   --disable-locking       Do not allow locking at all.],
825   [enable_locking="$enableval"],[enable_locking=yes])
826 if test $enable_locking = yes; then
827
828   # Check for Kerberos.
829   #
830   AC_ARG_WITH(kerberos, [
831   --with-kerberos         Include support for Kerberos authentication,
832                           if possible (this is the default.)
833   --without-kerberos      Do not compile in support for Kerberos.],
834   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
835   if test $with_kerberos = yes; then
836     AC_CACHE_CHECK([for Kerberos], ac_cv_kerberos,
837                    [AC_TRY_X_COMPILE([#include <krb.h>],,
838                                      [ac_cv_kerberos=yes],
839                                      [ac_cv_kerberos=no])])
840     if test $ac_cv_kerberos = yes ; then
841       have_kerberos=yes
842       AC_DEFINE(HAVE_KERBEROS)
843       PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lnsl -lsocket"
844     fi
845   elif test $with_kerberos != no; then
846     echo "error: must be yes or no: --with-kerberos=$with_kerberos"
847     exit 1
848   fi
849
850   # Next, check for the nine billion variants of shadow passwords...
851
852   passwd_cruft_done=no
853   AC_ARG_WITH(shadow,
854 [  --with-shadow           Include support for shadow password authentication,
855                           if possible (this is the default, if no Kerberos.)
856   --without-shadow        Do not compile in support for shadow passwords.
857 ],
858   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
859   if test $with_shadow = no; then
860     passwd_cruft_done=yes
861   elif test $with_shadow != yes; then
862     echo "error: must be yes or no: --with-shadow=$with_shadow"
863     exit 1
864   fi
865
866
867   # Sun's "adjunct" passwords.
868   #
869   if test $passwd_cruft_done = no ; then
870     AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
871                    [AC_TRY_X_COMPILE([#include <stdlib.h>
872                                       #include <unistd.h>
873                                       #include <sys/types.h>
874                                       #include <sys/label.h>
875                                       #include <sys/audit.h>
876                                       #include <pwdadj.h>],
877                         [struct passwd_adjunct *p = getpwanam("nobody");
878                          const char *pw = p->pwa_passwd;],
879                         [ac_cv_sun_adjunct=yes],
880                         [ac_cv_sun_adjunct=no])])
881     if test $ac_cv_sun_adjunct = yes; then
882       have_shadow=yes
883       need_setuid=yes
884       passwd_cruft_done=yes
885       AC_DEFINE(HAVE_ADJUNCT_PASSWD)
886     fi
887   fi
888
889   # DEC and SCO so-called "enhanced" security.
890   #
891   if test $passwd_cruft_done = no ; then
892     AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
893                    [AC_TRY_X_COMPILE([#include <stdlib.h>
894                                       #include <unistd.h>
895                                       #include <sys/types.h>
896                                       #include <pwd.h>
897                                       #include <sys/security.h>
898                                       #include <prot.h>],
899                         [struct pr_passwd *p;
900                          const char *pw;
901                          set_auth_parameters(0, 0);
902                          check_auth_parameters();
903                          p = getprpwnam("nobody");
904                          pw = p->ufld.fd_encrypt;],
905                         [ac_cv_enhanced_passwd=yes],
906                         [ac_cv_enhanced_passwd=no])])
907     if test $ac_cv_enhanced_passwd = yes; then
908       have_shadow=yes
909       need_setuid=yes
910       passwd_cruft_done=yes
911       AC_DEFINE(HAVE_ENHANCED_PASSWD)
912
913       # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
914       # (I'm told it needs -lcurses too, but I don't understand why.)
915       AC_CHECK_LIB(prot, getprpwnam, 
916                    [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
917                    [# On DEC, getprpwnam() is in -lsecurity
918                     AC_CHECK_LIB(security, getprpwnam, 
919                                  [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
920                    [-lx])
921     fi
922   fi
923
924   # HP's entry in the "Not Invented Here" Sweepstakes.
925   #
926   if test $passwd_cruft_done = no ; then
927     AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
928                    [AC_TRY_X_COMPILE([#include <stdlib.h>
929                                       #include <unistd.h>
930                                       #include <sys/types.h>
931                                       #include <pwd.h>
932                                       #include <hpsecurity.h>
933                                       #include <prot.h>],
934                         [struct s_passwd *p = getspwnam("nobody");
935                          const char *pw = p->pw_passwd;],
936                         [ac_cv_hpux_passwd=yes],
937                         [ac_cv_hpux_passwd=no])])
938     if test $ac_cv_hpux_passwd = yes; then
939       have_shadow=yes
940       need_setuid=yes
941       passwd_cruft_done=yes
942       AC_DEFINE(HAVE_HPUX_PASSWD)
943
944       # on HPUX, bigcrypt is in -lsec
945       AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
946     fi
947   fi
948
949   # Traditional (ha!) shadow passwords.
950   #
951   if test $passwd_cruft_done = no ; then
952     AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
953                    [AC_TRY_X_COMPILE([#include <stdlib.h>
954                                       #include <unistd.h>
955                                       #include <sys/types.h>
956                                       #include <pwd.h>
957                                       #include <shadow.h>],
958                         [struct spwd *p = getspnam("nobody");
959                          const char *pw = p->sp_pwdp;],
960                         [ac_cv_shadow=yes],
961                         [ac_cv_shadow=no])])
962     if test $ac_cv_shadow = yes; then
963       have_shadow=yes
964       need_setuid=yes
965       passwd_cruft_done=yes
966       AC_DEFINE(HAVE_SHADOW_PASSWD)
967
968       # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
969       have_getspnam=no
970       AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
971       if test $have_getspnam = no ; then
972         AC_CHECK_LIB(gen, getspnam,
973                      [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
974       fi
975     fi
976   fi
977
978   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
979   have_crypt=no
980   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
981   if test $have_crypt = no ; then
982     AC_CHECK_LIB(crypt, crypt,
983                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
984   fi
985
986
987   # Most of the above shadow mechanisms will have set need_setuid to yes,
988   # if they were found.  But, on some systems, we need setuid even when
989   # using plain old vanilla passwords.
990   #
991   if test $need_setuid = no ; then
992     case "$host" in
993       *-hpux* | *-aix* | *-netbsd* )
994         need_setuid=yes
995       ;;
996     esac
997   fi
998
999 elif test $enable_locking = no; then
1000   AC_DEFINE(NO_LOCKING)
1001 else
1002   echo "error: must be yes or no: --enable-locking=$enable_locking"
1003   exit 1
1004 fi
1005
1006
1007
1008 if test \! -z "$includedir" ; then 
1009   INCLUDES="-I$includedir"
1010 fi
1011
1012 if test \! -z "$libdir" ; then
1013   LDFLAGS="$LDFLAGS -L$libdir"
1014 fi
1015
1016
1017 ##### should have options to override the DEPEND crap, I guess...
1018 DEPEND=makedepend
1019 DEPEND_FLAGS=
1020 DEPEND_DEFINES=
1021
1022
1023
1024 # Done testing things -- now substitute in some stuff for the Makefiles.
1025 #
1026 if test $have_motif = yes; then
1027   AC_DEFINE(HAVE_MOTIF)
1028   DIALOG_SRCS='$(MOTIF_SRCS)'
1029   DIALOG_OBJS='$(MOTIF_OBJS)'
1030 elif test $have_athena = yes; then
1031   AC_DEFINE(HAVE_ATHENA)
1032   DIALOG_SRCS='$(ATHENA_SRCS)'
1033   DIALOG_OBJS='$(ATHENA_OBJS)'
1034 else
1035   DIALOG_SRCS=''
1036   DIALOG_OBJS=''
1037 fi
1038
1039 if test $have_kerberos = yes; then
1040   PASSWD_SRCS='$(KERBEROS_SRCS)'
1041   PASSWD_OBJS='$(KERBEROS_OBJS)'
1042 else
1043   PASSWD_SRCS='$(PWENT_SRCS)'
1044   PASSWD_OBJS='$(PWENT_OBJS)'
1045 fi
1046
1047 if test $enable_locking = yes; then
1048   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
1049   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
1050 else
1051   LOCK_SRCS=''
1052   LOCK_OBJS=''
1053 fi
1054
1055 if test $need_setuid = yes; then
1056   NEED_SETUID=yes
1057   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
1058 else
1059   NEED_SETUID=no
1060   INSTALL_SETUID='$(INSTALL_PROGRAM)'
1061 fi
1062
1063 tab='   '
1064 if test $have_gl = yes; then
1065   GL_EXES='$(GL_EXES)'
1066   GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'  \'
1067   GL_KLUDGE_2=${tab}
1068 else
1069   GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'\n'
1070   GL_KLUDGE_2='!'${tab}
1071 fi
1072
1073 AC_SUBST(INCLUDES)
1074
1075 AC_SUBST(SAVER_LIBS)
1076 AC_SUBST(HACK_LIBS)
1077 AC_SUBST(XPM_LIBS)
1078 AC_SUBST(GL_LIBS)
1079 AC_SUBST(PASSWD_LIBS)
1080 AC_SUBST(INSTALL_SETUID)
1081 AC_SUBST(NEED_SETUID)
1082
1083 AC_SUBST(DIALOG_SRCS)
1084 AC_SUBST(DIALOG_OBJS)
1085 AC_SUBST(PASSWD_SRCS)
1086 AC_SUBST(PASSWD_OBJS)
1087 AC_SUBST(XMU_SRCS)
1088 AC_SUBST(XMU_OBJS)
1089 AC_SUBST(LOCK_SRCS)
1090 AC_SUBST(LOCK_OBJS)
1091 AC_SUBST(GL_EXES)
1092 AC_SUBST(GL_KLUDGE_1)
1093 AC_SUBST(GL_KLUDGE_2)
1094 AC_SUBST(HACKDIR)
1095 AC_SUBST(APPDEFAULTS)
1096
1097 AC_SUBST(DEPEND)
1098 AC_SUBST(DEPEND_FLAGS)
1099 AC_SUBST(DEPEND_DEFINES)
1100
1101 # Print some warnings before emitting the Makefiles.
1102 #
1103 warning=no
1104 warnsep='    #################################################################'
1105 warn() {
1106   if test $warning = no ; then
1107     echo '' ; echo "$warnsep" ; echo ''
1108     warning=yes
1109   fi
1110   echo "    Warning:" $*
1111 }
1112
1113 warn2() {
1114   echo "            " $*
1115 }
1116
1117 if test $with_sgi_req = yes -a $have_sgi = no ; then
1118   warn 'The SGI saver extension was requested, but was not found.'
1119 fi
1120
1121 if test $with_mit_req = yes -a $have_mit = no ; then
1122   warn 'The MIT saver extension was requested, but was not found.'
1123 fi
1124
1125 if test $with_xidle_req = yes -a $have_xidle = no ; then
1126   warn 'The XIdle extension was requested, but was not found.'
1127 fi
1128
1129 if test $have_motif = no -a $have_athena = no ; then
1130   warn  "Neither Motif nor Athena widgets seem to be available;"
1131   warn2 "one or the other is required."
1132
1133 elif test $with_motif_req = yes -a $have_motif = no ; then
1134   warn  "Use of Motif was requested, but it wasn't found;"
1135   warn2 "Athena will be used instead."
1136
1137 elif test $with_athena_req = yes -a $have_athena = no ; then
1138   warn  "Use of Athena was requested, but it wasn't found;"
1139   warn2 "Motif will be used instead."
1140 fi
1141
1142 if test $have_motif = yes -a $have_lesstif = yes ; then
1143   warn  "Motif is being used, but it appears to actually be LessTif."
1144   warn2 "XScreenSaver has been reported to have problems with some"
1145   warn2 "versions of LessTif (notably 0.79).  You might want to use"
1146   warn2 "Athena instead."
1147 fi
1148
1149 if test $with_xpm_req = yes -a $have_xpm = no ; then
1150   warn 'Use of XPM was requested, but it was not found.'
1151 fi
1152
1153 if test $with_gl_req = yes -a $have_gl = no ; then
1154   warn 'Use of GL was requested, but it was not found.'
1155 fi
1156
1157 if test $with_readdisplay_req = yes -a $have_readdisplay = no ; then
1158   warn 'Use of XReadDisplay was requested, but it was not found.'
1159 fi
1160
1161 if test $with_kerberos_req = yes -a $have_kerberos = no ; then
1162   warn 'Use of Kerberos was requested, but it was not found.'
1163 fi
1164
1165 if test $with_shadow_req = yes -a $have_shadow = no ; then
1166   warn 'Use of shadow passwords was requested, but they were not found.'
1167 fi
1168
1169 if test $warning = yes; then
1170   echo '' ; echo "$warnsep" ; echo ''
1171 fi
1172
1173
1174 AC_OUTPUT(Makefile
1175           utils/Makefile
1176           driver/Makefile
1177           hacks/Makefile
1178           hacks/glx/Makefile
1179           driver/XScreenSaver.ad)