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