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