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