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