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