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