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