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