http://ftp.ksu.edu.tw/FTP/FreeBSD/distfiles/xscreensaver-4.20.tar.gz
[xscreensaver] / configure.in
1 # configure.in --- xscreensaver, Copyright (c) 1997-2005 Jamie Zawinski.
2 #
3
4 AC_PREREQ(2.52)
5 AC_INIT(driver/subprocs.c)
6 AC_CONFIG_HEADER(config.h)
7
8 echo "current directory: `pwd`"
9 echo "command line was: $0 $@"
10
11
12 # After checking to see that --srcdir is correct (which AC_INIT does)
13 # check for some random other files that come later in the tar file,
14 # to make sure everything is here.
15 #
16 for d in driver utils hacks hacks/glx ; do
17   f=$srcdir/$d/Makefile.in
18   if test \! -r $f ; then
19     echo ""
20     echo "ERROR: The package is incomplete: $f does not exist."
21     echo "       This probably means that your download was truncated."
22     echo ""
23     exit 1
24   fi
25 done
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     # not using GCC
38     AC_MSG_CHECKING(how to request ANSI compilation)
39     case "$host" in
40       *-hpux* )
41         AC_MSG_RESULT(HPUX: adding -Ae)
42         CC="$CC -Ae"
43       ;;
44       *-aix* )
45         AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
46         CC="$CC -qlanglvl=ansi -qhalt=e"
47       ;;
48       *-dec-* )
49         AC_MSG_RESULT(DEC: adding -std1 -ieee)
50         CC="$CC -std1"
51       ;;
52       *)
53         AC_MSG_RESULT(no idea)
54       ;;
55     esac
56   else
57     # using GCC
58     case "$host" in
59       *-solaris*)
60         AC_MSG_RESULT(Solaris: adding -D__EXTENSIONS__)
61         CC="$CC -D__EXTENSIONS__"
62       ;;
63     esac
64   fi
65
66   OBJCC="$CC"
67
68   AC_MSG_CHECKING([whether the compiler works on ANSI C])
69   AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
70      AC_MSG_RESULT(yes),
71      AC_MSG_RESULT(no)
72      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
73      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.))
74
75   if test -n "$GCC"; then
76     AC_MSG_RESULT(Turning on gcc compiler warnings.)
77     CC="$CC -pedantic -Wall -Wstrict-prototypes -Wnested-externs"
78     OBJCC="$OBJCC -Wall"
79     # supposedly gcc 3.4 will have "-Wdeclaration-after-statement"
80     # and then perhaps we can do without -pedantic?
81   else
82     case "$host" in
83       *-irix5* |*-irix6.[0-3]* )
84         AC_MSG_RESULT(Turning on SGI compiler warnings.)
85         CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
86       ;;
87 #     *-dec-osf* )
88 #       if test -z "$GCC"; then
89 #         AC_MSG_RESULT(Turning on DEC C compiler warnings.)
90 #         CC="$CC -migrate -w0 -verbose -warnprotos"
91 #       fi
92 #     ;;
93     esac
94   fi
95 ])
96
97
98 ###############################################################################
99 #
100 #       Functions to figure out how to disable // comments in ANSI C code.
101 #
102 #       (With recent gcc, this is done with "-std=c89".  With older gcc, this
103 #       is done by passing "-lang-c89" to cpp, by passing "-Wp,-lang-c89" to
104 #       gcc.  Old gcc doesn't support -std, and new gcc doesn't support -lang.
105 #       so much for compatibility!)
106 #
107 #       UPDATE: apparently there is NO WAY to tell gcc 3.2.2 to require that
108 #       declarations preceed statements, without resorting to "-pedantic".
109 #       This means that there is no way to get gcc3 to issue warnings that
110 #       ensure that your code complies with the ANSI/ISO C89 standard, without
111 #       also drowning in totally useless warnings.  Thank you master may I
112 #       have another.
113 #
114 #       So, I give up, let's just use -pedantic.
115 #
116 ###############################################################################
117
118 AC_DEFUN(AC_GCC_ACCEPTS_STD,
119  [if test -n "$GCC"; then
120    AC_CACHE_CHECK([whether gcc accepts -std],
121      ac_cv_gcc_accepts_std,
122     [if ( ( gcc -E -std=c89 - </dev/null >/dev/null ) 2>&1 | \
123           grep unrecognized >/dev/null ); then
124        ac_cv_gcc_accepts_std=no
125      else
126        ac_cv_gcc_accepts_std=yes
127      fi])
128    ac_gcc_accepts_std="$ac_cv_gcc_accepts_std"
129   fi
130 ])
131
132 AC_DEFUN(AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE,
133  [if test -n "$GCC"; then
134    AC_GCC_ACCEPTS_STD
135    AC_MSG_RESULT(Disabling C++ comments in ANSI C code.)
136    #
137    # The reason that // comments are banned from xscreensaver is that gcc is
138    # basically the only compiler in the world that supports them in C code.
139    # All other vendors support them only in their C++ compilers, not in their
140    # ANSI C compilers.  This means that it's a portability problem: every time
141    # these comments have snuck into the xscreensaver source code, I've gotten
142    # complaints about it the next day.  So we turn off support for them in gcc
143    # as well to prevent them from accidentially slipping in.
144    #
145    if test "$ac_gcc_accepts_std" = yes ; then
146      #
147      # -std=c89 defines __STRICT_ANSI__, which we don't want.
148      # (That appears to be the only additional preprocessor symbol
149      # it defines, in addition to the syntax changes it makes.)
150      #
151      # -std=gnu89 is no good, because // comments were a GNU extension
152      # before they were in the ANSI C 99 spec...  (gcc 2.96 permits //
153      # with -std=gnu89 but not with -std=c89.)
154      #
155      CC="$CC -std=c89 -U__STRICT_ANSI__"
156    else
157      # The old way:
158      CC="$CC -Wp,-lang-c89"
159    fi
160   fi
161 ])
162
163
164 ###############################################################################
165 #
166 #       Function to figure out how to turn off Objective C on MacOS X.
167 #       (We have to do this to work around an Apple-specific gcc bug.)
168 #
169 ###############################################################################
170
171 AC_DEFUN(AC_GCC_ACCEPTS_NO_CPP_PRECOMP,
172  [if test -n "$GCC"; then
173    AC_CACHE_CHECK([whether gcc accepts -no-cpp-precomp],
174      ac_cv_gcc_accepts_no_cpp_precomp,
175     [if ( ( gcc -E -no-cpp-precomp - </dev/null >/dev/null ) 2>&1 | \
176           grep unrecognized >/dev/null ); then
177        ac_cv_gcc_accepts_no_cpp_precomp=no
178      else
179        ac_cv_gcc_accepts_no_cpp_precomp=yes
180      fi])
181    ac_gcc_accepts_no_cpp_precomp="$ac_cv_gcc_accepts_no_cpp_precomp"
182   fi
183 ])
184
185 AC_DEFUN(AC_NO_OBJECTIVE_C,
186  [if test -n "$GCC"; then
187    AC_GCC_ACCEPTS_NO_CPP_PRECOMP
188    if test "$ac_gcc_accepts_no_cpp_precomp" = yes ; then
189      AC_MSG_RESULT(Disabling Objective C extensions in ANSI C code.)
190      CC="$CC -no-cpp-precomp"
191    fi
192   fi
193 ])
194
195
196 ###############################################################################
197 #
198 #       Function to figure out how to create directory trees.
199 #
200 ###############################################################################
201
202 AC_DEFUN(AC_PROG_INSTALL_DIRS,
203  [AC_CACHE_CHECK([whether "\${INSTALL} -d" creates intermediate directories],
204     ac_cv_install_d_creates_dirs,
205     [ac_cv_install_d_creates_dirs=no
206      rm -rf conftestdir
207      if mkdir conftestdir; then
208        cd conftestdir 2>/dev/null
209        ${INSTALL} -d `pwd`/dir1/dir2 >/dev/null 2>&1
210        if test -d dir1/dir2/. ; then
211          ac_cv_install_d_creates_dirs=yes
212        fi
213        cd .. 2>/dev/null
214        rm -rf conftestdir
215      fi
216     ])
217
218   if test "$ac_cv_install_d_creates_dirs" = no ; then
219     AC_CACHE_CHECK([whether "mkdir -p" creates intermediate directories],
220       ac_cv_mkdir_p_creates_dirs,
221       [ac_cv_mkdir_p_creates_dirs=no
222        rm -rf conftestdir
223        if mkdir conftestdir; then
224          cd conftestdir 2>/dev/null
225          mkdir -p dir1/dir2 >/dev/null 2>&1
226          if test -d dir1/dir2/. ; then
227            ac_cv_mkdir_p_creates_dirs=yes
228          fi
229          cd .. 2>/dev/null
230          rm -rf conftestdir
231        fi
232       ])
233   fi
234
235   if test "$ac_cv_install_d_creates_dirs" = yes ; then
236     INSTALL_DIRS='${INSTALL} -d'
237   elif test "$ac_cv_mkdir_p_creates_dirs" = yes ; then
238     INSTALL_DIRS='mkdir -p'
239   else
240     # any other ideas?
241     INSTALL_DIRS='${INSTALL} -d'
242   fi
243 ])
244
245
246 ###############################################################################
247 #
248 #       Function to check whether gettimeofday() exists, and how to call it.
249 #       This may define HAVE_GETTIMEOFDAY and GETTIMEOFDAY_TWO_ARGS.
250 #
251 ###############################################################################
252
253 AC_DEFUN(AC_GETTIMEOFDAY_ARGS,
254  [AC_MSG_CHECKING(how to call gettimeofday)
255   AC_CACHE_VAL(ac_cv_gettimeofday_args,
256    [AC_TRY_COMPILE([#include <stdlib.h>
257                     #include <sys/time.h>],
258                    [struct timeval tv; struct timezone tzp;
259                     gettimeofday(&tv, &tzp);],
260                    [ac_gettimeofday_args=2],
261                    [AC_TRY_COMPILE([#include <stdlib.h>
262                                     #include <sys/time.h>],
263                                    [struct timeval tv; gettimeofday(&tv);],
264                                    [ac_gettimeofday_args=1],
265                                    [ac_gettimeofday_args=0])])
266     ac_cv_gettimeofday_args=$ac_gettimeofday_args])
267   ac_gettimeofday_args=$ac_cv_gettimeofday_args
268   if test "$ac_gettimeofday_args" = 1 ; then
269     AC_DEFINE(HAVE_GETTIMEOFDAY)
270     AC_MSG_RESULT(one argument)
271   elif test "$ac_gettimeofday_args" = 2 ; then
272     AC_DEFINE(HAVE_GETTIMEOFDAY)
273     AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
274     AC_MSG_RESULT(two arguments)
275   else
276     AC_MSG_RESULT(unknown)
277   fi
278 ])
279
280
281 ###############################################################################
282 #
283 #       Function to find perl5 (defines PERL and PERL_VERSION.)
284 #
285 ###############################################################################
286
287 # M4 sucks!!  perl sucks too!!
288 changequote(X,Y)
289 perl_version_cmd='print $]'
290 changequote([,])
291
292 AC_DEFUN(AC_PROG_PERL,
293  [AC_PATH_PROGS(PERL, [perl5 perl],,)
294   if test -z "$PERL" ; then
295     PERL_VERSION=0
296   else
297     AC_CACHE_CHECK([perl version], ac_cv_perl_version,
298                    [ac_cv_perl_version=`$PERL -e "$perl_version_cmd"`])
299     PERL_VERSION=$ac_cv_perl_version
300   fi
301  ])
302
303
304 ###############################################################################
305 #
306 #       Function to demand "bc".  Losers.
307 #
308 ###############################################################################
309
310 AC_DEFUN(AC_DEMAND_BC,
311  [ac_bc_result=`echo 6+9 | bc 2>/dev/null`
312   AC_MSG_CHECKING([for bc])
313   if test "$ac_bc_result" = "15" ; then
314     AC_MSG_RESULT(yes)
315   else
316     AC_MSG_RESULT(no)
317     echo ''
318     AC_MSG_ERROR([Your system doesn't have \"bc\", which has been a standard
319                   part of Unix since the 1970s.  Come back when your vendor
320                   has grown a clue.])
321   fi
322  ])
323
324 ###############################################################################
325 #
326 #       Functions to check how to do ICMP PING requests.
327 #
328 ###############################################################################
329
330 AC_DEFUN(AC_CHECK_ICMP,
331  [AC_CACHE_CHECK([for struct icmp], ac_cv_have_icmp,
332   [AC_TRY_COMPILE([#include <stdlib.h>
333                    #include <stdio.h>
334                    #include <math.h>
335                    #include <unistd.h>
336                    #include <limits.h>
337                    #include <signal.h>
338                    #include <fcntl.h>
339                    #include <sys/types.h>
340                    #include <sys/time.h>
341                    #include <sys/ipc.h>
342                    #include <sys/shm.h>
343                    #include <sys/socket.h>
344                    #include <netinet/in_systm.h>
345                    #include <netinet/in.h>
346                    #include <netinet/ip.h>
347                    #include <netinet/ip_icmp.h>
348                    #include <netinet/udp.h>
349                    #include <arpa/inet.h>
350                    #include <netdb.h>],
351                   [struct icmp i;
352                    struct sockaddr s;
353                    struct sockaddr_in si;
354                    struct ip ip;
355                    i.icmp_type = ICMP_ECHO;
356                    i.icmp_code = 0;
357                    i.icmp_cksum = 0;
358                    i.icmp_id = 0;
359                    i.icmp_seq = 0;
360                    si.sin_family = AF_INET;
361                    #if defined(__DECC) || defined(_IP_VHL)
362                    ip.ip_vhl = 0;
363                    #else
364                    ip.ip_hl = 0;
365                    #endif
366                    ],
367                   [ac_cv_have_icmp=yes],
368                   [ac_cv_have_icmp=no])])
369  if test "$ac_cv_have_icmp" = yes ; then
370    AC_DEFINE(HAVE_ICMP)
371  fi])
372
373 AC_DEFUN(AC_CHECK_ICMPHDR,
374  [AC_CACHE_CHECK([for struct icmphdr], ac_cv_have_icmphdr,
375   [AC_TRY_COMPILE([#include <stdlib.h>
376                    #include <stdio.h>
377                    #include <math.h>
378                    #include <unistd.h>
379                    #include <limits.h>
380                    #include <signal.h>
381                    #include <fcntl.h>
382                    #include <sys/types.h>
383                    #include <sys/time.h>
384                    #include <sys/ipc.h>
385                    #include <sys/shm.h>
386                    #include <sys/socket.h>
387                    #include <netinet/in_systm.h>
388                    #include <netinet/in.h>
389                    #include <netinet/ip.h>
390                    #include <netinet/ip_icmp.h>
391                    #include <netinet/udp.h>
392                    #include <arpa/inet.h>
393                    #include <netdb.h>],
394                   [struct icmphdr i;
395                    struct sockaddr s;
396                    struct sockaddr_in si;
397                    struct ip ip;
398                    i.type = ICMP_ECHO;
399                    i.code = 0;
400                    i.checksum = 0;
401                    i.un.echo.id = 0;
402                    i.un.echo.sequence = 0;
403                    si.sin_family = AF_INET;
404                    ip.ip_hl = 0;],
405                   [ac_cv_have_icmphdr=yes],
406                   [ac_cv_have_icmphdr=no])])
407  if test "$ac_cv_have_icmphdr" = yes ; then
408    AC_DEFINE(HAVE_ICMPHDR)
409  fi])
410
411
412 ###############################################################################
413 #
414 #       Functions to check for various X11 crap.
415 #
416 ###############################################################################
417
418 # Try and find the app-defaults directory.
419 # It sucks that autoconf doesn't do this already...
420 #
421 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_XMKMF,[
422   rm -fr conftestdir
423   if mkdir conftestdir; then
424     cd conftestdir 2>/dev/null
425     # Make sure to not put "make" in the Imakefile rules, since we grep it out.
426     cat > Imakefile <<'EOF'
427 acfindx:
428         @echo 'ac_x_app_defaults="${XAPPLOADDIR}"'
429 EOF
430     if (xmkmf) >/dev/null 2>&1 && test -f Makefile; then
431       # GNU make sometimes prints "make[1]: Entering...", which'd confuse us.
432       eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
433     fi
434     cd .. 2>/dev/null
435     rm -fr conftestdir
436   fi])
437
438 AC_DEFUN(AC_PATH_X_APP_DEFAULTS_DIRECT,[
439   # Look for the directory under a standard set of common directories.
440   # Check X11 before X11Rn because it's often a symlink to the current release.
441   for ac_dir in                                 \
442     /usr/X11/lib/app-defaults                   \
443     /usr/X11R6/lib/app-defaults                 \
444     /usr/X11R6/lib/X11/app-defaults             \
445     /usr/X11R5/lib/app-defaults                 \
446     /usr/X11R5/lib/X11/app-defaults             \
447     /usr/X11R4/lib/app-defaults                 \
448     /usr/X11R4/lib/X11/app-defaults             \
449                                                 \
450     /usr/lib/X11/app-defaults                   \
451     /usr/lib/X11R6/app-defaults                 \
452     /usr/lib/X11R5/app-defaults                 \
453     /usr/lib/X11R4/app-defaults                 \
454                                                 \
455     /usr/local/X11/lib/app-defaults             \
456     /usr/local/X11R6/lib/app-defaults           \
457     /usr/local/X11R5/lib/app-defaults           \
458     /usr/local/X11R4/lib/app-defaults           \
459                                                 \
460     /usr/local/lib/X11/app-defaults             \
461     /usr/local/lib/X11R6/app-defaults           \
462     /usr/local/lib/X11R6/X11/app-defaults       \
463     /usr/local/lib/X11R5/app-defaults           \
464     /usr/local/lib/X11R5/X11/app-defaults       \
465     /usr/local/lib/X11R4/app-defaults           \
466     /usr/local/lib/X11R4/X11/app-defaults       \
467                                                 \
468     /usr/X386/lib/X11/app-defaults              \
469     /usr/x386/lib/X11/app-defaults              \
470     /usr/XFree86/lib/X11/app-defaults           \
471                                                 \
472     /usr/lib/X11/app-defaults                   \
473     /usr/local/lib/X11/app-defaults             \
474     /usr/unsupported/lib/X11/app-defaults       \
475     /usr/athena/lib/X11/app-defaults            \
476     /usr/local/x11r5/lib/X11/app-defaults       \
477     /usr/lpp/Xamples/lib/X11/app-defaults       \
478     /lib/usr/lib/X11/app-defaults               \
479                                                 \
480     /usr/openwin/lib/app-defaults               \
481     /usr/openwin/lib/X11/app-defaults           \
482     /usr/openwin/share/lib/app-defaults         \
483     /usr/openwin/share/lib/X11/app-defaults     \
484                                                 \
485     /X11R6/lib/app-defaults                     \
486     /X11R5/lib/app-defaults                     \
487     /X11R4/lib/app-defaults                     \
488     ; \
489   do
490     if test -d "$ac_dir"; then
491       ac_x_app_defaults=$ac_dir
492       break
493     fi
494   done
495 ])
496
497 AC_DEFUN(AC_PATH_X_APP_DEFAULTS,
498   [AC_REQUIRE_CPP()
499     AC_CACHE_CHECK([for X app-defaults directory], ac_cv_x_app_defaults,
500      [AC_PATH_X_APP_DEFAULTS_XMKMF
501       if test x"$ac_x_app_defaults" = x; then
502         AC_PATH_X_APP_DEFAULTS_DIRECT
503       fi
504       if test x"$ac_x_app_defaults" = x; then
505         ac_cv_x_app_defaults="/usr/lib/X11/app-defaults"
506       else
507         # Record where we found app-defaults for the cache.
508         ac_cv_x_app_defaults="$ac_x_app_defaults"
509       fi])
510     eval ac_x_app_defaults="$ac_cv_x_app_defaults"])
511
512
513 AC_DEFUN(AC_XPOINTER,
514  [AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
515                  [AC_TRY_X_COMPILE([#include <X11/Xlib.h>],
516                                    [XPointer foo = (XPointer) 0;],
517                                    [ac_cv_xpointer=yes],
518                                    [ac_cv_xpointer=no])])
519   if test "$ac_cv_xpointer" != yes; then
520    AC_DEFINE(XPointer,[char*])
521   fi])
522
523
524 # Random special-cases for X on certain pathological OSes.
525 # You know who you are.
526 #
527 AC_DEFUN(AC_X_RANDOM_PATHS,
528  [case "$host" in
529     *-hpux*)
530
531       # The following arcana was gleaned from conversations with
532       # Eric Schwartz <erics@col.hp.com>:
533       #
534       # On HPUX 10.x, the parts of X that HP considers "standard" live in
535       # /usr/{include,lib}/X11R6/.  The parts that HP doesn't consider
536       # "standard", notably, Xaw and Xmu, live in /usr/contrib/X11R6/.
537       # Yet /usr/contrib/X11R6/ comes preinstalled on all HPUX systems.
538       # Also, there are symlinks from /usr/include/ and /usr/lib/ into
539       # /usr/{include,lib}/X11R6/, so that (if you don't use Xmu at all)
540       # you don't need any -I or -L arguments.
541       #
542       # On HPUX 9.x, /usr/{include,lib}/X11R5/ and /usr/contrib/X11R5/
543       # are the same division as 10.x.  However, there are no symlinks to
544       # the X stuff from /usr/include/ and /usr/lib/, so -I and -L
545       # arguments are always necessary.
546       #
547       # However, X11R6 was available on HPUX 9.x as a patch: if that
548       # patch was installed, then all of X11R6 went in to
549       # /usr/contrib/X11R6/ (there was no /usr/{include,lib}/X11R6/.)
550       #
551       # HPUX 8.x was the same as 9.x, but was X11R4 instead (I don't know
552       # whether R5 was available as a patch; R6 undoubtedly was not.)
553       #
554       # So.  We try and use the highest numbered pair of
555       # /usr/{include,lib}/X11R?/ and /usr/contrib/X11R?/{include,lib}/
556       # that are available.  We do not mix and match different versions
557       # of X.
558       #
559       # Question I still don't know the answer to: (do you?)
560       #
561       #   * On HPUX 9.x, where /usr/include/X11R5/ was standard, and
562       #     /usr/contrib/X11R6/ could be installed as a patch, what was in
563       #     that contrib directory?  Did it contain so-called "standard"
564       #     X11R6, or did it include Xaw and Xmu as well?  If the former,
565       #     where did one find Xaw and Xmu on 9.x R6 systems?  Would this
566       #     be a situation where one had to reach into the R5 headers and
567       #     libs to find Xmu?  That is, must both R6 and R5 directories
568       #     be on the -I and -L lists in that case?
569       #
570       for version in X11R6 X11R5 X11R4 ; do
571         # if either pair of directories exists...
572         if test -d /usr/include/$version || test -d /usr/contrib/$version/include
573         then
574            # if contrib exists, use it...
575            if test -d /usr/contrib/$version/include ; then
576              X_CFLAGS="$X_CFLAGS -I/usr/contrib/$version/include"
577              X_LIBS="$X_LIBS -L/usr/contrib/$version/lib"
578            fi
579            # if the "standard" one exists, use it.
580            if test -d /usr/include/$version ; then
581              X_CFLAGS="$X_CFLAGS -I/usr/include/$version"
582              X_LIBS="$X_LIBS -L/usr/lib/$version"
583            fi
584            # since at least one of the pair exists, go no farther.
585            break
586         fi
587       done
588
589       # Now find Motif.  Thanks for not making xmkmf find this by
590       # default, you losers.
591       #
592       if test -d /usr/include/Motif2.1 ; then
593         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif2.1"
594         X_LIBS="$X_LIBS -L/usr/lib/Motif2.1"
595       elif test -d /usr/include/Motif1.2 ; then
596         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.2"
597         X_LIBS="$X_LIBS -L/usr/lib/Motif1.2"
598       elif test -d /usr/include/Motif1.1 ; then
599         X_CFLAGS="$X_CFLAGS -I/usr/include/Motif1.1"
600         X_LIBS="$X_LIBS -L/usr/lib/Motif1.1"
601       fi
602
603       # Now let's check for the pseudo-standard locations for OpenGL and XPM.
604       #
605       if test -d /opt/graphics/OpenGL/include ; then
606         # HP-UX 10.20 puts it here
607         X_CFLAGS="-I/opt/graphics/OpenGL/include $X_CFLAGS"
608         X_LIBS="-L/opt/graphics/OpenGL/lib $X_LIBS"
609       elif test -d /opt/Mesa/lib ; then
610         X_CFLAGS="-I/opt/Mesa/include $X_CFLAGS"
611         X_LIBS="-L/opt/Mesa/lib $X_LIBS"
612       fi
613
614
615       if test -d /opt/xpm/lib/X11 ; then
616         X_CFLAGS="-I/opt/xpm/include $X_CFLAGS"
617         X_LIBS="-L/opt/xpm/lib/X11 $X_LIBS"
618       fi
619
620       # On HPUX, default to installing in /opt/xscreensaver/ instead of
621       # in /usr/local/, unless there is already an xscreensaver in
622       # /usr/local/bin/.  This can be overridden with the --prefix arg
623       # to configure.  I'm not sure this is the right thing to do, but
624       # Richard Lloyd says so...
625       #
626       if test \! -x /usr/local/bin/xscreensaver ; then
627         ac_default_prefix=/opt/xscreensaver
628       fi
629
630     ;;
631     *-solaris*)
632
633       # Thanks for not making xmkmf find this by default, pinheads.
634       # And thanks for moving things around again, too.  Is this
635       # really the standard location now?  What happened to the
636       # joke that this kind of thing went in /opt?
637       # cthomp says "answer: CDE (Common Disorganized Environment)"
638       #
639       if test -f /usr/dt/include/Xm/Xm.h ; then
640         X_CFLAGS="$X_CFLAGS -I/usr/dt/include"
641         MOTIF_LIBS="$MOTIF_LIBS -L/usr/dt/lib -R/usr/dt/lib"
642
643         # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
644         AC_CHECK_LIB(gen, regcmp, [MOTIF_LIBS="$MOTIF_LIBS -lgen"])
645       fi
646
647     ;;
648     *-darwin*)
649
650       # On MacOS X (10.x with "fink"), many things are under /sw/.
651       #
652       if test -d /sw/include ; then
653         X_CFLAGS="-I/sw/include $X_CFLAGS"
654         X_LIBS="-L/sw/lib $X_LIBS"
655       fi
656     ;;
657   esac])
658
659
660
661 ###############################################################################
662 #
663 #       Some utility functions to make checking for X things easier.
664 #
665 ###############################################################################
666
667 # Like AC_CHECK_HEADER, but it uses the already-computed -I directories.
668 #
669 AC_DEFUN(AC_CHECK_X_HEADER, [
670   ac_save_CPPFLAGS="$CPPFLAGS"
671   if test \! -z "$includedir" ; then 
672     CPPFLAGS="$CPPFLAGS -I$includedir"
673   fi
674   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
675   AC_CHECK_HEADER([$1],[$2],[$3],[$4])
676   CPPFLAGS="$ac_save_CPPFLAGS"])
677
678 # Like AC_EGREP_HEADER, but it uses the already-computed -I directories.
679 #
680 AC_DEFUN(AC_EGREP_X_HEADER, [
681   ac_save_CPPFLAGS="$CPPFLAGS"
682   if test \! -z "$includedir" ; then 
683     CPPFLAGS="$CPPFLAGS -I$includedir"
684   fi
685   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
686   AC_EGREP_HEADER([$1], [$2], [$3], [$4])
687   CPPFLAGS="$ac_save_CPPFLAGS"])
688
689 # Like AC_TRY_COMPILE, but it uses the already-computed -I directories.
690 #
691 AC_DEFUN(AC_TRY_X_COMPILE, [
692   ac_save_CPPFLAGS="$CPPFLAGS"
693   if test \! -z "$includedir" ; then 
694     CPPFLAGS="$CPPFLAGS -I$includedir"
695   fi
696   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
697   AC_TRY_COMPILE([$1], [$2], [$3], [$4])
698   CPPFLAGS="$ac_save_CPPFLAGS"])
699
700
701 # Like AC_CHECK_LIB, but it uses the already-computed -I and -L directories.
702 # Use this sparingly; it probably doesn't work very well on X programs.
703 #
704 AC_DEFUN(AC_CHECK_X_LIB, [
705   ac_save_CPPFLAGS="$CPPFLAGS"
706   ac_save_LDFLAGS="$LDFLAGS"
707 #  ac_save_LIBS="$LIBS"
708
709   if test \! -z "$includedir" ; then 
710     CPPFLAGS="$CPPFLAGS -I$includedir"
711   fi
712   # note: $X_CFLAGS includes $x_includes
713   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
714
715   if test \! -z "$libdir" ; then
716     LDFLAGS="$LDFLAGS -L$libdir"
717   fi
718   # note: $X_LIBS includes $x_libraries
719   LDFLAGS="$LDFLAGS $X_LIBS $X_EXTRA_LIBS"
720
721   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
722   CPPFLAGS="$ac_save_CPPFLAGS"
723   LDFLAGS="$ac_save_LDFLAGS"
724 #  LIBS="$ac_save_LIBS"
725   ])
726
727 # Like AC_TRY_RUN, but it uses the already-computed -I directories.
728 # (But not the -L directories!)
729 #
730 AC_DEFUN(AC_TRY_X_RUN, [
731   ac_save_CPPFLAGS="$CPPFLAGS"
732   if test \! -z "$includedir" ; then 
733     CPPFLAGS="$CPPFLAGS -I$includedir"
734   fi
735   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
736   AC_TRY_RUN([$1], [$2], [$3], [$4])
737   CPPFLAGS="$ac_save_CPPFLAGS"])
738
739
740
741 # Usage: HANDLE_X_PATH_ARG([variable_name],
742 #                          [--command-line-option],
743 #                          [descriptive string])
744 #
745 # All of the --with options take three forms:
746 #
747 #   --with-foo (or --with-foo=yes)
748 #   --without-foo (or --with-foo=no)
749 #   --with-foo=/DIR
750 #
751 # This function, HANDLE_X_PATH_ARG, deals with the /DIR case.  When it sees
752 # a directory (string beginning with a slash) it checks to see whether
753 # /DIR/include and /DIR/lib exist, and adds them to $X_CFLAGS and $X_LIBS
754 # as appropriate.
755 #
756 AC_DEFUN(HANDLE_X_PATH_ARG, [
757    case "$[$1]" in
758     yes) ;;
759     no)  ;;
760
761     /*)
762      AC_MSG_CHECKING([for [$3] headers])
763      d=$[$1]/include
764      if test -d $d; then
765        X_CFLAGS="-I$d $X_CFLAGS"
766        AC_MSG_RESULT($d)
767      else
768        AC_MSG_RESULT(not found ($d: no such directory))
769      fi
770
771      AC_MSG_CHECKING([for [$3] libs])
772      d=$[$1]/lib
773      if test -d $d; then
774        X_LIBS="-L$d $X_LIBS"
775        AC_MSG_RESULT($d)
776      else
777        AC_MSG_RESULT(not found ($d: no such directory))
778      fi
779
780      # replace the directory string with "yes".
781      [$1]_req="yes"
782      [$1]=$[$1]_req
783      ;;
784
785     *)
786      echo ""
787      echo "error: argument to [$2] must be \"yes\", \"no\", or a directory."
788      echo "       If it is a directory, then \`DIR/include' will be added to"
789      echo "       the -I list, and \`DIR/lib' will be added to the -L list."
790      exit 1
791      ;;
792    esac
793   ])
794
795
796
797 ###############################################################################
798 ###############################################################################
799 #
800 #       End of function definitions.  Now start actually executing stuff.
801 #
802 ###############################################################################
803 ###############################################################################
804
805 # random compiler setup
806 AC_CANONICAL_HOST
807 AC_PROG_CC_ANSI
808 AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE
809 AC_NO_OBJECTIVE_C
810 AC_PROG_CPP
811 AC_C_CONST
812 AC_C_INLINE
813 AC_EXEEXT
814 AC_DEMAND_BC
815
816 # stuff for Makefiles
817 AC_PROG_INSTALL
818 AC_PROG_INSTALL_DIRS
819 AC_PROG_MAKE_SET
820
821 # By default, autoconf sets INSTALL_SCRIPT to '${INSTALL_PROGRAM}'.
822 # That's wrong: it should be set to '${INSTALL}', so that one can
823 # implement the "install-strip" target properly (strip executables,
824 # but do not try to strip scripts.)
825 #
826 INSTALL_SCRIPT='${INSTALL}'
827
828 # random libc stuff
829 AC_HEADER_STDC
830 AC_CHECK_HEADERS(unistd.h)
831 AC_TYPE_MODE_T
832 AC_TYPE_PID_T
833 AC_TYPE_SIZE_T
834 AC_TYPE_SIGNAL
835 AC_HEADER_TIME
836 AC_HEADER_SYS_WAIT
837 AC_HEADER_DIRENT
838 AC_GETTIMEOFDAY_ARGS
839 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv sbrk)
840 AC_CHECK_FUNCS(sigaction syslog realpath setrlimit)
841 AC_CHECK_ICMP
842 AC_CHECK_ICMPHDR
843 AC_CHECK_HEADERS(crypt.h sys/select.h)
844 AC_PROG_PERL
845
846 if test -z "$PERL" ; then
847   # don't let it be blank...
848   PERL=/usr/bin/perl
849 fi
850
851 AC_PATH_XTRA
852
853 if test "$have_x" != yes; then
854   AC_MSG_ERROR(Couldn't find X11 headers/libs.  Try `$0 --help'.)
855 fi
856
857 AC_PATH_X_APP_DEFAULTS
858 AC_X_RANDOM_PATHS
859 AC_XPOINTER
860
861 AC_MSG_CHECKING(whether this is MacOS X)
862   ac_macosx=no
863   case "$host" in
864     *-apple-darwin* )
865       ac_macosx=yes
866     ;;
867   esac
868 AC_MSG_RESULT($ac_macosx)
869
870
871
872 ###############################################################################
873 #
874 #       Gettext support
875 #
876 ###############################################################################
877
878 AC_PROG_INTLTOOL
879 GETTEXT_PACKAGE=xscreensaver
880 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE")
881 AC_DEFINE_UNQUOTED(PACKAGE, "$GETTEXT_PACKAGE")
882 AC_SUBST(GETTEXT_PACKAGE)
883
884 ALL_LINGUAS="ca da de es et fi fr hu it ja ko nl no pl pt pt_BR ru sk sv vi wa zh_CN zh_TW"
885 AM_GLIB_GNU_GETTEXT
886 MKINSTALLDIRS="$INSTALL_DIRS"
887
888
889 ###############################################################################
890 #
891 #       Check for -lXmu (some fucked up vendors don't ship it...)
892 #
893 ###############################################################################
894
895 have_xmu=no
896 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes],,
897                   [#include <stdlib.h>
898                    #include <stdio.h>
899                    #include <X11/Intrinsic.h>])
900 if test "$have_xmu" = no ; then
901   XMU_SRCS='$(UTILS_SRC)/xmu.c'
902   XMU_OBJS='$(UTILS_BIN)/xmu.o'
903   XMU_LIBS=''
904 else
905   XMU_SRCS=''
906   XMU_OBJS=''
907   XMU_LIBS='-lXmu'
908   AC_DEFINE(HAVE_XMU)
909 fi
910
911
912 ###############################################################################
913 #
914 #       Check for the SunOS 4.1.x _get_wmShellWidgetClass bug.
915 #       See comp.windows.x FAQ question 124.  The right fix is to
916 #       get OpenWindows 3.0 patches 100512-02 and 100573-03.
917 #
918 ###############################################################################
919
920 if test "$have_xmu" = yes ; then
921   case "$host" in
922     *-sunos4*)
923     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
924                    ac_cv_sunos_xmu_bug,
925                    [ac_save_LDFLAGS="$LDFLAGS"
926                     if test \! -z "$x_libraries" ; then
927                       LDFLAGS="$LDFLAGS -L$x_libraries"
928                     fi
929                     # Note: this trick never works!  (Generally.)
930                     # We're only getting away with using AC_TRY_LINK
931                     # with X libraries because we know it's SunOS.
932                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
933                     AC_TRY_LINK(,,
934                                 [ac_cv_sunos_xmu_bug=no],
935                                 [ac_cv_sunos_xmu_bug=yes])
936                     LDFLAGS="$ac_save_LDFLAGS"])
937     if test "$ac_cv_sunos_xmu_bug" = yes ; then
938       AC_CACHE_CHECK([whether the compiler understands -static], 
939                      ac_cv_ld_static,
940                      [ac_save_LDFLAGS="$LDFLAGS"
941                       LDFLAGS="$LDFLAGS -static"
942                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
943                     LDFLAGS="$ac_save_LDFLAGS"])
944       if test "$ac_cv_ld_static" = yes ; then
945         LDFLAGS="$LDFLAGS -static"
946       else
947         LDFLAGS="$LDFLAGS -Bstatic"
948       fi
949     fi
950     ;;
951   esac
952 fi
953
954
955 ###############################################################################
956 #
957 #       Handle the --with-hackdir option
958 #
959 ###############################################################################
960
961 have_hackdir=yes
962 with_hackdir_req=unspecified
963 AC_ARG_WITH(hackdir,[
964 Installation options:
965
966   --with-hackdir=DIR      Where to install the hundreds of demo executables.
967                           Default: `PREFIX/lib/xscreensaver/'],
968   [with_hackdir="$withval"; with_hackdir_req="$withval"],[with_hackdir=yes])
969
970 if test x"$with_hackdir" = xyes; then
971   HACKDIR='${exec_prefix}/lib/xscreensaver'
972 elif test x"$with_hackdir" = xno; then
973   HACKDIR='${bindir}'
974 else
975   # there must be a better way than this...
976   if test -z "`echo $with_hackdir | sed 's@^/.*@@'`" ; then
977     # absolute path
978     HACKDIR=$with_hackdir
979   else
980     # relative path
981     HACKDIR="\${exec_prefix}$with_hackdir"
982   fi
983 fi
984
985 # canonicalize slashes.
986 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
987
988 # This option used to be called --enable-subdir; make sure that is no longer
989 # used, since configure brain-damagedly ignores unknown --enable options.
990
991 obsolete_enable=
992 AC_ARG_ENABLE(subdir,,[obsolete_enable=yes])
993 if test -n "$obsolete_enable"; then
994   echo "error: the --enable-subdir option has been replaced with"
995   echo "       the new --with-hackdir option; see \`configure --help'"
996   echo "       for more information."
997   exit 1
998 fi
999
1000
1001 ###############################################################################
1002 #
1003 #       Handle the --with-configdir option
1004 #
1005 ###############################################################################
1006
1007 have_configdir=yes
1008 with_configdir_req=unspecified
1009 AC_ARG_WITH(configdir,
1010 [  --with-configdir=DIR    Where to install the data files that describe each
1011                           of the display modes to the GUI.
1012                           Default: `GTK_PREFIX/control-center/screensavers/'
1013                           or `PREFIX/lib/xscreensaver/config/', depending on
1014                           whether GTK is available.
1015 ],
1016   [with_configdir="$withval"; with_configdir_req="$withval"],
1017   [with_configdir=yes])
1018
1019 if test x"$with_configdir" = xyes; then
1020   # filled in later...
1021   HACK_CONF_DIR=''
1022 elif test x"$with_configdir" = xno; then
1023   echo "error: must be yes, or a pathname: --with-configdir=$with_configdir"
1024   exit 1
1025 else
1026   # there must be a better way than this...
1027   if test -z "`echo $with_configdir | sed 's@^/.*@@'`" ; then
1028     # absolute path
1029     HACK_CONF_DIR=$with_configdir
1030   else
1031     # relative path
1032     HACK_CONF_DIR="\${exec_prefix}$with_configdir"
1033   fi
1034 fi
1035
1036
1037
1038
1039 ###############################################################################
1040 #
1041 #       Check for the SGI SCREEN_SAVER server extension.
1042 #
1043 ###############################################################################
1044
1045 have_sgi=no
1046 with_sgi_req=unspecified
1047 AC_ARG_WITH(sgi-ext,
1048 [Except where noted, all of the --with options below can also take a
1049 directory argument: for example, `--with-motif=/opt/Motif'.  That would
1050 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
1051 to be added to the -L list, assuming those directories exist.  
1052
1053 By default, support for each of these options will be built in, if the
1054 relevant library routines exist.  At run time, they will then be used
1055 only if the X server being used supports them.  Each --with option has
1056 a corresponding --without option, to override building support for them
1057 at all.
1058
1059 Screen blanking and idle-detection options:
1060
1061   --with-sgi-ext          Include support for the SGI SCREEN_SAVER extension.],
1062   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
1063
1064 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
1065
1066 if test "$with_sgi" = yes; then
1067   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
1068                     [have_sgi=yes
1069                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)],,
1070                     [#include <X11/Xlib.h>])
1071
1072 elif test "$with_sgi" != no; then
1073   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
1074   exit 1
1075 fi
1076
1077
1078 ###############################################################################
1079 #
1080 #       Check for the MIT-SCREEN-SAVER server extension.
1081 #
1082 ###############################################################################
1083
1084 have_mit=no
1085 with_mit_req=unspecified
1086 AC_ARG_WITH(mit-ext,
1087 [  --with-mit-ext          Include support for the MIT-SCREEN-SAVER extension.],
1088   [with_mit="$withval"; with_mit_req="$withval"],[with_mit=yes])
1089
1090 HANDLE_X_PATH_ARG(with_mit, --with-mit-ext, MIT-SCREEN-SAVER)
1091
1092 if test "$with_mit" = yes; then
1093   AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes],,
1094                     [#include <X11/Xlib.h>])
1095
1096   # Now check to see if it's really in the library; XF86Free-3.3 ships
1097   # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
1098   #
1099   if test "$have_mit" = yes; then
1100     AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [true], [have_mit=no], -lm)
1101
1102     if test "$have_mit" = no; then
1103       # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
1104       # of in Xext.  Thank you master, may I have another.
1105       AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
1106                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXExExt"],
1107                      [true], -lX11 -lXext -lm)
1108     fi
1109
1110     if test "$have_mit" = no; then
1111       # Double fuck!  Looks like some versions of XFree86 (whichever version
1112       # it is that comes with RedHat Linux 2.0 -- I can't find a version 
1113       # number) put this garbage in Xss instead of Xext.  Thank you master,
1114       #  may I have another.
1115       AC_CHECK_X_LIB(Xss, XScreenSaverRegister,
1116                      [have_mit=yes; SAVER_LIBS="$SAVER_LIBS -lXss"],
1117                      [true], -lX11 -lXext -lm)
1118     fi
1119
1120   if test "$have_mit" = yes; then
1121     AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
1122   fi
1123
1124   fi
1125
1126 elif test "$with_mit" != no; then
1127   echo "error: must be yes or no: --with-mit-ext=$with_mit"
1128   exit 1
1129 fi
1130
1131
1132 ###############################################################################
1133 #
1134 #       Check for the XIDLE server extension.
1135 #
1136 ###############################################################################
1137
1138 have_xidle=no
1139 with_xidle_req=unspecified
1140 AC_ARG_WITH(xidle-ext,
1141 [  --with-xidle-ext        Include support for the XIDLE extension.],
1142   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
1143
1144 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
1145
1146 if test "$with_xidle" = yes; then
1147   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
1148                     [have_xidle=yes
1149                      AC_DEFINE(HAVE_XIDLE_EXTENSION)],,
1150                     [#include <X11/Xlib.h>])
1151 elif test "$with_xidle" != no; then
1152   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
1153   exit 1
1154 fi
1155
1156
1157 ###############################################################################
1158 #
1159 #       Check for the SGI-VIDEO-CONTROL server extension.
1160 #
1161 ###############################################################################
1162
1163 have_sgivc=no
1164 with_sgivc_req=unspecified
1165 AC_ARG_WITH(sgivc-ext,
1166 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension.],
1167   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
1168
1169 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
1170
1171 if test "$with_sgivc" = yes; then
1172
1173   # first check for XSGIvc.h
1174   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes],,
1175                     [#include <X11/Xlib.h>])
1176
1177   # if that succeeded, then check for the -lXsgivc
1178   if test "$have_sgivc" = yes; then
1179     have_sgivc=no
1180     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
1181                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [true],
1182                   -lXext -lX11)
1183   fi
1184
1185   # if that succeeded, then we've really got it.
1186   if test "$have_sgivc" = yes; then
1187     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
1188   fi
1189
1190 elif test "$with_sgivc" != no; then
1191   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
1192   exit 1
1193 fi
1194
1195
1196 ###############################################################################
1197 #
1198 #       Check for the DPMS server extension.
1199 #
1200 ###############################################################################
1201
1202 have_dpms=no
1203 with_dpms_req=unspecified
1204 AC_ARG_WITH(dpms-ext,
1205 [  --with-dpms-ext         Include support for the DPMS extension.],
1206   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
1207
1208 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
1209
1210 if test "$with_dpms" = yes; then
1211
1212   # first check for dpms.h
1213   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes],,
1214                     [#include <X11/Xlib.h>
1215                      #include <X11/Xmd.h>])
1216
1217   # if that succeeded, then check for the DPMS code in the libraries
1218   if test "$have_dpms" = yes; then
1219
1220     # first look in -lXext (this is where it is with XFree86 4.0)
1221     have_dpms=no
1222     AC_CHECK_X_LIB(Xext, DPMSInfo, [have_dpms=yes], [true], -lXext -lX11)
1223
1224     # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
1225     if test "$have_dpms" = no; then
1226       AC_CHECK_X_LIB(Xdpms, DPMSInfo,
1227                     [have_dpms=yes; XDPMS_LIBS="-lXdpms"], [true],
1228                     -lXext -lX11)
1229     fi
1230   fi
1231
1232
1233   # if that succeeded, then we've really got it.
1234   if test "$have_dpms" = yes; then
1235     AC_DEFINE(HAVE_DPMS_EXTENSION)
1236   fi
1237
1238 elif test "$with_dpms" != no; then
1239   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
1240   exit 1
1241 fi
1242
1243
1244 ###############################################################################
1245 #
1246 #       Check for the XINERAMA server extension.
1247 #
1248 ###############################################################################
1249
1250 have_xinerama=no
1251 with_xinerama_req=unspecified
1252 AC_ARG_WITH(xinerama-ext,
1253 [  --with-xinerama-ext     Include support for the XINERAMA extension.],
1254   [with_xinerama="$withval"; with_xinerama_req="$withval"],[with_xinerama=yes])
1255
1256 HANDLE_X_PATH_ARG(with_xinerama, --with-xinerama-ext, XINERAMA)
1257
1258 if test "$with_xinerama" = yes; then
1259
1260   # first check for Xinerama.h
1261   AC_CHECK_X_HEADER(X11/extensions/Xinerama.h, [have_xinerama=yes],,
1262                     [#include <X11/Xlib.h>])
1263
1264   # if that succeeded, then check for the XINERAMA code in the libraries
1265   if test "$have_xinerama" = yes; then
1266
1267     # first look in -lXext
1268     have_xinerama=no
1269     AC_CHECK_X_LIB(Xext, XineramaQueryScreens, [have_xinerama=yes], [true],
1270                   -lXext -lX11)
1271
1272     # if that failed, look in -lXinerama (this is where it is in XFree86 4.1.)
1273     if test "$have_xinerama" = no; then
1274       AC_CHECK_X_LIB(Xinerama, XineramaQueryScreens,
1275                      [have_xinerama=yes; SAVER_LIBS="$SAVER_LIBS -lXinerama"],
1276                      [true], -lXext -lX11)
1277     fi
1278   fi
1279
1280   # if that succeeded, then we've really got it.
1281   if test "$have_xinerama" = yes; then
1282     AC_DEFINE(HAVE_XINERAMA)
1283   fi
1284
1285 elif test "$with_xinerama" != no; then
1286   echo "error: must be yes or no: --with-xinerama-ext=$with_xinerama"
1287   exit 1
1288 fi
1289
1290
1291 ###############################################################################
1292 #
1293 #       Check for the XF86VMODE server extension (for virtual screens.)
1294 #
1295 ###############################################################################
1296
1297 have_xf86vmode=no
1298 with_xf86vmode_req=unspecified
1299 AC_ARG_WITH(xf86vmode-ext,
1300 [  --with-xf86vmode-ext    Include support for XFree86 virtual screens.],
1301   [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
1302   [with_xf86vmode=yes])
1303
1304 HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
1305
1306 VIDMODE_LIBS=""
1307
1308 if test "$with_xf86vmode" = yes; then
1309
1310   # first check for xf86vmode.h
1311   AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes],,
1312                     [#include <X11/Xlib.h>])
1313
1314   # if that succeeded, then check for the -lXxf86vm
1315   if test "$have_xf86vmode" = yes; then
1316     have_xf86vmode=no
1317     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
1318                   [have_xf86vmode=yes;
1319                    VIDMODE_LIBS="-lXxf86vm";
1320                    SAVER_LIBS="$SAVER_LIBS $VIDMODE_LIBS"],
1321                    [true], -lXext -lX11)
1322   fi
1323
1324   # if that succeeded, then we've really got it.
1325   if test "$have_xf86vmode" = yes; then
1326     AC_DEFINE(HAVE_XF86VMODE)
1327   fi
1328
1329 elif test "$with_xf86vmode" != no; then
1330   echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
1331   exit 1
1332 fi
1333
1334
1335 ###############################################################################
1336 #
1337 #       Check for the XF86VMODE server extension (for gamma fading.)
1338 #
1339 ###############################################################################
1340
1341 have_xf86gamma=no
1342 have_xf86gamma_ramp=no
1343 with_xf86gamma_req=unspecified
1344 AC_ARG_WITH(xf86gamma-ext,
1345 [  --with-xf86gamma-ext    Include support for XFree86 gamma fading.],
1346   [with_xf86gamma="$withval"; with_xf86gamma_req="$withval"],
1347   [with_xf86gamma=yes])
1348
1349 HANDLE_X_PATH_ARG(with_xf86gamma, --with-xf86gamma-ext, xf86gamma)
1350
1351 if test "$with_xf86gamma" = yes; then
1352
1353   # first check for xf86vmode.h, if we haven't already
1354   if test "$have_xf86vmode" = yes; then
1355     have_xf86gamma=yes
1356   else
1357     AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86gamma=yes],,
1358                       [#include <X11/Xlib.h>])
1359   fi
1360
1361   # if that succeeded, then check for the -lXxf86vm
1362   if test "$have_xf86gamma" = yes; then
1363     have_xf86gamma=no
1364     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGamma,
1365                   [have_xf86gamma=yes],
1366                    [true], -lXext -lX11)
1367   fi
1368
1369   # check for the Ramp versions of the functions too.
1370   if test "$have_xf86gamma" = yes; then
1371     have_xf86gamma_ramp=no
1372     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGammaRamp,
1373                   [have_xf86gamma_ramp=yes],
1374                    [true], -lXext -lX11)
1375   fi
1376
1377   # if those tests succeeded, then we've really got the functions.
1378   if test "$have_xf86gamma" = yes; then
1379     AC_DEFINE(HAVE_XF86VMODE_GAMMA)
1380   fi
1381
1382   if test "$have_xf86gamma_ramp" = yes; then
1383     AC_DEFINE(HAVE_XF86VMODE_GAMMA_RAMP)
1384   fi
1385
1386   # pull in the lib, if we haven't already
1387   if test "$have_xf86gamma" = yes -a "$have_xf86vmode" = no; then
1388     SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
1389   fi
1390
1391 elif test "$with_xf86gamma" != no; then
1392   echo "error: must be yes or no: --with-xf86gamma-ext=$with_xf86vmode"
1393   exit 1
1394 fi
1395
1396
1397 ###############################################################################
1398 #
1399 #       Check for the RANDR (Resize and Rotate) server extension.
1400 #
1401 #       We need this to detect when the resolution of the desktop
1402 #       has changed out from under us (this is a newer, different
1403 #       mechanism than the XF86VMODE virtual viewports.)
1404 #
1405 ###############################################################################
1406
1407 have_randr=no
1408 with_randr_req=unspecified
1409 AC_ARG_WITH(randr-ext,
1410 [  --with-randr-ext        Include support for the X Resize+Rotate extension.],
1411   [with_randr="$withval"; with_randr_req="$withval"],[with_randr=yes])
1412
1413 HANDLE_X_PATH_ARG(with_randr, --with-randr-ext, RANDR)
1414
1415 if test "$with_randr" = yes; then
1416
1417   # first check for Randr.h
1418   AC_CHECK_X_HEADER(X11/extensions/Xrandr.h, [have_randr=yes],,
1419                     [#include <X11/Xlib.h>])
1420
1421   # if that succeeded, then check for the XRR code in the libraries
1422   if test "$have_randr" = yes; then
1423
1424     # RANDR probably needs -lXrender
1425     xrender_libs=
1426     AC_CHECK_X_LIB(Xrender, XRenderSetSubpixelOrder,
1427                    [xrender_libs="-lXrender"], [true], -lXext -lX11)
1428
1429     # first look for RANDR in -lXext
1430     have_randr=no
1431     AC_CHECK_X_LIB(Xext, XRRGetScreenInfo,
1432                    [have_randr=yes; SAVER_LIBS="$SAVER_LIBS $xrender_libs"],
1433                    [true], $xrender_libs -lXext -lX11)
1434
1435     # if that failed, look in -lXrandr
1436     if test "$have_randr" = no; then
1437       AC_CHECK_X_LIB(Xrandr, XRRGetScreenInfo,
1438              [have_randr=yes; SAVER_LIBS="$SAVER_LIBS -lXrandr $xrender_libs"],
1439                      [true], $xrender_libs -lXext -lX11)
1440     fi
1441   fi
1442
1443   # if that succeeded, then we've really got it.
1444   if test "$have_randr" = yes; then
1445     AC_DEFINE(HAVE_RANDR)
1446   fi
1447
1448 elif test "$with_randr" != no; then
1449   echo "error: must be yes or no: --with-randr-ext=$with_randr"
1450   exit 1
1451 fi
1452
1453
1454 ###############################################################################
1455 #
1456 #       Check for XF86MiscSetGrabKeysState (but only bother if we are already
1457 #       using other XF86 stuff.)
1458 #
1459 ###############################################################################
1460
1461 have_xf86miscsetgrabkeysstate=no
1462 if test "$have_xf86gamma" = yes -o "$have_xf86vmode" = yes; then
1463   AC_CHECK_X_LIB(Xxf86misc, XF86MiscSetGrabKeysState,
1464                 [have_xf86miscsetgrabkeysstate=yes],
1465                 [true], -lXext -lX11)
1466   if test "$have_xf86miscsetgrabkeysstate" = yes ; then
1467     SAVER_LIBS="$SAVER_LIBS -lXxf86misc"
1468     AC_DEFINE(HAVE_XF86MISCSETGRABKEYSSTATE)
1469   fi
1470 fi
1471
1472
1473 ###############################################################################
1474 #
1475 #       Check for HP XHPDisableReset and XHPEnableReset.
1476 #
1477 ###############################################################################
1478
1479 AC_MSG_CHECKING([for XHPDisableReset in X11/XHPlib.h])
1480 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
1481                   [AC_DEFINE(HAVE_XHPDISABLERESET)
1482                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"
1483                    AC_MSG_RESULT(yes)],
1484                   [AC_MSG_RESULT(no)])
1485
1486
1487 ###############################################################################
1488 #
1489 #       Check for /proc/interrupts.
1490 #
1491 ###############################################################################
1492
1493 have_proc_interrupts=no
1494 with_proc_interrupts_req=unspecified
1495 AC_ARG_WITH(proc-interrupts,
1496 [  --with-proc-interrupts  Include support for consulting the /proc/interrupts
1497                           file to notice keyboard activity.],
1498   [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
1499   [with_proc_interrupts=yes])
1500
1501 if test "$with_proc_interrupts" = yes; then
1502
1503    AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
1504     ac_cv_have_proc_interrupts,
1505     [ac_cv_have_proc_interrupts=no
1506      if grep 'keyboard\|i8042' /proc/interrupts >/dev/null 2>&1 ; then
1507        ac_cv_have_proc_interrupts=yes
1508      fi
1509     ])
1510    have_proc_interrupts=$ac_cv_have_proc_interrupts
1511
1512   if test "$have_proc_interrupts" = yes; then
1513     AC_DEFINE(HAVE_PROC_INTERRUPTS)
1514   fi
1515
1516 elif test "$with_proc_interrupts" != no; then
1517   echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
1518   exit 1
1519 fi
1520
1521
1522 ###############################################################################
1523 #
1524 #       The --enable-locking option
1525 #
1526 ###############################################################################
1527
1528 AC_ARG_ENABLE(locking,[
1529 Screen locking options:
1530
1531   --enable-locking        Compile in support for locking the display.
1532   --disable-locking       Do not allow locking at all.],
1533   [enable_locking="$enableval"],[enable_locking=yes])
1534 if test "$enable_locking" = yes; then
1535   true
1536 elif test "$enable_locking" = no; then
1537   AC_DEFINE(NO_LOCKING)
1538 else
1539   echo "error: must be yes or no: --enable-locking=$enable_locking"
1540   exit 1
1541 fi
1542
1543 # We can't lock on MacOS X, so don't even bother compiling in support for it.
1544 #
1545 if test "$ac_macosx" = yes; then
1546   if test "$enable_locking" = yes; then
1547     AC_MSG_RESULT(locking disabled: it doesn't work on MacOS X)
1548     enable_locking=no
1549     AC_DEFINE(NO_LOCKING)
1550   fi
1551 fi
1552
1553
1554 ###############################################################################
1555 #
1556 #       The --enable-vt-locking option
1557 #
1558 ###############################################################################
1559
1560 #ac_vt_lockswitch=no
1561 #AC_ARG_ENABLE(vt-locking,[
1562 #  --enable-vt-locking     Compile in support for locking Virtual Terminals.
1563 #                          This is the default if the system supports it, and
1564 #                          if locking support is included (--enable-locking.)
1565 #  --disable-vt-locking    Do not allow locking of VTs, even if locking is
1566 #                          enabled.],
1567 #  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1568 #if test "$enable_vt_locking" = yes; then
1569 #
1570 #  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
1571 #   [AC_TRY_COMPILE([#include <fcntl.h>
1572 #                   #include <sys/ioctl.h>
1573 #                   #include <sys/vt.h>],
1574 #                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1575 #                  [ac_cv_vt_lockswitch=yes],
1576 #                  [ac_cv_vt_lockswitch=no])])
1577 #  ac_vt_lockswitch=$ac_cv_vt_lockswitch
1578 #
1579 #elif test "$enable_vt_locking" = no; then
1580 #  true
1581 #else
1582 #  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1583 #  exit 1
1584 #fi
1585 #
1586 #if test "$ac_vt_lockswitch" = yes; then
1587 #  AC_DEFINE(HAVE_VT_LOCKSWITCH)
1588 #  # the VT_LOCKSWITCH ioctl can only be used when running as root.
1589 #  # #### but it doesn't work yet, so don't worry about that for now.
1590 ##  need_setuid=yes
1591 #fi
1592
1593
1594 ###############################################################################
1595 #
1596 #       Check for PAM.
1597 #
1598 ###############################################################################
1599
1600 case "$host" in
1601   *-solaris*)
1602    # Solaris systems tend to come with PAM misconfigured.
1603    #  Don't build it by default, even if the headers exist.
1604    with_pam_default=no
1605    ;;
1606   *)
1607    # Default to building PAM support on all other systems, if it exists.
1608    with_pam_default=yes
1609   ;;
1610 esac
1611
1612 have_pam=no
1613 with_pam_req=unspecified
1614
1615 AC_ARG_WITH(pam,
1616 [  --with-pam              Include support for PAM (Pluggable Auth Modules.)],
1617   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
1618
1619 HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1620
1621 if test "$enable_locking" = yes -a "$with_pam" = yes; then
1622   AC_CACHE_CHECK([for PAM], ac_cv_pam,
1623                  [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1624                                    [ac_cv_pam=yes],
1625                                    [ac_cv_pam=no])])
1626   if test "$ac_cv_pam" = yes ; then
1627     have_pam=yes
1628     AC_DEFINE(HAVE_PAM)
1629     PASSWD_LIBS="${PASSWD_LIBS} -lpam"
1630
1631     # libpam typically requires dlopen and dlsym.  On FreeBSD,
1632     # those are in libc.  On Linux and Solaris, they're in libdl.
1633     AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
1634
1635     # On Linux, sigtimedwait() is in libc; on Solaris, it's in librt.
1636     have_timedwait=no
1637     AC_CHECK_LIB(c, sigtimedwait, [have_timedwait=yes])
1638     if test "$have_timedwait" = no ; then
1639       AC_CHECK_LIB(rt, sigtimedwait, [PASSWD_LIBS="${PASSWD_LIBS} -lrt"])
1640     fi
1641
1642     AC_MSG_CHECKING(how to call pam_strerror)
1643     AC_CACHE_VAL(ac_cv_pam_strerror_args,
1644      [AC_TRY_COMPILE([#include <stdio.h>
1645                       #include <stdlib.h>
1646                       #include <security/pam_appl.h>],
1647                      [pam_handle_t *pamh = 0;
1648                       char *s = pam_strerror(pamh, PAM_SUCCESS);],
1649                      [ac_pam_strerror_args=2],
1650                      [AC_TRY_COMPILE([#include <stdio.h>
1651                                       #include <stdlib.h>
1652                                       #include <security/pam_appl.h>],
1653                                      [char *s =
1654                                        pam_strerror(PAM_SUCCESS);],
1655                                      [ac_pam_strerror_args=1],
1656                                      [ac_pam_strerror_args=0])])
1657       ac_cv_pam_strerror_args=$ac_pam_strerror_args])
1658     ac_pam_strerror_args=$ac_cv_pam_strerror_args
1659     if test "$ac_pam_strerror_args" = 1 ; then
1660       AC_MSG_RESULT(one argument)
1661     elif test "$ac_pam_strerror_args" = 2 ; then
1662       AC_DEFINE(PAM_STRERROR_TWO_ARGS)
1663       AC_MSG_RESULT(two arguments)
1664     else
1665       AC_MSG_RESULT(unknown)
1666     fi
1667   fi
1668 fi
1669
1670
1671 ###############################################################################
1672 #
1673 #       Check for Kerberos.
1674 #
1675 ###############################################################################
1676
1677 have_kerberos=no
1678 have_kerberos5=no
1679 with_kerberos_req=unspecified
1680
1681 AC_ARG_WITH(kerberos, 
1682 [  --with-kerberos         Include support for Kerberos authentication.],
1683   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1684
1685 HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1686
1687 if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
1688   AC_CACHE_CHECK([for Kerberos 4], ac_cv_kerberos,
1689                  [AC_TRY_X_COMPILE([#include <krb.h>],,
1690                                    [ac_cv_kerberos=yes],
1691                                    [ac_cv_kerberos=no])])
1692   AC_CACHE_CHECK([for Kerberos 5], ac_cv_kerberos5,
1693                  [AC_TRY_X_COMPILE([#include <kerberosIV/krb.h>],,
1694                                    [ac_cv_kerberos5=yes],
1695                                    [ac_cv_kerberos5=no])])
1696
1697   if test "$ac_cv_kerberos" = yes ; then
1698     have_kerberos=yes
1699     AC_DEFINE(HAVE_KERBEROS)
1700   fi
1701
1702   if test "$ac_cv_kerberos5" = yes ; then
1703
1704     # Andrew Snare <ajs@pigpond.com> wrote:
1705     #
1706     # You were assuming that if kerberosV (krb5) was found, then kerberosIV
1707     # (krb4) was also available.  This turns out not to be the case with
1708     # mit-krb-1.2.7; apparently backwards-compatibility with KerberosIV
1709     # is optional.
1710     #
1711     # So, disable kerberosV support if libkrb4 can't be found.
1712     # This is not the best solution, but it makes the compile not fail.
1713     #
1714     AC_CHECK_X_LIB(krb4, krb_get_tf_realm,
1715                    [have_kerberos=yes],
1716                    [have_kerberos=no])
1717     if test "$have_kerberos" = yes ; then
1718       have_kerberos5=yes
1719       AC_DEFINE(HAVE_KERBEROS)
1720       AC_DEFINE(HAVE_KERBEROS5)
1721     else
1722       have_kerberos5=no
1723       AC_MSG_WARN([Cannot find compat lib (libkrb4) needed to use Kerberos 5])
1724     fi
1725
1726   fi
1727
1728   if test "$have_kerberos5" = yes ; then
1729     # from Matt Knopp <mhat@infocalypse.netlag.com>
1730     # (who got it from amu@mit.edu)
1731
1732     PASSWD_LIBS="$PASSWD_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"
1733
1734     # jwz: MacOS X uses -lkrb5, but not -lcrypt
1735     AC_CHECK_X_LIB(crypt, crypt, [PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1736
1737   elif test "$have_kerberos" = yes ; then
1738     # from Tim Showalter <tjs@psaux.com> for FreeBSD 4.2
1739     PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lcom_err"
1740   fi
1741
1742   if test "$have_kerberos" = yes ; then
1743     AC_CHECK_FUNC(res_search,,
1744       AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1745         AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1746       ))
1747   fi
1748 fi
1749
1750
1751 ###############################################################################
1752 #
1753 #       Check for the nine billion variants of shadow passwords...
1754 #
1755 ###############################################################################
1756
1757 need_setuid=no
1758
1759 have_shadow=no
1760 with_shadow_req=unspecified
1761
1762 AC_ARG_WITH(shadow,
1763 [  --with-shadow           Include support for shadow password authentication.],
1764   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1765
1766 HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1767
1768 if test "$enable_locking" = no ; then
1769   with_shadow_req=no
1770   with_shadow=no
1771 fi
1772
1773
1774 ###############################################################################
1775 #
1776 #       Check for Sun "adjunct" passwords.
1777 #
1778 ###############################################################################
1779
1780 if test "$with_shadow" = yes ; then
1781   AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1782                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1783                                     #include <unistd.h>
1784                                     #include <sys/types.h>
1785                                     #include <sys/label.h>
1786                                     #include <sys/audit.h>
1787                                     #include <pwdadj.h>],
1788                       [struct passwd_adjunct *p = getpwanam("nobody");
1789                        const char *pw = p->pwa_passwd;],
1790                       [ac_cv_sun_adjunct=yes],
1791                       [ac_cv_sun_adjunct=no])])
1792   if test "$ac_cv_sun_adjunct" = yes; then
1793     have_shadow_adjunct=yes
1794     have_shadow=yes
1795     need_setuid=yes
1796   fi
1797 fi
1798
1799
1800 ###############################################################################
1801 #
1802 #       Check for DEC and SCO so-called "enhanced" security.
1803 #
1804 ###############################################################################
1805
1806 if test "$with_shadow" = yes ; then
1807   AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1808                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1809                                     #include <unistd.h>
1810                                     #include <sys/types.h>
1811                                     #include <pwd.h>
1812                                     #include <sys/security.h>
1813                                     #include <prot.h>],
1814                       [struct pr_passwd *p;
1815                        const char *pw;
1816                        set_auth_parameters(0, 0);
1817                        check_auth_parameters();
1818                        p = getprpwnam("nobody");
1819                        pw = p->ufld.fd_encrypt;],
1820                       [ac_cv_enhanced_passwd=yes],
1821                       [ac_cv_enhanced_passwd=no])])
1822   if test $ac_cv_enhanced_passwd = yes; then
1823     have_shadow_enhanced=yes
1824     have_shadow=yes
1825     need_setuid=yes
1826
1827     # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1828     # (I'm told it needs -lcurses too, but I don't understand why.)
1829     # But on DEC, it's in -lsecurity.
1830     #
1831     AC_CHECK_LIB(prot, getprpwnam, 
1832                  [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1833                  [AC_CHECK_LIB(security, getprpwnam, 
1834                                [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1835                  [-lx])
1836   fi
1837 fi
1838
1839 ###############################################################################
1840 #
1841 #       Check for HP's entry in the "Not Invented Here" Sweepstakes.
1842 #
1843 ###############################################################################
1844
1845 if test "$with_shadow" = yes ; then
1846   AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1847                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1848                                     #include <unistd.h>
1849                                     #include <sys/types.h>
1850                                     #include <pwd.h>
1851                                     #include <hpsecurity.h>
1852                                     #include <prot.h>],
1853                       [struct s_passwd *p = getspwnam("nobody");
1854                        const char *pw = p->pw_passwd;],
1855                       [ac_cv_hpux_passwd=yes],
1856                       [ac_cv_hpux_passwd=no])])
1857   if test "$ac_cv_hpux_passwd" = yes; then
1858     have_shadow_hpux=yes
1859     have_shadow=yes
1860     need_setuid=yes
1861
1862     # on HPUX, bigcrypt is in -lsec
1863     AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1864   fi
1865 fi
1866
1867
1868 ###############################################################################
1869 #
1870 #       Check for FreeBSD-style shadow passwords.
1871 #
1872 #       On FreeBSD, getpwnam() and friends work just like on non-shadow-
1873 #       password systems -- except you only get stuff in the pw_passwd field
1874 #       if the running program is setuid.  So, guess that we've got this
1875 #       lossage to contend with if /etc/master.passwd exists, and default to
1876 #       a setuid installation.
1877 #
1878 ###############################################################################
1879
1880 if test "$with_shadow" = yes ; then
1881   AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1882                  [if test -f /etc/master.passwd ; then
1883                     ac_cv_master_passwd=yes
1884                   else
1885                     ac_cv_master_passwd=no
1886                   fi])
1887   if test "$ac_cv_master_passwd" = yes; then
1888     need_setuid=yes
1889   fi
1890 fi
1891
1892
1893 ###############################################################################
1894 #
1895 #       Check for traditional (ha!) shadow passwords.
1896 #
1897 ###############################################################################
1898
1899 if test "$with_shadow" = yes ; then
1900   AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1901                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1902                                     #include <unistd.h>
1903                                     #include <sys/types.h>
1904                                     #include <pwd.h>
1905                                     #include <shadow.h>],
1906                       [struct spwd *p = getspnam("nobody");
1907                        const char *pw = p->sp_pwdp;],
1908                       [ac_cv_shadow=yes],
1909                       [ac_cv_shadow=no])])
1910   if test "$ac_cv_shadow" = yes; then
1911     have_shadow=yes
1912     need_setuid=yes
1913
1914     # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1915     have_getspnam=no
1916     AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1917     if test "$have_getspnam" = no ; then
1918       AC_CHECK_LIB(gen, getspnam,
1919                    [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1920     fi
1921   fi
1922 fi
1923
1924
1925 ###############################################################################
1926 #
1927 #       Check for other libraries needed for non-shadow passwords.
1928 #
1929 ###############################################################################
1930
1931 if test "$enable_locking" = yes ; then
1932
1933   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1934   have_crypt=no
1935   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1936   if test "$have_crypt" = no ; then
1937     AC_CHECK_LIB(crypt, crypt,
1938                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1939   fi
1940 fi
1941
1942
1943 # Most of the above shadow mechanisms will have set need_setuid to yes,
1944 # if they were found.  But, on some systems, we need setuid even when
1945 # using plain old vanilla passwords.
1946 #
1947 if test "$enable_locking" = yes ; then
1948   case "$host" in
1949     *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1950       need_setuid=yes
1951     ;;
1952   esac
1953 fi
1954
1955
1956 if test "$have_shadow_adjunct" = yes ; then
1957   AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1958 elif test "$have_shadow_enhanced" = yes ; then
1959   AC_DEFINE(HAVE_ENHANCED_PASSWD)
1960 elif test "$have_shadow_hpux" = yes ; then
1961   AC_DEFINE(HAVE_HPUX_PASSWD)
1962 elif test "$have_shadow" = yes ; then
1963   AC_DEFINE(HAVE_SHADOW_PASSWD)
1964 fi
1965
1966
1967 ###############################################################################
1968 #
1969 #       Check for external password helper
1970 #       On SuSE, instead of having xscreensaver be a setuid program, they
1971 #       fork an external program that takes the password on stdin, and
1972 #       returns true if that password is a valid one.  Then only that
1973 #       smaller program needs to be setuid.
1974 #
1975 #       (Note that this external program is not a GUI: the GUI is still
1976 #       all in xscreensaver itself; the external program just does auth.)
1977 #
1978 ###############################################################################
1979
1980 have_passwd_helper=no
1981 with_passwd_helper_req=unspecified
1982
1983 AC_ARG_WITH(passwd-helper,
1984 [  --with-passwd-helper    Include support for an external password
1985                           verification helper program.],
1986   [with_passwd_helper="$withval"; with_passwd_helper_req="$withval"],[with_passwd_helper=no])
1987 # no HANDLE_X_PATH_ARG for this one
1988
1989 if test "$enable_locking" = no ; then
1990   with_passwd_helper_req=no
1991   with_passwd_helper=no
1992 fi
1993
1994 case "$with_passwd_helper" in
1995   ""|no) : ;;
1996   /*)
1997     AC_DEFINE_UNQUOTED(PASSWD_HELPER_PROGRAM, "$with_passwd_helper")
1998     have_passwd_helper=yes;;
1999   *)
2000     echo "error: --with-passwd-helper needs full pathname of helper (not '$with_passwd_helper')." >&2
2001     exit 1
2002 esac
2003
2004
2005 ###############################################################################
2006 #
2007 #       Check for -lgtk (and Gnome stuff)
2008 #
2009 ###############################################################################
2010
2011 have_gtk=no
2012 with_gtk_req=unspecified
2013 AC_ARG_WITH(gtk,[
2014 User interface options:
2015
2016   --with-gtk              Use the Gtk toolkit for the user interface.],
2017   [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
2018
2019 # if --with-gtk=/directory/ was specified, remember that directory so that
2020 # we can also look for the `gtk-config' program in that directory.
2021 case "$with_gtk" in
2022   /*)
2023     gtk_dir="$with_gtk"
2024     ;;
2025   *)
2026     gtk_dir=""
2027     ;;
2028 esac
2029
2030 HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
2031
2032 if test "$with_gtk" != yes -a "$with_gtk" != no ; then
2033   echo "error: must be yes or no: --with-gtk=$with_gtk"
2034   exit 1
2035 fi
2036
2037
2038 parse_gtk_version_string() {
2039   # M4 sucks!!
2040   changequote(X,Y)
2041   maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
2042   min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
2043   changequote([,])
2044   ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
2045   if test -z "$ac_gtk_version"; then
2046     ac_gtk_version=unknown
2047     ac_gtk_version_string=unknown
2048   fi
2049 }
2050
2051 # Find pkg-config... (need this for both gtk and gdk_pixbuf.)
2052 # if the user specified --with-gtk=/foo/ then look there.
2053 #
2054 gtk_path="$PATH"
2055 if test ! -z "$gtk_dir"; then
2056   # canonicalize slashes.
2057   foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
2058   gtk_path="$foo:$gtk_path"
2059 fi
2060
2061 AC_PATH_PROGS(pkg_config, pkg-config,, $gtk_path)
2062
2063 if test -z "$pkg_config" ; then
2064   AC_MSG_WARN([pkg-config not found!])
2065   pkg_config="false"
2066 fi
2067
2068
2069 # Utility function for running pkg-config-based tests...
2070 #
2071 pkgs=''
2072 pkg_check_version() {
2073   if test "$ok" = yes ; then
2074     req="$1"
2075     min="$2"
2076     AC_MSG_CHECKING(for $req)
2077     if $pkg_config --exists "$req" ; then
2078       vers=`$pkg_config --modversion "$req"`
2079       if $pkg_config --exists "$req >= $min" ; then
2080         AC_MSG_RESULT($vers)
2081         pkgs="$pkgs $req"
2082         return 1
2083       else
2084         AC_MSG_RESULT($vers (wanted >= $min))
2085         ok=no
2086         return 0
2087       fi
2088     else
2089       AC_MSG_RESULT(no)
2090       ok=no
2091       return 0
2092     fi
2093   fi
2094 }
2095
2096
2097 jurassic_gtk=no
2098 gtk_halfassed=no
2099
2100 if test "$with_gtk" = yes; then
2101   have_gtk=no
2102   
2103   ok="yes"
2104   pkg_check_version            gtk+-2.0  2.0.1  ; ac_gtk_version_string="$vers"
2105   pkg_check_version         gmodule-2.0  2.0.0
2106   pkg_check_version          libxml-2.0  2.4.6
2107   pkg_check_version        libglade-2.0  1.99.0
2108   pkg_check_version      gdk-pixbuf-2.0  2.0.0
2109   pkg_check_version gdk-pixbuf-xlib-2.0  2.0.0
2110   have_gtk="$ok"
2111
2112   if test "$have_gtk" = no; then
2113     if test -n "$ac_gtk_version_string" ; then
2114       gtk_halfassed="$ac_gtk_version_string"
2115       gtk_halfassed_lib="$req"
2116     fi
2117   fi
2118
2119   if test "$have_gtk" = yes; then
2120     parse_gtk_version_string
2121     jurassic_gtk=no
2122   fi
2123
2124   if test "$have_gtk" = yes; then
2125     AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
2126                    [ac_cv_gtk_config_cflags=`$pkg_config --cflags $pkgs`])
2127     AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
2128                    [ac_cv_gtk_config_libs=`$pkg_config --libs $pkgs`])
2129   fi
2130   ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
2131   ac_gtk_config_libs=$ac_cv_gtk_config_libs
2132
2133   GTK_EXTRA_OBJS=""
2134   GNOME_DATADIR=""
2135   GNOME_PANELDIR='$(GNOME_PANELDIR2)'
2136   if test "$have_gtk" = yes; then
2137     GNOME_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
2138     GNOME_DATADIR="$GNOME_DATADIR/share"
2139   fi
2140
2141   if test "$have_gtk" = yes; then
2142     INCLUDES="$INCLUDES $ac_gtk_config_cflags"
2143     GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
2144     AC_DEFINE(HAVE_GTK)
2145     AC_DEFINE(HAVE_GTK2)
2146     AC_DEFINE(HAVE_XML)
2147   fi
2148
2149 fi
2150
2151
2152 # Check for the various Gnome help and URL loading programs.
2153 #
2154 if test "$have_gtk" = yes; then
2155   AC_CHECK_PROGS(gnome_open_program,     gnome-open)
2156   AC_CHECK_PROGS(gnome_url_show_program, gnome-url-show)
2157 fi
2158
2159
2160 ###############################################################################
2161 #
2162 #       Check for -lXm.
2163 #
2164 ###############################################################################
2165
2166 have_motif=no
2167 with_motif_req=unspecified
2168 AC_ARG_WITH(motif,[  --with-motif            Use the Motif toolkit for the user interface
2169                           (not recommended.)],
2170   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
2171
2172 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
2173
2174 if test "$with_motif" != yes -a "$with_motif" != no ; then
2175   echo "error: must be yes or no: --with-motif=$with_motif"
2176   exit 1
2177 fi
2178
2179 if test "$with_motif" = yes; then
2180   have_motif=no
2181   AC_CHECK_X_HEADER(Xm/Xm.h,
2182                     [have_motif=yes
2183                      AC_DEFINE(HAVE_MOTIF)
2184                      MOTIF_LIBS="$MOTIF_LIBS -lXm"],,
2185                     [#include <stdlib.h>
2186                      #include <stdio.h>
2187                      #include <X11/Intrinsic.h>])
2188 fi
2189
2190
2191 if test "$have_motif" = yes; then
2192   AC_CHECK_X_HEADER(Xm/ComboBox.h, [AC_DEFINE(HAVE_XMCOMBOBOX)],,
2193                     [#include <stdlib.h>
2194                      #include <stdio.h>
2195                      #include <X11/Intrinsic.h>])
2196 fi
2197
2198
2199 ###############################################################################
2200 #
2201 #       Checking whether Motif is really Lesstif.
2202 #
2203 ###############################################################################
2204
2205 have_lesstif=no
2206 if test "$have_motif" = yes ; then
2207   AC_CACHE_CHECK([whether Motif is really LessTif], 
2208                  ac_cv_have_lesstif,
2209                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
2210                                    [long vers = LesstifVersion;],
2211                                    [ac_cv_have_lesstif=yes],
2212                                    [ac_cv_have_lesstif=no])])
2213   have_lesstif=$ac_cv_have_lesstif
2214 fi
2215
2216
2217 lesstif_version=unknown
2218 lesstif_version_string=unknown
2219
2220 if test "$have_lesstif" = yes ; then
2221   ltv=unknown
2222   echo unknown > conftest-lt
2223   AC_CACHE_CHECK([LessTif version number],
2224                  ac_cv_lesstif_version_string,
2225       [AC_TRY_X_RUN([#include <stdio.h>
2226                      #include <Xm/Xm.h>
2227                      int main() {
2228                        FILE *f = fopen("conftest-lt", "w");
2229                        if (!f) exit(1);
2230                        fprintf(f, "%d %d.%d\n", LesstifVersion,
2231                           LESSTIF_VERSION, LESSTIF_REVISION);
2232                        fclose(f);
2233                        exit(0);
2234                      }],
2235                     [ltv=`cat conftest-lt`
2236                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
2237                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
2238                     [ac_cv_lesstif_version=unknown
2239                      ac_cv_lesstif_version_string=unknown],
2240                     [ac_cv_lesstif_version=unknown
2241                      ac_cv_lesstif_version_string=unknown])])
2242   rm -f conftest-lt
2243   lesstif_version=$ac_cv_lesstif_version
2244   lesstif_version_string=$ac_cv_lesstif_version_string
2245
2246 fi
2247
2248
2249 if test "$have_motif" = yes ; then
2250   mtv=unknown
2251   echo unknown > conftest-mt
2252   AC_CACHE_CHECK([Motif version number],
2253                  ac_cv_motif_version_string,
2254       [AC_TRY_X_RUN([#include <stdio.h>
2255                      #include <Xm/Xm.h>
2256                      int main() {
2257                        FILE *f = fopen("conftest-mt", "w");
2258                        if (!f) exit(1);
2259                        fprintf(f, "%d %d.%d\n", XmVersion,
2260                           XmVERSION, XmREVISION);
2261                        fclose(f);
2262                        exit(0);
2263                      }],
2264                     [mtv=`cat conftest-mt`
2265                      ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
2266                      ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
2267                     [ac_cv_motif_version=unknown
2268                      ac_cv_motif_version_string=unknown],
2269                     [ac_cv_motif_version=unknown
2270                      ac_cv_motif_version_string=unknown])])
2271   rm -f conftest-mt
2272   motif_version=$ac_cv_motif_version
2273   motif_version_string=$ac_cv_motif_version_string
2274
2275 fi
2276
2277
2278 ###############################################################################
2279 #
2280 #       Checking whether Motif requires -lXpm.
2281 #
2282 #       If this is Motif 2.x, and we have XPM, then link against XPM as well.
2283 #       The deal is, Motif 2.x requires XPM -- but it's a compilation option
2284 #       of the library whether to build the XPM code into libXm, or whether
2285 #       to rely on an external libXm.  So the only way to tell whether XPM is
2286 #       a link-time requirement is to examine libXm.a, which is very
2287 #       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
2288 #       always link against XPM if the XPM lib exists (and this will be a
2289 #       no-op if libXm happens to already have the XPM code in it.)
2290 #
2291 ###############################################################################
2292
2293 motif_requires_xpm=no
2294 if test "$have_motif" = yes ; then
2295    AC_MSG_CHECKING(whether Motif requires XPM)
2296    if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
2297    then
2298      motif_requires_xpm=yes
2299      AC_MSG_RESULT(maybe)
2300    else
2301      AC_MSG_RESULT(no)
2302    fi
2303 fi
2304
2305
2306 ###############################################################################
2307 #
2308 #       Checking whether Motif requires -lXp.
2309 #
2310 #       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
2311 #       Extension".   Why this extension isn't in -lXext with all the others,
2312 #       I have no idea.
2313 #
2314 ###############################################################################
2315
2316 have_xp_ext=no
2317 if test "$have_motif" = yes ; then
2318    have_xp_ext=no
2319    AC_CHECK_X_LIB(Xp, XpQueryExtension,
2320                   [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
2321                   [true], -lX11 -lXext -lm)
2322 fi
2323
2324
2325 ###############################################################################
2326 #
2327 #       Checking whether Motif requires -lXintl (for _Xsetlocale.)
2328 #
2329 ###############################################################################
2330
2331 have_xintl=no
2332 if test "$have_motif" = yes ; then
2333   AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
2334                  -lX11 -lXext -lm)
2335   if test "$have_xintl" = yes; then
2336     MOTIF_LIBS="$MOTIF_LIBS -lXintl"
2337   fi
2338 fi
2339
2340
2341 ###############################################################################
2342 #
2343 #       Check for -lGL or -lMesaGL.
2344 #
2345 ###############################################################################
2346
2347 have_gl=no
2348 ac_have_mesa_gl=no
2349 with_gl_req=unspecified
2350 gl_halfassed=no
2351 AC_ARG_WITH(gl,[
2352 Graphics options:
2353
2354   --with-gl               Build those demos which depend on OpenGL.],
2355   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
2356
2357 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
2358
2359 ac_mesagl_version=unknown
2360 ac_mesagl_version_string=unknown
2361
2362 if test "$with_gl" = yes; then
2363   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
2364   if test "$have_gl" = yes ; then
2365     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no,
2366                       [#include <GL/gl.h>])
2367   fi
2368
2369   # If we have the headers, try and figure out which vendor it's from.
2370   #
2371   if test "$have_gl" = yes ; then
2372
2373     # We need to know whether it's MesaGL so that we know which libraries
2374     # to link against.
2375     #
2376     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
2377       [ac_cv_have_mesa_gl=no
2378        AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
2379       ])
2380     ac_have_mesa_gl=$ac_cv_have_mesa_gl
2381  
2382
2383     gl_lib_1=""
2384     GL_LIBS=""
2385
2386
2387     # Some versions of MesaGL are compiled to require -lpthread.
2388     # So if the Mesa headers exist, and -lpthread exists, then always
2389     # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
2390     #
2391     if test "$ac_have_mesa_gl" = yes; then
2392       AC_CHECK_LIB(pthread, pthread_create, [GL_LIBS="-lpthread"], [],)
2393     fi
2394
2395
2396     # If we have Mesa headers, check to see if we can link against -lMesaGL.
2397     # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
2398     # Else, warn that GL is busted.  (We have the headers, but no libs.)
2399     #
2400
2401     if test "$ac_have_mesa_gl" = yes ; then
2402       AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
2403                      [gl_lib_1="MesaGL"
2404                       GL_LIBS="-lMesaGL -lMesaGLU $VIDMODE_LIBS $GL_LIBS"],
2405                      [], -lMesaGLU $GL_LIBS -lX11 -lXext $VIDMODE_LIBS -lm)
2406     fi
2407
2408     if test "$gl_lib_1" = "" ; then
2409       AC_CHECK_X_LIB(GL, glXCreateContext, 
2410                      [gl_lib_1="GL"
2411                       GL_LIBS="-lGL -lGLU $VIDMODE_LIBS $GL_LIBS"],
2412                      [], -lGLU $GL_LIBS -lX11 -lXext $VIDMODE_LIBS -lm)
2413     fi
2414
2415     if test "$gl_lib_1" = "" ; then
2416       # we have headers, but no libs -- bail.
2417       have_gl=no
2418       ac_have_mesa_gl=no
2419       gl_halfassed=yes
2420     else
2421       # linking works -- we can build the GL hacks.
2422       AC_DEFINE(HAVE_GL)
2423       if test "$ac_have_mesa_gl" = yes ; then
2424         AC_DEFINE(HAVE_MESA_GL)
2425       fi
2426     fi
2427   fi
2428
2429
2430   # Now that we know we have GL headers and libs, do some more GL testing.
2431   #
2432
2433   if test "$have_gl" = yes ; then
2434     # If it's MesaGL, we'd like to issue a warning if the version number
2435     # is less than or equal to 2.6, because that version had a security bug.
2436     #
2437     if test "$ac_have_mesa_gl" = yes; then
2438
2439       AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
2440         [cat > conftest.$ac_ext <<EOF
2441 #line __oline__ "configure"
2442 #include "confdefs.h"
2443 #include <GL/gl.h>
2444 #ifndef MESA_MAJOR_VERSION
2445 # include <GL/xmesa.h>
2446 # ifdef XMESA_MAJOR_VERSION
2447    /* Around Mesa 3.2, they took out the Mesa version number, so instead,
2448       we have to check the XMesa version number (the number of the X protocol
2449       support, which seems to be the same as the Mesa version number.)
2450     */
2451 #  define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
2452 #  define MESA_MINOR_VERSION XMESA_MINOR_VERSION
2453 # else
2454    /* Oh great.  Some time after 3.4, they took out the xmesa.h header file,
2455       so we have no way of telling what version of Mesa this is at all.
2456       So, we'll guess that the osmesa version (the "offscreen protocol")
2457       is less than or equal to the real mesa version number.  Except that
2458       if OSmesa is 3.3, assume at least Mesa 3.4, since OSmesa was 3.3 in
2459       Mesa 3.4.  And Mesa 3.3 had xmesa.h.  What a complete load of shit!
2460     */
2461 # include <GL/osmesa.h>
2462 #  define MESA_MAJOR_VERSION OSMESA_MAJOR_VERSION
2463 #  define MESA_MINOR_VERSION OSMESA_MINOR_VERSION or newer, probably?
2464 #  if OSMESA_MAJOR_VERSION == 3 && OSMESA_MINOR_VERSION == 3
2465 #   undef MESA_MINOR_VERSION
2466 #   define MESA_MINOR_VERSION 4 or newer, probably?
2467 #  endif
2468 # endif
2469 #endif
2470 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
2471 EOF
2472
2473          ac_save_CPPFLAGS="$CPPFLAGS"
2474          if test \! -z "$includedir" ; then 
2475            CPPFLAGS="$CPPFLAGS -I$includedir"
2476          fi
2477          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2478
2479          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | grep configure:`
2480
2481          # M4 sucks!!
2482          changequote(X,Y)
2483           mglv=`echo "$mglv" | sed -n \
2484              's/^configure: *\([0-9][0-9]*\)  *\([0-9].*\)$/\1.\2/p'`
2485          changequote([,])
2486
2487          rm -f conftest.$ac_ext
2488
2489          CPPFLAGS="$ac_save_CPPFLAGS"
2490
2491          if test "$mglv" = ""; then
2492            ac_mesagl_version=unknown
2493            ac_mesagl_version_string=unknown
2494          else
2495            ac_mesagl_version_string="$mglv"
2496            # M4 sucks!!
2497            changequote(X,Y)
2498            maj=`echo "$mglv" | sed -n 's/^\([0-9][0-9]*\)\..*$/\1/p'`
2499            min=`echo "$mglv" | sed -n 's/^.*\.\([0-9][0-9]*\).*$/\1/p'`
2500            changequote([,])
2501            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
2502            if test -z "$ac_mesagl_version"; then
2503              ac_mesagl_version=unknown
2504              ac_mesagl_version_string=unknown
2505            fi
2506          fi
2507          ac_cv_mesagl_version=$ac_mesagl_version
2508          ac_cv_mesagl_version_string=$ac_mesagl_version_string
2509       ])
2510       ac_mesagl_version=$ac_cv_mesagl_version
2511       ac_mesagl_version_string=$ac_cv_mesagl_version_string
2512     fi
2513
2514
2515     # Check for OpenGL 1.1 features.
2516     #
2517     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
2518                    [true], $GL_LIBS -lX11 -lXext -lm)
2519   fi
2520
2521 elif test "$with_gl" != no; then
2522   echo "error: must be yes or no: --with-gl=$with_gl"
2523   exit 1
2524 fi
2525
2526
2527 ###############################################################################
2528 #
2529 #       Check for -lgle.
2530 #
2531 ###############################################################################
2532
2533 have_gle=no
2534 with_gle_req=unspecified
2535 gle_halfassed=no
2536 AC_ARG_WITH(gle,
2537 [  --with-gle              Build those demos which depend on GLE
2538                           (the OpenGL "extrusion" library.)],
2539   [with_gle="$withval"; with_gle_req="$withval"],[with_gle=yes])
2540
2541 HANDLE_X_PATH_ARG(with_gle, --with-gle, GLE)
2542
2543 GLE_LIBS=""
2544
2545 if test "$have_gl" = no ; then
2546  true
2547 elif test "$with_gle" = yes; then
2548
2549   AC_CHECK_X_HEADER(GL/gle.h, have_gle3=yes, have_gle3=no,
2550                     [#include <GL/gl.h>])
2551   if test "$have_gle3" = yes ; then
2552     have_gle=yes;
2553   else
2554     AC_CHECK_X_HEADER(GL/gutil.h, have_gle=yes, have_gle=no,
2555                     [#include <GL/gl.h>])
2556     if test "$have_gle" = yes ; then
2557       AC_CHECK_X_HEADER(GL/tube.h, have_gle=yes, have_gle=no,
2558                         [#include <GL/gl.h>])
2559     fi
2560   fi
2561
2562   if test "$have_gle" = yes ; then
2563     have_gle=no
2564     gle_halfassed=yes
2565     AC_CHECK_X_LIB(gle, gleCreateGC, 
2566                    [have_gle=yes; gle_halfassed=no; GLE_LIBS="-lgle"],
2567                    [], $GL_LIBS -lX11 -lXext -lm)
2568   fi
2569   if test "$have_gle" = yes ; then
2570     have_gle=no
2571     gle_halfassed=yes
2572
2573     # sometimes the libmatrix stuff is included in libgle.  look there first.
2574 #
2575 # I don't get it.  For some reason, this test passes on SGI, as if
2576 # uview_direction_d() was in libgle -- but it's not, it's in libmatrix.
2577 # Yet the link is succeeding.  Why???
2578 #
2579 #    AC_CHECK_X_LIB(gle, uview_direction_d, 
2580 #                   [have_gle=yes; gle_halfassed=no],
2581 #                   [], $GL_LIBS -lX11 -lXext -lm)
2582
2583     # As of GLE 3 this is in libgle, and has changed name to uview_direction!
2584     # *sigh*
2585     if test "$have_gle3" = yes ; then
2586       AC_CHECK_X_LIB(gle, uview_direction, 
2587                      [have_gle=yes; gle_halfassed=no],
2588                     [], $GL_LIBS -lX11 -lXext -lm)
2589     fi
2590     # if it wasn't in libgle, then look in libmatrix.
2591     if test "$have_gle" = no ; then
2592       AC_CHECK_X_LIB(matrix, uview_direction_d, 
2593                      [have_gle=yes; gle_halfassed=no;
2594                       GLE_LIBS="$GLE_LIBS -lmatrix"],
2595                     [], $GL_LIBS -lX11 -lXext -lm)
2596     fi
2597   fi
2598
2599   if test "$have_gle" = yes ; then
2600     AC_DEFINE(HAVE_GLE)
2601     if test "$have_gle3" = yes ; then
2602       AC_DEFINE(HAVE_GLE3)
2603     fi
2604   fi
2605
2606 elif test "$with_gle" != no; then
2607   echo "error: must be yes or no: --with-gle=$with_gle"
2608   exit 1
2609
2610 fi
2611
2612
2613 ###############################################################################
2614 #
2615 #       Check for -lgdk_pixbuf.
2616 #       These tests are for gdk_pixbuf usage of the hacks, 
2617 #       not xscreensaver-demo (thus we have to test again to get
2618 #       the libraries right: don't want to pull in all of GTK
2619 #       for the hacks.)
2620 #
2621 ###############################################################################
2622
2623 have_gdk_pixbuf=no
2624 with_gdk_pixbuf_req=unspecified
2625 AC_ARG_WITH(pixbuf,
2626 [  --with-pixbuf           Include support for the GDK-Pixbuf library in some
2627                           demos, which will make it possible for them to read
2628                           GIF, JPEG, and PNG files as well.],
2629   [with_gdk_pixbuf="$withval"; with_gdk_pixbuf_req="$withval"],
2630   [with_gdk_pixbuf=yes])
2631
2632 # if --with-pixbuf=/directory/ was specified, remember that directory so that
2633 # we can also look for the `gdk-pixbuf-config' program in that directory.
2634 case "$with_gdk_pixbuf" in
2635   /*)
2636     gdk_pixbuf_dir="$with_gdk_pixbuf"
2637     ;;
2638   *)
2639     gdk_pixbuf_dir=""
2640     ;;
2641 esac
2642
2643 HANDLE_X_PATH_ARG(with_gdk_pixbuf, --with-pixbuf, GDK_PIXBUF)
2644
2645 if test "$with_gdk_pixbuf" != yes -a "$with_gdk_pixbuf" != no ; then
2646   echo "error: must be yes or no: --with-pixbuf=$with_gdk_pixbuf"
2647   exit 1
2648 fi
2649
2650 if test "$with_gdk_pixbuf" = yes; then
2651   have_gdk_pixbuf=no
2652
2653   pkgs=''
2654   ok="yes"
2655
2656   pkg_check_version gdk-pixbuf-2.0      2.0.0
2657   pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
2658   have_gdk_pixbuf="$ok"
2659
2660   if test "$have_gdk_pixbuf" = yes; then
2661     AC_CACHE_CHECK([for gdk-pixbuf includes], ac_cv_gdk_pixbuf_config_cflags,
2662                [ac_cv_gdk_pixbuf_config_cflags=`$pkg_config --cflags $pkgs`])
2663     AC_CACHE_CHECK([for gdk-pixbuf libs], ac_cv_gdk_pixbuf_config_libs,
2664                [ac_cv_gdk_pixbuf_config_libs=`$pkg_config --libs $pkgs`])
2665   fi
2666   ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
2667   ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
2668
2669
2670   if test "$have_gdk_pixbuf" = yes; then
2671     #
2672     # we appear to have pixbuf; check for headers/libs to be sure.
2673     #
2674     ac_save_gdk_pixbuf_CPPFLAGS="$CPPFLAGS"
2675     CPPFLAGS="$CPPFLAGS $ac_gdk_pixbuf_config_cflags"
2676
2677     have_gdk_pixbuf=no
2678
2679     # check for header A...
2680     AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf.h, [have_gdk_pixbuf=yes])
2681
2682     # if that worked, check for header B...
2683     if test "$have_gdk_pixbuf" = yes; then
2684       have_gdk_pixbuf=no
2685       gdk_pixbuf_halfassed=yes
2686       AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf-xlib.h,
2687                         [have_gdk_pixbuf=yes
2688                          gdk_pixbuf_halfassed=no])
2689
2690       # yay, it has a new name in Gtk 2.x...
2691       if test "$have_gdk_pixbuf" = no; then
2692         have_gdk_pixbuf=no
2693         gdk_pixbuf_halfassed=yes
2694         AC_CHECK_X_HEADER(gdk-pixbuf-xlib/gdk-pixbuf-xlib.h,
2695                           [have_gdk_pixbuf=yes
2696                            gdk_pixbuf_halfassed=no])
2697       fi
2698     fi
2699     CPPFLAGS="$ac_save_gdk_pixbuf_CPPFLAGS"
2700   fi
2701
2702   if test "$have_gdk_pixbuf" = yes; then
2703     # we have the headers, now check for the libraries
2704     have_gdk_pixbuf=no
2705     gdk_pixbuf_halfassed=yes
2706
2707     AC_MSG_RESULT(checking for gdk_pixbuf usability...)
2708
2709     # library A...
2710     AC_CHECK_X_LIB(c, gdk_pixbuf_new_from_file, [have_gdk_pixbuf=yes],,
2711                    $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
2712     # library B...
2713     if test "$have_gdk_pixbuf" = yes; then
2714       have_gdk_pixbuf=no
2715       AC_CHECK_X_LIB(c, gdk_pixbuf_xlib_init,
2716                      [have_gdk_pixbuf=yes
2717                       gdk_pixbuf_halfassed=no],,
2718                      $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
2719     fi
2720   fi
2721
2722   if test "$have_gdk_pixbuf" = yes; then
2723     INCLUDES="$INCLUDES $ac_gdk_pixbuf_config_cflags"
2724     XPM_LIBS="$ac_gdk_pixbuf_config_libs"
2725     AC_DEFINE(HAVE_GDK_PIXBUF)
2726   else
2727     AC_MSG_RESULT(checking for gdk_pixbuf usability... no)
2728   fi
2729 fi
2730
2731
2732 ###############################################################################
2733 #
2734 #       Check for -lXpm.
2735 #
2736 ###############################################################################
2737
2738 have_xpm=no
2739 with_xpm_req=unspecified
2740 AC_ARG_WITH(xpm,
2741 [  --with-xpm              Include support for XPM files in some demos.
2742                           (Not needed if Pixbuf is used.)],
2743   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
2744
2745 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
2746
2747 if test "$with_xpm" = yes; then
2748   AC_CHECK_X_HEADER(X11/xpm.h,
2749                    [have_xpm=yes
2750                     AC_DEFINE(HAVE_XPM)
2751                     XPM_LIBS="-lXpm $XPM_LIBS"],,
2752                     [#include <X11/Xlib.h>])
2753 elif test "$with_xpm" != no; then
2754   echo "error: must be yes or no: --with-xpm=$with_xpm"
2755   exit 1
2756 fi
2757
2758 # See comment near $motif_requires_xpm, above.
2759 # Need to do this here, after both Motif and XPM have been checked for.
2760 #
2761 if test "$have_motif" = yes -a "$have_xpm" = yes ; then
2762   if test "$motif_requires_xpm" = yes ; then
2763     MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
2764   fi
2765 fi
2766
2767
2768 ###############################################################################
2769 #
2770 #       Check for -ljpeg
2771 #
2772 ###############################################################################
2773
2774 have_jpeg=no
2775 with_jpeg_req=unspecified
2776 jpeg_halfassed=no
2777 AC_ARG_WITH(jpeg,
2778 [  --with-jpeg             Include support for the JPEG library.],
2779   [with_jpeg="$withval"; with_jpeg_req="$withval"],
2780   [with_jpeg=yes])
2781
2782 HANDLE_X_PATH_ARG(with_jpeg, --with-jpeg, JPEG)
2783
2784 if test "$with_jpeg" != yes -a "$with_jpeg" != no ; then
2785   echo "error: must be yes or no: --with-jpeg=$with_jpeg"
2786   exit 1
2787 fi
2788
2789 if test "$with_jpeg" = yes; then
2790
2791   have_jpeg=no
2792   AC_CHECK_X_HEADER(jpeglib.h, [have_jpeg=yes])
2793
2794   if test "$have_jpeg" = yes; then
2795     # we have the header, now check for the library
2796     have_jpeg=no
2797     jpeg_halfassed=yes
2798     AC_CHECK_X_LIB(jpeg, jpeg_start_compress,
2799                    [have_jpeg=yes
2800                     jpeg_halfassed=no
2801                     JPEG_LIBS="-ljpeg"
2802                     AC_DEFINE(HAVE_JPEGLIB)])
2803   fi
2804 fi
2805
2806
2807 ###############################################################################
2808 #
2809 #       Check for pty support for 'phosphor'
2810 #
2811 ###############################################################################
2812
2813 PTY_LIBS=
2814 AC_CHECK_HEADERS(pty.h util.h)
2815 AC_CHECK_X_LIB(util, forkpty,
2816                [PTY_LIBS="-lutil"
2817                 AC_DEFINE(HAVE_FORKPTY)])
2818
2819
2820 ###############################################################################
2821 #
2822 #       Check for the XSHM server extension.
2823 #
2824 ###############################################################################
2825
2826 have_xshm=no
2827 with_xshm_req=unspecified
2828 AC_ARG_WITH(xshm-ext,
2829 [  --with-xshm-ext         Include support for the Shared Memory extension.],
2830   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
2831
2832 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
2833
2834 if test "$with_xshm" = yes; then
2835
2836   # first check for Xshm.h.
2837   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes],,
2838                     [#include <X11/Xlib.h>])
2839
2840   # if that succeeded, then check for sys/ipc.h.
2841   if test "$have_xshm" = yes; then
2842     have_xshm=no
2843     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
2844   fi
2845
2846   # if that succeeded, then check for sys/shm.h.
2847   if test "$have_xshm" = yes; then
2848     have_xshm=no
2849     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
2850   fi
2851
2852   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
2853   # to exist, but the library code to not exist.  And even better, the library
2854   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
2855   # lib doesn't exist, give up.  (This lib gets added to X_EXTRA_LIBS, and
2856   # that's not quite right, but close enough.)
2857   #
2858   case "$host" in
2859     *-aix*)
2860       if [ `uname -v` -eq 3 ]; then
2861         have_xshm=no
2862         AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
2863                        [have_xshm=yes; X_EXTRA_LIBS="$X_EXTRA_LIBS -lXextSam"],
2864                        [true], -lX11 -lXext -lm)
2865       fi
2866     ;;
2867   esac
2868
2869   # if that succeeded, then we've really got it.
2870   if test "$have_xshm" = yes; then
2871     AC_DEFINE(HAVE_XSHM_EXTENSION)
2872   fi
2873
2874 elif test "$with_xshm" != no; then
2875   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
2876   exit 1
2877 fi
2878
2879
2880 ###############################################################################
2881 #
2882 #       Check for the DOUBLE-BUFFER server extension.
2883 #
2884 ###############################################################################
2885
2886 have_xdbe=no
2887 with_xdbe_req=unspecified
2888 AC_ARG_WITH(xdbe-ext,
2889 [  --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension.],
2890   [with_xdbe="$withval"; with_xdbe_req="$withval"],[with_xdbe=yes])
2891
2892 HANDLE_X_PATH_ARG(with_xdbe, --with-xdbe-ext, DOUBLE-BUFFER)
2893
2894 if test "$with_xdbe" = yes; then
2895
2896   AC_CHECK_X_HEADER(X11/extensions/Xdbe.h, [have_xdbe=yes],,
2897                     [#include <X11/Xlib.h>])
2898   if test "$have_xdbe" = yes; then
2899     AC_DEFINE(HAVE_DOUBLE_BUFFER_EXTENSION)    
2900   fi
2901
2902 elif test "$with_xdbe" != no; then
2903   echo "error: must be yes or no: --with-xdbe-ext=$with_xshm"
2904   exit 1
2905 fi
2906
2907
2908 ###############################################################################
2909 #
2910 #       Check for the SGI XReadDisplay server extension.
2911 #
2912 #       Note: this has to be down here, rather than up with the other server
2913 #       extension tests, so that the output of `configure --help' is in the
2914 #       right order.  Arrgh!
2915 #
2916 ###############################################################################
2917
2918 have_readdisplay=no
2919 with_readdisplay_req=unspecified
2920 AC_ARG_WITH(readdisplay,
2921 [  --with-readdisplay      Include support for the XReadDisplay extension.],
2922   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
2923   [with_readdisplay=yes])
2924
2925 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
2926
2927 if test "$with_readdisplay" = yes; then
2928   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
2929                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION),,
2930                     [#include <X11/Xlib.h>])
2931 elif test "$with_readdisplay" != no; then
2932   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
2933   exit 1
2934 fi
2935
2936
2937 ###############################################################################
2938 #
2939 #       Check for a program to generate random text.
2940 #
2941 #       Zippy is funnier than the idiocy generally spat out by `fortune',
2942 #       so first see if "fortune zippy" works.  Else, use plain "fortune".
2943 #
2944 #       We used to dig around in Emacs to look for the "yow" program, but
2945 #       most people who have Emacs also have "fortune zippy", so nevermind.
2946 #
2947 ###############################################################################
2948
2949 with_fortune_req=""
2950 AC_ARG_WITH(fortune,[
2951   --with-fortune=PROGRAM  Some demos are able to run an external program and
2952                           display its text; this names the program to use by
2953                           default (though it can be overridden with X
2954                           resources.)  Default is "/usr/games/fortune".],
2955   [with_fortune_req="$withval"; with_fortune="$withval"],[with_fortune=yes])
2956
2957 if test "$with_fortune" = no || test "$with_fortune" = yes ; then
2958   with_fortune=""
2959   with_fortune_req=""
2960 fi
2961
2962 if test -n "$with_fortune_req" ; then
2963   ac_cv_fortune_program=""
2964   case "$with_fortune_req" in
2965     /*)
2966
2967       set dummy $with_fortune_req ; fortune_tmp=$2
2968       AC_MSG_CHECKING([for $fortune_tmp])
2969       if test -x "$fortune_tmp" ; then
2970         AC_MSG_RESULT(yes)
2971       else
2972         AC_MSG_RESULT(no)
2973         with_fortune=""
2974       fi
2975     ;;
2976     *)
2977       set dummy $with_fortune_req ; fortune_tmp=$2
2978       # don't cache
2979       unset ac_cv_path_fortune_tmp
2980       AC_PATH_PROG(fortune_tmp, $fortune_tmp, [])
2981       if test -z "$fortune_tmp" ; then
2982         with_fortune=""
2983       fi
2984     ;;
2985   esac
2986   ac_cv_fortune_program="$with_fortune"
2987
2988 elif test -n "$ac_cv_fortune_program"; then
2989   AC_MSG_RESULT([checking for fortune... (cached) $ac_cv_fortune_program])
2990 fi
2991
2992 unset ac_cv_path_fortune_tmp
2993 unset fortune_tmp
2994
2995 if test -z "$ac_cv_fortune_program" ; then
2996
2997   # first look for fortune in /usr/games/ (and use absolute path)
2998   AC_PATH_PROGS(fortune_tmp, fortune,, "/usr/games")
2999
3000   # if it's not there, look on $PATH (and don't use absolute path)
3001   if test -z "$fortune_tmp" ; then
3002      AC_CHECK_PROGS(fortune_tmp, fortune)
3003   fi
3004
3005   # if we didn't find anything, then just assume /usr/games/
3006   if test -z "$fortune_tmp" ; then
3007      fortune_tmp="/usr/games/fortune"
3008   fi
3009
3010   ac_cv_fortune_program="$fortune_tmp"
3011
3012   # now check to see whether "fortune zippy" works.
3013   #
3014   fortune_tmp="$fortune_tmp zippy"
3015   AC_MSG_CHECKING([for zippy quotes])
3016   if ( $fortune_tmp >/dev/null 2>&1 ); then
3017     ac_cv_fortune_program="$fortune_tmp"
3018     AC_MSG_RESULT($fortune_tmp)
3019   else
3020     AC_MSG_RESULT(no)
3021   fi
3022
3023 fi
3024
3025 unset ac_cv_path_fortune_tmp
3026 unset fortune_tmp
3027
3028 AC_DEFINE_UNQUOTED(FORTUNE_PROGRAM, "$ac_cv_fortune_program")
3029
3030
3031 ###############################################################################
3032 #
3033 #       Check whether it's ok to install some hacks as setuid (e.g., "sonar")
3034 #       This should be safe, but let's give people the option.
3035 #
3036 ###############################################################################
3037
3038 setuid_hacks_default=no
3039 setuid_hacks="$setuid_hacks_default"
3040 AC_ARG_WITH(setuid-hacks,
3041 [  --with-setuid-hacks     Allow some demos to be installed `setuid root'
3042                           (which is needed in order to ping other hosts.)
3043 ],
3044   [setuid_hacks="$withval"], [setuid_hacks="$setuid_hacks_default"])
3045
3046 HANDLE_X_PATH_ARG(setuid_hacks, --with-setuid-hacks, setuid hacks)
3047
3048 if test "$setuid_hacks" = yes; then
3049   true
3050 elif test "$setuid_hacks" != no; then
3051   echo "error: must be yes or no: --with-setuid-hacks=$setuid_hacks"
3052   exit 1
3053 fi
3054
3055
3056 ###############################################################################
3057 #
3058 #       Done testing.  Now, set up the various -I and -L variables,
3059 #       and decide which GUI program to build by default.
3060 #
3061 ###############################################################################
3062
3063 DEPEND=makedepend
3064 DEPEND_FLAGS=
3065 DEPEND_DEFINES=
3066
3067
3068 if test \! -z "$includedir" ; then 
3069   INCLUDES="$INCLUDES -I$includedir"
3070 fi
3071
3072 if test \! -z "$libdir" ; then
3073   LDFLAGS="$LDFLAGS -L$libdir"
3074 fi
3075
3076
3077 PREFERRED_DEMO_PROGRAM=''
3078 ALL_DEMO_PROGRAMS=
3079 if test "$have_motif" = yes; then
3080   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
3081   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3082 fi
3083 if test "$have_gtk" = yes; then
3084   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
3085   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3086 fi
3087
3088
3089 if test "$have_kerberos" = yes; then
3090   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
3091   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
3092 fi
3093 if test "$have_pam" = yes; then
3094   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
3095   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
3096   INSTALL_PAM="install-pam"
3097 fi
3098 if test "$have_passwd_helper" = yes; then
3099   PASSWD_SRCS="$PASSWD_SRCS \$(PWHELPER_SRCS)"
3100   PASSWD_OBJS="$PASSWD_OBJS \$(PWHELPER_OBJS)"
3101 fi
3102   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
3103   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
3104
3105
3106 if test "$enable_locking" = yes; then
3107   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
3108   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
3109 else
3110   LOCK_SRCS='$(NOLOCK_SRCS_1)'
3111   LOCK_OBJS='$(NOLOCK_OBJS_1)'
3112 fi
3113
3114 if test "$ac_macosx" = yes; then
3115   EXES_OSX='$(EXES_OSX)'
3116   SCRIPTS_OSX='$(SCRIPTS_OSX)'
3117   MEN_OSX='$(MEN_OSX)'
3118 else
3119   EXES_OSX=
3120   SCRIPTS_OSX=
3121   MEN_OSX=
3122 fi
3123
3124
3125 INSTALL_SETUID='$(INSTALL_PROGRAM) $(SUID_FLAGS)'
3126
3127 if test "$need_setuid" = yes; then
3128   NEED_SETUID=yes
3129 else
3130   NEED_SETUID=no
3131 fi
3132
3133 if test "$setuid_hacks" = yes; then
3134   SETUID_HACKS=yes
3135 else
3136   SETUID_HACKS=no
3137 fi
3138
3139 tab='   '
3140 if test "$have_gl" = yes; then
3141   GL_EXES='$(GL_EXES)'
3142   GL_UTIL_EXES='$(GL_UTIL_EXES)'
3143   GL_MEN='$(GL_MEN)'
3144   GL_KLUDGE="${tab}  "
3145 else
3146   GL_KLUDGE="-${tab}  "
3147 fi
3148
3149 if test "$have_gle" = yes; then
3150   GLE_EXES='$(GLE_EXES)'
3151   GLE_KLUDGE="${tab}   "
3152 else
3153   GLE_KLUDGE="-${tab}   "
3154 fi
3155
3156 if test "$have_jpeg" = yes -a "$have_gdk_pixbuf" = yes; then
3157  JPEG_EXES='$(JPEG_EXES)'
3158 fi
3159
3160
3161 # Another substitution in the XScreenSaver.ad.in file:
3162 #
3163 if test "$gnome_open_program" != ''; then
3164   GNOME24=''
3165   GNOME22='!    '
3166   NOGNOME='!    '
3167 elif test "$gnome_url_show_program" != ''; then
3168   GNOME24='!    '
3169   GNOME22=''
3170   NOGNOME='!    '
3171 else
3172   GNOME24='!    '
3173   GNOME22='!    '
3174   NOGNOME=''
3175 fi
3176
3177
3178 # Now that we know whether we have Gnome, we can decide where the XML
3179 # config files get installed.
3180 #
3181 if test -z "$HACK_CONF_DIR" ; then
3182   if test -n "$GNOME_DATADIR" ; then
3183     HACK_CONF_DIR='${GNOME_DATADIR}/control-center/screensavers'
3184   else
3185     HACK_CONF_DIR='${prefix}/lib/xscreensaver/config'
3186   fi
3187 fi
3188
3189
3190
3191 # After computing $HACK_CONF_DIR, make sure $GLADE_DATADIR has a value
3192 # so that we know where to install the Gtk pixmaps.
3193 #
3194 # It should usually be "/usr/share/pixmaps/", but we can't just use
3195 # "$(prefix)/share/pixmaps" because that would usually result in
3196 # "/usr/X11R6/share/pixmaps/", which is wrong.  It needs to be the
3197 # Gtk prefix, not the overall prefix.
3198 #
3199 if test -n "$GNOME_DATADIR" ; then
3200   GLADE_DATADIR='$(GNOME_DATADIR)/xscreensaver'
3201 elif test "$have_gtk" = yes; then
3202   GLADE_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
3203   GLADE_DATADIR="$GLADE_DATADIR/share/xscreensaver"
3204 else
3205   GLADE_DATADIR=''
3206 fi
3207
3208
3209 # Set PO_DATADIR to something sensible.
3210 #
3211 AC_MSG_CHECKING([for locale directory])
3212 if test -n "$GNOME_DATADIR" ; then
3213   PO_DATADIR="$GNOME_DATADIR"
3214 elif test "$have_gtk" = yes; then
3215   PO_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
3216   PO_DATADIR="$PO_DATADIR/share"
3217 fi
3218
3219 if test -z "$PO_DATADIR" ; then
3220   #
3221   # #### Total fucking kludge --
3222   # Map /build/prefix/usr/X11R6/share/ to /build/prefix/usr/share/
3223   # but of course we need to expand all the nested variables to do that...
3224   #
3225   dd=$datadir
3226   eval dd=${dd}
3227   eval dd=${dd}
3228   eval dd=${dd}
3229   eval dd=${dd}
3230   eval dd=${dd}
3231   PO_DATADIR=`echo $dd | sed 's@/X11R6/@/@'`
3232 fi
3233
3234 AC_MSG_RESULT($PO_DATADIR/locale)
3235
3236
3237 # canonicalize slashes.
3238 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
3239
3240 # gcc 3.0 likes to issue this warning for every file:
3241 #
3242 # cc1: warning: changing search order for system directory "/usr/local/include"
3243 # cc1: warning:   as it has already been specified as a non-system directory
3244 #
3245 # Yay.  We can only avoid that by deleting "-I${prefix}/include" from the list.
3246 # Which *should* be totally redundant, and thus an ok thing to delete?
3247 #
3248 INCLUDES=`echo "$INCLUDES" | sed 's@ -I${prefix}/include@@g;'`
3249
3250
3251 ###############################################################################
3252 #
3253 #       Perform substitutions and write Makefiles.
3254 #
3255 ###############################################################################
3256
3257 AC_SUBST(INCLUDES)
3258
3259 AC_SUBST(PREFERRED_DEMO_PROGRAM)
3260 AC_SUBST(ALL_DEMO_PROGRAMS)
3261 AC_SUBST(SAVER_LIBS)
3262 AC_SUBST(MOTIF_LIBS)
3263 AC_SUBST(GTK_LIBS)
3264 AC_SUBST(XML_LIBS)
3265 AC_SUBST(JPEG_LIBS)
3266 AC_SUBST(HACK_LIBS)
3267 AC_SUBST(XPM_LIBS)
3268 AC_SUBST(PTY_LIBS)
3269 AC_SUBST(GL_LIBS)
3270 AC_SUBST(GLE_LIBS)
3271 AC_SUBST(XDPMS_LIBS)
3272 AC_SUBST(PASSWD_LIBS)
3273 AC_SUBST(INSTALL_SETUID)
3274 AC_SUBST(SETUID_HACKS)
3275 AC_SUBST(INSTALL_DIRS)
3276 AC_SUBST(NEED_SETUID)
3277 AC_SUBST(INSTALL_PAM)
3278
3279 AC_SUBST(OBJCC)
3280 AC_SUBST(EXES_OSX)
3281 AC_SUBST(SCRIPTS_OSX)
3282 AC_SUBST(MEN_OSX)
3283
3284 AC_SUBST(PASSWD_SRCS)
3285 AC_SUBST(PASSWD_OBJS)
3286 AC_SUBST(XMU_SRCS)
3287 AC_SUBST(XMU_OBJS)
3288 AC_SUBST(XMU_LIBS)
3289 AC_SUBST(SAVER_GL_SRCS)
3290 AC_SUBST(SAVER_GL_OBJS)
3291 AC_SUBST(SAVER_GL_LIBS)
3292 AC_SUBST(LOCK_SRCS)
3293 AC_SUBST(LOCK_OBJS)
3294 AC_SUBST(JPEG_EXES)
3295 AC_SUBST(GL_EXES)
3296 AC_SUBST(GL_UTIL_EXES)
3297 AC_SUBST(GL_MEN)
3298 AC_SUBST(GL_KLUDGE)
3299 AC_SUBST(GLE_EXES)
3300 AC_SUBST(GLE_KLUDGE)
3301 AC_SUBST(GNOME24)
3302 AC_SUBST(GNOME22)
3303 AC_SUBST(NOGNOME)
3304 AC_SUBST(HACKDIR)
3305 AC_SUBST(GNOME_DATADIR)
3306 AC_SUBST(GLADE_DATADIR)
3307 AC_SUBST(PO_DATADIR)
3308 AC_SUBST(GNOME_PANELDIR)
3309 AC_SUBST(HACK_CONF_DIR)
3310 AC_SUBST(GTK_EXTRA_OBJS)
3311
3312 APPDEFAULTS=$ac_x_app_defaults
3313 AC_SUBST(APPDEFAULTS)
3314
3315 AC_SUBST(DEPEND)
3316 AC_SUBST(DEPEND_FLAGS)
3317 AC_SUBST(DEPEND_DEFINES)
3318 AC_SUBST(PERL)
3319
3320 AC_OUTPUT(Makefile
3321           utils/Makefile
3322           driver/Makefile
3323           hacks/Makefile
3324           hacks/glx/Makefile
3325           po/Makefile.in
3326           driver/XScreenSaver.ad)
3327
3328 ###############################################################################
3329 #
3330 #       Print some warnings at the end.
3331 #
3332 ###############################################################################
3333
3334 warn_prefix_1="    Warning:"
3335 warn_prefix_2="       Note:"
3336 warn_prefix="$warn_prefix_1"
3337
3338 warning=no
3339 warnsep='    #################################################################'
3340
3341 warnpre() {
3342   if test "$warning" = no ; then
3343     echo '' ; echo "$warnsep" ; echo ''
3344     warning=yes
3345   fi
3346 }
3347
3348 warn() {
3349   warnpre
3350   if test "$warning" = long ; then echo '' ; fi
3351   warning=yes
3352   rest="$@"
3353   echo "$warn_prefix $rest"
3354 }
3355
3356 warnL() {
3357   was=$warning
3358   warnpre
3359   warning=yes
3360   if test "$was" != no ; then echo '' ; fi
3361   rest="$@"
3362   echo "$warn_prefix $rest"
3363 }
3364
3365 warn2() {
3366   rest="$@"
3367   echo "             $rest"
3368   warning=long
3369 }
3370
3371 note() {
3372   warn_prefix="$warn_prefix_2"
3373   warn $@
3374   warn_prefix="$warn_prefix_1"
3375 }
3376
3377 noteL() {
3378   warn_prefix="$warn_prefix_2"
3379   warnL $@
3380   warn_prefix="$warn_prefix_1"
3381 }
3382
3383
3384 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
3385   warn 'The SGI saver extension was requested, but was not found.'
3386 fi
3387
3388 if test "$with_mit_req" = yes -a "$have_mit" = no ; then
3389   warn 'The MIT saver extension was requested, but was not found.'
3390 fi
3391
3392 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
3393   warn 'The XIdle extension was requested, but was not found.'
3394 fi
3395
3396 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
3397   warn 'The XSHM extension was requested, but was not found.'
3398 fi
3399
3400 if test "$with_xdbe_req" = yes -a "$have_xdbe" = no ; then
3401   warn 'The DOUBLE-BUFFER extension was requested, but was not found.'
3402 fi
3403
3404 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
3405   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
3406 fi
3407
3408 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
3409   warn 'The DPMS extension was requested, but was not found.'
3410 fi
3411
3412 if test "$with_xinerama_req" = yes -a "$have_xinerama" = no ; then
3413   warn 'The Xinerama extension was requested, but was not found.'
3414 fi
3415
3416 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
3417   warn 'The XF86VMODE extension was requested, but was not found.'
3418 fi
3419
3420 if test "$with_randr_req" = yes -a "$have_randr" = no ; then
3421   warn 'The RANDR extension was requested, but was not found.'
3422 fi
3423
3424 if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
3425   warn "Checking of /proc/interrupts was requested, but it's bogus."
3426 fi
3427
3428 if test "$pkg_config" = false ; then
3429   warnL 'The "pkg-config" program was not found.  Without that,'
3430   warn2 "detection of the various GTK libraries won't work."
3431 else
3432   pkgerr=`$pkg_config --list-all 2>&1 >/dev/null`
3433   if test "x$pkgerr" != "x" ; then
3434     warnL 'The "pkg-config" program produces errors.  This often causes'
3435     warn2 "detection of the various GTK libraries to malfunction."
3436     warn2 "The errors are:"
3437     echo ''
3438     echo "$pkgerr" | sed 's/^/             > /g'
3439   fi
3440 fi
3441
3442 if test "$gtk_halfassed" != no ; then
3443   warnL "GTK version $gtk_halfassed was found, but at least one supporting"
3444   warn2 "library ($gtk_halfassed_lib) was not, so GTK can't be used."
3445   warn2 "Perhaps some of the development packages are not installed?"
3446   if test "$have_gtk" = yes ; then
3447     v="$ac_gtk_version_string"
3448     warn2 "GTK $v is also installed, so it will be used instead."
3449     warn2 "Please read the above output and the \`config.log' file"
3450     warn2 "for more details."
3451   fi
3452 fi
3453
3454 motif_warn2() {
3455   warn2 'Though the Motif front-end to xscreensaver is still'
3456   warn2 'maintained, it is no longer being updated with new'
3457   warn2 'features: all new development on the xscreensaver-demo'
3458   warn2 'program is happening in the GTK version, and not in the'
3459   warn2 'Motif version.  It is recommended that you build against'
3460   warn2 'GTK instead of Motif.  See <http://www.gtk.org/>.'
3461 }
3462
3463 if test "$have_motif" = no -a "$have_gtk" = no; then
3464
3465   if test "$with_motif" = yes; then
3466     warnL "Neither the GTK nor Motif libraries were found; the"
3467     warn2 "\`xscreensaver-demo' program requires one of these."
3468     echo ''
3469     motif_warn2
3470   else
3471     warnL "The GTK libraries do not seem to be available; the"
3472     warn2 "\`xscreensaver-demo' program requires them."
3473 #   echo ''
3474 #   warn2 'You can use Motif or Lesstif instead of GTK (use the'
3475 #   warn2 "\`--with-motif' option) but that is NOT recommended."
3476 #   motif_warn2
3477   fi
3478
3479 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
3480   warnL "Use of Motif was requested, but it wasn't found;"
3481   warn2 "Gtk will be used instead."
3482
3483 elif test "$jurassic_gtk" = yes ; then
3484
3485   pref_gtk=2.0
3486
3487   v="$ac_gtk_version_string"
3488   if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
3489     warnL "Use of Gtk was requested, but its version number is unknown;"
3490   elif test "$with_gtk_req" = yes ; then
3491     warnL "Use of Gtk was requested, but it is version $v;"
3492   else
3493     warnL "Gtk was found on this system, but it is version $v;"
3494   fi
3495
3496   warn2 "Gtk $pref_gtk or newer is required."
3497
3498 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
3499   warnL "Use of Gtk was requested, but it wasn't found."
3500 fi
3501
3502
3503 if test "$have_gtk" = yes -a "$have_gdk_pixbuf" = no ; then
3504   warn  "GTK is being used, but the GDK-Pixbuf library and/or"
3505   warn2 "headers were not found.  That can't be good.  Please"
3506   warn2 "install the GDK-Pixbuf development kit and re-configure."
3507 fi
3508
3509 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
3510
3511   preferred_lesstif=0.92
3512
3513   if test "$lesstif_version" = unknown; then
3514     warnL "Unable to determine the LessTif version number!"
3515     warn2 "Make sure you are using version $preferred_lesstif or newer."
3516     warn2 "See <http://www.lesstif.org/>."
3517
3518   elif test \! $lesstif_version -gt 82; then
3519     warnL "LessTif version $lesstif_version_string is being used."
3520     warn2 "LessTif versions 0.82 and earlier are too buggy to"
3521     warn2 "use with XScreenSaver; it is strongly recommended"
3522     warn2 "that you upgrade to at least version $preferred_lesstif!"
3523     warn2 "See <http://www.lesstif.org/>."
3524   fi
3525 fi
3526
3527
3528 if test "$have_motif" = yes -a "$have_gtk" = no ; then
3529   warn  'Motif is being used, and GTK is not.'
3530   echo  ''
3531   motif_warn2
3532 fi
3533
3534
3535 if test "$with_xpm_req" = yes -a "$have_xpm" = no; then
3536   warnL 'Use of XPM was requested, but it was not found.'
3537 fi
3538
3539 if test "$with_gdk_pixbuf_req" = yes  -a "$have_gdk_pixbuf" = no; then
3540   warnL 'Use of GDK-Pixbuf was requested, but it was not found.'
3541 fi
3542
3543 if test "$have_gdk_pixbuf" = no -o "$gdk_pixbuf_halfassed" = yes || \
3544    test "$have_gdk_pixbuf" = no -a "$have_xpm" = no ; then
3545
3546   if test "$with_gdk_pixbuf_req" = yes ; then
3547     true
3548   elif test "$with_gdk_pixbuf_req" = no ; then
3549     warnL 'The GDK-Pixbuf library is not being used.'
3550   else
3551     warnL 'The GDK-Pixbuf library was not found.'
3552   fi
3553
3554   if test "$with_xpm_req" = yes -o "$have_xpm" = yes ; then
3555     true
3556   elif test "$with_xpm_req" = no ; then
3557     warnL 'The XPM library is not being used.'
3558   else
3559     warnL 'The XPM library was not found.'
3560   fi
3561
3562   if test "$have_gdk_pixbuf" = no -a "$have_xpm" = yes ; then
3563     warn2 'The XPM library is being used instead.'
3564   fi
3565
3566   if test "$gdk_pixbuf_halfassed" = yes ; then
3567     echo ''
3568     warn2 'More specifically, we found the headers, but not the'
3569     warn2 'libraries; so either GDK-Pixbuf is half-installed on this'
3570     warn2 "system, or something else went wrong.  The \`config.log'"
3571     warn2 'file might contain some clues.'
3572   fi
3573
3574   echo ''
3575   warn2 'Some of the demos will not use images as much as they could.'
3576   warn2 'You should consider installing GDK-Pixbuf and re-running'
3577   warn2 'configure.  (GDK-Pixbuf is recommended over XPM, as it'
3578   warn2 'provides support for more image formats.)'
3579 fi
3580
3581
3582 if test "$have_jpeg" = no ; then
3583   if test "$with_jpeg_req" = yes ; then
3584     warnL 'Use of libjpeg was requested, but it was not found.'
3585   elif test "$with_jpeg_req" = no ; then
3586     noteL 'The JPEG library is not being used.'
3587   else
3588     noteL 'The JPEG library was not found.'
3589   fi
3590
3591   if test "$jpeg_halfassed" = yes ; then
3592     echo ''
3593     warn2 'More specifically, we found the headers, but not the'
3594     warn2 'library; so either JPEG is half-installed on this'
3595     warn2 "system, or something else went wrong.  The \`config.log'"
3596     warn2 'file might contain some clues.'
3597     echo ''
3598   fi
3599
3600   if test "$have_gdk_pixbuf" = no ; then
3601     warn2 "This means that it won't be possible for the image-manipulating"
3602     warn2 "display modes to load files from disk; and it also means that"
3603     warn2 "the \`webcollage' program will be much slower."
3604   else
3605     warn2 "This means the \`webcollage' program will be much slower."
3606   fi
3607 fi
3608
3609
3610 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
3611   preferred_mesagl=3.4
3612   mgv="$ac_mesagl_version_string"
3613   pgl="$preferred_mesagl"
3614
3615   if test "$ac_mesagl_version" = unknown; then
3616     warnL "Unable to determine the MesaGL version number!"
3617     warn2 "Make sure you are using version $preferred_mesagl or newer."
3618
3619   elif test \! "$ac_mesagl_version" -gt 2006; then
3620     warnL "MesaGL version number is $mgv --"
3621     warn2 "MesaGL 2.6 and earlier have a security bug.  It is strongly"
3622     warn2 "recommended that you upgrade to at least version $preferred_mesagl."
3623
3624   elif test \! "$ac_mesagl_version" -gt 3003; then
3625     warnL "MesaGL version number is $mgv --"
3626     warn2 "MesaGL 3.3 and earlier have some bugs; it is recommended"
3627     warn2 "that you upgrade to $pgl or newer."
3628   fi
3629 fi
3630
3631 if test "$have_gl" = no ; then
3632   if test "$with_gl_req" = yes ; then
3633     warnL 'Use of GL was requested, but it was not found.'
3634   elif test "$with_gl_req" = no ; then
3635     noteL 'The OpenGL 3D library is not being used.'
3636   else
3637     noteL 'The OpenGL 3D library was not found.'
3638   fi
3639
3640   if test "$gl_halfassed" = yes ; then
3641     echo ''
3642     warn2 'More specifically, we found the headers, but not the'
3643     warn2 'libraries; so either GL is half-installed on this'
3644     warn2 "system, or something else went wrong.  The \`config.log'"
3645     warn2 'file might contain some clues.'
3646   fi
3647
3648   echo ''
3649   warn2 'Those demos which use 3D will not be built or installed.'
3650   warn2 'You might want to consider installing OpenGL and'
3651   warn2 "re-running configure.  If your vendor doesn't ship"
3652   warn2 'their own implementation of OpenGL, you can get a free'
3653   warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
3654   warn2 'info, see <http://www.opengl.org/>.'
3655
3656 fi
3657
3658
3659 if test "$have_gl" = yes -a "$have_gle" = no ; then
3660
3661  # nobody cares about this; don't print the warning unless it was
3662  # requested and not found, or halfway-found.
3663  if test "$with_gle_req" = yes -o "$gle_halfassed" = yes ; then
3664
3665   if test "$with_gle_req" = yes ; then
3666     noteL 'Use of the GLE (GL Extrusion) library was requested, but'
3667     warn2 'it was not found (though the OpenGL library was found, and'
3668     warn2 'is being used.)'
3669   elif test "$with_gle_req" = no ; then
3670     noteL 'The OpenGL Library is being used, but the GLE (GL Extrusion)'
3671     warn2 'library is not.'
3672   else
3673     noteL 'The OpenGL Library was found, but the GLE (GL Extrusion)'
3674     warn2 'was not.'
3675   fi
3676
3677   if test "$gle_halfassed" = yes ; then
3678     echo ''
3679     warn2 'More specifically, we found the headers, but not the'
3680     warn2 'libraries; so either GLE is half-installed on this'
3681     warn2 "system, or something else went wrong.  The \`config.log'"
3682     warn2 'file might contain some clues.'
3683   fi
3684
3685   echo ''
3686   warn2 'Some of the OpenGL (3D) demos (those that depend on GLE)'
3687   warn2 'will not be built or installed.  You might want to consider'
3688   warn2 'installing GLE and re-running configure.  You can find the'
3689   warn2 'GLE library at <http://www.linas.org/gle/>.  For general'
3690   warn2 'OpenGL info, see <http://www.opengl.org/>.'
3691
3692  fi
3693 fi
3694
3695
3696 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
3697   warn 'Use of XReadDisplay was requested, but it was not found.'
3698 fi
3699
3700 if test -n "$with_fortune_req"; then
3701   if test "$with_fortune_req" != "$ac_cv_fortune_program" ; then
3702     warnL "$with_fortune_req was requested as the Fortune program,"
3703     warn2 "but was not found.  The default will be used instead."
3704   fi
3705 fi
3706
3707 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
3708   warn 'Use of Kerberos was requested, but it was not found.'
3709 fi
3710
3711 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
3712   warn 'Use of PAM was requested, but it was not found.'
3713 fi
3714
3715 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
3716   warn 'Use of shadow passwords was requested, but they were not found.'
3717 fi
3718
3719
3720 # You are in a twisty maze of namespaces and syntaxes, all alike.
3721 # Fuck the skull of Unix.
3722 #
3723 eval bindir=${bindir}
3724 eval bindir=${bindir}
3725 eval bindir=${bindir}
3726 eval bindir=${bindir}
3727 eval bindir=${bindir}
3728 eval bindir=${bindir}
3729 eval HACKDIR=${HACKDIR}
3730 eval HACKDIR=${HACKDIR}
3731 eval HACKDIR=${HACKDIR}
3732 eval HACKDIR=${HACKDIR}
3733 eval HACKDIR=${HACKDIR}
3734 eval HACKDIR=${HACKDIR}
3735 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3736 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3737 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3738 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3739 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3740 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3741
3742 # canonicalize slashes.
3743 bindir=`echo  "${bindir}"              | sed 's@/$@@;s@//*@/@g'`
3744 HACKDIR=`echo "${HACKDIR}"             | sed 's@/$@@;s@//*@/@g'`
3745 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
3746
3747
3748 # Sanity check the hackdir
3749 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
3750   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
3751     echo ""
3752     AC_MSG_ERROR([\"--with-hackdir=${bindir}/${bad_choice}\" won't work.
3753                    There will be an executable installed with that name, so
3754                    that can't be the name of a directory as well.  Please
3755                    re-configure with a different directory name.])
3756   fi
3757 done
3758
3759
3760 do_dir_warning=no
3761
3762 # Now let's see if there's a previous RPM version already installed.  Blargh!
3763
3764 # M4 sucks!!
3765 changequote(X,Y)
3766 rpmv=`(rpm -qv xscreensaver) 2>/dev/null | \
3767       sed -n 's/^xscreensaver-\([0-9][0-9]*[.][0-9][0-9]*\)-.*$/\1/p'`
3768 changequote([,])
3769
3770 if test \! -z "$rpmv" ; then
3771   rpmbdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/xscreensaver-demo$@\1@p'`
3772   rpmhdir=`rpm -ql xscreensaver | sed -n 's@^\(.*\)/attraction$@\1@p'`
3773
3774   warning=no
3775   warnL "There is already an installed RPM of xscreensaver $rpmv"
3776   warn2 "on this system.  You might want to remove it (with"
3777   warn2 '"rpm -ve xscreensaver") before running "make install"'
3778   warn2 "from this directory."
3779   echo ""
3780   warn2 "Alternately, you could build this version of xscreensaver"
3781   warn2 'as an RPM, and then install that.  An "xscreensaver.spec"'
3782   warn2 'file is included.  Try "rpmbuild -v -ba xscreensaver.spec".'
3783   warn2 "See the RPM documentation for more info."
3784   echo ""
3785
3786   if test "$rpmbdir" = "$rpmhdir" ; then
3787     warn2 "The RPM version was installed in $rpmbdir/."
3788     do_dir_warning=yes
3789   else
3790     warn2 "The RPM version was installed in $rpmbdir/,"
3791     warn2 "with demos in $rpmhdir/."
3792   fi
3793 fi
3794
3795
3796 if test "${bindir}" = "${HACKDIR}" ; then
3797   do_dir_warning=yes
3798 fi
3799
3800 if test "$do_dir_warning" = yes; then
3801   echo ""
3802   echo "$warnsep"
3803   echo ""
3804   echo '      When you run "make install", the "xscreensaver",'
3805   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
3806   echo "      will be installed in ${bindir}/."
3807   echo ""
3808   echo "      The various graphics demos (190+ different executables) will"
3809   echo "      be installed in ${HACKDIR}/."
3810   echo ""
3811   echo "      If you would prefer the demos to be installed elsewhere,"
3812   echo "      you should re-run configure with the --with-hackdir=DIR"
3813   echo "      option.  For more information, run \`./configure --help'."
3814   warning=yes
3815 fi
3816
3817 if test "$warning" != no; then
3818   echo '' ; echo "$warnsep" ; echo ''
3819 fi
3820
3821 if test "$do_dir_warning" = no; then
3822   if test "$warning" = no; then
3823     echo ''
3824   fi
3825   echo "User programs will be installed in ${bindir}/"
3826   echo "Screen savers will be installed in ${HACKDIR}/"
3827   echo "Configuration will be installed in ${HACK_CONF_DIR}/"
3828   echo ''
3829 fi