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