205480884039f217ff1927372f523fb6fb90a7a7
[xscreensaver] / configure.in
1 # configure.in --- xscreensaver, Copyright (c) 1997-2000 Jamie Zawinski.
2 #
3
4 AC_INIT(driver/subprocs.c)
5 AC_CONFIG_HEADER(config.h)
6
7 echo "current directory: `pwd`"
8 echo "command line was: $0 $@"
9
10
11 # After checking to see that --srcdir is correct (which AC_INIT does)
12 # check for some random other files that come later in the tar file,
13 # to make sure everything is here.
14 #
15 for d in driver utils hacks hacks/glx ; do
16   f=$srcdir/$d/Makefile.in
17   if test \! -r $f ; then
18     echo ""
19     echo "ERROR: The package is incomplete: $f does not exist."
20     echo "       This probably means that your download was truncated."
21     echo ""
22     exit 1
23   fi
24 done
25
26
27 ###############################################################################
28 #
29 #       Function to figure out how to run the compiler.
30 #
31 ###############################################################################
32
33 AC_DEFUN(AC_PROG_CC_ANSI,
34  [AC_PROG_CC
35
36   if test -z "$GCC"; then
37     AC_MSG_CHECKING(how to request ANSI compilation)
38     case "$host" in
39       *-hpux* )
40         AC_MSG_RESULT(HPUX: adding -Ae)
41         CC="$CC -Ae"
42       ;;
43       *-aix* )
44         AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
45         CC="$CC -qlanglvl=ansi -qhalt=e"
46       ;;
47
48       *-dec-* )
49         AC_MSG_RESULT(DEC: adding -std1)
50         CC="$CC -std1"
51       ;;
52
53       *)
54         AC_MSG_RESULT(no idea)
55       ;;
56     esac
57   fi
58
59   AC_MSG_CHECKING([whether the compiler works on ANSI C])
60   AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
61      AC_MSG_RESULT(yes),
62      AC_MSG_RESULT(no)
63      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
64      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
65
66   if test -n "$GCC"; then
67     AC_MSG_RESULT(Turning on gcc compiler warnings.)
68     CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
69     AC_MSG_RESULT(Disabling C++ comments in ANSI C code.)
70     CC="$CC -Wp,-lang-c89"
71   else
72     case "$host" in
73       *-irix5* |*-irix6.[0-3]* )
74         AC_MSG_RESULT(Turning on SGI compiler warnings.)
75         CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
76       ;;
77 #     *-dec-osf* )
78 #       if test -z "$GCC"; then
79 #         AC_MSG_RESULT(Turning on DEC C compiler warnings.)
80 #         CC="$CC -migrate -w0 -verbose -warnprotos"
81 #       fi
82 #     ;;
83     esac
84   fi
85 ])
86
87
88 ###############################################################################
89 #
90 #       Function to figure out how to create directory trees.
91 #
92 ###############################################################################
93
94 AC_DEFUN(AC_PROG_INSTALL_DIRS,
95  [AC_CACHE_CHECK([whether \"\${INSTALL} -d\" creates intermediate directories],
96     ac_cv_install_d_creates_dirs,
97     [ac_cv_install_d_creates_dirs=no
98      rm -rf conftestdir
99      if mkdir conftestdir; then
100        cd conftestdir >&-
101        ${INSTALL} -d `pwd`/dir1/dir2 >&- 2>&-
102        if test -d dir1/dir2/. ; then
103          ac_cv_install_d_creates_dirs=yes
104        fi
105        cd .. >&-
106        rm -rf conftestdir
107      fi
108     ])
109
110   if test "$ac_cv_install_d_creates_dirs" = no ; then
111     AC_CACHE_CHECK([whether \"mkdir -p\" creates intermediate directories],
112       ac_cv_mkdir_p_creates_dirs,
113       [ac_cv_mkdir_p_creates_dirs=no
114        rm -rf conftestdir
115        if mkdir conftestdir; then
116          cd conftestdir >&-
117          mkdir -p dir1/dir2 >&- 2>&-
118          if test -d dir1/dir2/. ; then
119            ac_cv_mkdir_p_creates_dirs=yes
120          fi
121          cd .. >&-
122          rm -rf conftestdir
123        fi
124       ])
125   fi
126
127   if test "$ac_cv_install_d_creates_dirs" = yes ; then
128     INSTALL_DIRS='${INSTALL} -d'
129   elif test "$ac_cv_mkdir_p_creates_dirs" = yes ; then
130     INSTALL_DIRS='mkdir -p'
131   else
132     # any other ideas?
133     INSTALL_DIRS='${INSTALL} -d'
134   fi
135 ])
136
137
138 ###############################################################################
139 #
140 #       Function to check whether gettimeofday() exists, and how to call it.
141 #       This may define HAVE_GETTIMEOFDAY and GETTIMEOFDAY_TWO_ARGS.
142 #
143 ###############################################################################
144
145 AC_DEFUN(AC_GETTIMEOFDAY_ARGS,
146  [AC_MSG_CHECKING(how to call gettimeofday)
147   AC_CACHE_VAL(ac_cv_gettimeofday_args,
148    [AC_TRY_COMPILE([#include <stdlib.h>
149                     #include <sys/time.h>],
150                    [struct timeval tv; struct timezone tzp;
151                     gettimeofday(&tv, &tzp);],
152                    [ac_gettimeofday_args=2],
153                    [AC_TRY_COMPILE([#include <stdlib.h>
154                                     #include <sys/time.h>],
155                                    [struct timeval tv; gettimeofday(&tv);],
156                                    [ac_gettimeofday_args=1],
157                                    [ac_gettimeofday_args=0])])
158     ac_cv_gettimeofday_args=$ac_gettimeofday_args])
159   ac_gettimeofday_args=$ac_cv_gettimeofday_args
160   if test "$ac_gettimeofday_args" = 1 ; then
161     AC_DEFINE(HAVE_GETTIMEOFDAY)
162     AC_MSG_RESULT(one argument)
163   elif test "$ac_gettimeofday_args" = 2 ; then
164     AC_DEFINE(HAVE_GETTIMEOFDAY)
165     AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
166     AC_MSG_RESULT(two arguments)
167   else
168     AC_MSG_RESULT(unknown)
169   fi
170 ])
171
172
173 ###############################################################################
174 #
175 #       Function to find perl5 (defines PERL and PERL_VERSION.)
176 #
177 ###############################################################################
178
179 # M4 sucks!!  perl sucks too!!
180 changequote(X,Y)
181 perl_version_cmd='print $]'
182 changequote([,])
183
184 AC_DEFUN(AC_PROG_PERL,
185  [AC_PATH_PROGS(PERL, [perl5 perl],,)
186   if test -z "$PERL" ; then
187     PERL_VERSION=0
188   else
189     AC_CACHE_CHECK([perl version], ac_cv_perl_version,
190                    [ac_cv_perl_version=`$PERL -e "$perl_version_cmd"`])
191     PERL_VERSION=$ac_cv_perl_version
192   fi
193  ])
194
195
196 ###############################################################################
197 #
198 #       Function to demand "bc".  Losers.
199 #
200 ###############################################################################
201
202 AC_DEFUN(AC_DEMAND_BC,
203  [ac_bc_result=`echo 6+9 | bc 2>/dev/null`
204   AC_MSG_CHECKING([for bc])
205   if test "$ac_bc_result" = "15" ; then
206     AC_MSG_RESULT(yes)
207   else
208     AC_MSG_RESULT(no)
209     echo ''
210     AC_MSG_ERROR([Your system doesn't have \"bc\", which has been a standard
211                   part of Unix since the 1970s.  Come back when your vendor
212                   has grown a clue.])
213   fi
214  ])
215
216 ###############################################################################
217 #
218 #       Functions to check how to do ICMP PING requests.
219 #
220 ###############################################################################
221
222 AC_DEFUN(AC_CHECK_ICMP,
223  [AC_CACHE_CHECK([for struct icmp], ac_cv_have_icmp,
224   [AC_TRY_COMPILE([#include <stdlib.h>
225                    #include <stdio.h>
226                    #include <math.h>
227                    #include <unistd.h>
228                    #include <limits.h>
229                    #include <signal.h>
230                    #include <fcntl.h>
231                    #include <sys/types.h>
232                    #include <sys/time.h>
233                    #include <sys/ipc.h>
234                    #include <sys/shm.h>
235                    #include <sys/socket.h>
236                    #include <netinet/in_systm.h>
237                    #include <netinet/in.h>
238                    #include <netinet/ip.h>
239                    #include <netinet/ip_icmp.h>
240                    #include <netinet/udp.h>
241                    #include <arpa/inet.h>
242                    #include <netdb.h>],
243                   [struct icmp i;
244                    struct sockaddr s;
245                    struct sockaddr_in si;
246                    struct ip ip;
247                    i.icmp_type = ICMP_ECHO;
248                    i.icmp_code = 0;
249                    i.icmp_cksum = 0;
250                    i.icmp_id = 0;
251                    i.icmp_seq = 0;
252                    si.sin_family = AF_INET;
253                    ip.ip_hl = 0;],
254                   [ac_cv_have_icmp=yes],
255                   [ac_cv_have_icmp=no])])
256  if test "$ac_cv_have_icmp" = yes ; then
257    AC_DEFINE(HAVE_ICMP)
258  fi])
259
260 AC_DEFUN(AC_CHECK_ICMPHDR,
261  [AC_CACHE_CHECK([for struct icmphdr], ac_cv_have_icmphdr,
262   [AC_TRY_COMPILE([#include <stdlib.h>
263                    #include <stdio.h>
264                    #include <math.h>
265                    #include <unistd.h>
266                    #include <limits.h>
267                    #include <signal.h>
268                    #include <fcntl.h>
269                    #include <sys/types.h>
270                    #include <sys/time.h>
271                    #include <sys/ipc.h>
272                    #include <sys/shm.h>
273                    #include <sys/socket.h>
274                    #include <netinet/in_systm.h>
275                    #include <netinet/in.h>
276                    #include <netinet/ip.h>
277                    #include <netinet/ip_icmp.h>
278                    #include <netinet/udp.h>
279                    #include <arpa/inet.h>
280                    #include <netdb.h>],
281                   [struct icmphdr i;
282                    struct sockaddr s;
283                    struct sockaddr_in si;
284                    struct ip ip;
285                    i.type = ICMP_ECHO;
286                    i.code = 0;
287                    i.cksum = 0;
288                    i.un.echo.id = 0;
289                    i.un.echo.sequence = 0;
290                    si.sin_family = AF_INET;
291                    ip.ip_hl = 0;],
292                   [ac_cv_have_icmphdr=yes],
293                   [ac_cv_have_icmphdr=no])])
294  if test "$ac_cv_have_icmphdr" = yes ; then
295    AC_DEFINE(HAVE_ICMPHDR)
296  fi])
297
298
299 ###############################################################################
300 #
301 #       Functions to check for various X11 crap.
302 #
303 ###############################################################################
304
305 # Try and find the app-defaults directory.
306 # It sucks that autoconf doesn't do this already...
307 #
308 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,[
309   rm -fr conftestdir
310   if mkdir conftestdir; then
311     cd conftestdir >&-
312     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
313     cat > Imakefile <<'EOF'
314 acfindx:
315         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
316 EOF
317     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
318       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
319       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
320     fi
321     cd .. >&-
322     rm -fr conftestdir
323   fi])
324
325 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,[
326   # Look for the directory under a standard set of common directories.
327   # Check X11 before X11Rn because it's often a symlink to the current release.
328   for ac_dir in                                 \
329     /usr/X11/lib/app-defaults                   \
330     /usr/X11R6/lib/app-defaults                 \
331     /usr/X11R6/lib/X11/app-defaults             \
332     /usr/X11R5/lib/app-defaults                 \
333     /usr/X11R5/lib/X11/app-defaults             \
334     /usr/X11R4/lib/app-defaults                 \
335     /usr/X11R4/lib/X11/app-defaults             \
336                                                 \
337     /usr/lib/X11/app-defaults                   \
338     /usr/lib/X11R6/app-defaults                 \
339     /usr/lib/X11R5/app-defaults                 \
340     /usr/lib/X11R4/app-defaults                 \
341                                                 \
342     /usr/local/X11/lib/app-defaults             \
343     /usr/local/X11R6/lib/app-defaults           \
344     /usr/local/X11R5/lib/app-defaults           \
345     /usr/local/X11R4/lib/app-defaults           \
346                                                 \
347     /usr/local/lib/X11/app-defaults             \
348     /usr/local/lib/X11R6/app-defaults           \
349     /usr/local/lib/X11R6/X11/app-defaults       \
350     /usr/local/lib/X11R5/app-defaults           \
351     /usr/local/lib/X11R5/X11/app-defaults       \
352     /usr/local/lib/X11R4/app-defaults           \
353     /usr/local/lib/X11R4/X11/app-defaults       \
354                                                 \
355     /usr/X386/lib/X11/app-defaults              \
356     /usr/x386/lib/X11/app-defaults              \
357     /usr/XFree86/lib/X11/app-defaults           \
358                                                 \
359     /usr/lib/X11/app-defaults                   \
360     /usr/local/lib/X11/app-defaults             \
361     /usr/unsupported/lib/X11/app-defaults       \
362     /usr/athena/lib/X11/app-defaults            \
363     /usr/local/x11r5/lib/X11/app-defaults       \
364     /usr/lpp/Xamples/lib/X11/app-defaults       \
365     /lib/usr/lib/X11/app-defaults               \
366                                                 \
367     /usr/openwin/lib/app-defaults               \
368     /usr/openwin/lib/X11/app-defaults           \
369     /usr/openwin/share/lib/app-defaults         \
370     /usr/openwin/share/lib/X11/app-defaults     \
371                                                 \
372     /X11R6/lib/app-defaults                     \
373     /X11R5/lib/app-defaults                     \
374     /X11R4/lib/app-defaults                     \
375     ; \
376   do
377     if test -d "$ac_dir"; then
378       ac_x_app_defaults=$ac_dir
379       break
380     fi
381   done
382 ])
383
384 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
385   [AC_REQUIRE_CPP()
386     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
387      [AC_PATH_X_APP_DEFAULTS_XMKMF
388       if test x"$ac_x_app_defaults" = x; then
389         AC_PATH_X_APP_DEFAULTS_DIRECT
390       fi
391       if test x"$ac_x_app_defaults" = x; then
392         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
393       else
394         # Record where we found app-defaults for the cache.
395         ac_cv_x_app_defaults="$ac_x_app_defaults"
396       fi])
397     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
398
399
400 AC_DEFUN(AC_XPOINTER,
401  [AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
402                  [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
403                                    [XPointer foo = (XPointer) 0;],
404                                    [ac_cv_xpointer=yes],
405                                    [ac_cv_xpointer=no])])
406   if test "$ac_cv_xpointer" != yes; then
407    AC_DEFINE(XPointer,[char*])
408   fi])
409
410
411 # Random special-cases for X on certain pathological OSes.
412 # You know who you are.
413 #
414 AC_DEFUN(AC_X_RANDOM_PATHS,
415  [case "$host" in
416     *-hpux*)
417
418       # The following arcana was gleaned from conversations with
419       # Eric Schwartz <erics@col.hp.com>:
420       #
421       # On HPUX 10.x, the parts of X that HP considers "standard" live in
422       # /usr/{include,lib}/X11R6/.  The parts that HP doesn't consider
423       # "standard", notably, Xaw and Xmu, live in /usr/contrib/X11R6/.
424       # Yet /usr/contrib/X11R6/ comes preinstalled on all HPUX systems.
425       # Also, there are symlinks from /usr/include/ and /usr/lib/ into
426       # /usr/{include,lib}/X11R6/, so that (if you don't use Xmu at all)
427       # you don't need any -I or -L arguments.
428       #
429       # On HPUX 9.x, /usr/{include,lib}/X11R5/ and /usr/contrib/X11R5/
430       # are the same division as 10.x.  However, there are no symlinks to
431       # the X stuff from /usr/include/ and /usr/lib/, so -I and -L
432       # arguments are always necessary.
433       #
434       # However, X11R6 was available on HPUX 9.x as a patch: if that
435       # patch was installed, then all of X11R6 went in to
436       # /usr/contrib/X11R6/ (there was no /usr/{include,lib}/X11R6/.)
437       #
438       # HPUX 8.x was the same as 9.x, but was X11R4 instead (I don't know
439       # whether R5 was available as a patch; R6 undoubtedly was not.)
440       #
441       # So.  We try and use the highest numbered pair of
442       # /usr/{include,lib}/X11R?/ and /usr/contrib/X11R?/{include,lib}/
443       # that are available.  We do not mix and match different versions
444       # of X.
445       #
446       # Question I still don't know the answer to: (do you?)
447       #
448       #   * On HPUX 9.x, where /usr/include/X11R5/ was standard, and
449       #     /usr/contrib/X11R6/ could be installed as a patch, what was in
450       #     that contrib directory?  Did it contain so-called "standard"
451       #     X11R6, or did it include Xaw and Xmu as well?  If the former,
452       #     where did one find Xaw and Xmu on 9.x R6 systems?  Would this
453       #     be a situation where one had to reach into the R5 headers and
454       #     libs to find Xmu?  That is, must both R6 and R5 directories
455       #     be on the -I and -L lists in that case?
456       #
457       for version in X11R6 X11R5 X11R4 ; do
458         # if either pair of directories exists...
459         if test -d /usr/lib/$version || test -d /usr/contrib/$version/lib
460         then
461            # if contrib exists, use it...
462            if test -d /usr/contrib/$version/lib ; then
463              X_CFLAGS="$X_CFLAGS -I/usr/contrib/$version/include"
464              X_LIBS="$X_LIBS -L/usr/contrib/$version/lib"
465            fi
466            # if the "standard" one exists, use it.
467            if test -d /usr/lib/$version ; then
468              X_CFLAGS="$X_CFLAGS -I/usr/include/$version"
469              X_LIBS="$X_LIBS -L/usr/lib/$version"
470            fi
471            # since at least one of the pair exists, go no farther.
472            break
473         fi
474       done
475
476       # Now find Motif.  Thanks for not making xmkmf find this by
477       # default, you losers.
478       #
479       if test -d /usr/lib/Motif1.2 ; then
480         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.2"
481         X_LIBS="$X_LIBS -L/usr/lib/Motif1.2"
482       elif test -d /usr/lib/Motif1.1 ; then
483         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.1"
484         X_LIBS="$X_LIBS -L/usr/lib/Motif1.1"
485       fi
486
487       # Now let's check for the pseudo-standard locations for OpenGL and XPM.
488       #
489       if test -d /opt/Mesa/lib ; then
490         X_CFLAGS="-I/opt/Mesa/include $X_CFLAGS"
491         X_LIBS="-L/opt/Mesa/lib $X_LIBS"
492       fi
493
494       if test -d /opt/xpm/lib/X11 ; then
495         X_CFLAGS="-I/opt/xpm/include $X_CFLAGS"
496         X_LIBS="-L/opt/xpm/lib/X11 $X_LIBS"
497       fi
498
499       # On HPUX, default to installing in /opt/xscreensaver/ instead of
500       # in /usr/local/, unless there is already an xscreensaver in
501       # /usr/local/bin/.  This can be overridden with the --prefix arg
502       # to configure.  I'm not sure this is the right thing to do, but
503       # Richard Lloyd says so...
504       #
505       if test \! -x /usr/local/bin/xscreensaver ; then
506         ac_default_prefix=/opt/xscreensaver
507       fi
508
509     ;;
510     *-solaris*)
511
512       # Thanks for not making xmkmf find this by default, pinheads.
513       # And thanks for moving things around again, too.  Is this
514       # really the standard location now?  What happened to the
515       # joke that this kind of thing went in /opt?
516       # cthomp says "answer: CDE (Common Disorganized Environment)"
517       #
518       if test -f /usr/dt/include/Xm/Xm.h ; then
519         X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
520         X_LIBS="$X_LIBS -L/usr/dt/lib -R:/usr/dt/lib"
521
522         # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
523         AC_CHECK_LIB(gen, regcmp, [X_LIBS="$X_LIBS -lgen"])
524       fi
525     ;;
526   esac])
527
528
529
530 ###############################################################################
531 #
532 #       Some utility functions to make checking for X things easier.
533 #
534 ###############################################################################
535
536 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
537 #
538 AC_DEFUN(AC_CHECK_X_HEADER, [
539   ac_save_CPPFLAGS="$CPPFLAGS"
540   if test \! -z "$includedir" ; then 
541     CPPFLAGS="$CPPFLAGS -I$includedir"
542   fi
543   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
544   AC_CHECK_HEADER([$1], [$2])
545   CPPFLAGS="$ac_save_CPPFLAGS"])
546
547 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
548 #
549 AC_DEFUN(AC_EGREP_X_HEADER, [
550   ac_save_CPPFLAGS="$CPPFLAGS"
551   if test \! -z "$includedir" ; then 
552     CPPFLAGS="$CPPFLAGS -I$includedir"
553   fi
554   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
555   AC_EGREP_HEADER([$1], [$2], [$3], [$4])
556   CPPFLAGS="$ac_save_CPPFLAGS"])
557
558 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
559 #
560 AC_DEFUN(AC_TRY_X_COMPILE, [
561   ac_save_CPPFLAGS="$CPPFLAGS"
562   if test \! -z "$includedir" ; then 
563     CPPFLAGS="$CPPFLAGS -I$includedir"
564   fi
565   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
566   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
567   CPPFLAGS="$ac_save_CPPFLAGS"])
568
569
570 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
571 # Use this sparingly; it probably doesn't work very well on X programs.
572 #
573 AC_DEFUN(AC_CHECK_X_LIB, [
574   ac_save_CPPFLAGS="$CPPFLAGS"
575   ac_save_LDFLAGS="$LDFLAGS"
576 #  ac_save_LIBS="$LIBS"
577
578   if test \! -z "$includedir" ; then 
579     CPPFLAGS="$CPPFLAGS -I$includedir"
580   fi
581   # note: $X_CFLAGS includes $x_includes
582   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
583
584   if test \! -z "$libdir" ; then
585     LDFLAGS="$LDFLAGS -L$libdir"
586   fi
587   # note: $X_LIBS includes $x_libraries
588   LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
589
590   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
591   CPPFLAGS="$ac_save_CPPFLAGS"
592   LDFLAGS="$ac_save_LDFLAGS"
593 #  LIBS="$ac_save_LIBS"
594   ])
595
596 # Like AC_TRY_RUN, but it uses the already-computed -I directories.
597 # (But not the -L directories!)
598 #
599 AC_DEFUN(AC_TRY_X_RUN, [
600   ac_save_CPPFLAGS="$CPPFLAGS"
601   if test \! -z "$includedir" ; then 
602     CPPFLAGS="$CPPFLAGS -I$includedir"
603   fi
604   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
605   AC_TRY_RUN([$1], [$2], [$3], [$4])
606   CPPFLAGS="$ac_save_CPPFLAGS"])
607
608
609
610 # Usage: HANDLE_X_PATH_ARG([variable_name],
611 #                          [--command-line-option],
612 #                          [descriptive string])
613 #
614 # All of the --with options take three forms:
615 #
616 #   --with-foo (or --with-foo=yes)
617 #   --without-foo (or --with-foo=no)
618 #   --with-foo=/DIR
619 #
620 # This function, HANDLE_X_PATH_ARG, deals with the /DIR case.  When it sees
621 # a directory (string beginning with a slash) it checks to see whether
622 # /DIR/include and /DIR/lib exist, and adds them to $X_CFLAGS and $X_LIBS
623 # as appropriate.
624 #
625 AC_DEFUN(HANDLE_X_PATH_ARG, [
626    case "$[$1]" in
627     yes) ;;
628     no)  ;;
629
630     /*)
631      AC_MSG_CHECKING([for [$3] headers])
632      d=$[$1]/include
633      if test -d $d; then
634        X_CFLAGS="-I$d $X_CFLAGS"
635        AC_MSG_RESULT($d)
636      else
637        AC_MSG_RESULT(not found ($d: no such directory))
638      fi
639
640      AC_MSG_CHECKING([for [$3] libs])
641      d=$[$1]/lib
642      if test -d $d; then
643        X_LIBS="-L$d $X_LIBS"
644        AC_MSG_RESULT($d)
645      else
646        AC_MSG_RESULT(not found ($d: no such directory))
647      fi
648
649      # replace the directory string with "yes".
650      [$1]_req="yes"
651      [$1]=$[$1]_req
652      ;;
653
654     *)
655      echo ""
656      echo "error: argument to [$2] must be \"yes\", \"no\", or a directory."
657      echo "       If it is a directory, then \`DIR/include' will be added to"
658      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
659      exit 1
660      ;;
661    esac
662   ])
663
664
665
666 ###############################################################################
667 ###############################################################################
668 #
669 #       End of function definitions.  Now start actually executing stuff.
670 #
671 ###############################################################################
672 ###############################################################################
673
674 # random compiler setup
675 AC_CANONICAL_HOST
676 AC_PROG_CC_ANSI
677 AC_PROG_CPP
678 AC_C_CONST
679 AC_C_INLINE
680 AC_DEMAND_BC
681
682 # stuff for Makefiles
683 AC_PROG_INSTALL
684 AC_PROG_INSTALL_DIRS
685 AC_PROG_MAKE_SET
686
687 # random libc stuff
688 AC_HEADER_STDC
689 AC_CHECK_HEADERS(unistd.h)
690 AC_TYPE_MODE_T
691 AC_TYPE_PID_T
692 AC_TYPE_SIZE_T
693 AC_TYPE_SIGNAL
694 AC_HEADER_TIME
695 AC_HEADER_SYS_WAIT
696 AC_HEADER_DIRENT
697 AC_GETTIMEOFDAY_ARGS
698 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv)
699
700 AC_CHECK_FUNCS(sigaction syslog realpath)
701 AC_CHECK_ICMP
702 AC_CHECK_ICMPHDR
703 AC_CHECK_HEADERS(crypt.h sys/select.h)
704 AC_PROG_PERL
705
706 if test -z "$PERL" ; then
707   # don't let it be blank...
708   PERL=/usr/local/bin/perl5
709 fi
710
711 AC_PATH_XTRA
712
713 if test "$have_x" != yes; then
714   AC_MSG_ERROR(Couldn't find X11 headers/libs.  Try \`$0 --help'.)
715 fi
716
717 AC_PATH_X_APP_DEFAULTS
718 AC_X_RANDOM_PATHS
719 AC_XPOINTER
720
721
722
723 ###############################################################################
724 #
725 #       Check for -lXmu (some fucked up vendors don't ship it...)
726 #
727 ###############################################################################
728
729 have_xmu=no
730 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
731 if test "$have_xmu" = no ; then
732   XMU_SRCS='$(UTILS_SRC)/xmu.c'
733   XMU_OBJS='$(UTILS_BIN)/xmu.o'
734 else
735   XMU_SRCS=''
736   XMU_OBJS=''
737   SAVER_LIBS="-lXmu $SAVER_LIBS"
738   HACK_LIBS="-lXmu $HACK_LIBS"
739   MOTIF_LIBS="-lXmu $MOTIF_LIBS"
740   GTK_LIBS="-lXmu $GTK_LIBS"
741   AC_DEFINE(HAVE_XMU)
742 fi
743
744
745 ###############################################################################
746 #
747 #       Check for the SunOS 4.1.x _get_wmShellWidgetClass bug.
748 #       See comp.windows.x FAQ question 124.  The right fix is to
749 #       get OpenWindows 3.0 patches 100512-02 and 100573-03.
750 #
751 ###############################################################################
752
753 if test "$have_xmu" = yes ; then
754   case "$host" in
755     *-sunos4*)
756     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
757                    ac_cv_sunos_xmu_bug,
758                    [ac_save_LDFLAGS="$LDFLAGS"
759                     if test \! -z "$x_libraries" ; then
760                       LDFLAGS="$LDFLAGS -L$x_libraries"
761                     fi
762                     # Note: this trick never works!  (Generally.)
763                     # We're only getting away with using AC_TRY_LINK
764                     # with X libraries because we know it's SunOS.
765                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
766                     AC_TRY_LINK(,,
767                                 [ac_cv_sunos_xmu_bug=no],
768                                 [ac_cv_sunos_xmu_bug=yes])
769                     LDFLAGS="$ac_save_LDFLAGS"])
770     if test "$ac_cv_sunos_xmu_bug" = yes ; then
771       AC_CACHE_CHECK([whether the compiler understands -static], 
772                      ac_cv_ld_static,
773                      [ac_save_LDFLAGS="$LDFLAGS"
774                       LDFLAGS="$LDFLAGS -static"
775                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
776                     LDFLAGS="$ac_save_LDFLAGS"])
777       if test "$ac_cv_ld_static" = yes ; then
778         LDFLAGS="$LDFLAGS -static"
779       else
780         LDFLAGS="$LDFLAGS -Bstatic"
781       fi
782     fi
783     ;;
784   esac
785 fi
786
787
788 ###############################################################################
789 #
790 #       Handle the --enable-subdir option
791 #
792 ###############################################################################
793
794 AC_ARG_ENABLE(subdir,[
795 Installation options:
796
797   --enable-subdir=DIR     Put the demo programs in a subdirectory of \`bindir',
798                           instead of putting them in bindir itself.  You can
799                           specify the name of the subdirectory.  For example,
800                           \`--exec-prefix=/usr/local --enable-subdir=demos'
801                           would put xscreensaver in /usr/local/bin/, and would
802                           put the demos in /usr/local/bin/demos/.  (If DIR
803                           begins with /, then bindir will not be prepended.)
804
805   --disable-subdir        Just put the demos in \`bindir' (this is the default.)
806 ],
807   [enable_subdir="$enableval"],[enable_subdir=no])
808 if test x"$enable_subdir" = xno; then
809   HACKDIR='${bindir}'
810 elif test x"$enable_subdir" = xyes -o x"$enable_subdir" = x ; then
811   echo "error: must be a subdirectory name: --enable-subdir=$enable_subdir"
812   exit 1
813 else
814   # there must be a better way than this...
815   if test -z "`echo $enable_subdir | sed 's@^/.*@@'`" ; then
816     # absolute path
817     HACKDIR=$enable_subdir
818   else
819     # relative path
820     HACKDIR='${bindir}/'$enable_subdir
821   fi
822 fi
823
824 # canonicalize slashes.
825 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
826
827
828 ###############################################################################
829 #
830 #       Check for the SGI SCREEN_SAVER server extension.
831 #
832 ###############################################################################
833
834 have_sgi=no
835 with_sgi_req=unspecified
836 AC_ARG_WITH(sgi-ext,
837 [Except where noted, all of the --with options below can also take a
838 directory argument: for example, \`--with-motif=/opt/Motif'.  That would
839 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
840 to be added to the -L list, assuming those directories exist.  
841
842 By default, support for each of these options will be built in, if the
843 relevant library routines exist.  At run time, they will then be used
844 only if the X server being used supports them.  Each --with option has
845 a corresponding --without option, to override building support for them
846 at all.
847
848 Screen blanking and idle-detection options:
849
850   --with-sgi-ext          Include support for the SGI SCREEN_SAVER extension.],
851   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
852
853 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
854
855 if test "$with_sgi" = yes; then
856   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
857                     [have_sgi=yes
858                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
859
860 elif test "$with_sgi" != no; then
861   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
862   exit 1
863 fi
864
865
866 ###############################################################################
867 #
868 #       Check for the MIT-SCREEN-SAVER server extension.
869 #
870 ###############################################################################
871
872 have_mit=no
873 with_mit_req=unspecified
874 AC_ARG_WITH(mit-ext,
875 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER extension.],
876   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
877
878 HANDLE_X_PATH_ARG(with_mit, --with-mit-ext, MIT-SCREEN-SAVER)
879
880 if test "$with_mit" = yes; then
881   AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
882
883   # Now check to see if it's really in the library; XF86Free-3.3 ships
884   # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
885   #
886   if test "$have_mit" = yes; then
887     AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [true], [have_mit=no], -lm)
888
889     if test "$have_mit" = no; then
890       # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
891       # of in Xext.  Thank you master, may I have another.
892       AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
893                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
894                      [true], -lX11 -lXext -lm)
895     fi
896
897     if test "$have_mit" = no; then
898       # Double fuck!  Looks like some versions of XFree86 (whichever version
899       # it is that comes with RedHat Linux 2.0 -- I can't find a version 
900       # number) put this garbage in Xss instead of Xext.  Thank you master,
901       #  may I have another.
902       AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
903                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
904                      [true], -lX11 -lXext -lm)
905     fi
906
907   if test "$have_mit" = yes; then
908     AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
909   fi
910
911   fi
912
913 elif test "$with_mit" != no; then
914   echo "error: must be yes or no: --with-mit-ext=$with_mit"
915   exit 1
916 fi
917
918
919 ###############################################################################
920 #
921 #       Check for the XIDLE server extension.
922 #
923 ###############################################################################
924
925 have_xidle=no
926 with_xidle_req=unspecified
927 AC_ARG_WITH(xidle-ext,
928 [  --with-xidle-ext        Include support for the XIDLE extension.],
929   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
930
931 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
932
933 if test "$with_xidle" = yes; then
934   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
935                     [have_xidle=yes
936                      AC_DEFINE(HAVE_XIDLE_EXTENSION)])
937 elif test "$with_xidle" != no; then
938   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
939   exit 1
940 fi
941
942
943 ###############################################################################
944 #
945 #       Check for the SGI-VIDEO-CONTROL server extension.
946 #
947 ###############################################################################
948
949 have_sgivc=no
950 with_sgivc_req=unspecified
951 AC_ARG_WITH(sgivc-ext,
952 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension.],
953   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
954
955 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
956
957 if test "$with_sgivc" = yes; then
958
959   # first check for XSGIvc.h
960   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes])
961
962   # if that succeeded, then check for the -lXsgivc
963   if test "$have_sgivc" = yes; then
964     have_sgivc=no
965     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
966                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [true],
967                   -lXext -lX11)
968   fi
969
970   # if that succeeded, then we've really got it.
971   if test "$have_sgivc" = yes; then
972     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
973   fi
974
975 elif test "$with_sgivc" != no; then
976   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
977   exit 1
978 fi
979
980
981 ###############################################################################
982 #
983 #       Check for the DPMS server extension.
984 #
985 ###############################################################################
986
987 have_dpms=no
988 with_dpms_req=unspecified
989 AC_ARG_WITH(dpms-ext,
990 [  --with-dpms-ext         Include support for the DPMS extension.],
991   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
992
993 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
994
995 if test "$with_dpms" = yes; then
996
997   # first check for dpms.h
998   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
999
1000   # if that succeeded, then check for the DPMS code in the libraries
1001   if test "$have_dpms" = yes; then
1002
1003     # first look in -lXext (this is where it is with XFree86 4.0)
1004     have_dpms=no
1005     AC_CHECK_X_LIB(Xext, DPMSInfo, [have_dpms=yes], [true], -lXext -lX11)
1006
1007     # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
1008     if test "$have_dpms" = no; then
1009       AC_CHECK_X_LIB(Xdpms, DPMSInfo,
1010                     [have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"], [true],
1011                     -lXext -lX11)
1012     fi
1013   fi
1014
1015
1016   # if that succeeded, then we've really got it.
1017   if test "$have_dpms" = yes; then
1018     AC_DEFINE(HAVE_DPMS_EXTENSION)
1019   fi
1020
1021 elif test "$with_dpms" != no; then
1022   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
1023   exit 1
1024 fi
1025
1026
1027 ###############################################################################
1028 #
1029 #       Check for the XF86VMODE server extension.
1030 #
1031 ###############################################################################
1032
1033 have_xf86vmode=no
1034 with_xf86vmode_req=unspecified
1035 AC_ARG_WITH(xf86vmode-ext,
1036 [  --with-xf86vmode-ext    Include support for XFree86 virtual screens.],
1037   [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
1038   [with_xf86vmode=yes])
1039
1040 HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
1041
1042 if test "$with_xf86vmode" = yes; then
1043
1044   # first check for xf86vmode.h
1045   AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes])
1046
1047   # if that succeeded, then check for the -lXxf86vm
1048   if test "$have_xf86vmode" = yes; then
1049     have_xf86vmode=no
1050     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
1051                   [have_xf86vmode=yes; SAVER_LIBS="$SAVER_LIBS -lXxf86vm"],
1052                    [true], -lXext -lX11)
1053   fi
1054
1055   # if that succeeded, then we've really got it.
1056   if test "$have_xf86vmode" = yes; then
1057     AC_DEFINE(HAVE_XF86VMODE)
1058   fi
1059
1060 elif test "$with_xf86vmode" != no; then
1061   echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
1062   exit 1
1063 fi
1064
1065
1066 ###############################################################################
1067 #
1068 #       Check for HP XHPDisableReset and XHPEnableReset.
1069 #
1070 ###############################################################################
1071
1072 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
1073                   [AC_DEFINE(HAVE_XHPDISABLERESET)
1074                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"])
1075
1076
1077 ###############################################################################
1078 #
1079 #       Check for /proc/interrupts.
1080 #
1081 ###############################################################################
1082
1083 have_proc_interrupts=no
1084 with_proc_interrupts_req=unspecified
1085 AC_ARG_WITH(proc-interrupts,
1086 [  --with-proc-interrupts  Include support for consulting the /proc/interrupts
1087                           file to notice keyboard activity.],
1088   [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
1089   [with_proc_interrupts=yes])
1090
1091 if test "$with_proc_interrupts" = yes; then
1092
1093    AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
1094     ac_cv_have_proc_interrupts,
1095     [ac_cv_have_proc_interrupts=no
1096      if grep keyboard /proc/interrupts >/dev/null 2>&1 ; then
1097        ac_cv_have_proc_interrupts=yes
1098      fi
1099     ])
1100    have_proc_interrupts=$ac_cv_have_proc_interrupts
1101
1102   if test "$have_proc_interrupts" = yes; then
1103     AC_DEFINE(HAVE_PROC_INTERRUPTS)
1104   fi
1105
1106 elif test "$with_proc_interrupts" != no; then
1107   echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
1108   exit 1
1109 fi
1110
1111
1112 ###############################################################################
1113 #
1114 #       The --enable-locking option
1115 #
1116 ###############################################################################
1117
1118 AC_ARG_ENABLE(locking,[
1119 Screen locking options:
1120
1121   --enable-locking        Compile in support for locking the display.
1122   --disable-locking       Do not allow locking at all.
1123 ],
1124   [enable_locking="$enableval"],[enable_locking=yes])
1125 if test "$enable_locking" = yes; then
1126   true
1127 elif test "$enable_locking" = no; then
1128   AC_DEFINE(NO_LOCKING)
1129 else
1130   echo "error: must be yes or no: --enable-locking=$enable_locking"
1131   exit 1
1132 fi
1133
1134
1135
1136 ###############################################################################
1137 #
1138 #       The --enable-vt-locking option
1139 #
1140 ###############################################################################
1141
1142 #ac_vt_lockswitch=no
1143 #AC_ARG_ENABLE(vt-locking,[
1144 #  --enable-vt-locking     Compile in support for locking Virtual Terminals.
1145 #                          This is the default if the system supports it, and
1146 #                          if locking support is included (--enable-locking.)
1147 #  --disable-vt-locking    Do not allow locking of VTs, even if locking is
1148 #                          enabled.],
1149 #  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1150 #if test "$enable_vt_locking" = yes; then
1151 #
1152 #  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
1153 #   [AC_TRY_COMPILE([#include <fcntl.h>
1154 #                   #include <sys/ioctl.h>
1155 #                   #include <sys/vt.h>],
1156 #                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1157 #                  [ac_cv_vt_lockswitch=yes],
1158 #                  [ac_cv_vt_lockswitch=no])])
1159 #  ac_vt_lockswitch=$ac_cv_vt_lockswitch
1160 #
1161 #elif test "$enable_vt_locking" = no; then
1162 #  true
1163 #else
1164 #  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1165 #  exit 1
1166 #fi
1167 #
1168 #if test "$ac_vt_lockswitch" = yes; then
1169 #  AC_DEFINE(HAVE_VT_LOCKSWITCH)
1170 #  # the VT_LOCKSWITCH ioctl can only be used when running as root.
1171 #  # #### but it doesn't work yet, so don't worry about that for now.
1172 ##  need_setuid=yes
1173 #fi
1174
1175
1176
1177 ###############################################################################
1178 #
1179 #       Check for PAM.
1180 #
1181 ###############################################################################
1182
1183 case "$host" in
1184   *-solaris*)
1185    # Solaris systems tend to come with PAM misconfigured.
1186    #  Don't build it by default, even if the headers exist.
1187    with_pam_default=no
1188    ;;
1189   *)
1190    # Default to building PAM support on all other systems, if it exists.
1191    with_pam_default=yes
1192   ;;
1193 esac
1194
1195 have_pam=no
1196 with_pam_req=unspecified
1197
1198 AC_ARG_WITH(pam,
1199 [  --with-pam              Include support for PAM (Pluggable Auth Modules.)],
1200   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
1201
1202 HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1203
1204 if test "$enable_locking" = yes -a "$with_pam" = yes; then
1205   AC_CACHE_CHECK([for PAM], ac_cv_pam,
1206                  [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1207                                    [ac_cv_pam=yes],
1208                                    [ac_cv_pam=no])])
1209   if test "$ac_cv_pam" = yes ; then
1210     have_pam=yes
1211     AC_DEFINE(HAVE_PAM)
1212     PASSWD_LIBS="${PASSWD_LIBS} -lpam"
1213
1214     # libpam typically requires dlopen and dlsym.  On FreeBSD,
1215     # those are in libc.  On Linux and Solaris, they're in libdl.
1216     AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
1217
1218     AC_MSG_CHECKING(how to call pam_strerror)
1219     AC_CACHE_VAL(ac_cv_pam_strerror_args,
1220      [AC_TRY_COMPILE([#include <stdio.h>
1221                       #include <stdlib.h>
1222                       #include <security/pam_appl.h>],
1223                      [pam_handle_t *pamh = 0;
1224                       char *s = pam_strerror(pamh, PAM_SUCCESS);],
1225                      [ac_pam_strerror_args=2],
1226                      [AC_TRY_COMPILE([#include <stdio.h>
1227                                       #include <stdlib.h>
1228                                       #include <security/pam_appl.h>],
1229                                      [char *s =
1230                                        pam_strerror(PAM_SUCCESS);],
1231                                      [ac_pam_strerror_args=1],
1232                                      [ac_pam_strerror_args=0])])
1233       ac_cv_pam_strerror_args=$ac_pam_strerror_args])
1234     ac_pam_strerror_args=$ac_cv_pam_strerror_args
1235     if test "$ac_pam_strerror_args" = 1 ; then
1236       AC_MSG_RESULT(one argument)
1237     elif test "$ac_pam_strerror_args" = 2 ; then
1238       AC_DEFINE(PAM_STRERROR_TWO_ARGS)
1239       AC_MSG_RESULT(two arguments)
1240     else
1241       AC_MSG_RESULT(unknown)
1242     fi
1243   fi
1244 fi
1245
1246
1247 ###############################################################################
1248 #
1249 #       Check for Kerberos.
1250 #
1251 ###############################################################################
1252
1253 have_kerberos=no
1254 have_kerberos5=no
1255 with_kerberos_req=unspecified
1256
1257 AC_ARG_WITH(kerberos, 
1258 [  --with-kerberos         Include support for Kerberos authentication.],
1259   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1260
1261 HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1262
1263 if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
1264   AC_CACHE_CHECK([for Kerberos 4], ac_cv_kerberos,
1265                  [AC_TRY_X_COMPILE([#include <krb.h>],,
1266                                    [ac_cv_kerberos=yes],
1267                                    [ac_cv_kerberos=no])])
1268   AC_CACHE_CHECK([for Kerberos 5], ac_cv_kerberos5,
1269                  [AC_TRY_X_COMPILE([#include <kerberosIV/krb.h>],,
1270                                    [ac_cv_kerberos5=yes],
1271                                    [ac_cv_kerberos5=no])])
1272
1273   if test "$ac_cv_kerberos" = yes ; then
1274     have_kerberos=yes
1275     AC_DEFINE(HAVE_KERBEROS)
1276   fi
1277
1278   if test "$ac_cv_kerberos5" = yes ; then
1279     have_kerberos=yes
1280     have_kerberos5=yes
1281     AC_DEFINE(HAVE_KERBEROS)
1282     AC_DEFINE(HAVE_KERBEROS5)
1283   fi
1284
1285   if test "$have_kerberos5" = yes ; then
1286     # from Matt Knopp <mhat@infocalypse.netlag.com>
1287     # (who got it from amu@mit.edu)
1288     PASSWD_LIBS="$PASSWD_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcrypt -lcom_err"
1289   elif test "$have_kerberos" = yes ; then
1290     # from Tim Showalter <tjs+@andrew.cmu.edu>
1291     PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes"
1292   fi
1293
1294   if test "$have_kerberos" = yes ; then
1295     AC_CHECK_FUNC(res_search,,
1296       AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1297         AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1298       ))
1299   fi
1300 fi
1301
1302
1303 ###############################################################################
1304 #
1305 #       Check for the nine billion variants of shadow passwords...
1306 #
1307 ###############################################################################
1308
1309 need_setuid=no
1310
1311 have_shadow=no
1312 with_shadow_req=unspecified
1313
1314 AC_ARG_WITH(shadow,
1315 [  --with-shadow           Include support for shadow password authentication.],
1316   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1317
1318 HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1319
1320 if test "$enable_locking" = no ; then
1321   with_shadow_req=no
1322   with_shadow=no
1323 fi
1324
1325
1326 ###############################################################################
1327 #
1328 #       Check for Sun "adjunct" passwords.
1329 #
1330 ###############################################################################
1331
1332 if test "$with_shadow" = yes ; then
1333   AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1334                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1335                                     #include <unistd.h>
1336                                     #include <sys/types.h>
1337                                     #include <sys/label.h>
1338                                     #include <sys/audit.h>
1339                                     #include <pwdadj.h>],
1340                       [struct passwd_adjunct *p = getpwanam("nobody");
1341                        const char *pw = p->pwa_passwd;],
1342                       [ac_cv_sun_adjunct=yes],
1343                       [ac_cv_sun_adjunct=no])])
1344   if test "$ac_cv_sun_adjunct" = yes; then
1345     have_shadow_adjunct=yes
1346     have_shadow=yes
1347     need_setuid=yes
1348   fi
1349 fi
1350
1351
1352 ###############################################################################
1353 #
1354 #       Check for DEC and SCO so-called "enhanced" security.
1355 #
1356 ###############################################################################
1357
1358 if test "$with_shadow" = yes ; then
1359   AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1360                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1361                                     #include <unistd.h>
1362                                     #include <sys/types.h>
1363                                     #include <pwd.h>
1364                                     #include <sys/security.h>
1365                                     #include <prot.h>],
1366                       [struct pr_passwd *p;
1367                        const char *pw;
1368                        set_auth_parameters(0, 0);
1369                        check_auth_parameters();
1370                        p = getprpwnam("nobody");
1371                        pw = p->ufld.fd_encrypt;],
1372                       [ac_cv_enhanced_passwd=yes],
1373                       [ac_cv_enhanced_passwd=no])])
1374   if test $ac_cv_enhanced_passwd = yes; then
1375     have_shadow_enhanced=yes
1376     have_shadow=yes
1377     need_setuid=yes
1378
1379     # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1380     # (I'm told it needs -lcurses too, but I don't understand why.)
1381     # But on DEC, it's in -lsecurity.
1382     #
1383     AC_CHECK_LIB(prot, getprpwnam, 
1384                  [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1385                  [AC_CHECK_LIB(security, getprpwnam, 
1386                                [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1387                  [-lx])
1388   fi
1389 fi
1390
1391 ###############################################################################
1392 #
1393 #       Check for HP's entry in the "Not Invented Here" Sweepstakes.
1394 #
1395 ###############################################################################
1396
1397 if test "$with_shadow" = yes ; then
1398   AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1399                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1400                                     #include <unistd.h>
1401                                     #include <sys/types.h>
1402                                     #include <pwd.h>
1403                                     #include <hpsecurity.h>
1404                                     #include <prot.h>],
1405                       [struct s_passwd *p = getspwnam("nobody");
1406                        const char *pw = p->pw_passwd;],
1407                       [ac_cv_hpux_passwd=yes],
1408                       [ac_cv_hpux_passwd=no])])
1409   if test "$ac_cv_hpux_passwd" = yes; then
1410     have_shadow_hpux=yes
1411     have_shadow=yes
1412     need_setuid=yes
1413
1414     # on HPUX, bigcrypt is in -lsec
1415     AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1416   fi
1417 fi
1418
1419
1420 ###############################################################################
1421 #
1422 #       Check for FreeBSD-style shadow passwords.
1423 #
1424 #       On FreeBSD, getpwnam() and friends work just like on non-shadow-
1425 #       password systems -- except you only get stuff in the pw_passwd field
1426 #       if the running program is setuid.  So, guess that we've got this
1427 #       lossage to contend with if /etc/master.passwd exists, and default to
1428 #       a setuid installation.
1429 #
1430 ###############################################################################
1431
1432 if test "$with_shadow" = yes ; then
1433   AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1434                  [if test -f /etc/master.passwd ; then
1435                     ac_cv_master_passwd=yes
1436                   else
1437                     ac_cv_master_passwd=no
1438                   fi])
1439   if test "$ac_cv_master_passwd" = yes; then
1440     need_setuid=yes
1441   fi
1442 fi
1443
1444
1445 ###############################################################################
1446 #
1447 #       Check for traditional (ha!) shadow passwords.
1448 #
1449 ###############################################################################
1450
1451 if test "$with_shadow" = yes ; then
1452   AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1453                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1454                                     #include <unistd.h>
1455                                     #include <sys/types.h>
1456                                     #include <pwd.h>
1457                                     #include <shadow.h>],
1458                       [struct spwd *p = getspnam("nobody");
1459                        const char *pw = p->sp_pwdp;],
1460                       [ac_cv_shadow=yes],
1461                       [ac_cv_shadow=no])])
1462   if test "$ac_cv_shadow" = yes; then
1463     have_shadow=yes
1464     need_setuid=yes
1465
1466     # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1467     have_getspnam=no
1468     AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1469     if test "$have_getspnam" = no ; then
1470       AC_CHECK_LIB(gen, getspnam,
1471                    [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1472     fi
1473   fi
1474 fi
1475
1476
1477 ###############################################################################
1478 #
1479 #       Check for other libraries needed for non-shadow passwords.
1480 #
1481 ###############################################################################
1482
1483 if test "$enable_locking" = yes ; then
1484
1485   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1486   have_crypt=no
1487   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1488   if test "$have_crypt" = no ; then
1489     AC_CHECK_LIB(crypt, crypt,
1490                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1491   fi
1492 fi
1493
1494
1495 # Most of the above shadow mechanisms will have set need_setuid to yes,
1496 # if they were found.  But, on some systems, we need setuid even when
1497 # using plain old vanilla passwords.
1498 #
1499 if test "$enable_locking" = yes ; then
1500   case "$host" in
1501     *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1502       need_setuid=yes
1503     ;;
1504   esac
1505 fi
1506
1507
1508 if test "$have_shadow_adjunct" = yes ; then
1509   AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1510 elif test "$have_shadow_enhanced" = yes ; then
1511   AC_DEFINE(HAVE_ENHANCED_PASSWD)
1512 elif test "$have_shadow_hpux" = yes ; then
1513   AC_DEFINE(HAVE_HPUX_PASSWD)
1514 elif test "$have_shadow" = yes ; then
1515   AC_DEFINE(HAVE_SHADOW_PASSWD)
1516 fi
1517
1518
1519 ###############################################################################
1520 #
1521 #       Check for -lXm.
1522 #
1523 ###############################################################################
1524
1525 have_motif=no
1526 with_motif_req=unspecified
1527 AC_ARG_WITH(motif,[
1528 User interface options:
1529
1530   --with-motif            Use the Motif toolkit for the user interface.],
1531   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=yes])
1532
1533 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
1534
1535 if test "$with_motif" != yes -a "$with_motif" != no ; then
1536   echo "error: must be yes or no: --with-motif=$with_motif"
1537   exit 1
1538 fi
1539
1540 if test "$with_motif" = yes; then
1541   have_motif=no
1542   AC_CHECK_X_HEADER(Xm/Xm.h,
1543                     [have_motif=yes
1544                      AC_DEFINE(HAVE_MOTIF)
1545                      MOTIF_LIBS="$MOTIF_LIBS -lXm"])
1546 fi
1547
1548
1549 if test "$have_motif" = yes; then
1550   AC_CHECK_X_HEADER(Xm/ComboBox.h, [AC_DEFINE(HAVE_XMCOMBOBOX)])
1551 fi
1552
1553
1554 ###############################################################################
1555 #
1556 #       Check for -lgtk (and Gnome stuff)
1557 #
1558 ###############################################################################
1559
1560 have_gtk=no
1561 with_gtk_req=unspecified
1562 AC_ARG_WITH(gtk,
1563 [  --with-gtk              Use the Gtk toolkit for the user interface.],
1564   [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
1565
1566 # if --with-gtk=/directory/ was specified, remember that directory so that
1567 # we can also look for the `gtk-config' program in that directory.
1568 case "$with_gtk" in
1569   /*)
1570     gtk_dir="$with_gtk"
1571     ;;
1572   *)
1573     gtk_dir=""
1574     ;;
1575 esac
1576
1577 HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
1578
1579 if test "$with_gtk" != yes -a "$with_gtk" != no ; then
1580   echo "error: must be yes or no: --with-gtk=$with_gtk"
1581   exit 1
1582 fi
1583
1584 have_gnome=no
1585 with_gnome_req=unspecified
1586 AC_ARG_WITH(gnome,
1587 [  --with-gnome            Include support for the Gnome Control Center.],
1588   [with_gnome="$withval"; with_gnome_req="$withval"],[with_gnome=yes])
1589
1590 # if --with-gnome=/directory/ was specified, remember that directory so that
1591 # we can also look for the `gnome-config' program in that directory.
1592 case "$with_gnome" in
1593   /*)
1594     gnome_dir="$with_gnome"
1595     ;;
1596   *)
1597     gnome_dir=""
1598     ;;
1599 esac
1600
1601 HANDLE_X_PATH_ARG(with_gnome, --with-gnome, Gnome)
1602
1603 if test "$with_gnome" != yes -a "$with_gnome" != no ; then
1604   echo "error: must be yes or no: --with-gnome=$with_gnome"
1605   exit 1
1606 fi
1607
1608
1609 jurassic_gtk=no
1610 if test "$with_gtk" = yes; then
1611   have_gtk=no
1612   
1613   # if the user specified --with-gtk=/foo/ then look in /foo/bin/
1614   # for glib-config and gtk-config.
1615   #
1616   gtk_path="$PATH"
1617
1618   if test ! -z "$gtk_dir"; then
1619     # canonicalize slashes.
1620     gtk_dir=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
1621     gtk_path="$gtk_dir:$gtk_path"
1622   fi
1623
1624   if test ! -z "gnome_dir"; then
1625     # canonicalize slashes.
1626     gnome_dir=`echo "${gnome_dir}/bin" | sed 's@//*@/@g'`
1627     gtk_path="$gnome_dir:$gtk_path"
1628   fi
1629
1630   AC_PATH_PROGS(glib_config,  glib12-config glib-config,,  $gtk_path)
1631   AC_PATH_PROGS(gtk_config,   gtk12-config  gtk-config,,   $gtk_path)
1632
1633   if test "$with_gnome" = yes; then
1634     AC_PATH_PROGS(gnome_config, gnome-config,, $gtk_path)
1635   fi
1636
1637   if test -n "$glib_config" -a  -n "gtk_config" ; then
1638     have_gtk=yes
1639     if test "$with_gnome" = yes -a -n "$gnome_config" ; then
1640       have_gnome=yes
1641     fi
1642   fi
1643
1644   if test "$have_gtk" = yes; then
1645     AC_CACHE_CHECK([Gtk version number], ac_cv_gtk_version_string,
1646                    [ac_cv_gtk_version_string=`$gtk_config --version`])
1647     ac_gtk_version_string=$ac_cv_gtk_version_string
1648     # M4 sucks!!
1649     changequote(X,Y)
1650     maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
1651     min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
1652     changequote([,])
1653     ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
1654     if test -z "$ac_gtk_version"; then
1655       ac_gtk_version=unknown
1656       ac_gtk_version_string=unknown
1657     fi
1658     if test "$ac_gtk_version" = "unknown" || test "$ac_gtk_version" -lt 1002
1659     then
1660       have_gtk=no
1661       have_gnome=no
1662       jurassic_gtk=yes
1663     fi
1664   fi
1665
1666   if test "$have_gtk" = yes; then
1667     AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
1668                    [ac_cv_gtk_config_cflags=`$gtk_config --cflags`])
1669     AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
1670                    [ac_cv_gtk_config_libs=`$gtk_config --libs`])
1671   fi
1672   ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
1673   ac_gtk_config_libs=$ac_cv_gtk_config_libs
1674
1675   # Check for Gnome Capplet support.
1676   #
1677   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1678     gnome_config_libs="capplet gnomeui"
1679     AC_MSG_CHECKING(for Gnome capplet includes)
1680     AC_CACHE_VAL(ac_cv_gnome_config_cflags,
1681       [if ( $gnome_config --cflags $gnome_config_libs 2>&1 >/dev/null | \
1682             grep Unknown >/dev/null ) ; then
1683          ac_cv_gnome_config_cflags=''
1684        else
1685          ac_cv_gnome_config_cflags=`$gnome_config --cflags $gnome_config_libs`
1686        fi])
1687     ac_gnome_config_cflags=$ac_cv_gnome_config_cflags
1688     if test "$ac_gnome_config_cflags" = "" ; then
1689       have_gnome=no
1690       AC_MSG_RESULT(no)
1691     else
1692       AC_MSG_RESULT($ac_gnome_config_cflags)
1693     fi
1694   fi
1695
1696   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1697     AC_MSG_CHECKING(for Gnome capplet libs)
1698     AC_CACHE_VAL(ac_cv_gnome_config_libs,
1699       [if ( $gnome_config --libs $gnome_config_libs 2>&1 >/dev/null |
1700             grep Unknown >/dev/null ) ; then
1701          ac_cv_gnome_config_libs=''
1702        else
1703          ac_cv_gnome_config_libs=`$gnome_config --libs $gnome_config_libs`
1704        fi])
1705     ac_gnome_config_libs=$ac_cv_gnome_config_libs
1706     if test "$ac_gnome_config_libs" = "" ; then
1707       have_gnome=no
1708       AC_MSG_RESULT(no)
1709     else
1710       AC_MSG_RESULT($ac_gnome_config_libs)
1711     fi
1712   fi
1713
1714   GNOME_DATADIR=""
1715   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1716     GNOME_DATADIR=`$gnome_config --datadir`
1717   fi
1718
1719
1720   # If we have Gnome, then override the gtk-config values with 
1721   # the gnome-config values.
1722   #
1723   if test "$have_gnome" = yes -a "$have_gtk" = yes; then
1724     ac_gtk_config_cflags=$ac_gnome_config_cflags
1725     ac_gtk_config_libs=$ac_gnome_config_libs
1726     AC_DEFINE(HAVE_CRAPPLET)
1727   fi
1728
1729
1730   if test "$have_gtk" = yes; then
1731     INCLUDES="$INCLUDES $ac_gtk_config_cflags"
1732     GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
1733     AC_DEFINE(HAVE_GTK)
1734   fi
1735
1736 fi
1737
1738
1739 ###############################################################################
1740 #
1741 #       Checking whether Motif is really Lesstif.
1742 #
1743 ###############################################################################
1744
1745 have_lesstif=no
1746 if test "$have_motif" = yes ; then
1747   AC_CACHE_CHECK([whether Motif is really LessTif], 
1748                  ac_cv_have_lesstif,
1749                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
1750                                    [long vers = LesstifVersion;],
1751                                    [ac_cv_have_lesstif=yes],
1752                                    [ac_cv_have_lesstif=no])])
1753   have_lesstif=$ac_cv_have_lesstif
1754 fi
1755
1756
1757 lesstif_version=unknown
1758 lesstif_version_string=unknown
1759
1760 if test "$have_lesstif" = yes ; then
1761   ltv=unknown
1762   echo unknown > conftest-lt
1763   AC_CACHE_CHECK([LessTif version number],
1764                  ac_cv_lesstif_version_string,
1765       [AC_TRY_X_RUN([#include <stdio.h>
1766                      #include <Xm/Xm.h>
1767                      int main() {
1768                        FILE *f = fopen("conftest-lt", "w");
1769                        if (!f) exit(1);
1770                        fprintf(f, "%d %d.%d\n", LesstifVersion,
1771                           LESSTIF_VERSION, LESSTIF_REVISION);
1772                        fclose(f);
1773                        exit(0);
1774                      }],
1775                     [ltv=`cat conftest-lt`
1776                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
1777                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
1778                     [ac_cv_lesstif_version=unknown
1779                      ac_cv_lesstif_version_string=unknown],
1780                     [ac_cv_lesstif_version=unknown
1781                      ac_cv_lesstif_version_string=unknown])])
1782   rm -f conftest-lt
1783   lesstif_version=$ac_cv_lesstif_version
1784   lesstif_version_string=$ac_cv_lesstif_version_string
1785
1786 fi
1787
1788
1789 if test "$have_motif" = yes ; then
1790   mtv=unknown
1791   echo unknown > conftest-mt
1792   AC_CACHE_CHECK([Motif version number],
1793                  ac_cv_motif_version_string,
1794       [AC_TRY_X_RUN([#include <stdio.h>
1795                      #include <Xm/Xm.h>
1796                      int main() {
1797                        FILE *f = fopen("conftest-mt", "w");
1798                        if (!f) exit(1);
1799                        fprintf(f, "%d %d.%d\n", XmVersion,
1800                           XmVERSION, XmREVISION);
1801                        fclose(f);
1802                        exit(0);
1803                      }],
1804                     [mtv=`cat conftest-mt`
1805                      ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
1806                      ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
1807                     [ac_cv_motif_version=unknown
1808                      ac_cv_motif_version_string=unknown],
1809                     [ac_cv_motif_version=unknown
1810                      ac_cv_motif_version_string=unknown])])
1811   rm -f conftest-mt
1812   motif_version=$ac_cv_motif_version
1813   motif_version_string=$ac_cv_motif_version_string
1814
1815 fi
1816
1817
1818 ###############################################################################
1819 #
1820 #       Checking whether Motif requires -lXpm.
1821 #
1822 #       If this is Motif 2.x, and we have XPM, then link against XPM as well.
1823 #       The deal is, Motif 2.x requires XPM -- but it's a compilation option
1824 #       of the library whether to build the XPM code into libXm, or whether
1825 #       to rely on an external libXm.  So the only way to tell whether XPM is
1826 #       a link-time requirement is to examine libXm.a, which is very
1827 #       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
1828 #       always link against XPM if the XPM lib exists (and this will be a
1829 #       no-op if libXm happens to already have the XPM code in it.)
1830 #
1831 ###############################################################################
1832
1833 motif_requires_xpm=no
1834 if test "$have_motif" = yes ; then
1835    AC_MSG_CHECKING(whether Motif requires XPM)
1836    if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
1837    then
1838      motif_requires_xpm=yes
1839      AC_MSG_RESULT(maybe)
1840    else
1841      AC_MSG_RESULT(no)
1842    fi
1843 fi
1844
1845
1846 ###############################################################################
1847 #
1848 #       Checking whether Motif requires -lXp.
1849 #
1850 #       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
1851 #       Extension".   Why this extension isn't in -lXext with all the others,
1852 #       I have no idea.
1853 #
1854 ###############################################################################
1855
1856 have_xp_ext=no
1857 if test "$have_motif" = yes ; then
1858    have_xp_ext=no
1859    AC_CHECK_X_LIB(Xp, XpQueryExtension,
1860                   [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
1861                   [true], -lX11 -lXext -lm)
1862 fi
1863
1864
1865 ###############################################################################
1866 #
1867 #       Checking whether Motif requires -lXintl (for _Xsetlocale.)
1868 #
1869 ###############################################################################
1870
1871 have_xintl=no
1872 if test "$have_motif" = yes ; then
1873   AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
1874                  -lX11 -lXext -lm)
1875   if test "$have_xintl" = yes; then
1876     MOTIF_LIBS="$MOTIF_LIBS -lXintl"
1877   fi
1878 fi
1879
1880
1881 ###############################################################################
1882 #
1883 #       Check for -lGL or -lMesaGL.
1884 #
1885 ###############################################################################
1886
1887 have_gl=no
1888 ac_have_mesa_gl=no
1889 with_gl_req=unspecified
1890 gl_halfassed=no
1891 AC_ARG_WITH(gl,[
1892 Graphics options:
1893
1894   --with-gl               Build those demos which depend on OpenGL.],
1895   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
1896
1897 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
1898
1899 ac_mesagl_version=unknown
1900 ac_mesagl_version_string=unknown
1901
1902 if test "$with_gl" = yes; then
1903   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
1904   if test "$have_gl" = yes ; then
1905     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
1906   fi
1907
1908   # If we have the headers, try and figure out which vendor it's from.
1909   #
1910   if test "$have_gl" = yes ; then
1911
1912     # We need to know whether it's MesaGL so that we know which libraries
1913     # to link against.
1914     #
1915     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
1916       [ac_cv_have_mesa_gl=no
1917        AC_EGREP_X_HEADER(Mesa, GL/glx.h, [ac_cv_have_mesa_gl=yes])
1918       ])
1919     ac_have_mesa_gl=$ac_cv_have_mesa_gl
1920  
1921
1922     gl_lib_1=""
1923     GL_LIBS=""
1924
1925
1926     # Some versions of MesaGL are compiled to require -lpthread.
1927     # So if the Mesa headers exist, and -lpthread exists, then always
1928     # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
1929     #
1930     if test "$ac_have_mesa_gl" = yes; then
1931       AC_CHECK_LIB(pthread, pthread_create, [GL_LIBS="-lpthread"], [],)
1932     fi
1933
1934
1935     # If we have Mesa headers, check to see if we can link against -lMesaGL.
1936     # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
1937     # Else, warn that GL is busted.  (We have the headers, but no libs.)
1938     #
1939
1940     if test "$ac_have_mesa_gl" = yes ; then
1941       AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
1942                      [gl_lib_1="MesaGL"
1943                       GL_LIBS="-lMesaGL -lMesaGLU $GL_LIBS"],
1944                      [], -lMesaGLU $GL_LIBS -lX11 -lXext -lm)
1945     fi
1946
1947     if test "$gl_lib_1" = "" ; then
1948       AC_CHECK_X_LIB(GL, glXCreateContext, 
1949                      [gl_lib_1="GL"
1950                       GL_LIBS="-lGL -lGLU $GL_LIBS"],
1951                      [], -lGLU $GL_LIBS -lX11 -lXext -lm)
1952     fi
1953
1954     if test "$gl_lib_1" = "" ; then
1955       # we have headers, but no libs -- bail.
1956       have_gl=no
1957       ac_have_mesa_gl=no
1958       gl_halfassed=yes
1959     else
1960       # linking works -- we can build the GL hacks.
1961       AC_DEFINE(HAVE_GL)
1962       if test "$ac_have_mesa_gl" = yes ; then
1963         AC_DEFINE(HAVE_MESA_GL)
1964       fi
1965     fi
1966   fi
1967
1968
1969   # Now that we know we have GL headers and libs, do some more GL testing.
1970   #
1971
1972   if test "$have_gl" = yes ; then
1973     # If it's MesaGL, we'd like to issue a warning if the version number
1974     # is less than or equal to 2.6, because that version had a security bug.
1975     #
1976     if test "$ac_have_mesa_gl" = yes; then
1977
1978       AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
1979         [cat > conftest.$ac_ext <<EOF
1980 #line __oline__ "configure"
1981 #include "confdefs.h"
1982 #include <GL/gl.h>
1983 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
1984 EOF
1985
1986          ac_save_CPPFLAGS="$CPPFLAGS"
1987          if test \! -z "$includedir" ; then 
1988            CPPFLAGS="$CPPFLAGS -I$includedir"
1989          fi
1990          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1991
1992           # M4 sucks!!
1993          changequote(X,Y)
1994          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
1995               's/^configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
1996          changequote([,])
1997
1998          rm -f conftest.$ac_ext
1999
2000          CPPFLAGS="$ac_save_CPPFLAGS"
2001
2002          if test "$mglv" = ""; then
2003            ac_mesagl_version=unknown
2004            ac_mesagl_version_string=unknown
2005          else
2006            ac_mesagl_version_string=$mglv
2007            maj=`echo $mglv | sed -n 's/\..*//p'`
2008            min=`echo $mglv | sed -n 's/.*\.//p'`
2009            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
2010            if test -z "$ac_mesagl_version"; then
2011              ac_mesagl_version=unknown
2012              ac_mesagl_version_string=unknown
2013            fi
2014          fi
2015          ac_cv_mesagl_version=$ac_mesagl_version
2016          ac_cv_mesagl_version_string=$ac_mesagl_version_string
2017       ])
2018       ac_mesagl_version=$ac_cv_mesagl_version
2019       ac_mesagl_version_string=$ac_cv_mesagl_version_string
2020     fi
2021
2022
2023     # Check for OpenGL 1.1 features.
2024     #
2025     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
2026                    [true], $GL_LIBS -lX11 -lXext -lm)
2027   fi
2028
2029 elif test "$with_gl" != no; then
2030   echo "error: must be yes or no: --with-gl=$with_gl"
2031   exit 1
2032 fi
2033
2034
2035 ###############################################################################
2036 #
2037 #       Check for -lgle.
2038 #
2039 ###############################################################################
2040
2041 have_gle=no
2042 with_gle_req=unspecified
2043 gle_halfassed=no
2044 AC_ARG_WITH(gle,
2045 [  --with-gle              Build those demos which depend on GLE
2046                           (the OpenGL "extrusion" library.)],
2047   [with_gle="$withval"; with_gle_req="$withval"],[with_gle=yes])
2048
2049 HANDLE_X_PATH_ARG(with_gle, --with-gle, GLE)
2050
2051 GLE_LIBS=""
2052
2053 if test "$with_gle" = yes; then
2054
2055   AC_CHECK_X_HEADER(GL/gle.h, have_gle3=yes, have_gle3=no)
2056   if test "$have_gle3" = yes ; then
2057     have_gle=yes;
2058   else
2059     AC_CHECK_X_HEADER(GL/gutil.h, have_gle=yes, have_gle=no)
2060     if test "$have_gle" = yes ; then
2061       AC_CHECK_X_HEADER(GL/tube.h, have_gle=yes, have_gle=no)
2062     fi
2063   fi
2064
2065   if test "$have_gle" = yes ; then
2066     have_gle=no
2067     gle_halfassed=yes
2068     AC_CHECK_X_LIB(gle, gleCreateGC, 
2069                    [have_gle=yes; gle_halfassed=no; GLE_LIBS="-lgle"],
2070                    [], $GL_LIBS -lX11 -lXext -lm)
2071   fi
2072   if test "$have_gle" = yes ; then
2073     have_gle=no
2074     gle_halfassed=yes
2075
2076     # sometimes the libmatrix stuff is included in libgle.  look there first.
2077 #
2078 # I don't get it.  For some reason, this test passes on SGI, as if
2079 # uview_direction_d() was in libgle -- but it's not, it's in libmatrix.
2080 # Yet the link is succeeding.  Why???
2081 #
2082 #    AC_CHECK_X_LIB(gle, uview_direction_d, 
2083 #                   [have_gle=yes; gle_halfassed=no],
2084 #                   [], $GL_LIBS -lX11 -lXext -lm)
2085
2086     # As of GLE 3 this is in libgle, and has changed name to uview_direction!
2087     # *sigh*
2088     if test "$have_gle3" = yes ; then
2089       AC_CHECK_X_LIB(gle, uview_direction, 
2090                      [have_gle=yes; gle_halfassed=no],
2091                     [], $GL_LIBS -lX11 -lXext -lm)
2092     fi
2093     # if it wasn't in libgle, then look in libmatrix.
2094     if test "$have_gle" = no ; then
2095       AC_CHECK_X_LIB(matrix, uview_direction_d, 
2096                      [have_gle=yes; gle_halfassed=no;
2097                       GLE_LIBS="$GLE_LIBS -lmatrix"],
2098                     [], $GL_LIBS -lX11 -lXext -lm)
2099     fi
2100   fi
2101
2102   if test "$have_gle" = yes ; then
2103     AC_DEFINE(HAVE_GLE)
2104     if test "$have_gle3" = yes ; then
2105       AC_DEFINE(HAVE_GLE3)
2106     fi
2107   fi
2108
2109 elif test "$with_gle" != no; then
2110   echo "error: must be yes or no: --with-gle=$with_gle"
2111   exit 1
2112
2113 fi
2114
2115
2116
2117 ###############################################################################
2118 #
2119 #       Check for -lXpm.
2120 #
2121 ###############################################################################
2122
2123 have_xpm=no
2124 with_xpm_req=unspecified
2125 AC_ARG_WITH(xpm,
2126 [  --with-xpm              Include support for XPM files in some demos.],
2127   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
2128
2129 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
2130
2131 if test "$with_xpm" = yes; then
2132   AC_CHECK_X_HEADER(X11/xpm.h,
2133                    [have_xpm=yes
2134                     AC_DEFINE(HAVE_XPM)
2135                     XPM_LIBS="-lXpm"])
2136 elif test "$with_xpm" != no; then
2137   echo "error: must be yes or no: --with-xpm=$with_xpm"
2138   exit 1
2139 fi
2140
2141 # See comment near $motif_requires_xpm, above.
2142 # Need to do this here, after both Motif and XPM have been checked for.
2143 #
2144 if test "$have_motif" = yes -a "$have_xpm" = yes ; then
2145   if test "$motif_requires_xpm" = yes ; then
2146     MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
2147   fi
2148 fi
2149
2150
2151 ###############################################################################
2152 #
2153 #       Check for the XSHM server extension.
2154 #
2155 ###############################################################################
2156
2157 have_xshm=no
2158 with_xshm_req=unspecified
2159 AC_ARG_WITH(xshm-ext,
2160 [  --with-xshm-ext         Include support for the XSHM extension.],
2161   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
2162
2163 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
2164
2165 if test "$with_xshm" = yes; then
2166
2167   # first check for Xshm.h.
2168   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes])
2169
2170   # if that succeeded, then check for sys/ipc.h.
2171   if test "$have_xshm" = yes; then
2172     have_xshm=no
2173     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
2174   fi
2175
2176   # if that succeeded, then check for sys/shm.h.
2177   if test "$have_xshm" = yes; then
2178     have_xshm=no
2179     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
2180   fi
2181
2182   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
2183   # to exist, but the library code to not exist.  And even better, the library
2184   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
2185   # lib doesn't exist, give up.  (This lib gets added to X_EXTRA_LIBS, and
2186   # that's not quite right, but close enough.)
2187   #
2188   case "$host" in
2189     *-aix*)
2190       if [ `uname -v` -eq 3 ]; then
2191         have_xshm=no
2192         AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
2193                        [have_xshm=yes; X_EXTRA_LIBS="$X_EXTRA_LIBS -lXextSam"],
2194                        [true], -lX11 -lXext -lm)
2195       fi
2196     ;;
2197   esac
2198
2199   # if that succeeded, then we've really got it.
2200   if test "$have_xshm" = yes; then
2201     AC_DEFINE(HAVE_XSHM_EXTENSION)
2202   fi
2203
2204 elif test "$with_xshm" != no; then
2205   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
2206   exit 1
2207 fi
2208
2209
2210 ###############################################################################
2211 #
2212 #       Check for the DOUBLE-BUFFER server extension.
2213 #
2214 ###############################################################################
2215
2216 have_xdbe=no
2217 with_xdbe_req=unspecified
2218 AC_ARG_WITH(xdbe-ext,
2219 [  --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension.],
2220   [with_xdbe="$withval"; with_xdbe_req="$withval"],[with_xdbe=yes])
2221
2222 HANDLE_X_PATH_ARG(with_xdbe, --with-xdbe-ext, DOUBLE-BUFFER)
2223
2224 if test "$with_xdbe" = yes; then
2225
2226   AC_CHECK_X_HEADER(X11/extensions/Xdbe.h, [have_xdbe=yes])
2227   if test "$have_xdbe" = yes; then
2228     AC_DEFINE(HAVE_DOUBLE_BUFFER_EXTENSION)    
2229   fi
2230
2231 elif test "$with_xdbe" != no; then
2232   echo "error: must be yes or no: --with-xdbe-ext=$with_xshm"
2233   exit 1
2234 fi
2235
2236
2237 ###############################################################################
2238 #
2239 #       Check for the SGI XReadDisplay server extension.
2240 #
2241 #       Note: this has to be down here, rather than up with the other server
2242 #       extension tests, so that the output of `configure --help' is in the
2243 #       right order.  Arrgh!
2244 #
2245 ###############################################################################
2246
2247 have_readdisplay=no
2248 with_readdisplay_req=unspecified
2249 AC_ARG_WITH(readdisplay,
2250 [  --with-readdisplay      Include support for the XReadDisplay extension.],
2251   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
2252   [with_readdisplay=yes])
2253
2254 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
2255
2256 if test "$with_readdisplay" = yes; then
2257   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
2258                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
2259 elif test "$with_readdisplay" != no; then
2260   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
2261   exit 1
2262 fi
2263
2264
2265 ###############################################################################
2266 #
2267 #       Check for the SGI Iris Video Library.
2268 #
2269 ###############################################################################
2270
2271 have_sgivideo=no
2272 with_sgivideo_req=unspecified
2273 AC_ARG_WITH(sgivideo,
2274 [  --with-sgivideo         Include support for SGI's Iris Video Library.],
2275   [with_sgivideo="$withval"; with_sgivideo_req="$withval"],
2276   [with_sgivideo=yes])
2277
2278 HANDLE_X_PATH_ARG(with_sgivideo, --with-sgivideo, Iris Video)
2279
2280 if test "$with_sgivideo" = yes; then
2281   AC_CHECK_X_HEADER(dmedia/vl.h, have_sgivideo=yes)
2282   if test "$have_sgivideo" = yes; then
2283     have_sgivideo=no
2284     AC_CHECK_LIB(vl, vlOpenVideo, [have_sgivideo=yes])
2285     if test "$have_sgivideo" = yes; then
2286       SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
2287       SGI_VIDEO_LIBS="-lvl"
2288       AC_DEFINE(HAVE_SGI_VIDEO)
2289     fi
2290   fi
2291 elif test "$with_sgivideo" != no; then
2292   echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
2293   exit 1
2294 fi
2295
2296
2297 ###############################################################################
2298 #
2299 #       Check for a program to generate random text.
2300 #
2301 #       Zippy is funnier than the idiocy generally spat out by `fortune',
2302 #       so try to find that, by invoking Emacs and asking it where its 
2303 #       libexec directory is ("yow" lives in there.)
2304 #
2305 #       If that doesn't work, see if fortune, zippy, or yow are on $PATH,
2306 #       and if so, use them.
2307 #
2308 #       If that doesn't work, look in /usr/games, and if it's there, use
2309 #       the full pathname.
2310 #
2311 ###############################################################################
2312
2313 with_zippy_req=""
2314 AC_ARG_WITH(zippy,[
2315   --with-zippy=PROGRAM    Some demos are able to run an external program and
2316                           display its text; this names the program to use by
2317                           default (though it can be overridden with X
2318                           resources.)  If you don't specify this, the default
2319                           is to use \"yow\" from the Emacs distribution (if you
2320                           have it) or else to use \"fortune\".
2321 ],
2322   [with_zippy_req="$withval"; with_zippy="$withval"],[with_zippy=yes])
2323
2324 if test "$with_zippy" = no || test "$with_zippy" = yes ; then
2325   with_zippy=""
2326   with_zippy_req=""
2327 fi
2328
2329 if test -n "$with_zippy_req" ; then
2330   ac_cv_zippy_program=""
2331   case "$with_zippy_req" in
2332     /*)
2333       AC_MSG_CHECKING([for $with_zippy_req])
2334       if test -x "$with_zippy_req" ; then
2335         AC_MSG_RESULT(yes)
2336       else
2337         AC_MSG_RESULT(no)
2338         with_zippy=""
2339       fi
2340     ;;
2341     *)
2342       # don't cache
2343       unset ac_cv_path_zip2
2344       AC_PATH_PROG(zip2, $with_zippy_req, [])
2345       if test "$zip2" = ""; then
2346         with_zippy=""
2347       fi
2348     ;;
2349   esac
2350   ac_cv_zippy_program="$with_zippy"
2351
2352 elif test -n "$ac_cv_zippy_program"; then
2353   AC_MSG_RESULT([checking for zippy... (cached) $ac_cv_zippy_program])
2354 fi
2355
2356 if test ! -n "$ac_cv_zippy_program"; then
2357
2358   AC_CHECK_PROGS(emacs_exe, emacs)
2359   AC_CHECK_PROGS(xemacs_exe, xemacs)
2360
2361   ac_cv_zippy_program=""
2362   eargs='-batch -q -nw --eval'
2363
2364   if test -n "$emacs_exe" ; then
2365     AC_MSG_CHECKING([for emacs yow])
2366     #
2367     # get emacs to tell us where the libexec directory is.
2368     #
2369     dir=`$emacs_exe $eargs '(princ (concat exec-directory "\n"))' \
2370          2>/dev/null | tail -1`
2371     dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
2372     #
2373     # try running libexec/yow and see if it exits without error.
2374     #
2375     if test x"$dir" != x -a -x "$dir/yow" ; then
2376       if $dir/yow >&- 2>&- ; then
2377         ac_cv_zippy_program="$dir/yow"
2378         AC_MSG_RESULT($ac_cv_zippy_program)
2379       else
2380         AC_MSG_RESULT(no)
2381       fi
2382     fi
2383   fi
2384
2385   if test -z "$ac_cv_zippy_program" ; then
2386     AC_MSG_CHECKING([for xemacs yow])
2387     if test -n "$xemacs_exe" ; then
2388       #
2389       # get xemacs to tell us where the libexec directory is.
2390       #
2391       dir=`$xemacs_exe $eargs '(princ (concat exec-directory "\n"))' \
2392            2>/dev/null | tail -1`
2393       dir=`echo "$dir" | sed 's@///*@/@g;s@/$@@'`
2394       #
2395       # try running libexec/yow and see if it exits without error.
2396       #
2397       if test x"$dir" != x -a -x "$dir/yow" ; then
2398         if $dir/yow >&- 2>&- ; then
2399           ac_cv_zippy_program="$dir/yow"
2400           AC_MSG_RESULT($ac_cv_zippy_program)
2401         else
2402           #
2403           # in some xemacs installations, the pathname of the yow.lines file
2404           # isn't hardcoded into the yow executable, and must be passed on 
2405           # the command line.  See if it's in libexec/../etc/.
2406
2407           # M4 sucks!!
2408           changequote(X,Y)
2409           dir_up=`echo "$dir" | sed 's@/[^/]*$@@'`
2410           changequote([,])
2411
2412           yowlines="$dir_up/etc/yow.lines"
2413           if $dir/yow -f $yowlines >&- 2>&- ; then
2414             ac_cv_zippy_program="$dir/yow -f $yowlines"
2415             AC_MSG_RESULT($ac_cv_zippy_program)
2416           else
2417             #
2418             # In newer XEmacs releases, yow.lines is in a different place,
2419             # and the easiest way to get it is by calling the new function
2420             # `locate-data-file'.
2421             #
2422             yowlines=`$xemacs_exe $eargs \
2423               '(princ (concat (locate-data-file "yow.lines") "\n"))' \
2424               2>/dev/null | tail -1`
2425             if $dir/yow -f $yowlines >&- 2>&- ; then
2426               ac_cv_zippy_program="$dir/yow -f $yowlines"
2427               AC_MSG_RESULT($ac_cv_zippy_program)
2428             else
2429               AC_MSG_RESULT(no)
2430             fi
2431           fi
2432         fi
2433       fi
2434     fi
2435   fi
2436
2437   # if that didn't work, try for some other programs...
2438   if test -z "$ac_cv_zippy_program" ; then
2439     fortune=''
2440     AC_CHECK_PROGS(fortune, [fortune zippy yow])
2441     # if that didn't work, try for those programs in /usr/games...
2442     if test -z "$fortune" ; then
2443       AC_PATH_PROGS(fortune, [fortune zippy yow], fortune,
2444                     /usr/games:/usr/local/games:$PATH)
2445     fi
2446   fi
2447 fi
2448
2449 if test -z "$ac_cv_zippy_program" ; then
2450   ac_cv_zippy_program=fortune
2451 fi
2452
2453 AC_DEFINE_UNQUOTED(ZIPPY_PROGRAM, "$ac_cv_zippy_program")
2454
2455
2456 ###############################################################################
2457 #
2458 #       Done testing.  Now, set up the various -I and -L variables,
2459 #       and decide which GUI program to build by default.
2460 #
2461 ###############################################################################
2462
2463 DEPEND=makedepend
2464 DEPEND_FLAGS=
2465 DEPEND_DEFINES=
2466
2467
2468 if test \! -z "$includedir" ; then 
2469   INCLUDES="$INCLUDES -I$includedir"
2470 fi
2471
2472 if test \! -z "$libdir" ; then
2473   LDFLAGS="$LDFLAGS -L$libdir"
2474 fi
2475
2476
2477 PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
2478 ALL_DEMO_PROGRAMS=
2479 if test "$have_motif" = yes; then
2480   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
2481   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2482 fi
2483 if test "$have_gtk" = yes; then
2484   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
2485   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
2486 fi
2487
2488
2489 if test "$have_kerberos" = yes; then
2490   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
2491   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
2492 fi
2493 if test "$have_pam" = yes; then
2494   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
2495   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
2496   INSTALL_PAM="install-pam"
2497 fi
2498   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
2499   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
2500
2501
2502 if test "$enable_locking" = yes; then
2503   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
2504   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
2505 else
2506   LOCK_SRCS='$(NOLOCK_SRCS_1)'
2507   LOCK_OBJS='$(NOLOCK_OBJS_1)'
2508 fi
2509
2510 if test "$need_setuid" = yes; then
2511   NEED_SETUID=yes
2512   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
2513 else
2514   NEED_SETUID=no
2515   INSTALL_SETUID='$(INSTALL_PROGRAM)'
2516 fi
2517
2518 tab='   '
2519 if test "$have_gl" = yes; then
2520   GL_EXES='$(GL_EXES)'
2521   GL_MEN='$(GL_MEN)'
2522   GL_KLUDGE="${tab}  "
2523 else
2524   GL_KLUDGE="-${tab}  "
2525 fi
2526
2527 if test "$have_gle" = yes; then
2528   GLE_EXES='$(GLE_EXES)'
2529   GLE_MEN='$(GLE_MEN)'
2530   GLE_KLUDGE="${tab}   "
2531 else
2532   GLE_KLUDGE="-${tab}   "
2533 fi
2534
2535
2536 ###############################################################################
2537 #
2538 #       Perform substitutions and write Makefiles.
2539 #
2540 ###############################################################################
2541
2542 AC_SUBST(INCLUDES)
2543
2544 AC_SUBST(PREFERRED_DEMO_PROGRAM)
2545 AC_SUBST(ALL_DEMO_PROGRAMS)
2546 AC_SUBST(SAVER_LIBS)
2547 AC_SUBST(MOTIF_LIBS)
2548 AC_SUBST(GTK_LIBS)
2549 AC_SUBST(HACK_LIBS)
2550 AC_SUBST(XPM_LIBS)
2551 AC_SUBST(GL_LIBS)
2552 AC_SUBST(GLE_LIBS)
2553 AC_SUBST(PASSWD_LIBS)
2554 AC_SUBST(INSTALL_SETUID)
2555 AC_SUBST(INSTALL_DIRS)
2556 AC_SUBST(NEED_SETUID)
2557 AC_SUBST(INSTALL_PAM)
2558 AC_SUBST(SGI_VIDEO_OBJS)
2559 AC_SUBST(SGI_VIDEO_LIBS)
2560
2561 AC_SUBST(PASSWD_SRCS)
2562 AC_SUBST(PASSWD_OBJS)
2563 AC_SUBST(XMU_SRCS)
2564 AC_SUBST(XMU_OBJS)
2565 AC_SUBST(SAVER_GL_SRCS)
2566 AC_SUBST(SAVER_GL_OBJS)
2567 AC_SUBST(SAVER_GL_LIBS)
2568 AC_SUBST(LOCK_SRCS)
2569 AC_SUBST(LOCK_OBJS)
2570 AC_SUBST(GL_EXES)
2571 AC_SUBST(GL_MEN)
2572 AC_SUBST(GL_KLUDGE)
2573 AC_SUBST(GLE_EXES)
2574 AC_SUBST(GLE_MEN)
2575 AC_SUBST(GLE_KLUDGE)
2576 AC_SUBST(HACKDIR)
2577 AC_SUBST(GNOME_DATADIR)
2578
2579 APPDEFAULTS=$ac_x_app_defaults
2580 AC_SUBST(APPDEFAULTS)
2581
2582 AC_SUBST(DEPEND)
2583 AC_SUBST(DEPEND_FLAGS)
2584 AC_SUBST(DEPEND_DEFINES)
2585 AC_SUBST(PERL)
2586
2587 AC_OUTPUT(Makefile
2588           utils/Makefile
2589           driver/Makefile
2590           hacks/Makefile
2591           hacks/glx/Makefile
2592           driver/XScreenSaver.ad)
2593
2594 ###############################################################################
2595 #
2596 #       Print some warnings at the end.
2597 #
2598 ###############################################################################
2599
2600 warn_prefix_1="    Warning:"
2601 warn_prefix_2="       Note:"
2602 warn_prefix="$warn_prefix_1"
2603
2604 warning=no
2605 warnsep='    #################################################################'
2606
2607 warnpre() {
2608   if test "$warning" = no ; then
2609     echo '' ; echo "$warnsep" ; echo ''
2610     warning=yes
2611   fi
2612 }
2613
2614 warn() {
2615   warnpre
2616   if test "$warning" = long ; then echo '' ; fi
2617   warning=yes
2618   echo "$warn_prefix $@"
2619 }
2620
2621 warnL() {
2622   was=$warning
2623   warnpre
2624   warning=yes
2625   if test "$was" != no ; then echo '' ; fi
2626   echo "$warn_prefix $@"
2627 }
2628
2629 warn2() {
2630   echo "             $@"
2631   warning=long
2632 }
2633
2634 note() {
2635   warn_prefix="$warn_prefix_2"
2636   warn $@
2637   warn_prefix="$warn_prefix_1"
2638 }
2639
2640 noteL() {
2641   warn_prefix="$warn_prefix_2"
2642   warnL $@
2643   warn_prefix="$warn_prefix_1"
2644 }
2645
2646
2647 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
2648   warn 'The SGI saver extension was requested, but was not found.'
2649 fi
2650
2651 if test "$with_mit_req" = yes -a "$have_mit" = no ; then
2652   warn 'The MIT saver extension was requested, but was not found.'
2653 fi
2654
2655 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
2656   warn 'The XIdle extension was requested, but was not found.'
2657 fi
2658
2659 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
2660   warn 'The XSHM extension was requested, but was not found.'
2661 fi
2662
2663 if test "$with_xdbe_req" = yes -a "$have_xdbe" = no ; then
2664   warn 'The DOUBLE-BUFFER extension was requested, but was not found.'
2665 fi
2666
2667 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
2668   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
2669 fi
2670
2671 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
2672   warn 'The DPMS extension was requested, but was not found.'
2673 fi
2674
2675 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
2676   warn 'The XF86VMODE extension was requested, but was not found.'
2677 fi
2678
2679 if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
2680   warn "Checking of /proc/interrupts was requested, but it's bogus."
2681 fi
2682
2683
2684 if test "$have_motif" = no -a "$have_gtk" = no; then
2685   warnL "Neither Motif nor Gtk seem to be available;"
2686   warn2 "the \`xscreensaver-demo' program requires one of these."
2687
2688 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
2689   warnL "Use of Motif was requested, but it wasn't found;"
2690   warn2 "Gtk will be used instead."
2691
2692 elif test "$jurassic_gtk" = yes ; then
2693
2694   pref_gtk=1.2
2695
2696   v="$ac_gtk_version_string"
2697   if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
2698     warnL "Use of Gtk was requested, but its version number is unknown;"
2699   elif test "$with_gtk_req" = yes ; then
2700     warnL "Use of Gtk was requested, but it is version $v;"
2701   else
2702     warnL "Gtk was found on this system, but it is version $v;"
2703   fi
2704
2705   warn2 "Gtk $pref_gtk or newer is required.  Motif will be used instead."
2706
2707 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
2708   warnL "Use of Gtk was requested, but it wasn't found;"
2709   warn2 "Motif will be used instead."
2710
2711 fi
2712
2713
2714 if test "$with_gnome_req" = yes -a "$have_gnome" = no ; then
2715   warn  'Use of the Gnome Control Panel was requested, but the necessary'
2716   warn2 'headers and/or libraries were not found.'
2717 fi
2718
2719
2720 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
2721
2722   preferred_lesstif=0.86
2723
2724   if test "$lesstif_version" = unknown; then
2725     warnL "Unable to determine the LessTif version number!"
2726     warn2 "Make sure you are using version $preferred_lesstif or newer."
2727     warn2 "See <http://www.lesstif.org/>."
2728
2729   elif test \! $lesstif_version -gt 82; then
2730     warnL "LessTif version $lesstif_version_string is being used."
2731     warn2 "LessTif versions 0.82 and earlier are too buggy to"
2732     warn2 "use with XScreenSaver; it is strongly recommended"
2733     warn2 "that you upgrade to at least version $preferred_lesstif!"
2734     warn2 "See <http://www.lesstif.org/>."
2735   fi
2736 fi
2737
2738
2739
2740 if test "$have_xpm" = no ; then
2741   if test "$with_xpm_req" = yes ; then
2742     warnL 'Use of XPM was requested, but it was not found.'
2743   elif test "$with_xpm_req" = no ; then
2744     noteL 'The XPM library is not being used.'
2745   else
2746     noteL 'The XPM library was not found.'
2747   fi
2748
2749   echo ''
2750   warn2 'Some of the demos will not be as colorful as they'
2751   warn2 'could be.  You might want to consider installing XPM'
2752   warn2 'and re-running configure.  (Remember to delete the'
2753   warn2 'config.cache file first.)  You can find XPM at most'
2754   warn2 'X11 archive sites, such as <http://sunsite.unc.edu/>.'
2755 fi
2756
2757
2758 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
2759   preferred_mesagl=3.0
2760
2761   if test "$ac_mesagl_version" = unknown; then
2762     warnL "Unable to determine the MesaGL version number!"
2763     warn2 "Make sure you are using version $preferred_mesagl or newer."
2764
2765   elif test \! "$ac_mesagl_version" -gt 2006; then
2766     warnL "MesaGL version $ac_mesagl_version_string is being used."
2767     warn2 "MesaGL versions 2.6 and earlier have a security bug."
2768     warn2 "It is strongly recommended that you upgrade to at"
2769     warn2 "least version $preferred_mesagl."
2770   fi
2771 fi
2772
2773 if test "$have_gl" = no ; then
2774   if test "$with_gl_req" = yes ; then
2775     warnL 'Use of GL was requested, but it was not found.'
2776   elif test "$with_gl_req" = no ; then
2777     noteL 'The OpenGL 3D library is not being used.'
2778   else
2779     noteL 'The OpenGL 3D library was not found.'
2780   fi
2781
2782   if test "$gl_halfassed" = yes ; then
2783     echo ''
2784     warn2 'More specifically, we found the headers, but not the'
2785     warn2 'libraries; so either GL is half-installed on this'
2786     warn2 "system, or something else went wrong.  The \`config.log'"
2787     warn2 'file might contain some clues.'
2788   fi
2789
2790   echo ''
2791   warn2 'Those demos which use 3D will not be built or installed.'
2792   warn2 'You might want to consider installing OpenGL and'
2793   warn2 're-running configure.  (Remember to delete the'
2794   warn2 "config.cache file first.)  If your vendor doesn't ship"
2795   warn2 'their own implementation of OpenGL, you can get a free'
2796   warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
2797   warn2 'info, see <http://www.opengl.org/>.'
2798
2799 fi
2800
2801
2802 if test "$have_gl" = yes -a "$have_gle" = no ; then
2803   if test "$with_gle_req" = yes ; then
2804     noteL 'Use of the GLE (GL Extrusion) library was requested, but'
2805     warn2 'it was not found (though the OpenGL library was found, and'
2806     warn2 'is being used.)'
2807   elif test "$with_gle_req" = no ; then
2808     noteL 'The OpenGL Library is being used, but the GLE (GL Extrusion)'
2809     warn2 'library is not.'
2810   else
2811     noteL 'The OpenGL Library was found, but the GLE (GL Extrusion)'
2812     warn2 'was not.'
2813   fi
2814
2815   if test "$gle_halfassed" = yes ; then
2816     echo ''
2817     warn2 'More specifically, we found the headers, but not the'
2818     warn2 'libraries; so either GLE is half-installed on this'
2819     warn2 "system, or something else went wrong.  The \`config.log'"
2820     warn2 'file might contain some clues.'
2821   fi
2822
2823   echo ''
2824   warn2 'Some of the OpenGL (3D) demos (those that depend on GLE)'
2825   warn2 'will not be built or installed.  You might want to consider'
2826   warn2 'installing GLE and re-running configure.  (Remember to delete'
2827   warn2 'the config.cache file first.)  You can find the GLE library'
2828   warn2 'at <http://www.linas.org/gle/>.  For general OpenGL info,'
2829   warn2 'see <http://www.opengl.org/>.'
2830
2831 fi
2832
2833
2834 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
2835   warn 'Use of XReadDisplay was requested, but it was not found.'
2836 fi
2837
2838 if test "$with_sgivideo_req" = yes -a "$have_sgivideo" = no ; then
2839   warn 'Use of the Iris Video Library was requested, but it was not found.'
2840 fi
2841
2842 if test -n "$with_zippy_req"; then
2843   if test "$with_zippy_req" != "$ac_cv_zippy_program" ; then
2844     warnL "$with_zippy_req was requested as the Zippy program,"
2845     warn2 "but was not found.  The default will be used instead."
2846   fi
2847 fi
2848
2849 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
2850   warn 'Use of Kerberos was requested, but it was not found.'
2851 fi
2852
2853 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
2854   warn 'Use of PAM was requested, but it was not found.'
2855 fi
2856
2857 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
2858   warn 'Use of shadow passwords was requested, but they were not found.'
2859 fi
2860
2861
2862 # You are in a twisty maze of namespaces and syntaxes, all alike.
2863 # Fuck the skull of Unix.
2864 #
2865 eval bindir=${bindir}
2866 eval bindir=${bindir}
2867 eval bindir=${bindir}
2868 eval bindir=${bindir}
2869 eval bindir=${bindir}
2870 eval bindir=${bindir}
2871 eval HACKDIR=${HACKDIR}
2872 eval HACKDIR=${HACKDIR}
2873 eval HACKDIR=${HACKDIR}
2874 eval HACKDIR=${HACKDIR}
2875 eval HACKDIR=${HACKDIR}
2876 eval HACKDIR=${HACKDIR}
2877
2878 # canonicalize slashes.
2879 bindir=`echo  "${bindir}"  | sed 's@/$@@;s@//*@/@g'`
2880 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
2881
2882
2883 # Sanity check the subdir
2884 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
2885   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
2886     echo ""
2887     AC_MSG_ERROR([\"--enable-subdir=${bindir}/${bad_choice}\" won't work.
2888                    There will be an executable installed with that name, so
2889                    that can't be the name of a directory as well.  Please
2890                    re-configure with a different directory name.])
2891   fi
2892 done
2893
2894
2895 do_dir_warning=no
2896
2897 # Now let's see if there's a previous RPM version already installed.  Blargh!
2898
2899 # M4 sucks!!
2900 changequote(X,Y)
2901 rpmv=`(rpm -qv xscreensaver) 2>&- | \
2902       sed 's/^xscreensaver-\([0-9][0-9]*[.][0-9][0-9]*\)-.*$/\1/'`
2903 changequote([,])
2904
2905 if test \! -z "$rpmv" ; then
2906   rpmbdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/xscreensaver-demo$@\1@p'`
2907   rpmhdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/attraction$@\1@p'`
2908
2909   warning=no
2910   warnL "There is already an installed RPM of xscreensaver $rpmv"
2911   warn2 "on this system.  You might want to remove it (with"
2912   warn2 '"rpm -ve xscreensaver") before running "make install"'
2913   warn2 "from this directory."
2914   echo ""
2915   warn2 "Alternately, you could build this version of xscreensaver"
2916   warn2 'as an RPM, and then install that.  An "xscreensaver.spec"'
2917   warn2 "file is included.  See the RPM documentation for more info."
2918   echo ""
2919
2920   if test "$rpmbdir" = "$rpmhdir" ; then
2921     warn2 "The RPM version was installed in $rpmbdir."
2922   else
2923     warn2 "The RPM version was installed in $rpmbdir,"
2924     warn2 "with demos in $rpmhdir."
2925   fi
2926
2927   do_dir_warning=yes
2928 fi
2929
2930
2931 # Warn about egregious GNOME bogosity.
2932 #
2933 #if (rpm -qv control-center) >&- 2>&- ; then
2934 #  warning=no
2935 #  warnL "The Gnome Control Center seems to be installed."
2936 #  echo  ""
2937 #  warn2 "Note that simply installing this version of xscreensaver"
2938 #  warn2 "will not cause GNOME to know about the newly-added display"
2939 #  warn2 "modes -- GNOME is just lame that way.  Instead of using the"
2940 #  warn2 "Control Center, try using the \`xscreensaver-demo' command."
2941 #fi
2942
2943
2944 if test "${bindir}" = "${HACKDIR}" ; then
2945   do_dir_warning=yes
2946 fi
2947
2948 if test "$do_dir_warning" = yes; then
2949   echo ""
2950   echo "$warnsep"
2951   echo ""
2952   echo '      When you run "make install", the "xscreensaver",'
2953   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
2954   echo "      will be installed in ${bindir}."
2955   echo ""
2956   echo "      The various graphics demos (100+ different executables) will"
2957   echo "      also be installed in ${HACKDIR}."
2958   echo ""
2959   echo "      If you would prefer the demos to be installed elsewhere"
2960   echo "      (for example, in a dedicated directory) you should re-run"
2961   echo "      configure with the --enable-subdir=DIR option.  For more"
2962   echo "      information, run $0 --help."
2963   warning=yes
2964 fi
2965
2966 if test "$warning" != no; then
2967   echo '' ; echo "$warnsep" ; echo ''
2968 fi