ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.21.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
965 Installation options:
966   --with-hackdir=DIR      Where to install the hundreds of demo executables.
967                           Default: `EPREFIX/lib/xscreensaver/'],
968   [with_hackdir="$withval"; with_hackdir_req="$withval"],[with_hackdir=yes])
969
970 if test x"$with_hackdir" = xyes; then
971   HACKDIR='${libexecdir}/xscreensaver'
972 elif test x"$with_hackdir" = xno; then
973   HACKDIR='${bindir}'
974 else
975   HACKDIR=$with_hackdir
976 fi
977
978 # canonicalize slashes.
979 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
980
981 # This option used to be called --enable-subdir; make sure that is no longer
982 # used, since configure brain-damagedly ignores unknown --enable options.
983
984 obsolete_enable=
985 AC_ARG_ENABLE(subdir,,[obsolete_enable=yes])
986 if test -n "$obsolete_enable"; then
987   echo "error: the --enable-subdir option has been replaced with"
988   echo "       the new --with-hackdir option; see \`configure --help'"
989   echo "       for more information."
990   exit 1
991 fi
992
993
994 ###############################################################################
995 #
996 #       Handle the --with-configdir option
997 #
998 ###############################################################################
999
1000 have_configdir=yes
1001 with_configdir_req=unspecified
1002 AC_ARG_WITH(configdir,
1003 [  --with-configdir=DIR    Where to install the data files that describe each
1004                           of the display modes to the GUI.
1005                           Default: `PREFIX/share/xscreensaver/config/'
1006 ],
1007   [with_configdir="$withval"; with_configdir_req="$withval"],
1008   [with_configdir=yes])
1009
1010 if test x"$with_configdir" = xyes; then
1011   HACK_CONF_DIR='${datadir}/xscreensaver/config'
1012 elif test x"$with_configdir" = xno; then
1013   echo "error: must be yes, or a pathname: --with-configdir=$with_configdir"
1014   exit 1
1015 else
1016   # there must be a better way than this...
1017   if test -z "`echo $with_configdir | sed 's@^/.*@@'`" ; then
1018     # absolute path
1019     HACK_CONF_DIR=$with_configdir
1020   else
1021     # relative path
1022     HACK_CONF_DIR="\${exec_prefix}$with_configdir"
1023   fi
1024 fi
1025
1026
1027
1028
1029 ###############################################################################
1030 #
1031 #       Check for the SGI SCREEN_SAVER server extension.
1032 #
1033 ###############################################################################
1034
1035 have_sgi=no
1036 with_sgi_req=unspecified
1037 AC_ARG_WITH(sgi-ext,
1038 [Except where noted, all of the --with options below can also take a
1039 directory argument: for example, `--with-motif=/opt/Motif'.  That would
1040 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
1041 to be added to the -L list, assuming those directories exist.  
1042
1043 By default, support for each of these options will be built in, if the
1044 relevant library routines exist.  At run time, they will then be used
1045 only if the X server being used supports them.  Each --with option has
1046 a corresponding --without option, to override building support for them
1047 at all.
1048
1049 Screen blanking and idle-detection options:
1050
1051   --with-sgi-ext          Include support for the SGI SCREEN_SAVER extension.],
1052   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
1053
1054 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
1055
1056 if test "$with_sgi" = yes; then
1057   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
1058                     [have_sgi=yes
1059                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)],,
1060                     [#include <X11/Xlib.h>])
1061
1062 elif test "$with_sgi" != no; then
1063   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
1064   exit 1
1065 fi
1066
1067
1068 ###############################################################################
1069 #
1070 #       Check for the XIDLE server extension.
1071 #
1072 ###############################################################################
1073
1074 have_xidle=no
1075 with_xidle_req=unspecified
1076 AC_ARG_WITH(xidle-ext,
1077 [  --with-xidle-ext        Include support for the XIDLE extension.],
1078   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
1079
1080 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
1081
1082 if test "$with_xidle" = yes; then
1083   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
1084                     [have_xidle=yes
1085                      AC_DEFINE(HAVE_XIDLE_EXTENSION)],,
1086                     [#include <X11/Xlib.h>])
1087 elif test "$with_xidle" != no; then
1088   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
1089   exit 1
1090 fi
1091
1092
1093 ###############################################################################
1094 #
1095 #       Check for the SGI-VIDEO-CONTROL server extension.
1096 #
1097 ###############################################################################
1098
1099 have_sgivc=no
1100 with_sgivc_req=unspecified
1101 AC_ARG_WITH(sgivc-ext,
1102 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension.],
1103   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
1104
1105 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
1106
1107 if test "$with_sgivc" = yes; then
1108
1109   # first check for XSGIvc.h
1110   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes],,
1111                     [#include <X11/Xlib.h>])
1112
1113   # if that succeeded, then check for the -lXsgivc
1114   if test "$have_sgivc" = yes; then
1115     have_sgivc=no
1116     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
1117                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [true],
1118                   -lXext -lX11)
1119   fi
1120
1121   # if that succeeded, then we've really got it.
1122   if test "$have_sgivc" = yes; then
1123     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
1124   fi
1125
1126 elif test "$with_sgivc" != no; then
1127   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
1128   exit 1
1129 fi
1130
1131
1132 ###############################################################################
1133 #
1134 #       Check for the DPMS server extension.
1135 #
1136 ###############################################################################
1137
1138 have_dpms=no
1139 with_dpms_req=unspecified
1140 AC_ARG_WITH(dpms-ext,
1141 [  --with-dpms-ext         Include support for the DPMS extension.],
1142   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
1143
1144 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
1145
1146 if test "$with_dpms" = yes; then
1147
1148   # first check for dpms.h
1149   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes],,
1150                     [#include <X11/Xlib.h>
1151                      #include <X11/Xmd.h>])
1152
1153   # if that succeeded, then check for the DPMS code in the libraries
1154   if test "$have_dpms" = yes; then
1155
1156     # first look in -lXext (this is where it is with XFree86 4.0)
1157     have_dpms=no
1158     AC_CHECK_X_LIB(Xext, DPMSInfo, [have_dpms=yes], [true], -lXext -lX11)
1159
1160     # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
1161     if test "$have_dpms" = no; then
1162       AC_CHECK_X_LIB(Xdpms, DPMSInfo,
1163                     [have_dpms=yes; XDPMS_LIBS="-lXdpms"], [true],
1164                     -lXext -lX11)
1165     fi
1166   fi
1167
1168
1169   # if that succeeded, then we've really got it.
1170   if test "$have_dpms" = yes; then
1171     AC_DEFINE(HAVE_DPMS_EXTENSION)
1172   fi
1173
1174 elif test "$with_dpms" != no; then
1175   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
1176   exit 1
1177 fi
1178
1179
1180 ###############################################################################
1181 #
1182 #       Check for the XINERAMA server extension.
1183 #
1184 ###############################################################################
1185
1186 have_xinerama=no
1187 with_xinerama_req=unspecified
1188 AC_ARG_WITH(xinerama-ext,
1189 [  --with-xinerama-ext     Include support for the XINERAMA extension.],
1190   [with_xinerama="$withval"; with_xinerama_req="$withval"],[with_xinerama=yes])
1191
1192 HANDLE_X_PATH_ARG(with_xinerama, --with-xinerama-ext, XINERAMA)
1193
1194 if test "$with_xinerama" = yes; then
1195
1196   # first check for Xinerama.h
1197   AC_CHECK_X_HEADER(X11/extensions/Xinerama.h, [have_xinerama=yes],,
1198                     [#include <X11/Xlib.h>])
1199
1200   # if that succeeded, then check for the XINERAMA code in the libraries
1201   if test "$have_xinerama" = yes; then
1202
1203     # first look in -lXext
1204     have_xinerama=no
1205     AC_CHECK_X_LIB(Xext, XineramaQueryScreens, [have_xinerama=yes], [true],
1206                   -lXext -lX11)
1207
1208     # if that failed, look in -lXinerama (this is where it is in XFree86 4.1.)
1209     if test "$have_xinerama" = no; then
1210       AC_CHECK_X_LIB(Xinerama, XineramaQueryScreens,
1211                      [have_xinerama=yes; XINERAMA_LIBS="-lXinerama"],
1212                      [true], -lXext -lX11)
1213     fi
1214   fi
1215
1216   # if that succeeded, then we've really got it.
1217   if test "$have_xinerama" = yes; then
1218     AC_DEFINE(HAVE_XINERAMA)
1219   fi
1220
1221 elif test "$with_xinerama" != no; then
1222   echo "error: must be yes or no: --with-xinerama-ext=$with_xinerama"
1223   exit 1
1224 fi
1225
1226
1227 ###############################################################################
1228 #
1229 #       Check for the XF86VMODE server extension (for virtual screens.)
1230 #
1231 ###############################################################################
1232
1233 have_xf86vmode=no
1234 with_xf86vmode_req=unspecified
1235 AC_ARG_WITH(xf86vmode-ext,
1236 [  --with-xf86vmode-ext    Include support for XFree86 virtual screens.],
1237   [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
1238   [with_xf86vmode=yes])
1239
1240 HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
1241
1242 VIDMODE_LIBS=""
1243
1244 if test "$with_xf86vmode" = yes; then
1245
1246   # first check for xf86vmode.h
1247   AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes],,
1248                     [#include <X11/Xlib.h>])
1249
1250   # if that succeeded, then check for the -lXxf86vm
1251   if test "$have_xf86vmode" = yes; then
1252     have_xf86vmode=no
1253     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
1254                   [have_xf86vmode=yes;
1255                    VIDMODE_LIBS="-lXxf86vm";
1256                    SAVER_LIBS="$SAVER_LIBS $VIDMODE_LIBS"],
1257                    [true], -lXext -lX11)
1258   fi
1259
1260   # if that succeeded, then we've really got it.
1261   if test "$have_xf86vmode" = yes; then
1262     AC_DEFINE(HAVE_XF86VMODE)
1263   fi
1264
1265 elif test "$with_xf86vmode" != no; then
1266   echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
1267   exit 1
1268 fi
1269
1270
1271 ###############################################################################
1272 #
1273 #       Check for the XF86VMODE server extension (for gamma fading.)
1274 #
1275 ###############################################################################
1276
1277 have_xf86gamma=no
1278 have_xf86gamma_ramp=no
1279 with_xf86gamma_req=unspecified
1280 AC_ARG_WITH(xf86gamma-ext,
1281 [  --with-xf86gamma-ext    Include support for XFree86 gamma fading.],
1282   [with_xf86gamma="$withval"; with_xf86gamma_req="$withval"],
1283   [with_xf86gamma=yes])
1284
1285 HANDLE_X_PATH_ARG(with_xf86gamma, --with-xf86gamma-ext, xf86gamma)
1286
1287 if test "$with_xf86gamma" = yes; then
1288
1289   # first check for xf86vmode.h, if we haven't already
1290   if test "$have_xf86vmode" = yes; then
1291     have_xf86gamma=yes
1292   else
1293     AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86gamma=yes],,
1294                       [#include <X11/Xlib.h>])
1295   fi
1296
1297   # if that succeeded, then check for the -lXxf86vm
1298   if test "$have_xf86gamma" = yes; then
1299     have_xf86gamma=no
1300     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGamma,
1301                   [have_xf86gamma=yes],
1302                    [true], -lXext -lX11)
1303   fi
1304
1305   # check for the Ramp versions of the functions too.
1306   if test "$have_xf86gamma" = yes; then
1307     have_xf86gamma_ramp=no
1308     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGammaRamp,
1309                   [have_xf86gamma_ramp=yes],
1310                    [true], -lXext -lX11)
1311   fi
1312
1313   # if those tests succeeded, then we've really got the functions.
1314   if test "$have_xf86gamma" = yes; then
1315     AC_DEFINE(HAVE_XF86VMODE_GAMMA)
1316   fi
1317
1318   if test "$have_xf86gamma_ramp" = yes; then
1319     AC_DEFINE(HAVE_XF86VMODE_GAMMA_RAMP)
1320   fi
1321
1322   # pull in the lib, if we haven't already
1323   if test "$have_xf86gamma" = yes -a "$have_xf86vmode" = no; then
1324     SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
1325   fi
1326
1327 elif test "$with_xf86gamma" != no; then
1328   echo "error: must be yes or no: --with-xf86gamma-ext=$with_xf86vmode"
1329   exit 1
1330 fi
1331
1332
1333 ###############################################################################
1334 #
1335 #       Check for the RANDR (Resize and Rotate) server extension.
1336 #
1337 #       We need this to detect when the resolution of the desktop
1338 #       has changed out from under us (this is a newer, different
1339 #       mechanism than the XF86VMODE virtual viewports.)
1340 #
1341 ###############################################################################
1342
1343 have_randr=no
1344 with_randr_req=unspecified
1345 AC_ARG_WITH(randr-ext,
1346 [  --with-randr-ext        Include support for the X Resize+Rotate extension.],
1347   [with_randr="$withval"; with_randr_req="$withval"],[with_randr=yes])
1348
1349 HANDLE_X_PATH_ARG(with_randr, --with-randr-ext, RANDR)
1350
1351 if test "$with_randr" = yes; then
1352
1353   # first check for Randr.h
1354   AC_CHECK_X_HEADER(X11/extensions/Xrandr.h, [have_randr=yes],,
1355                     [#include <X11/Xlib.h>])
1356
1357   # if that succeeded, then check for the XRR code in the libraries
1358   if test "$have_randr" = yes; then
1359
1360     # RANDR probably needs -lXrender
1361     xrender_libs=
1362     AC_CHECK_X_LIB(Xrender, XRenderSetSubpixelOrder,
1363                    [xrender_libs="-lXrender"], [true], -lXext -lX11)
1364
1365     # first look for RANDR in -lXext
1366     have_randr=no
1367     AC_CHECK_X_LIB(Xext, XRRGetScreenInfo,
1368                    [have_randr=yes; SAVER_LIBS="$SAVER_LIBS $xrender_libs"],
1369                    [true], $xrender_libs -lXext -lX11)
1370
1371     # if that failed, look in -lXrandr
1372     if test "$have_randr" = no; then
1373       AC_CHECK_X_LIB(Xrandr, XRRGetScreenInfo,
1374              [have_randr=yes; SAVER_LIBS="$SAVER_LIBS -lXrandr $xrender_libs"],
1375                      [true], $xrender_libs -lXext -lX11)
1376     fi
1377   fi
1378
1379   # if that succeeded, then we've really got it.
1380   if test "$have_randr" = yes; then
1381     AC_DEFINE(HAVE_RANDR)
1382   fi
1383
1384 elif test "$with_randr" != no; then
1385   echo "error: must be yes or no: --with-randr-ext=$with_randr"
1386   exit 1
1387 fi
1388
1389
1390 ###############################################################################
1391 #
1392 #       Check for XF86MiscSetGrabKeysState (but only bother if we are already
1393 #       using other XF86 stuff.)
1394 #
1395 ###############################################################################
1396
1397 have_xf86miscsetgrabkeysstate=no
1398 if test "$have_xf86gamma" = yes -o "$have_xf86vmode" = yes; then
1399   AC_CHECK_X_LIB(Xxf86misc, XF86MiscSetGrabKeysState,
1400                 [have_xf86miscsetgrabkeysstate=yes],
1401                 [true], -lXext -lX11)
1402   if test "$have_xf86miscsetgrabkeysstate" = yes ; then
1403     SAVER_LIBS="$SAVER_LIBS -lXxf86misc"
1404     AC_DEFINE(HAVE_XF86MISCSETGRABKEYSSTATE)
1405   fi
1406 fi
1407
1408
1409 ###############################################################################
1410 #
1411 #       Check for HP XHPDisableReset and XHPEnableReset.
1412 #
1413 ###############################################################################
1414
1415 AC_MSG_CHECKING([for XHPDisableReset in X11/XHPlib.h])
1416 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
1417                   [AC_DEFINE(HAVE_XHPDISABLERESET)
1418                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"
1419                    AC_MSG_RESULT(yes)],
1420                   [AC_MSG_RESULT(no)])
1421
1422
1423 ###############################################################################
1424 #
1425 #       Check for /proc/interrupts.
1426 #
1427 ###############################################################################
1428
1429 have_proc_interrupts=no
1430 with_proc_interrupts_req=unspecified
1431 AC_ARG_WITH(proc-interrupts,
1432 [  --with-proc-interrupts  Include support for consulting the /proc/interrupts
1433                           file to notice keyboard activity.],
1434   [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
1435   [with_proc_interrupts=yes])
1436
1437 if test "$with_proc_interrupts" = yes; then
1438
1439    AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
1440     ac_cv_have_proc_interrupts,
1441     [ac_cv_have_proc_interrupts=no
1442      if grep 'keyboard\|i8042' /proc/interrupts >/dev/null 2>&1 ; then
1443        ac_cv_have_proc_interrupts=yes
1444      fi
1445     ])
1446    have_proc_interrupts=$ac_cv_have_proc_interrupts
1447
1448   if test "$have_proc_interrupts" = yes; then
1449     AC_DEFINE(HAVE_PROC_INTERRUPTS)
1450   fi
1451
1452 elif test "$with_proc_interrupts" != no; then
1453   echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
1454   exit 1
1455 fi
1456
1457
1458 ###############################################################################
1459 #
1460 #       The --enable-locking option
1461 #
1462 ###############################################################################
1463
1464 AC_ARG_ENABLE(locking,[Screen locking options:
1465   --enable-locking        Compile in support for locking the display.
1466   --disable-locking       Do not allow locking at all.],
1467   [enable_locking="$enableval"],[enable_locking=yes])
1468 if test "$enable_locking" = yes; then
1469   true
1470 elif test "$enable_locking" = no; then
1471   AC_DEFINE(NO_LOCKING)
1472 else
1473   echo "error: must be yes or no: --enable-locking=$enable_locking"
1474   exit 1
1475 fi
1476
1477 # We can't lock on MacOS X, so don't even bother compiling in support for it.
1478 #
1479 if test "$ac_macosx" = yes; then
1480   if test "$enable_locking" = yes; then
1481     AC_MSG_RESULT(locking disabled: it doesn't work on MacOS X)
1482     enable_locking=no
1483     AC_DEFINE(NO_LOCKING)
1484   fi
1485 fi
1486
1487
1488 ###############################################################################
1489 #
1490 #       The --enable-vt-locking option
1491 #
1492 ###############################################################################
1493
1494 #ac_vt_lockswitch=no
1495 #AC_ARG_ENABLE(vt-locking,[
1496 #  --enable-vt-locking     Compile in support for locking Virtual Terminals.
1497 #                          This is the default if the system supports it, and
1498 #                          if locking support is included (--enable-locking.)
1499 #  --disable-vt-locking    Do not allow locking of VTs, even if locking is
1500 #                          enabled.],
1501 #  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1502 #if test "$enable_vt_locking" = yes; then
1503 #
1504 #  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
1505 #   [AC_TRY_COMPILE([#include <fcntl.h>
1506 #                   #include <sys/ioctl.h>
1507 #                   #include <sys/vt.h>],
1508 #                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1509 #                  [ac_cv_vt_lockswitch=yes],
1510 #                  [ac_cv_vt_lockswitch=no])])
1511 #  ac_vt_lockswitch=$ac_cv_vt_lockswitch
1512 #
1513 #elif test "$enable_vt_locking" = no; then
1514 #  true
1515 #else
1516 #  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1517 #  exit 1
1518 #fi
1519 #
1520 #if test "$ac_vt_lockswitch" = yes; then
1521 #  AC_DEFINE(HAVE_VT_LOCKSWITCH)
1522 #  # the VT_LOCKSWITCH ioctl can only be used when running as root.
1523 #  # #### but it doesn't work yet, so don't worry about that for now.
1524 ##  need_setuid=yes
1525 #fi
1526
1527
1528 ###############################################################################
1529 #
1530 #       Check for PAM.
1531 #
1532 ###############################################################################
1533
1534 case "$host" in
1535   *-solaris*)
1536    # Solaris systems tend to come with PAM misconfigured.
1537    #  Don't build it by default, even if the headers exist.
1538    with_pam_default=no
1539    ;;
1540   *)
1541    # Default to building PAM support on all other systems, if it exists.
1542    with_pam_default=yes
1543   ;;
1544 esac
1545
1546 have_pam=no
1547 with_pam_req=unspecified
1548
1549 AC_ARG_WITH(pam,
1550 [  --with-pam              Include support for PAM (Pluggable Auth Modules.)],
1551   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
1552
1553 HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1554
1555 if test "$enable_locking" = yes -a "$with_pam" = yes; then
1556   AC_CACHE_CHECK([for PAM], ac_cv_pam,
1557                  [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1558                                    [ac_cv_pam=yes],
1559                                    [ac_cv_pam=no])])
1560   if test "$ac_cv_pam" = yes ; then
1561     have_pam=yes
1562     AC_DEFINE(HAVE_PAM)
1563     PASSWD_LIBS="${PASSWD_LIBS} -lpam"
1564
1565     # libpam typically requires dlopen and dlsym.  On FreeBSD,
1566     # those are in libc.  On Linux and Solaris, they're in libdl.
1567     AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
1568
1569     # On Linux, sigtimedwait() is in libc; on Solaris, it's in librt.
1570     have_timedwait=no
1571     AC_CHECK_LIB(c, sigtimedwait, [have_timedwait=yes])
1572     if test "$have_timedwait" = no ; then
1573       AC_CHECK_LIB(rt, sigtimedwait, [PASSWD_LIBS="${PASSWD_LIBS} -lrt"])
1574     fi
1575
1576     AC_MSG_CHECKING(how to call pam_strerror)
1577     AC_CACHE_VAL(ac_cv_pam_strerror_args,
1578      [AC_TRY_COMPILE([#include <stdio.h>
1579                       #include <stdlib.h>
1580                       #include <security/pam_appl.h>],
1581                      [pam_handle_t *pamh = 0;
1582                       char *s = pam_strerror(pamh, PAM_SUCCESS);],
1583                      [ac_pam_strerror_args=2],
1584                      [AC_TRY_COMPILE([#include <stdio.h>
1585                                       #include <stdlib.h>
1586                                       #include <security/pam_appl.h>],
1587                                      [char *s =
1588                                        pam_strerror(PAM_SUCCESS);],
1589                                      [ac_pam_strerror_args=1],
1590                                      [ac_pam_strerror_args=0])])
1591       ac_cv_pam_strerror_args=$ac_pam_strerror_args])
1592     ac_pam_strerror_args=$ac_cv_pam_strerror_args
1593     if test "$ac_pam_strerror_args" = 1 ; then
1594       AC_MSG_RESULT(one argument)
1595     elif test "$ac_pam_strerror_args" = 2 ; then
1596       AC_DEFINE(PAM_STRERROR_TWO_ARGS)
1597       AC_MSG_RESULT(two arguments)
1598     else
1599       AC_MSG_RESULT(unknown)
1600     fi
1601   fi
1602 fi
1603
1604
1605 ###############################################################################
1606 #
1607 #       Check for Kerberos.
1608 #
1609 ###############################################################################
1610
1611 have_kerberos=no
1612 have_kerberos5=no
1613 with_kerberos_req=unspecified
1614
1615 AC_ARG_WITH(kerberos, 
1616 [  --with-kerberos         Include support for Kerberos authentication.],
1617   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1618
1619 HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1620
1621 if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
1622   AC_CACHE_CHECK([for Kerberos 4], ac_cv_kerberos,
1623                  [AC_TRY_X_COMPILE([#include <krb.h>],,
1624                                    [ac_cv_kerberos=yes],
1625                                    [ac_cv_kerberos=no])])
1626   AC_CACHE_CHECK([for Kerberos 5], ac_cv_kerberos5,
1627                  [AC_TRY_X_COMPILE([#include <kerberosIV/krb.h>],,
1628                                    [ac_cv_kerberos5=yes],
1629                                    [ac_cv_kerberos5=no])])
1630
1631   if test "$ac_cv_kerberos" = yes ; then
1632     have_kerberos=yes
1633     AC_DEFINE(HAVE_KERBEROS)
1634   fi
1635
1636   if test "$ac_cv_kerberos5" = yes ; then
1637
1638     # Andrew Snare <ajs@pigpond.com> wrote:
1639     #
1640     # You were assuming that if kerberosV (krb5) was found, then kerberosIV
1641     # (krb4) was also available.  This turns out not to be the case with
1642     # mit-krb-1.2.7; apparently backwards-compatibility with KerberosIV
1643     # is optional.
1644     #
1645     # So, disable kerberosV support if libkrb4 can't be found.
1646     # This is not the best solution, but it makes the compile not fail.
1647     #
1648     AC_CHECK_X_LIB(krb4, krb_get_tf_realm,
1649                    [have_kerberos=yes],
1650                    [have_kerberos=no])
1651     if test "$have_kerberos" = yes ; then
1652       have_kerberos5=yes
1653       AC_DEFINE(HAVE_KERBEROS)
1654       AC_DEFINE(HAVE_KERBEROS5)
1655     else
1656       have_kerberos5=no
1657       AC_MSG_WARN([Cannot find compat lib (libkrb4) needed to use Kerberos 5])
1658     fi
1659
1660   fi
1661
1662   if test "$have_kerberos5" = yes ; then
1663     # from Matt Knopp <mhat@infocalypse.netlag.com>
1664     # (who got it from amu@mit.edu)
1665
1666     PASSWD_LIBS="$PASSWD_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"
1667
1668     # jwz: MacOS X uses -lkrb5, but not -lcrypt
1669     AC_CHECK_X_LIB(crypt, crypt, [PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1670
1671   elif test "$have_kerberos" = yes ; then
1672     # from Tim Showalter <tjs@psaux.com> for FreeBSD 4.2
1673     PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lcom_err"
1674   fi
1675
1676   if test "$have_kerberos" = yes ; then
1677     AC_CHECK_FUNC(res_search,,
1678       AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1679         AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1680       ))
1681   fi
1682 fi
1683
1684
1685 ###############################################################################
1686 #
1687 #       Check for the nine billion variants of shadow passwords...
1688 #
1689 ###############################################################################
1690
1691 need_setuid=no
1692
1693 have_shadow=no
1694 with_shadow_req=unspecified
1695
1696 AC_ARG_WITH(shadow,
1697 [  --with-shadow           Include support for shadow password authentication.],
1698   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1699
1700 HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1701
1702 if test "$enable_locking" = no ; then
1703   with_shadow_req=no
1704   with_shadow=no
1705 fi
1706
1707
1708 ###############################################################################
1709 #
1710 #       Check for Sun "adjunct" passwords.
1711 #
1712 ###############################################################################
1713
1714 if test "$with_shadow" = yes ; then
1715   AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
1716                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1717                                     #include <unistd.h>
1718                                     #include <sys/types.h>
1719                                     #include <sys/label.h>
1720                                     #include <sys/audit.h>
1721                                     #include <pwdadj.h>],
1722                       [struct passwd_adjunct *p = getpwanam("nobody");
1723                        const char *pw = p->pwa_passwd;],
1724                       [ac_cv_sun_adjunct=yes],
1725                       [ac_cv_sun_adjunct=no])])
1726   if test "$ac_cv_sun_adjunct" = yes; then
1727     have_shadow_adjunct=yes
1728     have_shadow=yes
1729     need_setuid=yes
1730   fi
1731 fi
1732
1733
1734 ###############################################################################
1735 #
1736 #       Check for DEC and SCO so-called "enhanced" security.
1737 #
1738 ###############################################################################
1739
1740 if test "$with_shadow" = yes ; then
1741   AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
1742                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1743                                     #include <unistd.h>
1744                                     #include <sys/types.h>
1745                                     #include <pwd.h>
1746                                     #include <sys/security.h>
1747                                     #include <prot.h>],
1748                       [struct pr_passwd *p;
1749                        const char *pw;
1750                        set_auth_parameters(0, 0);
1751                        check_auth_parameters();
1752                        p = getprpwnam("nobody");
1753                        pw = p->ufld.fd_encrypt;],
1754                       [ac_cv_enhanced_passwd=yes],
1755                       [ac_cv_enhanced_passwd=no])])
1756   if test $ac_cv_enhanced_passwd = yes; then
1757     have_shadow_enhanced=yes
1758     have_shadow=yes
1759     need_setuid=yes
1760
1761     # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
1762     # (I'm told it needs -lcurses too, but I don't understand why.)
1763     # But on DEC, it's in -lsecurity.
1764     #
1765     AC_CHECK_LIB(prot, getprpwnam, 
1766                  [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
1767                  [AC_CHECK_LIB(security, getprpwnam, 
1768                                [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
1769                  [-lx])
1770   fi
1771 fi
1772
1773 ###############################################################################
1774 #
1775 #       Check for HP's entry in the "Not Invented Here" Sweepstakes.
1776 #
1777 ###############################################################################
1778
1779 if test "$with_shadow" = yes ; then
1780   AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
1781                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1782                                     #include <unistd.h>
1783                                     #include <sys/types.h>
1784                                     #include <pwd.h>
1785                                     #include <hpsecurity.h>
1786                                     #include <prot.h>],
1787                       [struct s_passwd *p = getspwnam("nobody");
1788                        const char *pw = p->pw_passwd;],
1789                       [ac_cv_hpux_passwd=yes],
1790                       [ac_cv_hpux_passwd=no])])
1791   if test "$ac_cv_hpux_passwd" = yes; then
1792     have_shadow_hpux=yes
1793     have_shadow=yes
1794     need_setuid=yes
1795
1796     # on HPUX, bigcrypt is in -lsec
1797     AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
1798   fi
1799 fi
1800
1801
1802 ###############################################################################
1803 #
1804 #       Check for FreeBSD-style shadow passwords.
1805 #
1806 #       On FreeBSD, getpwnam() and friends work just like on non-shadow-
1807 #       password systems -- except you only get stuff in the pw_passwd field
1808 #       if the running program is setuid.  So, guess that we've got this
1809 #       lossage to contend with if /etc/master.passwd exists, and default to
1810 #       a setuid installation.
1811 #
1812 ###############################################################################
1813
1814 if test "$with_shadow" = yes ; then
1815   AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
1816                  [if test -f /etc/master.passwd ; then
1817                     ac_cv_master_passwd=yes
1818                   else
1819                     ac_cv_master_passwd=no
1820                   fi])
1821   if test "$ac_cv_master_passwd" = yes; then
1822     need_setuid=yes
1823   fi
1824 fi
1825
1826
1827 ###############################################################################
1828 #
1829 #       Check for traditional (ha!) shadow passwords.
1830 #
1831 ###############################################################################
1832
1833 if test "$with_shadow" = yes ; then
1834   AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
1835                  [AC_TRY_X_COMPILE([#include <stdlib.h>
1836                                     #include <unistd.h>
1837                                     #include <sys/types.h>
1838                                     #include <pwd.h>
1839                                     #include <shadow.h>],
1840                       [struct spwd *p = getspnam("nobody");
1841                        const char *pw = p->sp_pwdp;],
1842                       [ac_cv_shadow=yes],
1843                       [ac_cv_shadow=no])])
1844   if test "$ac_cv_shadow" = yes; then
1845     have_shadow=yes
1846     need_setuid=yes
1847
1848     # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
1849     have_getspnam=no
1850     AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
1851     if test "$have_getspnam" = no ; then
1852       AC_CHECK_LIB(gen, getspnam,
1853                    [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
1854     fi
1855   fi
1856 fi
1857
1858
1859 ###############################################################################
1860 #
1861 #       Check for other libraries needed for non-shadow passwords.
1862 #
1863 ###############################################################################
1864
1865 if test "$enable_locking" = yes ; then
1866
1867   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
1868   have_crypt=no
1869   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
1870   if test "$have_crypt" = no ; then
1871     AC_CHECK_LIB(crypt, crypt,
1872                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1873   fi
1874 fi
1875
1876
1877 # Most of the above shadow mechanisms will have set need_setuid to yes,
1878 # if they were found.  But, on some systems, we need setuid even when
1879 # using plain old vanilla passwords.
1880 #
1881 if test "$enable_locking" = yes ; then
1882   case "$host" in
1883     *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
1884       need_setuid=yes
1885     ;;
1886   esac
1887 fi
1888
1889
1890 if test "$have_shadow_adjunct" = yes ; then
1891   AC_DEFINE(HAVE_ADJUNCT_PASSWD)
1892 elif test "$have_shadow_enhanced" = yes ; then
1893   AC_DEFINE(HAVE_ENHANCED_PASSWD)
1894 elif test "$have_shadow_hpux" = yes ; then
1895   AC_DEFINE(HAVE_HPUX_PASSWD)
1896 elif test "$have_shadow" = yes ; then
1897   AC_DEFINE(HAVE_SHADOW_PASSWD)
1898 fi
1899
1900
1901 ###############################################################################
1902 #
1903 #       Check for external password helper
1904 #       On SuSE, instead of having xscreensaver be a setuid program, they
1905 #       fork an external program that takes the password on stdin, and
1906 #       returns true if that password is a valid one.  Then only that
1907 #       smaller program needs to be setuid.
1908 #
1909 #       (Note that this external program is not a GUI: the GUI is still
1910 #       all in xscreensaver itself; the external program just does auth.)
1911 #
1912 ###############################################################################
1913
1914 have_passwd_helper=no
1915 with_passwd_helper_req=unspecified
1916
1917 AC_ARG_WITH(passwd-helper,
1918 [  --with-passwd-helper    Include support for an external password
1919                           verification helper program.],
1920   [with_passwd_helper="$withval"; with_passwd_helper_req="$withval"],[with_passwd_helper=no])
1921 # no HANDLE_X_PATH_ARG for this one
1922
1923 if test "$enable_locking" = no ; then
1924   with_passwd_helper_req=no
1925   with_passwd_helper=no
1926 fi
1927
1928 case "$with_passwd_helper" in
1929   ""|no) : ;;
1930   /*)
1931     AC_DEFINE_UNQUOTED(PASSWD_HELPER_PROGRAM, "$with_passwd_helper")
1932     have_passwd_helper=yes;;
1933   *)
1934     echo "error: --with-passwd-helper needs full pathname of helper (not '$with_passwd_helper')." >&2
1935     exit 1
1936 esac
1937
1938
1939 ###############################################################################
1940 #
1941 #       Check for a login manager for a "New Login" button on the lock dialog.
1942 #       Usually this will be "/usr/bin/gdmflexiserver".
1943 #
1944 ###############################################################################
1945
1946 have_login_manager=no
1947 with_login_manager_req=unspecified
1948 default_login_manager='gdmflexiserver -l'
1949
1950 AC_ARG_WITH(login-manager,
1951 [  --with-login-manager    Put a "New Login" button on the unlock dialog that
1952                           runs a login manager such as gdmflexiserver.],
1953   [with_login_manager="$withval"; with_login_manager_req="$withval"],
1954   [with_login_manager=no])
1955 # no HANDLE_X_PATH_ARG for this one
1956
1957 if test "$enable_locking" = no ; then
1958   with_login_manager_req=no
1959   with_login_manager=no
1960 fi
1961
1962 if test -n "$with_login_manager_req" ; then
1963   ac_cv_login_manager_program=""
1964
1965  if test "$with_login_manager_req" = "yes" ; then
1966    with_login_manager_req=$default_login_manager
1967  fi
1968
1969   case "$with_login_manager_req" in
1970     /*)
1971       # absolute path
1972       set dummy $with_login_manager_req ; login_manager_tmp=$2
1973       AC_MSG_CHECKING([for $login_manager_tmp])
1974       if test -x "$login_manager_tmp" ; then
1975         AC_MSG_RESULT(yes)
1976         with_login_manager="$login_manager_tmp"
1977       else
1978         AC_MSG_RESULT(no)
1979         with_login_manager=""
1980       fi
1981     ;;
1982     *)
1983       # relative path
1984       set dummy $with_login_manager_req ; login_manager_tmp=$2
1985       # don't cache
1986       unset ac_cv_path_login_manager_tmp
1987       AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
1988       if test -z "$login_manager_tmp" ; then
1989         with_login_manager=""
1990       else
1991         with_login_manager="$login_manager_tmp"
1992       fi
1993     ;;
1994   esac
1995   ac_cv_login_manager_program="$with_login_manager"
1996
1997 elif test -n "$ac_cv_login_manager_program"; then
1998   AC_MSG_RESULT([checking for login_manager... (cached) $ac_cv_login_manager_program])
1999 fi
2000
2001 NEW_LOGIN_COMMAND_P=''
2002 NEW_LOGIN_COMMAND="$ac_cv_login_manager_program"
2003
2004 if test -z "$NEW_LOGIN_COMMAND" ; then
2005   NEW_LOGIN_COMMAND="$default_login_manager"
2006   NEW_LOGIN_COMMAND_P='! '
2007 fi
2008
2009
2010
2011 ###############################################################################
2012 #
2013 #       Check for -lgtk (and Gnome stuff)
2014 #
2015 ###############################################################################
2016
2017 have_gtk=no
2018 with_gtk_req=unspecified
2019 AC_ARG_WITH(gtk,[
2020 User interface options:
2021
2022   --with-gtk              Use the Gtk toolkit for the user interface.],
2023   [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
2024
2025 # if --with-gtk=/directory/ was specified, remember that directory so that
2026 # we can also look for the `gtk-config' program in that directory.
2027 case "$with_gtk" in
2028   /*)
2029     gtk_dir="$with_gtk"
2030     ;;
2031   *)
2032     gtk_dir=""
2033     ;;
2034 esac
2035
2036 HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
2037
2038 if test "$with_gtk" != yes -a "$with_gtk" != no ; then
2039   echo "error: must be yes or no: --with-gtk=$with_gtk"
2040   exit 1
2041 fi
2042
2043
2044 parse_gtk_version_string() {
2045   # M4 sucks!!
2046   changequote(X,Y)
2047   maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
2048   min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
2049   changequote([,])
2050   ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
2051   if test -z "$ac_gtk_version"; then
2052     ac_gtk_version=unknown
2053     ac_gtk_version_string=unknown
2054   fi
2055 }
2056
2057 # Find pkg-config... (need this for both gtk and gdk_pixbuf.)
2058 # if the user specified --with-gtk=/foo/ then look there.
2059 #
2060 gtk_path="$PATH"
2061 if test ! -z "$gtk_dir"; then
2062   # canonicalize slashes.
2063   foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
2064   gtk_path="$foo:$gtk_path"
2065 fi
2066
2067 AC_PATH_PROGS(pkg_config, pkg-config,, $gtk_path)
2068
2069 if test -z "$pkg_config" ; then
2070   AC_MSG_WARN([pkg-config not found!])
2071   pkg_config="false"
2072 fi
2073
2074
2075 # Utility function for running pkg-config-based tests...
2076 #
2077 pkgs=''
2078 pkg_check_version() {
2079   if test "$ok" = yes ; then
2080     req="$1"
2081     min="$2"
2082     AC_MSG_CHECKING(for $req)
2083     if $pkg_config --exists "$req" ; then
2084       vers=`$pkg_config --modversion "$req"`
2085       if $pkg_config --exists "$req >= $min" ; then
2086         AC_MSG_RESULT($vers)
2087         pkgs="$pkgs $req"
2088         return 1
2089       else
2090         AC_MSG_RESULT($vers (wanted >= $min))
2091         ok=no
2092         return 0
2093       fi
2094     else
2095       AC_MSG_RESULT(no)
2096       ok=no
2097       return 0
2098     fi
2099   fi
2100 }
2101
2102
2103 jurassic_gtk=no
2104 gtk_halfassed=no
2105
2106 if test "$with_gtk" = yes; then
2107   have_gtk=no
2108   
2109   ok="yes"
2110   pkg_check_version            gtk+-2.0  2.0.1  ; ac_gtk_version_string="$vers"
2111   pkg_check_version         gmodule-2.0  2.0.0
2112   pkg_check_version          libxml-2.0  2.4.6
2113   pkg_check_version        libglade-2.0  1.99.0
2114   pkg_check_version      gdk-pixbuf-2.0  2.0.0
2115   pkg_check_version gdk-pixbuf-xlib-2.0  2.0.0
2116   have_gtk="$ok"
2117
2118   if test "$have_gtk" = no; then
2119     if test -n "$ac_gtk_version_string" ; then
2120       gtk_halfassed="$ac_gtk_version_string"
2121       gtk_halfassed_lib="$req"
2122     fi
2123   fi
2124
2125   if test "$have_gtk" = yes; then
2126     parse_gtk_version_string
2127     jurassic_gtk=no
2128   fi
2129
2130   if test "$have_gtk" = yes; then
2131     AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
2132                    [ac_cv_gtk_config_cflags=`$pkg_config --cflags $pkgs`])
2133     AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
2134                    [ac_cv_gtk_config_libs=`$pkg_config --libs $pkgs`])
2135   fi
2136   ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
2137   ac_gtk_config_libs=$ac_cv_gtk_config_libs
2138
2139   GTK_EXTRA_OBJS=""
2140   GTK_DATADIR=""
2141   if test "$have_gtk" = yes; then
2142     GTK_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
2143     GTK_DATADIR="$GTK_DATADIR/share"
2144   fi
2145
2146   if test "$have_gtk" = yes; then
2147     INCLUDES="$INCLUDES $ac_gtk_config_cflags"
2148     GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
2149     AC_DEFINE(HAVE_GTK)
2150     AC_DEFINE(HAVE_GTK2)
2151     AC_DEFINE(HAVE_XML)
2152   fi
2153
2154 fi
2155
2156
2157 # Check for the various Gnome help and URL loading programs.
2158 #
2159 if test "$have_gtk" = yes; then
2160   AC_CHECK_PROGS(gnome_open_program,     gnome-open)
2161   AC_CHECK_PROGS(gnome_url_show_program, gnome-url-show)
2162 fi
2163
2164
2165 ###############################################################################
2166 #
2167 #       Check for -lXm.
2168 #
2169 ###############################################################################
2170
2171 have_motif=no
2172 with_motif_req=unspecified
2173 AC_ARG_WITH(motif,[  --with-motif            Use the Motif toolkit for the user interface
2174                           (not recommended.)],
2175   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
2176
2177 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
2178
2179 if test "$with_motif" != yes -a "$with_motif" != no ; then
2180   echo "error: must be yes or no: --with-motif=$with_motif"
2181   exit 1
2182 fi
2183
2184 if test "$with_motif" = yes; then
2185   have_motif=no
2186   AC_CHECK_X_HEADER(Xm/Xm.h,
2187                     [have_motif=yes
2188                      AC_DEFINE(HAVE_MOTIF)
2189                      MOTIF_LIBS="$MOTIF_LIBS -lXm"],,
2190                     [#include <stdlib.h>
2191                      #include <stdio.h>
2192                      #include <X11/Intrinsic.h>])
2193 fi
2194
2195
2196 if test "$have_motif" = yes; then
2197   AC_CHECK_X_HEADER(Xm/ComboBox.h, [AC_DEFINE(HAVE_XMCOMBOBOX)],,
2198                     [#include <stdlib.h>
2199                      #include <stdio.h>
2200                      #include <X11/Intrinsic.h>])
2201 fi
2202
2203
2204 ###############################################################################
2205 #
2206 #       Checking whether Motif is really Lesstif.
2207 #
2208 ###############################################################################
2209
2210 have_lesstif=no
2211 if test "$have_motif" = yes ; then
2212   AC_CACHE_CHECK([whether Motif is really LessTif], 
2213                  ac_cv_have_lesstif,
2214                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
2215                                    [long vers = LesstifVersion;],
2216                                    [ac_cv_have_lesstif=yes],
2217                                    [ac_cv_have_lesstif=no])])
2218   have_lesstif=$ac_cv_have_lesstif
2219 fi
2220
2221
2222 lesstif_version=unknown
2223 lesstif_version_string=unknown
2224
2225 if test "$have_lesstif" = yes ; then
2226   ltv=unknown
2227   echo unknown > conftest-lt
2228   AC_CACHE_CHECK([LessTif version number],
2229                  ac_cv_lesstif_version_string,
2230       [AC_TRY_X_RUN([#include <stdio.h>
2231                      #include <Xm/Xm.h>
2232                      int main() {
2233                        FILE *f = fopen("conftest-lt", "w");
2234                        if (!f) exit(1);
2235                        fprintf(f, "%d %d.%d\n", LesstifVersion,
2236                           LESSTIF_VERSION, LESSTIF_REVISION);
2237                        fclose(f);
2238                        exit(0);
2239                      }],
2240                     [ltv=`cat conftest-lt`
2241                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
2242                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
2243                     [ac_cv_lesstif_version=unknown
2244                      ac_cv_lesstif_version_string=unknown],
2245                     [ac_cv_lesstif_version=unknown
2246                      ac_cv_lesstif_version_string=unknown])])
2247   rm -f conftest-lt
2248   lesstif_version=$ac_cv_lesstif_version
2249   lesstif_version_string=$ac_cv_lesstif_version_string
2250
2251 fi
2252
2253
2254 if test "$have_motif" = yes ; then
2255   mtv=unknown
2256   echo unknown > conftest-mt
2257   AC_CACHE_CHECK([Motif version number],
2258                  ac_cv_motif_version_string,
2259       [AC_TRY_X_RUN([#include <stdio.h>
2260                      #include <Xm/Xm.h>
2261                      int main() {
2262                        FILE *f = fopen("conftest-mt", "w");
2263                        if (!f) exit(1);
2264                        fprintf(f, "%d %d.%d\n", XmVersion,
2265                           XmVERSION, XmREVISION);
2266                        fclose(f);
2267                        exit(0);
2268                      }],
2269                     [mtv=`cat conftest-mt`
2270                      ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
2271                      ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
2272                     [ac_cv_motif_version=unknown
2273                      ac_cv_motif_version_string=unknown],
2274                     [ac_cv_motif_version=unknown
2275                      ac_cv_motif_version_string=unknown])])
2276   rm -f conftest-mt
2277   motif_version=$ac_cv_motif_version
2278   motif_version_string=$ac_cv_motif_version_string
2279
2280 fi
2281
2282
2283 ###############################################################################
2284 #
2285 #       Checking whether Motif requires -lXpm.
2286 #
2287 #       If this is Motif 2.x, and we have XPM, then link against XPM as well.
2288 #       The deal is, Motif 2.x requires XPM -- but it's a compilation option
2289 #       of the library whether to build the XPM code into libXm, or whether
2290 #       to rely on an external libXm.  So the only way to tell whether XPM is
2291 #       a link-time requirement is to examine libXm.a, which is very
2292 #       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
2293 #       always link against XPM if the XPM lib exists (and this will be a
2294 #       no-op if libXm happens to already have the XPM code in it.)
2295 #
2296 ###############################################################################
2297
2298 motif_requires_xpm=no
2299 if test "$have_motif" = yes ; then
2300    AC_MSG_CHECKING(whether Motif requires XPM)
2301    if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
2302    then
2303      motif_requires_xpm=yes
2304      AC_MSG_RESULT(maybe)
2305    else
2306      AC_MSG_RESULT(no)
2307    fi
2308 fi
2309
2310
2311 ###############################################################################
2312 #
2313 #       Checking whether Motif requires -lXp.
2314 #
2315 #       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
2316 #       Extension".   Why this extension isn't in -lXext with all the others,
2317 #       I have no idea.
2318 #
2319 ###############################################################################
2320
2321 have_xp_ext=no
2322 if test "$have_motif" = yes ; then
2323    have_xp_ext=no
2324    AC_CHECK_X_LIB(Xp, XpQueryExtension,
2325                   [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
2326                   [true], -lX11 -lXext -lm)
2327 fi
2328
2329
2330 ###############################################################################
2331 #
2332 #       Checking whether Motif requires -lXintl (for _Xsetlocale.)
2333 #
2334 ###############################################################################
2335
2336 have_xintl=no
2337 if test "$have_motif" = yes ; then
2338   AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
2339                  -lX11 -lXext -lm)
2340   if test "$have_xintl" = yes; then
2341     MOTIF_LIBS="$MOTIF_LIBS -lXintl"
2342   fi
2343 fi
2344
2345
2346 ###############################################################################
2347 #
2348 #       Check for -lGL or -lMesaGL.
2349 #
2350 ###############################################################################
2351
2352 have_gl=no
2353 ac_have_mesa_gl=no
2354 with_gl_req=unspecified
2355 gl_halfassed=no
2356 AC_ARG_WITH(gl,[
2357 Graphics options:
2358
2359   --with-gl               Build those demos which depend on OpenGL.],
2360   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
2361
2362 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
2363
2364 ac_mesagl_version=unknown
2365 ac_mesagl_version_string=unknown
2366
2367 if test "$with_gl" = yes; then
2368   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
2369   if test "$have_gl" = yes ; then
2370     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no,
2371                       [#include <GL/gl.h>])
2372   fi
2373
2374   # If we have the headers, try and figure out which vendor it's from.
2375   #
2376   if test "$have_gl" = yes ; then
2377
2378     # We need to know whether it's MesaGL so that we know which libraries
2379     # to link against.
2380     #
2381     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
2382       [ac_cv_have_mesa_gl=no
2383        AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
2384       ])
2385     ac_have_mesa_gl=$ac_cv_have_mesa_gl
2386  
2387
2388     gl_lib_1=""
2389     GL_LIBS=""
2390
2391
2392     # Some versions of MesaGL are compiled to require -lpthread.
2393     # So if the Mesa headers exist, and -lpthread exists, then always
2394     # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
2395     #
2396     if test "$ac_have_mesa_gl" = yes; then
2397       AC_CHECK_LIB(pthread, pthread_create, [GL_LIBS="-lpthread"], [],)
2398     fi
2399
2400
2401     # If we have Mesa headers, check to see if we can link against -lMesaGL.
2402     # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
2403     # Else, warn that GL is busted.  (We have the headers, but no libs.)
2404     #
2405
2406     if test "$ac_have_mesa_gl" = yes ; then
2407       AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
2408                      [gl_lib_1="MesaGL"
2409                       GL_LIBS="-lMesaGL -lMesaGLU $VIDMODE_LIBS $GL_LIBS"],
2410                      [], -lMesaGLU $GL_LIBS -lX11 -lXext $VIDMODE_LIBS -lm)
2411     fi
2412
2413     if test "$gl_lib_1" = "" ; then
2414       AC_CHECK_X_LIB(GL, glXCreateContext, 
2415                      [gl_lib_1="GL"
2416                       GL_LIBS="-lGL -lGLU $VIDMODE_LIBS $GL_LIBS"],
2417                      [], -lGLU $GL_LIBS -lX11 -lXext $VIDMODE_LIBS -lm)
2418     fi
2419
2420     if test "$gl_lib_1" = "" ; then
2421       # we have headers, but no libs -- bail.
2422       have_gl=no
2423       ac_have_mesa_gl=no
2424       gl_halfassed=yes
2425     else
2426       # linking works -- we can build the GL hacks.
2427       AC_DEFINE(HAVE_GL)
2428       if test "$ac_have_mesa_gl" = yes ; then
2429         AC_DEFINE(HAVE_MESA_GL)
2430       fi
2431     fi
2432   fi
2433
2434
2435   # Now that we know we have GL headers and libs, do some more GL testing.
2436   #
2437
2438   if test "$have_gl" = yes ; then
2439     # If it's MesaGL, we'd like to issue a warning if the version number
2440     # is less than or equal to 2.6, because that version had a security bug.
2441     #
2442     if test "$ac_have_mesa_gl" = yes; then
2443
2444       AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
2445         [cat > conftest.$ac_ext <<EOF
2446 #line __oline__ "configure"
2447 #include "confdefs.h"
2448 #include <GL/gl.h>
2449 #ifndef MESA_MAJOR_VERSION
2450 # include <GL/xmesa.h>
2451 # ifdef XMESA_MAJOR_VERSION
2452    /* Around Mesa 3.2, they took out the Mesa version number, so instead,
2453       we have to check the XMesa version number (the number of the X protocol
2454       support, which seems to be the same as the Mesa version number.)
2455     */
2456 #  define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
2457 #  define MESA_MINOR_VERSION XMESA_MINOR_VERSION
2458 # else
2459    /* Oh great.  Some time after 3.4, they took out the xmesa.h header file,
2460       so we have no way of telling what version of Mesa this is at all.
2461       So, we'll guess that the osmesa version (the "offscreen protocol")
2462       is less than or equal to the real mesa version number.  Except that
2463       if OSmesa is 3.3, assume at least Mesa 3.4, since OSmesa was 3.3 in
2464       Mesa 3.4.  And Mesa 3.3 had xmesa.h.  What a complete load of shit!
2465     */
2466 # include <GL/osmesa.h>
2467 #  define MESA_MAJOR_VERSION OSMESA_MAJOR_VERSION
2468 #  define MESA_MINOR_VERSION OSMESA_MINOR_VERSION or newer, probably?
2469 #  if OSMESA_MAJOR_VERSION == 3 && OSMESA_MINOR_VERSION == 3
2470 #   undef MESA_MINOR_VERSION
2471 #   define MESA_MINOR_VERSION 4 or newer, probably?
2472 #  endif
2473 # endif
2474 #endif
2475 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
2476 EOF
2477
2478          ac_save_CPPFLAGS="$CPPFLAGS"
2479          if test \! -z "$includedir" ; then 
2480            CPPFLAGS="$CPPFLAGS -I$includedir"
2481          fi
2482          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2483
2484          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | grep configure:`
2485
2486          # M4 sucks!!
2487          changequote(X,Y)
2488           mglv=`echo "$mglv" | sed -n \
2489              's/^configure: *\([0-9][0-9]*\)  *\([0-9].*\)$/\1.\2/p'`
2490          changequote([,])
2491
2492          rm -f conftest.$ac_ext
2493
2494          CPPFLAGS="$ac_save_CPPFLAGS"
2495
2496          if test "$mglv" = ""; then
2497            ac_mesagl_version=unknown
2498            ac_mesagl_version_string=unknown
2499          else
2500            ac_mesagl_version_string="$mglv"
2501            # M4 sucks!!
2502            changequote(X,Y)
2503            maj=`echo "$mglv" | sed -n 's/^\([0-9][0-9]*\)\..*$/\1/p'`
2504            min=`echo "$mglv" | sed -n 's/^.*\.\([0-9][0-9]*\).*$/\1/p'`
2505            changequote([,])
2506            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
2507            if test -z "$ac_mesagl_version"; then
2508              ac_mesagl_version=unknown
2509              ac_mesagl_version_string=unknown
2510            fi
2511          fi
2512          ac_cv_mesagl_version=$ac_mesagl_version
2513          ac_cv_mesagl_version_string=$ac_mesagl_version_string
2514       ])
2515       ac_mesagl_version=$ac_cv_mesagl_version
2516       ac_mesagl_version_string=$ac_cv_mesagl_version_string
2517     fi
2518
2519
2520     # Check for OpenGL 1.1 features.
2521     #
2522     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
2523                    [true], $GL_LIBS -lX11 -lXext -lm)
2524   fi
2525
2526 elif test "$with_gl" != no; then
2527   echo "error: must be yes or no: --with-gl=$with_gl"
2528   exit 1
2529 fi
2530
2531
2532 ###############################################################################
2533 #
2534 #       Check for -lgle.
2535 #
2536 ###############################################################################
2537
2538 have_gle=no
2539 with_gle_req=unspecified
2540 gle_halfassed=no
2541 AC_ARG_WITH(gle,
2542 [  --with-gle              Build those demos which depend on GLE
2543                           (the OpenGL "extrusion" library.)],
2544   [with_gle="$withval"; with_gle_req="$withval"],[with_gle=yes])
2545
2546 HANDLE_X_PATH_ARG(with_gle, --with-gle, GLE)
2547
2548 GLE_LIBS=""
2549
2550 if test "$have_gl" = no ; then
2551  true
2552 elif test "$with_gle" = yes; then
2553
2554   AC_CHECK_X_HEADER(GL/gle.h, have_gle3=yes, have_gle3=no,
2555                     [#include <GL/gl.h>])
2556   if test "$have_gle3" = yes ; then
2557     have_gle=yes;
2558   else
2559     AC_CHECK_X_HEADER(GL/gutil.h, have_gle=yes, have_gle=no,
2560                     [#include <GL/gl.h>])
2561     if test "$have_gle" = yes ; then
2562       AC_CHECK_X_HEADER(GL/tube.h, have_gle=yes, have_gle=no,
2563                         [#include <GL/gl.h>])
2564     fi
2565   fi
2566
2567   if test "$have_gle" = yes ; then
2568     have_gle=no
2569     gle_halfassed=yes
2570     AC_CHECK_X_LIB(gle, gleCreateGC, 
2571                    [have_gle=yes; gle_halfassed=no; GLE_LIBS="-lgle"],
2572                    [], $GL_LIBS -lX11 -lXext -lm)
2573   fi
2574   if test "$have_gle" = yes ; then
2575     have_gle=no
2576     gle_halfassed=yes
2577
2578     # sometimes the libmatrix stuff is included in libgle.  look there first.
2579 #
2580 # I don't get it.  For some reason, this test passes on SGI, as if
2581 # uview_direction_d() was in libgle -- but it's not, it's in libmatrix.
2582 # Yet the link is succeeding.  Why???
2583 #
2584 #    AC_CHECK_X_LIB(gle, uview_direction_d, 
2585 #                   [have_gle=yes; gle_halfassed=no],
2586 #                   [], $GL_LIBS -lX11 -lXext -lm)
2587
2588     # As of GLE 3 this is in libgle, and has changed name to uview_direction!
2589     # *sigh*
2590     if test "$have_gle3" = yes ; then
2591       AC_CHECK_X_LIB(gle, uview_direction, 
2592                      [have_gle=yes; gle_halfassed=no],
2593                     [], $GL_LIBS -lX11 -lXext -lm)
2594     fi
2595     # if it wasn't in libgle, then look in libmatrix.
2596     if test "$have_gle" = no ; then
2597       AC_CHECK_X_LIB(matrix, uview_direction_d, 
2598                      [have_gle=yes; gle_halfassed=no;
2599                       GLE_LIBS="$GLE_LIBS -lmatrix"],
2600                     [], $GL_LIBS -lX11 -lXext -lm)
2601     fi
2602   fi
2603
2604   if test "$have_gle" = yes ; then
2605     AC_DEFINE(HAVE_GLE)
2606     if test "$have_gle3" = yes ; then
2607       AC_DEFINE(HAVE_GLE3)
2608     fi
2609   fi
2610
2611 elif test "$with_gle" != no; then
2612   echo "error: must be yes or no: --with-gle=$with_gle"
2613   exit 1
2614
2615 fi
2616
2617
2618 ###############################################################################
2619 #
2620 #       Check for -lgdk_pixbuf.
2621 #       These tests are for gdk_pixbuf usage of the hacks, 
2622 #       not xscreensaver-demo (thus we have to test again to get
2623 #       the libraries right: don't want to pull in all of GTK
2624 #       for the hacks.)
2625 #
2626 ###############################################################################
2627
2628 have_gdk_pixbuf=no
2629 with_gdk_pixbuf_req=unspecified
2630 AC_ARG_WITH(pixbuf,
2631 [  --with-pixbuf           Include support for the GDK-Pixbuf library in some
2632                           demos, which will make it possible for them to read
2633                           GIF, JPEG, and PNG files as well.],
2634   [with_gdk_pixbuf="$withval"; with_gdk_pixbuf_req="$withval"],
2635   [with_gdk_pixbuf=yes])
2636
2637 # if --with-pixbuf=/directory/ was specified, remember that directory so that
2638 # we can also look for the `gdk-pixbuf-config' program in that directory.
2639 case "$with_gdk_pixbuf" in
2640   /*)
2641     gdk_pixbuf_dir="$with_gdk_pixbuf"
2642     ;;
2643   *)
2644     gdk_pixbuf_dir=""
2645     ;;
2646 esac
2647
2648 HANDLE_X_PATH_ARG(with_gdk_pixbuf, --with-pixbuf, GDK_PIXBUF)
2649
2650 if test "$with_gdk_pixbuf" != yes -a "$with_gdk_pixbuf" != no ; then
2651   echo "error: must be yes or no: --with-pixbuf=$with_gdk_pixbuf"
2652   exit 1
2653 fi
2654
2655 if test "$with_gdk_pixbuf" = yes; then
2656   have_gdk_pixbuf=no
2657
2658   pkgs=''
2659   ok="yes"
2660
2661   pkg_check_version gdk-pixbuf-2.0      2.0.0
2662   pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
2663   have_gdk_pixbuf="$ok"
2664
2665   if test "$have_gdk_pixbuf" = yes; then
2666     AC_CACHE_CHECK([for gdk-pixbuf includes], ac_cv_gdk_pixbuf_config_cflags,
2667                [ac_cv_gdk_pixbuf_config_cflags=`$pkg_config --cflags $pkgs`])
2668     AC_CACHE_CHECK([for gdk-pixbuf libs], ac_cv_gdk_pixbuf_config_libs,
2669                [ac_cv_gdk_pixbuf_config_libs=`$pkg_config --libs $pkgs`])
2670   fi
2671   ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
2672   ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
2673
2674
2675   if test "$have_gdk_pixbuf" = yes; then
2676     #
2677     # we appear to have pixbuf; check for headers/libs to be sure.
2678     #
2679     ac_save_gdk_pixbuf_CPPFLAGS="$CPPFLAGS"
2680     CPPFLAGS="$CPPFLAGS $ac_gdk_pixbuf_config_cflags"
2681
2682     have_gdk_pixbuf=no
2683
2684     # check for header A...
2685     AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf.h, [have_gdk_pixbuf=yes])
2686
2687     # if that worked, check for header B...
2688     if test "$have_gdk_pixbuf" = yes; then
2689       have_gdk_pixbuf=no
2690       gdk_pixbuf_halfassed=yes
2691       AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf-xlib.h,
2692                         [have_gdk_pixbuf=yes
2693                          gdk_pixbuf_halfassed=no])
2694
2695       # yay, it has a new name in Gtk 2.x...
2696       if test "$have_gdk_pixbuf" = no; then
2697         have_gdk_pixbuf=no
2698         gdk_pixbuf_halfassed=yes
2699         AC_CHECK_X_HEADER(gdk-pixbuf-xlib/gdk-pixbuf-xlib.h,
2700                           [have_gdk_pixbuf=yes
2701                            gdk_pixbuf_halfassed=no])
2702       fi
2703     fi
2704     CPPFLAGS="$ac_save_gdk_pixbuf_CPPFLAGS"
2705   fi
2706
2707   if test "$have_gdk_pixbuf" = yes; then
2708     # we have the headers, now check for the libraries
2709     have_gdk_pixbuf=no
2710     gdk_pixbuf_halfassed=yes
2711
2712     AC_MSG_RESULT(checking for gdk_pixbuf usability...)
2713
2714     # library A...
2715     AC_CHECK_X_LIB(c, gdk_pixbuf_new_from_file, [have_gdk_pixbuf=yes],,
2716                    $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
2717     # library B...
2718     if test "$have_gdk_pixbuf" = yes; then
2719       have_gdk_pixbuf=no
2720       AC_CHECK_X_LIB(c, gdk_pixbuf_xlib_init,
2721                      [have_gdk_pixbuf=yes
2722                       gdk_pixbuf_halfassed=no],,
2723                      $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
2724     fi
2725   fi
2726
2727   if test "$have_gdk_pixbuf" = yes; then
2728     INCLUDES="$INCLUDES $ac_gdk_pixbuf_config_cflags"
2729     XPM_LIBS="$ac_gdk_pixbuf_config_libs"
2730     AC_DEFINE(HAVE_GDK_PIXBUF)
2731   else
2732     AC_MSG_RESULT(checking for gdk_pixbuf usability... no)
2733   fi
2734 fi
2735
2736
2737 ###############################################################################
2738 #
2739 #       Check for -lXpm.
2740 #
2741 ###############################################################################
2742
2743 have_xpm=no
2744 with_xpm_req=unspecified
2745 AC_ARG_WITH(xpm,
2746 [  --with-xpm              Include support for XPM files in some demos.
2747                           (Not needed if Pixbuf is used.)],
2748   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
2749
2750 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
2751
2752 if test "$with_xpm" = yes; then
2753   AC_CHECK_X_HEADER(X11/xpm.h,
2754                    [have_xpm=yes
2755                     AC_DEFINE(HAVE_XPM)
2756                     XPM_LIBS="-lXpm $XPM_LIBS"],,
2757                     [#include <X11/Xlib.h>])
2758 elif test "$with_xpm" != no; then
2759   echo "error: must be yes or no: --with-xpm=$with_xpm"
2760   exit 1
2761 fi
2762
2763 # See comment near $motif_requires_xpm, above.
2764 # Need to do this here, after both Motif and XPM have been checked for.
2765 #
2766 if test "$have_motif" = yes -a "$have_xpm" = yes ; then
2767   if test "$motif_requires_xpm" = yes ; then
2768     MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
2769   fi
2770 fi
2771
2772
2773 ###############################################################################
2774 #
2775 #       Check for -ljpeg
2776 #
2777 ###############################################################################
2778
2779 have_jpeg=no
2780 with_jpeg_req=unspecified
2781 jpeg_halfassed=no
2782 AC_ARG_WITH(jpeg,
2783 [  --with-jpeg             Include support for the JPEG library.],
2784   [with_jpeg="$withval"; with_jpeg_req="$withval"],
2785   [with_jpeg=yes])
2786
2787 HANDLE_X_PATH_ARG(with_jpeg, --with-jpeg, JPEG)
2788
2789 if test "$with_jpeg" != yes -a "$with_jpeg" != no ; then
2790   echo "error: must be yes or no: --with-jpeg=$with_jpeg"
2791   exit 1
2792 fi
2793
2794 if test "$with_jpeg" = yes; then
2795
2796   have_jpeg=no
2797   AC_CHECK_X_HEADER(jpeglib.h, [have_jpeg=yes])
2798
2799   if test "$have_jpeg" = yes; then
2800     # we have the header, now check for the library
2801     have_jpeg=no
2802     jpeg_halfassed=yes
2803     AC_CHECK_X_LIB(jpeg, jpeg_start_compress,
2804                    [have_jpeg=yes
2805                     jpeg_halfassed=no
2806                     JPEG_LIBS="-ljpeg"
2807                     AC_DEFINE(HAVE_JPEGLIB)])
2808   fi
2809 fi
2810
2811
2812 ###############################################################################
2813 #
2814 #       Check for pty support for 'phosphor'
2815 #
2816 ###############################################################################
2817
2818 PTY_LIBS=
2819 AC_CHECK_HEADERS(pty.h util.h)
2820 AC_CHECK_X_LIB(util, forkpty,
2821                [PTY_LIBS="-lutil"
2822                 AC_DEFINE(HAVE_FORKPTY)])
2823
2824
2825 ###############################################################################
2826 #
2827 #       Check for the XSHM server extension.
2828 #
2829 ###############################################################################
2830
2831 have_xshm=no
2832 with_xshm_req=unspecified
2833 AC_ARG_WITH(xshm-ext,
2834 [  --with-xshm-ext         Include support for the Shared Memory extension.],
2835   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
2836
2837 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
2838
2839 if test "$with_xshm" = yes; then
2840
2841   # first check for Xshm.h.
2842   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes],,
2843                     [#include <X11/Xlib.h>])
2844
2845   # if that succeeded, then check for sys/ipc.h.
2846   if test "$have_xshm" = yes; then
2847     have_xshm=no
2848     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
2849   fi
2850
2851   # if that succeeded, then check for sys/shm.h.
2852   if test "$have_xshm" = yes; then
2853     have_xshm=no
2854     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
2855   fi
2856
2857   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
2858   # to exist, but the library code to not exist.  And even better, the library
2859   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
2860   # lib doesn't exist, give up.  (This lib gets added to X_EXTRA_LIBS, and
2861   # that's not quite right, but close enough.)
2862   #
2863   case "$host" in
2864     *-aix*)
2865       if [ `uname -v` -eq 3 ]; then
2866         have_xshm=no
2867         AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
2868                        [have_xshm=yes; X_EXTRA_LIBS="$X_EXTRA_LIBS -lXextSam"],
2869                        [true], -lX11 -lXext -lm)
2870       fi
2871     ;;
2872   esac
2873
2874   # if that succeeded, then we've really got it.
2875   if test "$have_xshm" = yes; then
2876     AC_DEFINE(HAVE_XSHM_EXTENSION)
2877   fi
2878
2879 elif test "$with_xshm" != no; then
2880   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
2881   exit 1
2882 fi
2883
2884
2885 ###############################################################################
2886 #
2887 #       Check for the DOUBLE-BUFFER server extension.
2888 #
2889 ###############################################################################
2890
2891 have_xdbe=no
2892 with_xdbe_req=unspecified
2893 AC_ARG_WITH(xdbe-ext,
2894 [  --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension.],
2895   [with_xdbe="$withval"; with_xdbe_req="$withval"],[with_xdbe=yes])
2896
2897 HANDLE_X_PATH_ARG(with_xdbe, --with-xdbe-ext, DOUBLE-BUFFER)
2898
2899 if test "$with_xdbe" = yes; then
2900
2901   AC_CHECK_X_HEADER(X11/extensions/Xdbe.h, [have_xdbe=yes],,
2902                     [#include <X11/Xlib.h>])
2903   if test "$have_xdbe" = yes; then
2904     AC_DEFINE(HAVE_DOUBLE_BUFFER_EXTENSION)    
2905   fi
2906
2907 elif test "$with_xdbe" != no; then
2908   echo "error: must be yes or no: --with-xdbe-ext=$with_xshm"
2909   exit 1
2910 fi
2911
2912
2913 ###############################################################################
2914 #
2915 #       Check for the SGI XReadDisplay server extension.
2916 #
2917 #       Note: this has to be down here, rather than up with the other server
2918 #       extension tests, so that the output of `configure --help' is in the
2919 #       right order.  Arrgh!
2920 #
2921 ###############################################################################
2922
2923 have_readdisplay=no
2924 with_readdisplay_req=unspecified
2925 AC_ARG_WITH(readdisplay,
2926 [  --with-readdisplay      Include support for the XReadDisplay extension.],
2927   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
2928   [with_readdisplay=yes])
2929
2930 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
2931
2932 if test "$with_readdisplay" = yes; then
2933   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
2934                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION),,
2935                     [#include <X11/Xlib.h>])
2936 elif test "$with_readdisplay" != no; then
2937   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
2938   exit 1
2939 fi
2940
2941
2942 ###############################################################################
2943 #
2944 #       Check for a directory full of images to use as the default value
2945 #       of the "imageDirectory" preference.
2946 #
2947 ###############################################################################
2948
2949 have_imagedir=no
2950 with_imagedir_req=unspecified
2951
2952 AC_ARG_WITH(image-directory,
2953 [  --with-image-directory=DIR  By default, some screen savers may load
2954                           random images out of this directory.],
2955   [with_imagedir="$withval"; with_imagedir_req="$withval"],
2956   [with_imagedir=yes])
2957 # no HANDLE_X_PATH_ARG for this one
2958
2959 case "$with_imagedir" in
2960   /*)
2961     # absolute path
2962     AC_MSG_CHECKING([for image directory $with_imagedir])
2963     if test -d "$with_imagedir" ; then
2964       AC_MSG_RESULT(yes)
2965     else
2966       AC_MSG_RESULT(no)
2967       with_imagedir=""
2968     fi
2969   ;;
2970   yes)
2971     with_imagedir=""
2972
2973     #### Could use some more defaults here...
2974     for dd in \
2975       "/usr/share/backgrounds/images/"          \
2976       "/usr/share/wallpapers/"                  \
2977       "/Library/Desktop Pictures/"              \
2978     ; do
2979       if test -z "$with_imagedir"; then
2980         AC_MSG_CHECKING([for image directory $dd])
2981         if test -d "$dd" ; then
2982           AC_MSG_RESULT(yes)
2983           with_imagedir="$dd"
2984         else
2985           AC_MSG_RESULT(no)
2986         fi
2987       fi
2988     done
2989
2990   ;;
2991   no)
2992     with_imagedir=""
2993   ;;
2994
2995   *)
2996     echo "error: must be an absolute path: --with-image-directory=$with_imagedir_req"
2997     exit 1
2998   ;;
2999 esac
3000 ac_cv_imagedir="$with_imagedir"
3001
3002 DEFAULT_IMAGES_P='True'
3003 DEFAULT_IMAGE_DIRECTORY="$ac_cv_imagedir"
3004
3005 if test -z "$DEFAULT_IMAGE_DIRECTORY" ; then
3006   DEFAULT_IMAGES_P='False'
3007 fi
3008
3009
3010 ###############################################################################
3011 #
3012 #       Check whether it's ok to install some hacks as setuid (e.g., "sonar")
3013 #       This should be safe, but let's give people the option.
3014 #
3015 ###############################################################################
3016
3017 setuid_hacks_default=no
3018 setuid_hacks="$setuid_hacks_default"
3019 AC_ARG_WITH(setuid-hacks,
3020 [  --with-setuid-hacks     Allow some demos to be installed `setuid root'
3021                           (which is needed in order to ping other hosts.)
3022 ],
3023   [setuid_hacks="$withval"], [setuid_hacks="$setuid_hacks_default"])
3024
3025 HANDLE_X_PATH_ARG(setuid_hacks, --with-setuid-hacks, setuid hacks)
3026
3027 if test "$setuid_hacks" = yes; then
3028   true
3029 elif test "$setuid_hacks" != no; then
3030   echo "error: must be yes or no: --with-setuid-hacks=$setuid_hacks"
3031   exit 1
3032 fi
3033
3034
3035 ###############################################################################
3036 #
3037 #       Done testing.  Now, set up the various -I and -L variables,
3038 #       and decide which GUI program to build by default.
3039 #
3040 ###############################################################################
3041
3042 DEPEND=makedepend
3043 DEPEND_FLAGS=
3044 DEPEND_DEFINES=
3045
3046
3047 if test \! -z "$includedir" ; then 
3048   INCLUDES="$INCLUDES -I$includedir"
3049 fi
3050
3051 if test \! -z "$libdir" ; then
3052   LDFLAGS="$LDFLAGS -L$libdir"
3053 fi
3054
3055
3056 PREFERRED_DEMO_PROGRAM=''
3057 ALL_DEMO_PROGRAMS=
3058 if test "$have_motif" = yes; then
3059   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
3060   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3061 fi
3062 if test "$have_gtk" = yes; then
3063   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
3064   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3065 fi
3066
3067
3068 if test "$have_kerberos" = yes; then
3069   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
3070   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
3071 fi
3072 if test "$have_pam" = yes; then
3073   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
3074   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
3075   INSTALL_PAM="install-pam"
3076 fi
3077 if test "$have_passwd_helper" = yes; then
3078   PASSWD_SRCS="$PASSWD_SRCS \$(PWHELPER_SRCS)"
3079   PASSWD_OBJS="$PASSWD_OBJS \$(PWHELPER_OBJS)"
3080 fi
3081   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
3082   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
3083
3084
3085 if test "$enable_locking" = yes; then
3086   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
3087   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
3088 else
3089   LOCK_SRCS='$(NOLOCK_SRCS_1)'
3090   LOCK_OBJS='$(NOLOCK_OBJS_1)'
3091 fi
3092
3093 if test "$ac_macosx" = yes; then
3094   EXES_OSX='$(EXES_OSX)'
3095   SCRIPTS_OSX='$(SCRIPTS_OSX)'
3096   MEN_OSX='$(MEN_OSX)'
3097 else
3098   EXES_OSX=
3099   SCRIPTS_OSX=
3100   MEN_OSX=
3101 fi
3102
3103
3104 INSTALL_SETUID='$(INSTALL_PROGRAM) $(SUID_FLAGS)'
3105
3106 if test "$need_setuid" = yes; then
3107   NEED_SETUID=yes
3108 else
3109   NEED_SETUID=no
3110 fi
3111
3112 if test "$setuid_hacks" = yes; then
3113   SETUID_HACKS=yes
3114 else
3115   SETUID_HACKS=no
3116 fi
3117
3118 tab='   '
3119 if test "$have_gl" = yes; then
3120   GL_EXES='$(GL_EXES)'
3121   GL_UTIL_EXES='$(GL_UTIL_EXES)'
3122   GL_MEN='$(GL_MEN)'
3123   GL_KLUDGE="${tab}  "
3124 else
3125   GL_KLUDGE="-${tab}  "
3126 fi
3127
3128 if test "$have_gle" = yes; then
3129   GLE_EXES='$(GLE_EXES)'
3130   GLE_KLUDGE="${tab}   "
3131 else
3132   GLE_KLUDGE="-${tab}   "
3133 fi
3134
3135 if test "$have_jpeg" = yes -a "$have_gdk_pixbuf" = yes; then
3136  JPEG_EXES='$(JPEG_EXES)'
3137 fi
3138
3139
3140 # Another substitution in the XScreenSaver.ad.in file:
3141 #
3142 if test "$gnome_open_program" != ''; then
3143   GNOME24=''
3144   GNOME22='!    '
3145   NOGNOME='!    '
3146 elif test "$gnome_url_show_program" != ''; then
3147   GNOME24='!    '
3148   GNOME22=''
3149   NOGNOME='!    '
3150 else
3151   GNOME24='!    '
3152   GNOME22='!    '
3153   NOGNOME=''
3154 fi
3155
3156
3157 # Set PO_DATADIR to something sensible.
3158 #
3159 AC_MSG_CHECKING([for locale directory])
3160 if test -n "$GTK_DATADIR" ; then
3161   PO_DATADIR="$GTK_DATADIR"
3162 elif test "$have_gtk" = yes; then
3163   PO_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
3164   PO_DATADIR="$PO_DATADIR/share"
3165 fi
3166
3167 if test -z "$PO_DATADIR" ; then
3168   #
3169   # #### Total fucking kludge --
3170   # Map /build/prefix/usr/X11R6/share/ to /build/prefix/usr/share/
3171   # but of course we need to expand all the nested variables to do that...
3172   #
3173   dd=$datadir
3174   eval dd=${dd}
3175   eval dd=${dd}
3176   eval dd=${dd}
3177   eval dd=${dd}
3178   eval dd=${dd}
3179   PO_DATADIR=`echo $dd | sed 's@/X11R6/@/@'`
3180 fi
3181
3182 AC_MSG_RESULT($PO_DATADIR/locale)
3183
3184
3185 # canonicalize slashes.
3186 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
3187
3188 # gcc 3.0 likes to issue this warning for every file:
3189 #
3190 # cc1: warning: changing search order for system directory "/usr/local/include"
3191 # cc1: warning:   as it has already been specified as a non-system directory
3192 #
3193 # Yay.  We can only avoid that by deleting "-I${prefix}/include" from the list.
3194 # Which *should* be totally redundant, and thus an ok thing to delete?
3195 #
3196 INCLUDES=`echo "$INCLUDES" | sed 's@ -I${prefix}/include@@g;'`
3197
3198
3199 ###############################################################################
3200 #
3201 #       Perform substitutions and write Makefiles.
3202 #
3203 ###############################################################################
3204
3205 AC_SUBST(INCLUDES)
3206
3207 AC_SUBST(PREFERRED_DEMO_PROGRAM)
3208 AC_SUBST(ALL_DEMO_PROGRAMS)
3209 AC_SUBST(SAVER_LIBS)
3210 AC_SUBST(MOTIF_LIBS)
3211 AC_SUBST(GTK_LIBS)
3212 AC_SUBST(XML_LIBS)
3213 AC_SUBST(JPEG_LIBS)
3214 AC_SUBST(HACK_LIBS)
3215 AC_SUBST(XPM_LIBS)
3216 AC_SUBST(PTY_LIBS)
3217 AC_SUBST(GL_LIBS)
3218 AC_SUBST(GLE_LIBS)
3219 AC_SUBST(XDPMS_LIBS)
3220 AC_SUBST(XINERAMA_LIBS)
3221 AC_SUBST(PASSWD_LIBS)
3222 AC_SUBST(INSTALL_SETUID)
3223 AC_SUBST(SETUID_HACKS)
3224 AC_SUBST(INSTALL_DIRS)
3225 AC_SUBST(NEED_SETUID)
3226 AC_SUBST(INSTALL_PAM)
3227 AC_SUBST(NEW_LOGIN_COMMAND)
3228 AC_SUBST(NEW_LOGIN_COMMAND_P)
3229 AC_SUBST(DEFAULT_IMAGES_P)
3230 AC_SUBST(DEFAULT_IMAGE_DIRECTORY)
3231
3232 AC_SUBST(OBJCC)
3233 AC_SUBST(EXES_OSX)
3234 AC_SUBST(SCRIPTS_OSX)
3235 AC_SUBST(MEN_OSX)
3236
3237 AC_SUBST(PASSWD_SRCS)
3238 AC_SUBST(PASSWD_OBJS)
3239 AC_SUBST(XMU_SRCS)
3240 AC_SUBST(XMU_OBJS)
3241 AC_SUBST(XMU_LIBS)
3242 AC_SUBST(SAVER_GL_SRCS)
3243 AC_SUBST(SAVER_GL_OBJS)
3244 AC_SUBST(SAVER_GL_LIBS)
3245 AC_SUBST(LOCK_SRCS)
3246 AC_SUBST(LOCK_OBJS)
3247 AC_SUBST(JPEG_EXES)
3248 AC_SUBST(GL_EXES)
3249 AC_SUBST(GL_UTIL_EXES)
3250 AC_SUBST(GL_MEN)
3251 AC_SUBST(GL_KLUDGE)
3252 AC_SUBST(GLE_EXES)
3253 AC_SUBST(GLE_KLUDGE)
3254 AC_SUBST(GNOME24)
3255 AC_SUBST(GNOME22)
3256 AC_SUBST(NOGNOME)
3257 AC_SUBST(HACKDIR)
3258 AC_SUBST(GTK_DATADIR)
3259 AC_SUBST(PO_DATADIR)
3260 AC_SUBST(HACK_CONF_DIR)
3261 AC_SUBST(GTK_EXTRA_OBJS)
3262
3263 APPDEFAULTS=$ac_x_app_defaults
3264 AC_SUBST(APPDEFAULTS)
3265
3266 AC_SUBST(DEPEND)
3267 AC_SUBST(DEPEND_FLAGS)
3268 AC_SUBST(DEPEND_DEFINES)
3269 AC_SUBST(PERL)
3270
3271 AC_OUTPUT(Makefile
3272           utils/Makefile
3273           driver/Makefile
3274           hacks/Makefile
3275           hacks/glx/Makefile
3276           po/Makefile.in
3277           driver/XScreenSaver.ad)
3278
3279 ###############################################################################
3280 #
3281 #       Print some warnings at the end.
3282 #
3283 ###############################################################################
3284
3285 warn_prefix_1="    Warning:"
3286 warn_prefix_2="       Note:"
3287 warn_prefix="$warn_prefix_1"
3288
3289 warning=no
3290 warnsep='    #################################################################'
3291
3292 warnpre() {
3293   if test "$warning" = no ; then
3294     echo '' ; echo "$warnsep" ; echo ''
3295     warning=yes
3296   fi
3297 }
3298
3299 warn() {
3300   warnpre
3301   if test "$warning" = long ; then echo '' ; fi
3302   warning=yes
3303   rest="$@"
3304   echo "$warn_prefix $rest"
3305 }
3306
3307 warnL() {
3308   was=$warning
3309   warnpre
3310   warning=yes
3311   if test "$was" != no ; then echo '' ; fi
3312   rest="$@"
3313   echo "$warn_prefix $rest"
3314 }
3315
3316 warn2() {
3317   rest="$@"
3318   echo "             $rest"
3319   warning=long
3320 }
3321
3322 note() {
3323   warn_prefix="$warn_prefix_2"
3324   warn $@
3325   warn_prefix="$warn_prefix_1"
3326 }
3327
3328 noteL() {
3329   warn_prefix="$warn_prefix_2"
3330   warnL $@
3331   warn_prefix="$warn_prefix_1"
3332 }
3333
3334
3335 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
3336   warn 'The SGI saver extension was requested, but was not found.'
3337 fi
3338
3339 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
3340   warn 'The XIdle extension was requested, but was not found.'
3341 fi
3342
3343 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
3344   warn 'The XSHM extension was requested, but was not found.'
3345 fi
3346
3347 if test "$with_xdbe_req" = yes -a "$have_xdbe" = no ; then
3348   warn 'The DOUBLE-BUFFER extension was requested, but was not found.'
3349 fi
3350
3351 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
3352   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
3353 fi
3354
3355 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
3356   warn 'The DPMS extension was requested, but was not found.'
3357 fi
3358
3359 if test "$with_xinerama_req" = yes -a "$have_xinerama" = no ; then
3360   warn 'The Xinerama extension was requested, but was not found.'
3361 fi
3362
3363 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
3364   warn 'The XF86VMODE extension was requested, but was not found.'
3365 fi
3366
3367 if test "$with_randr_req" = yes -a "$have_randr" = no ; then
3368   warn 'The RANDR extension was requested, but was not found.'
3369 fi
3370
3371 if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
3372   warn "Checking of /proc/interrupts was requested, but it's bogus."
3373 fi
3374
3375 if test "$pkg_config" = false ; then
3376   warnL 'The "pkg-config" program was not found.  Without that,'
3377   warn2 "detection of the various GTK libraries won't work."
3378 else
3379   pkgerr=`$pkg_config --list-all 2>&1 >/dev/null`
3380   if test "x$pkgerr" != "x" ; then
3381     warnL 'The "pkg-config" program produces errors.  This often causes'
3382     warn2 "detection of the various GTK libraries to malfunction."
3383     warn2 "The errors are:"
3384     echo ''
3385     echo "$pkgerr" | sed 's/^/             > /g'
3386   fi
3387 fi
3388
3389 if test "$gtk_halfassed" != no ; then
3390   warnL "GTK version $gtk_halfassed was found, but at least one supporting"
3391   warn2 "library ($gtk_halfassed_lib) was not, so GTK can't be used."
3392   warn2 "Perhaps some of the development packages are not installed?"
3393   if test "$have_gtk" = yes ; then
3394     v="$ac_gtk_version_string"
3395     warn2 "GTK $v is also installed, so it will be used instead."
3396     warn2 "Please read the above output and the \`config.log' file"
3397     warn2 "for more details."
3398   fi
3399 fi
3400
3401 motif_warn2() {
3402   warn2 'Though the Motif front-end to xscreensaver is still'
3403   warn2 'maintained, it is no longer being updated with new'
3404   warn2 'features: all new development on the xscreensaver-demo'
3405   warn2 'program is happening in the GTK version, and not in the'
3406   warn2 'Motif version.  It is recommended that you build against'
3407   warn2 'GTK instead of Motif.  See <http://www.gtk.org/>.'
3408 }
3409
3410 if test "$have_motif" = no -a "$have_gtk" = no; then
3411
3412   if test "$with_motif" = yes; then
3413     warnL "Neither the GTK nor Motif libraries were found; the"
3414     warn2 "\`xscreensaver-demo' program requires one of these."
3415     echo ''
3416     motif_warn2
3417   else
3418     warnL "The GTK libraries do not seem to be available; the"
3419     warn2 "\`xscreensaver-demo' program requires them."
3420 #   echo ''
3421 #   warn2 'You can use Motif or Lesstif instead of GTK (use the'
3422 #   warn2 "\`--with-motif' option) but that is NOT recommended."
3423 #   motif_warn2
3424   fi
3425
3426 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
3427   warnL "Use of Motif was requested, but it wasn't found;"
3428   warn2 "Gtk will be used instead."
3429
3430 elif test "$jurassic_gtk" = yes ; then
3431
3432   pref_gtk=2.0
3433
3434   v="$ac_gtk_version_string"
3435   if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
3436     warnL "Use of Gtk was requested, but its version number is unknown;"
3437   elif test "$with_gtk_req" = yes ; then
3438     warnL "Use of Gtk was requested, but it is version $v;"
3439   else
3440     warnL "Gtk was found on this system, but it is version $v;"
3441   fi
3442
3443   warn2 "Gtk $pref_gtk or newer is required."
3444
3445 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
3446   warnL "Use of Gtk was requested, but it wasn't found."
3447 fi
3448
3449
3450 if test "$have_gtk" = yes -a "$have_gdk_pixbuf" = no ; then
3451   warn  "GTK is being used, but the GDK-Pixbuf library and/or"
3452   warn2 "headers were not found.  That can't be good.  Please"
3453   warn2 "install the GDK-Pixbuf development kit and re-configure."
3454 fi
3455
3456 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
3457
3458   preferred_lesstif=0.92
3459
3460   if test "$lesstif_version" = unknown; then
3461     warnL "Unable to determine the LessTif version number!"
3462     warn2 "Make sure you are using version $preferred_lesstif or newer."
3463     warn2 "See <http://www.lesstif.org/>."
3464
3465   elif test \! $lesstif_version -gt 82; then
3466     warnL "LessTif version $lesstif_version_string is being used."
3467     warn2 "LessTif versions 0.82 and earlier are too buggy to"
3468     warn2 "use with XScreenSaver; it is strongly recommended"
3469     warn2 "that you upgrade to at least version $preferred_lesstif!"
3470     warn2 "See <http://www.lesstif.org/>."
3471   fi
3472 fi
3473
3474
3475 if test "$have_motif" = yes -a "$have_gtk" = no ; then
3476   warn  'Motif is being used, and GTK is not.'
3477   echo  ''
3478   motif_warn2
3479 fi
3480
3481
3482 if test "$with_xpm_req" = yes -a "$have_xpm" = no; then
3483   warnL 'Use of XPM was requested, but it was not found.'
3484 fi
3485
3486 if test "$with_gdk_pixbuf_req" = yes  -a "$have_gdk_pixbuf" = no; then
3487   warnL 'Use of GDK-Pixbuf was requested, but it was not found.'
3488 fi
3489
3490 if test "$have_gdk_pixbuf" = no -o "$gdk_pixbuf_halfassed" = yes || \
3491    test "$have_gdk_pixbuf" = no -a "$have_xpm" = no ; then
3492
3493   if test "$with_gdk_pixbuf_req" = yes ; then
3494     true
3495   elif test "$with_gdk_pixbuf_req" = no ; then
3496     warnL 'The GDK-Pixbuf library is not being used.'
3497   else
3498     warnL 'The GDK-Pixbuf library was not found.'
3499   fi
3500
3501   if test "$with_xpm_req" = yes -o "$have_xpm" = yes ; then
3502     true
3503   elif test "$with_xpm_req" = no ; then
3504     warnL 'The XPM library is not being used.'
3505   else
3506     warnL 'The XPM library was not found.'
3507   fi
3508
3509   if test "$have_gdk_pixbuf" = no -a "$have_xpm" = yes ; then
3510     warn2 'The XPM library is being used instead.'
3511   fi
3512
3513   if test "$gdk_pixbuf_halfassed" = yes ; then
3514     echo ''
3515     warn2 'More specifically, we found the headers, but not the'
3516     warn2 'libraries; so either GDK-Pixbuf is half-installed on this'
3517     warn2 "system, or something else went wrong.  The \`config.log'"
3518     warn2 'file might contain some clues.'
3519   fi
3520
3521   echo ''
3522   warn2 'Some of the demos will not use images as much as they could.'
3523   warn2 'You should consider installing GDK-Pixbuf and re-running'
3524   warn2 'configure.  (GDK-Pixbuf is recommended over XPM, as it'
3525   warn2 'provides support for more image formats.)'
3526 fi
3527
3528
3529 if test "$have_jpeg" = no ; then
3530   if test "$with_jpeg_req" = yes ; then
3531     warnL 'Use of libjpeg was requested, but it was not found.'
3532   elif test "$with_jpeg_req" = no ; then
3533     noteL 'The JPEG library is not being used.'
3534   else
3535     noteL 'The JPEG library was not found.'
3536   fi
3537
3538   if test "$jpeg_halfassed" = yes ; then
3539     echo ''
3540     warn2 'More specifically, we found the headers, but not the'
3541     warn2 'library; so either JPEG is half-installed on this'
3542     warn2 "system, or something else went wrong.  The \`config.log'"
3543     warn2 'file might contain some clues.'
3544     echo ''
3545   fi
3546
3547   if test "$have_gdk_pixbuf" = no ; then
3548     warn2 "This means that it won't be possible for the image-manipulating"
3549     warn2 "display modes to load files from disk; and it also means that"
3550     warn2 "the \`webcollage' program will be much slower."
3551   else
3552     warn2 "This means the \`webcollage' program will be much slower."
3553   fi
3554 fi
3555
3556
3557 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
3558   preferred_mesagl=3.4
3559   mgv="$ac_mesagl_version_string"
3560   pgl="$preferred_mesagl"
3561
3562   if test "$ac_mesagl_version" = unknown; then
3563     warnL "Unable to determine the MesaGL version number!"
3564     warn2 "Make sure you are using version $preferred_mesagl or newer."
3565
3566   elif test \! "$ac_mesagl_version" -gt 2006; then
3567     warnL "MesaGL version number is $mgv --"
3568     warn2 "MesaGL 2.6 and earlier have a security bug.  It is strongly"
3569     warn2 "recommended that you upgrade to at least version $preferred_mesagl."
3570
3571   elif test \! "$ac_mesagl_version" -gt 3003; then
3572     warnL "MesaGL version number is $mgv --"
3573     warn2 "MesaGL 3.3 and earlier have some bugs; it is recommended"
3574     warn2 "that you upgrade to $pgl or newer."
3575   fi
3576 fi
3577
3578 if test "$have_gl" = no ; then
3579   if test "$with_gl_req" = yes ; then
3580     warnL 'Use of GL was requested, but it was not found.'
3581   elif test "$with_gl_req" = no ; then
3582     noteL 'The OpenGL 3D library is not being used.'
3583   else
3584     noteL 'The OpenGL 3D library was not found.'
3585   fi
3586
3587   if test "$gl_halfassed" = yes ; then
3588     echo ''
3589     warn2 'More specifically, we found the headers, but not the'
3590     warn2 'libraries; so either GL is half-installed on this'
3591     warn2 "system, or something else went wrong.  The \`config.log'"
3592     warn2 'file might contain some clues.'
3593   fi
3594
3595   echo ''
3596   warn2 'Those demos which use 3D will not be built or installed.'
3597   warn2 'You might want to consider installing OpenGL and'
3598   warn2 "re-running configure.  If your vendor doesn't ship"
3599   warn2 'their own implementation of OpenGL, you can get a free'
3600   warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
3601   warn2 'info, see <http://www.opengl.org/>.'
3602
3603 fi
3604
3605
3606 if test "$have_gl" = yes -a "$have_gle" = no ; then
3607
3608  # nobody cares about this; don't print the warning unless it was
3609  # requested and not found, or halfway-found.
3610  if test "$with_gle_req" = yes -o "$gle_halfassed" = yes ; then
3611
3612   if test "$with_gle_req" = yes ; then
3613     noteL 'Use of the GLE (GL Extrusion) library was requested, but'
3614     warn2 'it was not found (though the OpenGL library was found, and'
3615     warn2 'is being used.)'
3616   elif test "$with_gle_req" = no ; then
3617     noteL 'The OpenGL Library is being used, but the GLE (GL Extrusion)'
3618     warn2 'library is not.'
3619   else
3620     noteL 'The OpenGL Library was found, but the GLE (GL Extrusion)'
3621     warn2 'was not.'
3622   fi
3623
3624   if test "$gle_halfassed" = yes ; then
3625     echo ''
3626     warn2 'More specifically, we found the headers, but not the'
3627     warn2 'libraries; so either GLE is half-installed on this'
3628     warn2 "system, or something else went wrong.  The \`config.log'"
3629     warn2 'file might contain some clues.'
3630   fi
3631
3632   echo ''
3633   warn2 'Some of the OpenGL (3D) demos (those that depend on GLE)'
3634   warn2 'will not be built or installed.  You might want to consider'
3635   warn2 'installing GLE and re-running configure.  You can find the'
3636   warn2 'GLE library at <http://www.linas.org/gle/>.  For general'
3637   warn2 'OpenGL info, see <http://www.opengl.org/>.'
3638
3639  fi
3640 fi
3641
3642
3643 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
3644   warn 'Use of XReadDisplay was requested, but it was not found.'
3645 fi
3646
3647 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
3648   warn 'Use of Kerberos was requested, but it was not found.'
3649 fi
3650
3651 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
3652   warn 'Use of PAM was requested, but it was not found.'
3653 fi
3654
3655 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
3656   warn 'Use of shadow passwords was requested, but they were not found.'
3657 fi
3658
3659
3660 # You are in a twisty maze of namespaces and syntaxes, all alike.
3661 # Fuck the skull of Unix.
3662 #
3663 eval bindir=${bindir}
3664 eval bindir=${bindir}
3665 eval bindir=${bindir}
3666 eval bindir=${bindir}
3667 eval bindir=${bindir}
3668 eval bindir=${bindir}
3669 eval HACKDIR=${HACKDIR}
3670 eval HACKDIR=${HACKDIR}
3671 eval HACKDIR=${HACKDIR}
3672 eval HACKDIR=${HACKDIR}
3673 eval HACKDIR=${HACKDIR}
3674 eval HACKDIR=${HACKDIR}
3675 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3676 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3677 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3678 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3679 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3680 eval HACK_CONF_DIR=${HACK_CONF_DIR}
3681
3682 # canonicalize slashes.
3683 bindir=`echo  "${bindir}"              | sed 's@/$@@;s@//*@/@g'`
3684 HACKDIR=`echo "${HACKDIR}"             | sed 's@/$@@;s@//*@/@g'`
3685 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
3686
3687
3688 # Sanity check the hackdir
3689 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
3690   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
3691     echo ""
3692     AC_MSG_ERROR([\"--with-hackdir=${bindir}/${bad_choice}\" won't work.
3693                    There will be an executable installed with that name, so
3694                    that can't be the name of a directory as well.  Please
3695                    re-configure with a different directory name.])
3696   fi
3697 done
3698
3699
3700 do_dir_warning=no
3701
3702 # Now let's warn if there's a previous RPM version already installed.
3703 # But don't bother with this test if we are currently *building* an RPM.
3704
3705 if test -z "$RPM_PACKAGE_VERSION" ; then
3706
3707   rpmnames="xscreensaver xscreensaver-base xscreensaver-extras"
3708
3709   # M4 sucks!!
3710   changequote(X,Y)
3711   rpmv=`(rpm -qv $rpmnames) 2>/dev/null | \
3712         sed -n 's/^[-a-z]*-\([0-9][0-9]*[.][0-9][0-9a-z]*\)-.*$/\1/p' | \
3713         head -1`
3714   changequote([,])
3715
3716   if test \! -z "$rpmv" ; then
3717     rpmbdir=`rpm -ql $rpmnames | sed -n 's@^\(.*\)/xscreensaver-demo$@\1@p'`
3718     rpmhdir=`rpm -ql $rpmnames | sed -n 's@^\(.*\)/attraction$@\1@p'`
3719
3720     warning=no
3721     warnL "There is already an installed RPM of xscreensaver $rpmv"
3722     warn2 'on this system.  You might want to remove it ("rpm -ve")'
3723     warn2 'before running "make install" in this directory.'
3724     echo ""
3725     warn2 "Alternately, you could build this version of xscreensaver"
3726     warn2 'as an RPM, and then install that.  An "xscreensaver.spec"'
3727     warn2 'file is included.  Try "rpmbuild -v -ba xscreensaver.spec".'
3728     warn2 "See the RPM documentation for more info."
3729     echo ""
3730
3731     if test "$rpmbdir" = "$rpmhdir" ; then
3732       warn2 "The RPM version was installed in $rpmbdir/."
3733       do_dir_warning=yes
3734     else
3735       warn2 "The RPM version was installed in $rpmbdir/,"
3736       warn2 "with demos in $rpmhdir/."
3737     fi
3738   fi
3739 fi
3740
3741 if test "${bindir}" = "${HACKDIR}" ; then
3742   do_dir_warning=yes
3743 fi
3744
3745 if test "$do_dir_warning" = yes; then
3746   echo ""
3747   echo "$warnsep"
3748   echo ""
3749   echo '      When you run "make install", the "xscreensaver",'
3750   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
3751   echo "      will be installed in ${bindir}/."
3752   echo ""
3753   echo "      The various graphics demos (190+ different executables) will"
3754   echo "      be installed in ${HACKDIR}/."
3755   echo ""
3756   echo "      If you would prefer the demos to be installed elsewhere,"
3757   echo "      you should re-run configure with the --with-hackdir=DIR"
3758   echo "      option.  For more information, run \`./configure --help'."
3759   warning=yes
3760 fi
3761
3762 if test "$warning" != no; then
3763   echo '' ; echo "$warnsep" ; echo ''
3764 fi
3765
3766 if test "$do_dir_warning" = no; then
3767   if test "$warning" = no; then
3768     echo ''
3769   fi
3770   echo "User programs will be installed in ${bindir}/"
3771   echo "Screen savers will be installed in ${HACKDIR}/"
3772   echo "Configuration will be installed in ${HACK_CONF_DIR}/"
3773   echo ''
3774 fi