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