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