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