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