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