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