7889de45e9d4af2f13b630688f2caa84773db59c
[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
1148 ###############################################################################
1149 #
1150 #       Gettext support
1151 #
1152 ###############################################################################
1153
1154 AC_PROG_INTLTOOL
1155 GETTEXT_PACKAGE=xscreensaver
1156 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
1157                    [This is the name of the gettext package to use.])
1158 AC_DEFINE_UNQUOTED(PACKAGE, "$GETTEXT_PACKAGE",
1159                    [This is the same as GETTEXT_PACKAGE, but for the glade
1160                    generated code.])
1161 AC_SUBST(GETTEXT_PACKAGE)
1162
1163 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"
1164 AM_GLIB_GNU_GETTEXT
1165 MKINSTALLDIRS="$INSTALL_DIRS"
1166
1167
1168 ###############################################################################
1169 #
1170 #       Check for -lXmu (some fucked up vendors don't ship it...)
1171 #
1172 ###############################################################################
1173
1174 have_xmu=no
1175 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes],,
1176                   [#include <stdlib.h>
1177                    #include <stdio.h>
1178                    #include <X11/Intrinsic.h>])
1179 if test "$have_xmu" = no ; then
1180   XMU_SRCS='$(UTILS_SRC)/xmu.c'
1181   XMU_OBJS='$(UTILS_BIN)/xmu.o'
1182   XMU_LIBS=''
1183 else
1184   XMU_SRCS=''
1185   XMU_OBJS=''
1186   XMU_LIBS='-lXmu'
1187   AC_DEFINE(HAVE_XMU)
1188 fi
1189
1190
1191 ###############################################################################
1192 #
1193 #       Check for the SunOS 4.1.x _get_wmShellWidgetClass bug.
1194 #       See comp.windows.x FAQ question 124.  The right fix is to
1195 #       get OpenWindows 3.0 patches 100512-02 and 100573-03.
1196 #
1197 ###############################################################################
1198
1199 if test "$have_xmu" = yes ; then
1200   case "$host" in
1201     *-sunos4*)
1202     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
1203                    ac_cv_sunos_xmu_bug,
1204                    [ac_save_LDFLAGS="$LDFLAGS"
1205                     if test \! -z "$x_libraries" ; then
1206                       LDFLAGS="$LDFLAGS -L$x_libraries"
1207                     fi
1208                     # Note: this trick never works!  (Generally.)
1209                     # We're only getting away with using AC_TRY_LINK
1210                     # with X libraries because we know it's SunOS.
1211                     LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
1212                     AC_TRY_LINK(,,
1213                                 [ac_cv_sunos_xmu_bug=no],
1214                                 [ac_cv_sunos_xmu_bug=yes])
1215                     LDFLAGS="$ac_save_LDFLAGS"])
1216     if test "$ac_cv_sunos_xmu_bug" = yes ; then
1217       AC_CACHE_CHECK([whether the compiler understands -static], 
1218                      ac_cv_ld_static,
1219                      [ac_save_LDFLAGS="$LDFLAGS"
1220                       LDFLAGS="$LDFLAGS -static"
1221                       AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
1222                     LDFLAGS="$ac_save_LDFLAGS"])
1223       if test "$ac_cv_ld_static" = yes ; then
1224         LDFLAGS="$LDFLAGS -static"
1225       else
1226         LDFLAGS="$LDFLAGS -Bstatic"
1227       fi
1228     fi
1229     ;;
1230   esac
1231 fi
1232
1233
1234 ###############################################################################
1235 #
1236 #       Handle the --with-hackdir option
1237 #
1238 ###############################################################################
1239
1240 have_hackdir=yes
1241 with_hackdir_req=unspecified
1242 AC_ARG_WITH(hackdir,[
1243
1244 Installation options:
1245   --with-hackdir=DIR      Where to install the hundreds of demo executables.
1246                           Default: `PREFIX/libexec/xscreensaver/'],
1247   [with_hackdir="$withval"; with_hackdir_req="$withval"],[with_hackdir=yes])
1248
1249 if test x"$with_hackdir" = xyes; then
1250   HACKDIR='${libexecdir}/xscreensaver'
1251 elif test x"$with_hackdir" = xno; then
1252   HACKDIR='${bindir}'
1253 else
1254   HACKDIR=$with_hackdir
1255 fi
1256
1257 # canonicalize slashes.
1258 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
1259
1260 # This option used to be called --enable-subdir; make sure that is no longer
1261 # used, since configure brain-damagedly ignores unknown --enable options.
1262
1263 obsolete_enable=
1264 AC_ARG_ENABLE(subdir,,[obsolete_enable=yes])
1265 if test -n "$obsolete_enable"; then
1266   echo "error: the --enable-subdir option has been replaced with"
1267   echo "       the new --with-hackdir option; see \`configure --help'"
1268   echo "       for more information."
1269   exit 1
1270 fi
1271
1272
1273 ###############################################################################
1274 #
1275 #       Handle the --with-configdir option
1276 #
1277 ###############################################################################
1278
1279 have_configdir=yes
1280 with_configdir_req=unspecified
1281 AC_ARG_WITH(configdir,
1282 [  --with-configdir=DIR    Where to install the data files that describe each
1283                           of the display modes to the GUI.
1284                           Default: `PREFIX/share/xscreensaver/config/'
1285 ],
1286   [with_configdir="$withval"; with_configdir_req="$withval"],
1287   [with_configdir=yes])
1288
1289 if test x"$with_configdir" = xyes; then
1290   HACK_CONF_DIR='${datadir}/xscreensaver/config'
1291 elif test x"$with_configdir" = xno; then
1292   echo "error: must be yes, or a pathname: --with-configdir=$with_configdir"
1293   exit 1
1294 else
1295   # there must be a better way than this...
1296   if test -z "`echo $with_configdir | sed 's@^/.*@@'`" ; then
1297     # absolute path
1298     HACK_CONF_DIR=$with_configdir
1299   else
1300     # relative path
1301     HACK_CONF_DIR="\${exec_prefix}$with_configdir"
1302   fi
1303 fi
1304
1305
1306
1307
1308 ###############################################################################
1309 #
1310 #       Check for the SGI SCREEN_SAVER server extension.
1311 #
1312 ###############################################################################
1313
1314 have_sgi=no
1315 with_sgi_req=unspecified
1316 AC_ARG_WITH(sgi-ext,
1317 [Except where noted, all of the --with options below can also take a
1318 directory argument: for example, `--with-motif=/opt/Motif'.  That would
1319 cause /opt/Motif/include/ to be added to the -I list, and /opt/Motif/lib/
1320 to be added to the -L list, assuming those directories exist.  
1321
1322 By default, support for each of these options will be built in, if the
1323 relevant library routines exist.  At run time, they will then be used
1324 only if the X server being used supports them.  Each --with option has
1325 a corresponding --without option, to override building support for them
1326 at all.
1327
1328 Screen blanking and idle-detection options:
1329
1330   --with-sgi-ext          Include support for the SGI SCREEN_SAVER extension.],
1331   [with_sgi="$withval"; with_sgi_req="$withval"],[with_sgi=yes])
1332
1333 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
1334
1335 if test "$with_sgi" = yes; then
1336   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
1337                     [have_sgi=yes
1338                      AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)],,
1339                     [#include <X11/Xlib.h>])
1340
1341 elif test "$with_sgi" != no; then
1342   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
1343   exit 1
1344 fi
1345
1346
1347 ###############################################################################
1348 #
1349 #       Check for the XIDLE server extension.
1350 #
1351 ###############################################################################
1352
1353 have_xidle=no
1354 with_xidle_req=unspecified
1355 AC_ARG_WITH(xidle-ext,
1356 [  --with-xidle-ext        Include support for the XIDLE extension.],
1357   [with_xidle="$withval"; with_xidle_req="$withval"],[with_xidle=yes])
1358
1359 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
1360
1361 if test "$with_xidle" = yes; then
1362   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
1363                     [have_xidle=yes
1364                      AC_DEFINE(HAVE_XIDLE_EXTENSION)],,
1365                     [#include <X11/Xlib.h>])
1366 elif test "$with_xidle" != no; then
1367   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
1368   exit 1
1369 fi
1370
1371
1372 ###############################################################################
1373 #
1374 #       Check for the SGI-VIDEO-CONTROL server extension.
1375 #
1376 ###############################################################################
1377
1378 have_sgivc=no
1379 with_sgivc_req=unspecified
1380 AC_ARG_WITH(sgivc-ext,
1381 [  --with-sgivc-ext        Include support for the SGI-VIDEO-CONTROL extension.],
1382   [with_sgivc="$withval"; with_sgivc_req="$withval"],[with_sgivc=yes])
1383
1384 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
1385
1386 if test "$with_sgivc" = yes; then
1387
1388   # first check for XSGIvc.h
1389   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes],,
1390                     [#include <X11/Xlib.h>])
1391
1392   # if that succeeded, then check for the -lXsgivc
1393   if test "$have_sgivc" = yes; then
1394     have_sgivc=no
1395     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
1396                   [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [true],
1397                   -lXext -lX11)
1398   fi
1399
1400   # if that succeeded, then we've really got it.
1401   if test "$have_sgivc" = yes; then
1402     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
1403   fi
1404
1405 elif test "$with_sgivc" != no; then
1406   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
1407   exit 1
1408 fi
1409
1410
1411 ###############################################################################
1412 #
1413 #       Check for the DPMS server extension.
1414 #
1415 ###############################################################################
1416
1417 have_dpms=no
1418 with_dpms_req=unspecified
1419 AC_ARG_WITH(dpms-ext,
1420 [  --with-dpms-ext         Include support for the DPMS extension.],
1421   [with_dpms="$withval"; with_dpms_req="$withval"],[with_dpms=yes])
1422
1423 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
1424
1425 if test "$with_dpms" = yes; then
1426
1427   # first check for dpms.h
1428   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes],,
1429                     [#include <X11/Xlib.h>
1430                      #include <X11/Xmd.h>])
1431
1432   # if that succeeded, then check for the DPMS code in the libraries
1433   if test "$have_dpms" = yes; then
1434
1435     # first look in -lXext (this is where it is with XFree86 4.0)
1436     have_dpms=no
1437     AC_CHECK_X_LIB(Xext, DPMSInfo, [have_dpms=yes], [true], -lXext -lX11)
1438
1439     # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
1440     if test "$have_dpms" = no; then
1441       AC_CHECK_X_LIB(Xdpms, DPMSInfo,
1442                     [have_dpms=yes; XDPMS_LIBS="-lXdpms"], [true],
1443                     -lXext -lX11)
1444     fi
1445   fi
1446
1447
1448   # if that succeeded, then we've really got it.
1449   if test "$have_dpms" = yes; then
1450     AC_DEFINE(HAVE_DPMS_EXTENSION)
1451   fi
1452
1453 elif test "$with_dpms" != no; then
1454   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
1455   exit 1
1456 fi
1457
1458
1459 ###############################################################################
1460 #
1461 #       Check for the XINERAMA server extension.
1462 #
1463 ###############################################################################
1464
1465 have_xinerama=no
1466 with_xinerama_req=unspecified
1467 AC_ARG_WITH(xinerama-ext,
1468 [  --with-xinerama-ext     Include support for the XINERAMA extension.],
1469   [with_xinerama="$withval"; with_xinerama_req="$withval"],[with_xinerama=yes])
1470
1471 HANDLE_X_PATH_ARG(with_xinerama, --with-xinerama-ext, XINERAMA)
1472
1473 if test "$with_xinerama" = yes; then
1474
1475   # first check for Xinerama.h
1476   AC_CHECK_X_HEADER(X11/extensions/Xinerama.h, [have_xinerama=yes],,
1477                     [#include <X11/Xlib.h>])
1478
1479   # if that succeeded, then check for the XINERAMA code in the libraries
1480   if test "$have_xinerama" = yes; then
1481
1482     # first look in -lXext
1483     have_xinerama=no
1484     AC_CHECK_X_LIB(Xext, XineramaQueryScreens, [have_xinerama=yes], [true],
1485                   -lXext -lX11)
1486
1487     # if that failed, look in -lXinerama (this is where it is in XFree86 4.1.)
1488     if test "$have_xinerama" = no; then
1489       AC_CHECK_X_LIB(Xinerama, XineramaQueryScreens,
1490                      [have_xinerama=yes; XINERAMA_LIBS="-lXinerama"],
1491                      [true], -lXext -lX11)
1492     fi
1493   fi
1494
1495   # if that succeeded, then we've really got it.
1496   if test "$have_xinerama" = yes; then
1497     AC_DEFINE(HAVE_XINERAMA)
1498   fi
1499
1500 elif test "$with_xinerama" != no; then
1501   echo "error: must be yes or no: --with-xinerama-ext=$with_xinerama"
1502   exit 1
1503 fi
1504
1505
1506 ###############################################################################
1507 #
1508 #       Check for the XF86VMODE server extension (for virtual screens.)
1509 #
1510 ###############################################################################
1511
1512 have_xf86vmode=no
1513 with_xf86vmode_req=unspecified
1514 AC_ARG_WITH(xf86vmode-ext,
1515 [  --with-xf86vmode-ext    Include support for XFree86 virtual screens.],
1516   [with_xf86vmode="$withval"; with_xf86vmode_req="$withval"],
1517   [with_xf86vmode=yes])
1518
1519 HANDLE_X_PATH_ARG(with_xf86vmode, --with-xf86vmode-ext, xf86vmode)
1520
1521 VIDMODE_LIBS=""
1522
1523 if test "$with_xf86vmode" = yes; then
1524
1525   # first check for xf86vmode.h
1526   AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86vmode=yes],,
1527                     [#include <X11/Xlib.h>])
1528
1529   # if that succeeded, then check for the -lXxf86vm
1530   if test "$have_xf86vmode" = yes; then
1531     have_xf86vmode=no
1532     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeGetViewPort,
1533                   [have_xf86vmode=yes;
1534                    VIDMODE_LIBS="-lXxf86vm";
1535                    SAVER_LIBS="$SAVER_LIBS $VIDMODE_LIBS"],
1536                    [true], -lXext -lX11)
1537   fi
1538
1539   # if that succeeded, then we've really got it.
1540   if test "$have_xf86vmode" = yes; then
1541     AC_DEFINE(HAVE_XF86VMODE)
1542   fi
1543
1544 elif test "$with_xf86vmode" != no; then
1545   echo "error: must be yes or no: --with-xf86vmode-ext=$with_xf86vmode"
1546   exit 1
1547 fi
1548
1549
1550 ###############################################################################
1551 #
1552 #       Check for the XF86VMODE server extension (for gamma fading.)
1553 #
1554 ###############################################################################
1555
1556 have_xf86gamma=no
1557 have_xf86gamma_ramp=no
1558 with_xf86gamma_req=unspecified
1559 AC_ARG_WITH(xf86gamma-ext,
1560 [  --with-xf86gamma-ext    Include support for XFree86 gamma fading.],
1561   [with_xf86gamma="$withval"; with_xf86gamma_req="$withval"],
1562   [with_xf86gamma=yes])
1563
1564 HANDLE_X_PATH_ARG(with_xf86gamma, --with-xf86gamma-ext, xf86gamma)
1565
1566 if test "$with_xf86gamma" = yes; then
1567
1568   # first check for xf86vmode.h, if we haven't already
1569   if test "$have_xf86vmode" = yes; then
1570     have_xf86gamma=yes
1571   else
1572     AC_CHECK_X_HEADER(X11/extensions/xf86vmode.h, [have_xf86gamma=yes],,
1573                       [#include <X11/Xlib.h>])
1574   fi
1575
1576   # if that succeeded, then check for the -lXxf86vm
1577   if test "$have_xf86gamma" = yes; then
1578     have_xf86gamma=no
1579     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGamma,
1580                   [have_xf86gamma=yes],
1581                    [true], -lXext -lX11)
1582   fi
1583
1584   # check for the Ramp versions of the functions too.
1585   if test "$have_xf86gamma" = yes; then
1586     have_xf86gamma_ramp=no
1587     AC_CHECK_X_LIB(Xxf86vm, XF86VidModeSetGammaRamp,
1588                   [have_xf86gamma_ramp=yes],
1589                    [true], -lXext -lX11)
1590   fi
1591
1592   # if those tests succeeded, then we've really got the functions.
1593   if test "$have_xf86gamma" = yes; then
1594     AC_DEFINE(HAVE_XF86VMODE_GAMMA)
1595   fi
1596
1597   if test "$have_xf86gamma_ramp" = yes; then
1598     AC_DEFINE(HAVE_XF86VMODE_GAMMA_RAMP)
1599   fi
1600
1601   # pull in the lib, if we haven't already
1602   if test "$have_xf86gamma" = yes -a "$have_xf86vmode" = no; then
1603     SAVER_LIBS="$SAVER_LIBS -lXxf86vm"
1604   fi
1605
1606 elif test "$with_xf86gamma" != no; then
1607   echo "error: must be yes or no: --with-xf86gamma-ext=$with_xf86vmode"
1608   exit 1
1609 fi
1610
1611
1612 ###############################################################################
1613 #
1614 #       Check for the RANDR (Resize and Rotate) server extension.
1615 #
1616 #       We need this to detect when the resolution of the desktop
1617 #       has changed out from under us (this is a newer, different
1618 #       mechanism than the XF86VMODE virtual viewports.)
1619 #
1620 ###############################################################################
1621
1622 have_randr=no
1623 with_randr_req=unspecified
1624 AC_ARG_WITH(randr-ext,
1625 [  --with-randr-ext        Include support for the X Resize+Rotate extension.],
1626   [with_randr="$withval"; with_randr_req="$withval"],[with_randr=yes])
1627
1628 HANDLE_X_PATH_ARG(with_randr, --with-randr-ext, RANDR)
1629
1630 if test "$with_randr" = yes; then
1631
1632   # first check for Randr.h
1633   AC_CHECK_X_HEADER(X11/extensions/Xrandr.h, [have_randr=yes],,
1634                     [#include <X11/Xlib.h>])
1635
1636   # if that succeeded, then check for the XRR code in the libraries
1637   if test "$have_randr" = yes; then
1638
1639     # RANDR probably needs -lXrender
1640     xrender_libs=
1641     AC_CHECK_X_LIB(Xrender, XRenderSetSubpixelOrder,
1642                    [xrender_libs="-lXrender"], [true], -lXext -lX11)
1643
1644     # first look for RANDR in -lXext
1645     have_randr=no
1646     AC_CHECK_X_LIB(Xext, XRRGetScreenInfo,
1647                    [have_randr=yes; SAVER_LIBS="$SAVER_LIBS $xrender_libs"],
1648                    [true], $xrender_libs -lXext -lX11)
1649
1650     # if that failed, look in -lXrandr
1651     if test "$have_randr" = no; then
1652       AC_CHECK_X_LIB(Xrandr, XRRGetScreenInfo,
1653              [have_randr=yes; SAVER_LIBS="$SAVER_LIBS -lXrandr $xrender_libs"],
1654                      [true], $xrender_libs -lXext -lX11)
1655     fi
1656   fi
1657
1658   # if that succeeded, then we've really got it.
1659   if test "$have_randr" = yes; then
1660     AC_DEFINE(HAVE_RANDR)
1661   fi
1662
1663 elif test "$with_randr" != no; then
1664   echo "error: must be yes or no: --with-randr-ext=$with_randr"
1665   exit 1
1666 fi
1667
1668
1669 ###############################################################################
1670 #
1671 #       Check for XF86MiscSetGrabKeysState (but only bother if we are already
1672 #       using other XF86 stuff.)
1673 #
1674 ###############################################################################
1675
1676 have_xf86miscsetgrabkeysstate=no
1677 if test "$have_xf86gamma" = yes -o "$have_xf86vmode" = yes; then
1678   AC_CHECK_X_LIB(Xxf86misc, XF86MiscSetGrabKeysState,
1679                 [have_xf86miscsetgrabkeysstate=yes],
1680                 [true], -lXext -lX11)
1681   if test "$have_xf86miscsetgrabkeysstate" = yes ; then
1682     SAVER_LIBS="$SAVER_LIBS -lXxf86misc"
1683     AC_DEFINE(HAVE_XF86MISCSETGRABKEYSSTATE)
1684   fi
1685 fi
1686
1687
1688 ###############################################################################
1689 #
1690 #       Check for HP XHPDisableReset and XHPEnableReset.
1691 #
1692 ###############################################################################
1693
1694 AC_MSG_CHECKING([for XHPDisableReset in X11/XHPlib.h])
1695 AC_EGREP_X_HEADER(XHPDisableReset, X11/XHPlib.h,
1696                   [AC_DEFINE(HAVE_XHPDISABLERESET)
1697                    SAVER_LIBS="-lXhp11 $SAVER_LIBS"
1698                    AC_MSG_RESULT(yes)],
1699                   [AC_MSG_RESULT(no)])
1700
1701
1702 ###############################################################################
1703 #
1704 #       Check for /proc/interrupts.
1705 #
1706 ###############################################################################
1707
1708 have_proc_interrupts=no
1709 with_proc_interrupts_req=unspecified
1710 AC_ARG_WITH(proc-interrupts,
1711 [  --with-proc-interrupts  Include support for consulting the /proc/interrupts
1712                           file to notice keyboard activity.],
1713   [with_proc_interrupts="$withval"; with_proc_interrupts_req="$withval"],
1714   [with_proc_interrupts=yes])
1715
1716 if test "$with_proc_interrupts" = yes; then
1717
1718    AC_CACHE_CHECK([whether /proc/interrupts contains keyboard data],
1719     ac_cv_have_proc_interrupts,
1720     [ac_cv_have_proc_interrupts=no
1721      if grep 'keyboard\|i8042' /proc/interrupts >/dev/null 2>&1 ; then
1722        ac_cv_have_proc_interrupts=yes
1723      fi
1724     ])
1725    have_proc_interrupts=$ac_cv_have_proc_interrupts
1726
1727   if test "$have_proc_interrupts" = yes; then
1728     AC_DEFINE(HAVE_PROC_INTERRUPTS)
1729   fi
1730
1731 elif test "$with_proc_interrupts" != no; then
1732   echo "error: must be yes or no: --with-proc-interrupts=$with_proc_interrupts"
1733   exit 1
1734 fi
1735
1736
1737 ###############################################################################
1738 #
1739 #       The --enable-locking option
1740 #
1741 ###############################################################################
1742
1743 AC_ARG_ENABLE(locking,[Screen locking options:
1744   --enable-locking        Compile in support for locking the display.
1745   --disable-locking       Do not allow locking at all.],
1746   [enable_locking="$enableval"],[enable_locking=yes])
1747 if test "$enable_locking" = yes; then
1748   true
1749 elif test "$enable_locking" = no; then
1750   AC_DEFINE(NO_LOCKING)
1751 else
1752   echo "error: must be yes or no: --enable-locking=$enable_locking"
1753   exit 1
1754 fi
1755
1756 # We can't lock on MacOS X, so don't even bother compiling in support for it.
1757 #
1758 if test "$ac_macosx" = yes; then
1759   if test "$enable_locking" = yes; then
1760     AC_MSG_RESULT(locking disabled: it doesn't work on MacOS X)
1761     enable_locking=no
1762     AC_DEFINE(NO_LOCKING)
1763   fi
1764 fi
1765
1766
1767 ###############################################################################
1768 #
1769 #       The --enable-vt-locking option
1770 #
1771 ###############################################################################
1772
1773 #ac_vt_lockswitch=no
1774 #AC_ARG_ENABLE(vt-locking,[
1775 #  --enable-vt-locking     Compile in support for locking Virtual Terminals.
1776 #                          This is the default if the system supports it, and
1777 #                          if locking support is included (--enable-locking.)
1778 #  --disable-vt-locking    Do not allow locking of VTs, even if locking is
1779 #                          enabled.],
1780 #  [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
1781 #if test "$enable_vt_locking" = yes; then
1782 #
1783 #  AC_CACHE_CHECK([for the VT_LOCKSWITCH ioctl], ac_cv_vt_lockswitch,
1784 #   [AC_TRY_COMPILE([#include <fcntl.h>
1785 #                   #include <sys/ioctl.h>
1786 #                   #include <sys/vt.h>],
1787 #                  [int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;],
1788 #                  [ac_cv_vt_lockswitch=yes],
1789 #                  [ac_cv_vt_lockswitch=no])])
1790 #  ac_vt_lockswitch=$ac_cv_vt_lockswitch
1791 #
1792 #elif test "$enable_vt_locking" = no; then
1793 #  true
1794 #else
1795 #  echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
1796 #  exit 1
1797 #fi
1798 #
1799 #if test "$ac_vt_lockswitch" = yes; then
1800 #  AC_DEFINE(HAVE_VT_LOCKSWITCH)
1801 #  # the VT_LOCKSWITCH ioctl can only be used when running as root.
1802 #  # #### but it doesn't work yet, so don't worry about that for now.
1803 ##  need_setuid=yes
1804 #fi
1805
1806
1807 ###############################################################################
1808 #
1809 #       Check for PAM.
1810 #
1811 ###############################################################################
1812
1813 case "$host" in
1814   *-solaris*)
1815    # Solaris systems tend to come with PAM misconfigured.
1816    #  Don't build it by default, even if the headers exist.
1817    with_pam_default=no
1818    ;;
1819   *)
1820    # Default to building PAM support on all other systems, if it exists.
1821    with_pam_default=yes
1822   ;;
1823 esac
1824
1825 have_pam=no
1826 with_pam_req=unspecified
1827
1828 AC_ARG_WITH(pam,
1829 [  --with-pam              Include support for PAM (Pluggable Auth Modules.)],
1830   [with_pam="$withval"; with_pam_req="$withval"],[with_pam=$with_pam_default])
1831
1832 AC_ARG_WITH([pam_service_name],
1833             AC_HELP_STRING([--with-pam-service-name=NAME],
1834                            [NAME is the name of the PAM service that
1835                            xscreensaver will authenticate as.]),
1836             [pam_service_name="$withval"],[pam_service_name="xscreensaver"])
1837
1838 HANDLE_X_PATH_ARG(with_pam, --with-pam, PAM)
1839
1840 if test "$enable_locking" = yes -a "$with_pam" = yes; then
1841   AC_CACHE_CHECK([for PAM], ac_cv_pam,
1842                  [AC_TRY_X_COMPILE([#include <security/pam_appl.h>],,
1843                                    [ac_cv_pam=yes],
1844                                    [ac_cv_pam=no])])
1845   if test "$ac_cv_pam" = yes ; then
1846     have_pam=yes
1847     AC_DEFINE(HAVE_PAM)
1848     AC_DEFINE_UNQUOTED(PAM_SERVICE_NAME,"$pam_service_name")
1849     
1850     PASSWD_LIBS="${PASSWD_LIBS} -lpam"
1851
1852     # libpam typically requires dlopen and dlsym.  On FreeBSD,
1853     # those are in libc.  On Linux and Solaris, they're in libdl.
1854     AC_CHECK_LIB(dl, dlopen, [PASSWD_LIBS="${PASSWD_LIBS} -ldl"])
1855
1856     # On Linux, sigtimedwait() is in libc; on Solaris, it's in librt.
1857     have_timedwait=no
1858     AC_CHECK_LIB(c, sigtimedwait, [have_timedwait=yes])
1859     if test "$have_timedwait" = no ; then
1860       AC_CHECK_LIB(rt, sigtimedwait, [PASSWD_LIBS="${PASSWD_LIBS} -lrt"])
1861     fi
1862
1863     AC_MSG_CHECKING(how to call pam_strerror)
1864     AC_CACHE_VAL(ac_cv_pam_strerror_args,
1865      [AC_TRY_COMPILE([#include <stdio.h>
1866                       #include <stdlib.h>
1867                       #include <security/pam_appl.h>],
1868                      [pam_handle_t *pamh = 0;
1869                       char *s = pam_strerror(pamh, PAM_SUCCESS);],
1870                      [ac_pam_strerror_args=2],
1871                      [AC_TRY_COMPILE([#include <stdio.h>
1872                                       #include <stdlib.h>
1873                                       #include <security/pam_appl.h>],
1874                                      [char *s =
1875                                        pam_strerror(PAM_SUCCESS);],
1876                                      [ac_pam_strerror_args=1],
1877                                      [ac_pam_strerror_args=0])])
1878       ac_cv_pam_strerror_args=$ac_pam_strerror_args])
1879     ac_pam_strerror_args=$ac_cv_pam_strerror_args
1880     if test "$ac_pam_strerror_args" = 1 ; then
1881       AC_MSG_RESULT(one argument)
1882     elif test "$ac_pam_strerror_args" = 2 ; then
1883       AC_DEFINE(PAM_STRERROR_TWO_ARGS)
1884       AC_MSG_RESULT(two arguments)
1885     else
1886       AC_MSG_RESULT(unknown)
1887     fi
1888   fi
1889 fi
1890
1891
1892 ###############################################################################
1893 #
1894 #       Check for Kerberos.
1895 #
1896 ###############################################################################
1897
1898 have_kerberos=no
1899 have_kerberos5=no
1900 with_kerberos_req=unspecified
1901
1902 AC_ARG_WITH(kerberos, 
1903 [  --with-kerberos         Include support for Kerberos authentication.],
1904   [with_kerberos="$withval"; with_kerberos_req="$withval"],[with_kerberos=yes])
1905
1906 HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
1907
1908 if test "$enable_locking" = yes -a "$with_kerberos" = yes; then
1909   AC_CACHE_CHECK([for Kerberos 4], ac_cv_kerberos,
1910                  [AC_TRY_X_COMPILE([#include <krb.h>],,
1911                                    [ac_cv_kerberos=yes],
1912                                    [ac_cv_kerberos=no])])
1913   AC_CACHE_CHECK([for Kerberos 5], ac_cv_kerberos5,
1914                  [AC_TRY_X_COMPILE([#include <kerberosIV/krb.h>],,
1915                                    [ac_cv_kerberos5=yes],
1916                                    [ac_cv_kerberos5=no])])
1917
1918   if test "$ac_cv_kerberos" = yes ; then
1919     have_kerberos=yes
1920     AC_DEFINE(HAVE_KERBEROS)
1921   fi
1922
1923   if test "$ac_cv_kerberos5" = yes ; then
1924
1925     # Andrew Snare <ajs@pigpond.com> wrote:
1926     #
1927     # You were assuming that if kerberosV (krb5) was found, then kerberosIV
1928     # (krb4) was also available.  This turns out not to be the case with
1929     # mit-krb-1.2.7; apparently backwards-compatibility with KerberosIV
1930     # is optional.
1931     #
1932     # So, disable kerberosV support if libkrb4 can't be found.
1933     # This is not the best solution, but it makes the compile not fail.
1934     #
1935     AC_CHECK_X_LIB(krb4, krb_get_tf_realm,
1936                    [have_kerberos=yes],
1937                    [have_kerberos=no])
1938     if test "$have_kerberos" = yes ; then
1939       have_kerberos5=yes
1940       AC_DEFINE(HAVE_KERBEROS)
1941       AC_DEFINE(HAVE_KERBEROS5)
1942     else
1943       have_kerberos5=no
1944       AC_MSG_WARN([Cannot find compat lib (libkrb4) needed to use Kerberos 5])
1945     fi
1946
1947   fi
1948
1949   if test "$have_kerberos5" = yes ; then
1950     # from Matt Knopp <mhat@infocalypse.netlag.com>
1951     # (who got it from amu@mit.edu)
1952
1953     PASSWD_LIBS="$PASSWD_LIBS -lkrb4 -ldes425 -lkrb5 -lk5crypto -lcom_err"
1954
1955     # jwz: MacOS X uses -lkrb5, but not -lcrypt
1956     AC_CHECK_X_LIB(crypt, crypt, [PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
1957
1958   elif test "$have_kerberos" = yes ; then
1959     # from Tim Showalter <tjs@psaux.com> for FreeBSD 4.2
1960     PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes -lcom_err"
1961   fi
1962
1963   if test "$have_kerberos" = yes ; then
1964     AC_CHECK_FUNC(res_search,,
1965       AC_CHECK_LIB(resolv,res_search,PASSWD_LIBS="${PASSWD_LIBS} -lresolv",
1966         AC_MSG_WARN([Can't find DNS resolver libraries needed for Kerberos])
1967       ))
1968   fi
1969 fi
1970
1971
1972 ###############################################################################
1973 #
1974 #       Check for the nine billion variants of shadow passwords...
1975 #
1976 ###############################################################################
1977
1978 need_setuid=no
1979
1980 have_shadow=no
1981 with_shadow_req=unspecified
1982
1983 AC_ARG_WITH(shadow,
1984 [  --with-shadow           Include support for shadow password authentication.],
1985   [with_shadow="$withval"; with_shadow_req="$withval"],[with_shadow=yes])
1986
1987 HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
1988
1989 if test "$enable_locking" = no ; then
1990   with_shadow_req=no
1991   with_shadow=no
1992 fi
1993
1994
1995 ###############################################################################
1996 #
1997 #       Check for Sun "adjunct" passwords.
1998 #
1999 ###############################################################################
2000
2001 if test "$with_shadow" = yes ; then
2002   AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
2003                  [AC_TRY_X_COMPILE([#include <stdlib.h>
2004                                     #include <unistd.h>
2005                                     #include <sys/types.h>
2006                                     #include <sys/label.h>
2007                                     #include <sys/audit.h>
2008                                     #include <pwdadj.h>],
2009                       [struct passwd_adjunct *p = getpwanam("nobody");
2010                        const char *pw = p->pwa_passwd;],
2011                       [ac_cv_sun_adjunct=yes],
2012                       [ac_cv_sun_adjunct=no])])
2013   if test "$ac_cv_sun_adjunct" = yes; then
2014     have_shadow_adjunct=yes
2015     have_shadow=yes
2016     need_setuid=yes
2017   fi
2018 fi
2019
2020
2021 ###############################################################################
2022 #
2023 #       Check for DEC and SCO so-called "enhanced" security.
2024 #
2025 ###############################################################################
2026
2027 if test "$with_shadow" = yes ; then
2028   AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
2029                  [AC_TRY_X_COMPILE([#include <stdlib.h>
2030                                     #include <unistd.h>
2031                                     #include <sys/types.h>
2032                                     #include <pwd.h>
2033                                     #include <sys/security.h>
2034                                     #include <prot.h>],
2035                       [struct pr_passwd *p;
2036                        const char *pw;
2037                        set_auth_parameters(0, 0);
2038                        check_auth_parameters();
2039                        p = getprpwnam("nobody");
2040                        pw = p->ufld.fd_encrypt;],
2041                       [ac_cv_enhanced_passwd=yes],
2042                       [ac_cv_enhanced_passwd=no])])
2043   if test $ac_cv_enhanced_passwd = yes; then
2044     have_shadow_enhanced=yes
2045     have_shadow=yes
2046     need_setuid=yes
2047
2048     # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
2049     # (I'm told it needs -lcurses too, but I don't understand why.)
2050     # But on DEC, it's in -lsecurity.
2051     #
2052     AC_CHECK_LIB(prot, getprpwnam, 
2053                  [PASSWD_LIBS="$PASSWD_LIBS -lprot -lcurses -lx"],
2054                  [AC_CHECK_LIB(security, getprpwnam, 
2055                                [PASSWD_LIBS="$PASSWD_LIBS -lsecurity"])],
2056                  [-lx])
2057   fi
2058 fi
2059
2060 ###############################################################################
2061 #
2062 #       Check for HP's entry in the "Not Invented Here" Sweepstakes.
2063 #
2064 ###############################################################################
2065
2066 if test "$with_shadow" = yes ; then
2067   AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
2068                  [AC_TRY_X_COMPILE([#include <stdlib.h>
2069                                     #include <unistd.h>
2070                                     #include <sys/types.h>
2071                                     #include <pwd.h>
2072                                     #include <hpsecurity.h>
2073                                     #include <prot.h>],
2074                       [struct s_passwd *p = getspwnam("nobody");
2075                        const char *pw = p->pw_passwd;],
2076                       [ac_cv_hpux_passwd=yes],
2077                       [ac_cv_hpux_passwd=no])])
2078   if test "$ac_cv_hpux_passwd" = yes; then
2079     have_shadow_hpux=yes
2080     have_shadow=yes
2081     need_setuid=yes
2082
2083     # on HPUX, bigcrypt is in -lsec
2084     AC_CHECK_LIB(sec, bigcrypt, [PASSWD_LIBS="$PASSWD_LIBS -lsec"])
2085   fi
2086 fi
2087
2088
2089 ###############################################################################
2090 #
2091 #       Check for FreeBSD-style shadow passwords.
2092 #
2093 #       On FreeBSD, getpwnam() and friends work just like on non-shadow-
2094 #       password systems -- except you only get stuff in the pw_passwd field
2095 #       if the running program is setuid.  So, guess that we've got this
2096 #       lossage to contend with if /etc/master.passwd exists, and default to
2097 #       a setuid installation.
2098 #
2099 ###############################################################################
2100
2101 if test "$with_shadow" = yes ; then
2102   AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
2103                  [if test -f /etc/master.passwd ; then
2104                     ac_cv_master_passwd=yes
2105                   else
2106                     ac_cv_master_passwd=no
2107                   fi])
2108   if test "$ac_cv_master_passwd" = yes; then
2109     need_setuid=yes
2110   fi
2111 fi
2112
2113
2114 ###############################################################################
2115 #
2116 #       Check for traditional (ha!) shadow passwords.
2117 #
2118 ###############################################################################
2119
2120 if test "$with_shadow" = yes ; then
2121   AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
2122                  [AC_TRY_X_COMPILE([#include <stdlib.h>
2123                                     #include <unistd.h>
2124                                     #include <sys/types.h>
2125                                     #include <pwd.h>
2126                                     #include <shadow.h>],
2127                       [struct spwd *p = getspnam("nobody");
2128                        const char *pw = p->sp_pwdp;],
2129                       [ac_cv_shadow=yes],
2130                       [ac_cv_shadow=no])])
2131   if test "$ac_cv_shadow" = yes; then
2132     have_shadow=yes
2133     need_setuid=yes
2134
2135     # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
2136     have_getspnam=no
2137     AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
2138     if test "$have_getspnam" = no ; then
2139       AC_CHECK_LIB(gen, getspnam,
2140                    [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
2141     fi
2142   fi
2143 fi
2144
2145
2146 ###############################################################################
2147 #
2148 #       Check for other libraries needed for non-shadow passwords.
2149 #
2150 ###############################################################################
2151
2152 if test "$enable_locking" = yes ; then
2153
2154   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
2155   have_crypt=no
2156   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
2157   if test "$have_crypt" = no ; then
2158     AC_CHECK_LIB(crypt, crypt,
2159                  [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
2160   fi
2161 fi
2162
2163
2164 # Most of the above shadow mechanisms will have set need_setuid to yes,
2165 # if they were found.  But, on some systems, we need setuid even when
2166 # using plain old vanilla passwords.
2167 #
2168 if test "$enable_locking" = yes ; then
2169   case "$host" in
2170     *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
2171       need_setuid=yes
2172     ;;
2173   esac
2174 fi
2175
2176
2177 if test "$have_shadow_adjunct" = yes ; then
2178   AC_DEFINE(HAVE_ADJUNCT_PASSWD)
2179 elif test "$have_shadow_enhanced" = yes ; then
2180   AC_DEFINE(HAVE_ENHANCED_PASSWD)
2181 elif test "$have_shadow_hpux" = yes ; then
2182   AC_DEFINE(HAVE_HPUX_PASSWD)
2183 elif test "$have_shadow" = yes ; then
2184   AC_DEFINE(HAVE_SHADOW_PASSWD)
2185 fi
2186
2187
2188 ###############################################################################
2189 #
2190 #       Check for external password helper
2191 #       On SuSE, instead of having xscreensaver be a setuid program, they
2192 #       fork an external program that takes the password on stdin, and
2193 #       returns true if that password is a valid one.  Then only that
2194 #       smaller program needs to be setuid.
2195 #
2196 #       (Note that this external program is not a GUI: the GUI is still
2197 #       all in xscreensaver itself; the external program just does auth.)
2198 #
2199 ###############################################################################
2200
2201 have_passwd_helper=no
2202 with_passwd_helper_req=unspecified
2203
2204 AC_ARG_WITH(passwd-helper,
2205 [  --with-passwd-helper    Include support for an external password
2206                           verification helper program.],
2207   [with_passwd_helper="$withval"; with_passwd_helper_req="$withval"],[with_passwd_helper=no])
2208 # no HANDLE_X_PATH_ARG for this one
2209
2210 if test "$enable_locking" = no ; then
2211   with_passwd_helper_req=no
2212   with_passwd_helper=no
2213 fi
2214
2215 case "$with_passwd_helper" in
2216   ""|no) : ;;
2217   /*)
2218     AC_DEFINE_UNQUOTED(PASSWD_HELPER_PROGRAM, "$with_passwd_helper")
2219     have_passwd_helper=yes;;
2220   *)
2221     echo "error: --with-passwd-helper needs full pathname of helper (not '$with_passwd_helper')." >&2
2222     exit 1
2223 esac
2224
2225
2226 ###############################################################################
2227 #
2228 #       Check for a login manager for a "New Login" button on the lock dialog.
2229 #       Usually this will be "/usr/bin/gdmflexiserver".
2230 #
2231 ###############################################################################
2232
2233 have_login_manager=no
2234 with_login_manager_req=unspecified
2235 default_login_manager='gdmflexiserver -l'
2236
2237 AC_ARG_WITH(login-manager,
2238 [  --with-login-manager    Put a "New Login" button on the unlock dialog that
2239                           runs a login manager such as gdmflexiserver.],
2240   [with_login_manager="$withval"; with_login_manager_req="$withval"],
2241   [with_login_manager=no])
2242 # no HANDLE_X_PATH_ARG for this one
2243
2244 if test "$enable_locking" = no ; then
2245   with_login_manager_req=no
2246   with_login_manager=no
2247 fi
2248
2249 if test -n "$with_login_manager_req" ; then
2250   ac_cv_login_manager_program=""
2251
2252  if test "$with_login_manager_req" = "yes" ; then
2253    with_login_manager_req=$default_login_manager
2254  fi
2255
2256   case "$with_login_manager_req" in
2257     /*)
2258       # absolute path
2259       set dummy $with_login_manager_req ; login_manager_tmp=$2
2260       AC_MSG_CHECKING([for $login_manager_tmp])
2261       if test -x "$login_manager_tmp" ; then
2262         AC_MSG_RESULT(yes)
2263         with_login_manager="$login_manager_tmp"
2264       else
2265         AC_MSG_RESULT(no)
2266         with_login_manager=""
2267       fi
2268     ;;
2269     *)
2270       # relative path
2271       set dummy $with_login_manager_req ; login_manager_tmp=$2
2272       # don't cache
2273       unset ac_cv_path_login_manager_tmp
2274       AC_PATH_PROG(login_manager_tmp, $login_manager_tmp, [])
2275       if test -z "$login_manager_tmp" ; then
2276         with_login_manager=""
2277       else
2278         with_login_manager="$login_manager_tmp"
2279       fi
2280     ;;
2281   esac
2282   ac_cv_login_manager_program="$with_login_manager"
2283
2284 elif test -n "$ac_cv_login_manager_program"; then
2285   AC_MSG_RESULT([checking for login_manager... (cached) $ac_cv_login_manager_program])
2286 fi
2287
2288 NEW_LOGIN_COMMAND_P=''
2289 NEW_LOGIN_COMMAND="$ac_cv_login_manager_program"
2290
2291 if test -z "$NEW_LOGIN_COMMAND" ; then
2292   NEW_LOGIN_COMMAND="$default_login_manager"
2293   NEW_LOGIN_COMMAND_P='! '
2294 fi
2295
2296
2297
2298 ###############################################################################
2299 #
2300 #       Check for -lgtk (and Gnome stuff)
2301 #
2302 ###############################################################################
2303
2304 have_gtk=no
2305 with_gtk_req=unspecified
2306 AC_ARG_WITH(gtk,[
2307 User interface options:
2308
2309   --with-gtk              Use the Gtk toolkit for the user interface.],
2310   [with_gtk="$withval"; with_gtk_req="$withval"],[with_gtk=yes])
2311
2312 # if --with-gtk=/directory/ was specified, remember that directory so that
2313 # we can also look for the `gtk-config' program in that directory.
2314 case "$with_gtk" in
2315   /*)
2316     gtk_dir="$with_gtk"
2317     ;;
2318   *)
2319     gtk_dir=""
2320     ;;
2321 esac
2322
2323 HANDLE_X_PATH_ARG(with_gtk, --with-gtk, Gtk)
2324
2325 if test "$with_gtk" != yes -a "$with_gtk" != no ; then
2326   echo "error: must be yes or no: --with-gtk=$with_gtk"
2327   exit 1
2328 fi
2329
2330
2331 parse_gtk_version_string() {
2332   # M4 sucks!!
2333   changequote(X,Y)
2334   maj=`echo $ac_gtk_version_string | sed -n 's/\..*//p'`
2335   min=`echo $ac_gtk_version_string | sed -n 's/[^.]*\.\([^.]*\).*/\1/p'`
2336   changequote([,])
2337   ac_gtk_version=`echo "$maj * 1000 + $min" | bc`
2338   if test -z "$ac_gtk_version"; then
2339     ac_gtk_version=unknown
2340     ac_gtk_version_string=unknown
2341   fi
2342 }
2343
2344 # Find pkg-config... (need this for both gtk and gdk_pixbuf.)
2345 # if the user specified --with-gtk=/foo/ then look there.
2346 #
2347 gtk_path="$PATH"
2348 if test ! -z "$gtk_dir"; then
2349   # canonicalize slashes.
2350   foo=`echo "${gtk_dir}/bin" | sed 's@//*@/@g'`
2351   gtk_path="$foo:$gtk_path"
2352 fi
2353
2354 AC_PATH_PROGS(pkg_config, pkg-config,, $gtk_path)
2355
2356 if test -z "$pkg_config" ; then
2357   AC_MSG_WARN([pkg-config not found!])
2358   pkg_config="false"
2359 fi
2360
2361
2362 # Utility function for running pkg-config-based tests...
2363 #
2364 pkgs=''
2365 pkg_check_version() {
2366   if test "$ok" = yes ; then
2367     req="$1"
2368     min="$2"
2369     AC_MSG_CHECKING(for $req)
2370     if $pkg_config --exists "$req" ; then
2371       vers=`$pkg_config --modversion "$req"`
2372       if $pkg_config --exists "$req >= $min" ; then
2373         AC_MSG_RESULT($vers)
2374         pkgs="$pkgs $req"
2375         return 1
2376       else
2377         AC_MSG_RESULT($vers (wanted >= $min))
2378         ok=no
2379         return 0
2380       fi
2381     else
2382       AC_MSG_RESULT(no)
2383       ok=no
2384       return 0
2385     fi
2386   fi
2387 }
2388
2389
2390 jurassic_gtk=no
2391 gtk_halfassed=no
2392
2393 if test "$with_gtk" = yes; then
2394   have_gtk=no
2395   
2396   ok="yes"
2397   pkg_check_version            gtk+-2.0  2.0.1  ; ac_gtk_version_string="$vers"
2398   pkg_check_version         gmodule-2.0  2.0.0
2399   pkg_check_version          libxml-2.0  2.4.6
2400   pkg_check_version        libglade-2.0  1.99.0
2401   pkg_check_version      gdk-pixbuf-2.0  2.0.0
2402   pkg_check_version gdk-pixbuf-xlib-2.0  2.0.0
2403   have_gtk="$ok"
2404
2405   if test "$have_gtk" = no; then
2406     if test -n "$ac_gtk_version_string" ; then
2407       gtk_halfassed="$ac_gtk_version_string"
2408       gtk_halfassed_lib="$req"
2409     fi
2410   fi
2411
2412   if test "$have_gtk" = yes; then
2413     parse_gtk_version_string
2414     jurassic_gtk=no
2415   fi
2416
2417   if test "$have_gtk" = yes; then
2418     AC_CACHE_CHECK([for Gtk includes], ac_cv_gtk_config_cflags,
2419                    [ac_cv_gtk_config_cflags=`$pkg_config --cflags $pkgs`])
2420     AC_CACHE_CHECK([for Gtk libs], ac_cv_gtk_config_libs,
2421                    [ac_cv_gtk_config_libs=`$pkg_config --libs $pkgs`])
2422   fi
2423   ac_gtk_config_cflags=$ac_cv_gtk_config_cflags
2424   ac_gtk_config_libs=$ac_cv_gtk_config_libs
2425
2426   GTK_EXTRA_OBJS=""
2427   GTK_DATADIR=""
2428   if test "$have_gtk" = yes; then
2429     GTK_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
2430     GTK_DATADIR="$GTK_DATADIR/share"
2431   fi
2432
2433   if test "$have_gtk" = yes; then
2434     INCLUDES="$INCLUDES $ac_gtk_config_cflags"
2435     GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
2436     AC_DEFINE(HAVE_GTK)
2437     AC_DEFINE(HAVE_GTK2)
2438     AC_DEFINE(HAVE_XML)
2439   fi
2440
2441 fi
2442
2443
2444 # Check for the various Gnome help and URL loading programs.
2445 #
2446 if test "$have_gtk" = yes; then
2447   AC_CHECK_PROGS(gnome_open_program,     gnome-open)
2448   AC_CHECK_PROGS(gnome_url_show_program, gnome-url-show)
2449 fi
2450
2451
2452 ###############################################################################
2453 #
2454 #       Check for -lXm.
2455 #
2456 ###############################################################################
2457
2458 have_motif=no
2459 with_motif_req=unspecified
2460 AC_ARG_WITH(motif,[  --with-motif            Use the Motif toolkit for the user interface
2461                           (not recommended.)],
2462   [with_motif="$withval"; with_motif_req="$withval"],[with_motif=no])
2463
2464 HANDLE_X_PATH_ARG(with_motif, --with-motif, Motif)
2465
2466 if test "$with_motif" != yes -a "$with_motif" != no ; then
2467   echo "error: must be yes or no: --with-motif=$with_motif"
2468   exit 1
2469 fi
2470
2471 if test "$with_motif" = yes; then
2472   have_motif=no
2473   AC_CHECK_X_HEADER(Xm/Xm.h,
2474                     [have_motif=yes
2475                      AC_DEFINE(HAVE_MOTIF)
2476                      MOTIF_LIBS="$MOTIF_LIBS -lXm"],,
2477                     [#include <stdlib.h>
2478                      #include <stdio.h>
2479                      #include <X11/Intrinsic.h>])
2480 fi
2481
2482
2483 if test "$have_motif" = yes; then
2484   AC_CHECK_X_HEADER(Xm/ComboBox.h, [AC_DEFINE(HAVE_XMCOMBOBOX)],,
2485                     [#include <stdlib.h>
2486                      #include <stdio.h>
2487                      #include <X11/Intrinsic.h>])
2488 fi
2489
2490
2491 ###############################################################################
2492 #
2493 #       Checking whether Motif is really Lesstif.
2494 #
2495 ###############################################################################
2496
2497 have_lesstif=no
2498 if test "$have_motif" = yes ; then
2499   AC_CACHE_CHECK([whether Motif is really LessTif], 
2500                  ac_cv_have_lesstif,
2501                  [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
2502                                    [long vers = LesstifVersion;],
2503                                    [ac_cv_have_lesstif=yes],
2504                                    [ac_cv_have_lesstif=no])])
2505   have_lesstif=$ac_cv_have_lesstif
2506 fi
2507
2508
2509 lesstif_version=unknown
2510 lesstif_version_string=unknown
2511
2512 if test "$have_lesstif" = yes ; then
2513   ltv=unknown
2514   echo unknown > conftest-lt
2515   AC_CACHE_CHECK([LessTif version number],
2516                  ac_cv_lesstif_version_string,
2517       [AC_TRY_X_RUN([#include <stdio.h>
2518                      #include <Xm/Xm.h>
2519                      int main() {
2520                        FILE *f = fopen("conftest-lt", "w");
2521                        if (!f) exit(1);
2522                        fprintf(f, "%d %d.%d\n", LesstifVersion,
2523                           LESSTIF_VERSION, LESSTIF_REVISION);
2524                        fclose(f);
2525                        exit(0);
2526                      }],
2527                     [ltv=`cat conftest-lt`
2528                      ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
2529                      ac_cv_lesstif_version_string=`echo $ltv | sed 's/.* //'`],
2530                     [ac_cv_lesstif_version=unknown
2531                      ac_cv_lesstif_version_string=unknown],
2532                     [ac_cv_lesstif_version=unknown
2533                      ac_cv_lesstif_version_string=unknown])])
2534   rm -f conftest-lt
2535   lesstif_version=$ac_cv_lesstif_version
2536   lesstif_version_string=$ac_cv_lesstif_version_string
2537
2538 fi
2539
2540
2541 if test "$have_motif" = yes ; then
2542   mtv=unknown
2543   echo unknown > conftest-mt
2544   AC_CACHE_CHECK([Motif version number],
2545                  ac_cv_motif_version_string,
2546       [AC_TRY_X_RUN([#include <stdio.h>
2547                      #include <Xm/Xm.h>
2548                      int main() {
2549                        FILE *f = fopen("conftest-mt", "w");
2550                        if (!f) exit(1);
2551                        fprintf(f, "%d %d.%d\n", XmVersion,
2552                           XmVERSION, XmREVISION);
2553                        fclose(f);
2554                        exit(0);
2555                      }],
2556                     [mtv=`cat conftest-mt`
2557                      ac_cv_motif_version=`echo $mtv | sed 's/ .*//'`
2558                      ac_cv_motif_version_string=`echo $mtv | sed 's/.* //'`],
2559                     [ac_cv_motif_version=unknown
2560                      ac_cv_motif_version_string=unknown],
2561                     [ac_cv_motif_version=unknown
2562                      ac_cv_motif_version_string=unknown])])
2563   rm -f conftest-mt
2564   motif_version=$ac_cv_motif_version
2565   motif_version_string=$ac_cv_motif_version_string
2566
2567 fi
2568
2569
2570 ###############################################################################
2571 #
2572 #       Checking whether Motif requires -lXpm.
2573 #
2574 #       If this is Motif 2.x, and we have XPM, then link against XPM as well.
2575 #       The deal is, Motif 2.x requires XPM -- but it's a compilation option
2576 #       of the library whether to build the XPM code into libXm, or whether
2577 #       to rely on an external libXm.  So the only way to tell whether XPM is
2578 #       a link-time requirement is to examine libXm.a, which is very
2579 #       difficult to do in an autoconf script.  So... if it's Motif 2.x, we
2580 #       always link against XPM if the XPM lib exists (and this will be a
2581 #       no-op if libXm happens to already have the XPM code in it.)
2582 #
2583 ###############################################################################
2584
2585 motif_requires_xpm=no
2586 if test "$have_motif" = yes ; then
2587    AC_MSG_CHECKING(whether Motif requires XPM)
2588    if test "$motif_version" = "unknown" || test "$motif_version" -ge 2000
2589    then
2590      motif_requires_xpm=yes
2591      AC_MSG_RESULT(maybe)
2592    else
2593      AC_MSG_RESULT(no)
2594    fi
2595 fi
2596
2597
2598 ###############################################################################
2599 #
2600 #       Checking whether Motif requires -lXp.
2601 #
2602 #       Some versions of Motif (2.1.0, at least) require -lXp, the "X Printing
2603 #       Extension".   Why this extension isn't in -lXext with all the others,
2604 #       I have no idea.
2605 #
2606 ###############################################################################
2607
2608 have_xp_ext=no
2609 if test "$have_motif" = yes ; then
2610    have_xp_ext=no
2611    AC_CHECK_X_LIB(Xp, XpQueryExtension,
2612                   [have_xp_ext=yes; MOTIF_LIBS="$MOTIF_LIBS -lXp"],
2613                   [true], -lX11 -lXext -lm)
2614 fi
2615
2616
2617 ###############################################################################
2618 #
2619 #       Checking whether Motif requires -lXintl (for _Xsetlocale.)
2620 #
2621 ###############################################################################
2622
2623 have_xintl=no
2624 if test "$have_motif" = yes ; then
2625   AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
2626                  -lX11 -lXext -lm)
2627   if test "$have_xintl" = yes; then
2628     MOTIF_LIBS="$MOTIF_LIBS -lXintl"
2629   fi
2630 fi
2631
2632
2633 ###############################################################################
2634 #
2635 #       Check for -lGL or -lMesaGL.
2636 #
2637 ###############################################################################
2638
2639 have_gl=no
2640 ac_have_mesa_gl=no
2641 with_gl_req=unspecified
2642 gl_halfassed=no
2643 AC_ARG_WITH(gl,[
2644 Graphics options:
2645
2646   --with-gl               Build those demos which depend on OpenGL.],
2647   [with_gl="$withval"; with_gl_req="$withval"],[with_gl=yes])
2648
2649 HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
2650
2651 ac_mesagl_version=unknown
2652 ac_mesagl_version_string=unknown
2653
2654 if test "$with_gl" = yes; then
2655   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
2656   if test "$have_gl" = yes ; then
2657     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no,
2658                       [#include <GL/gl.h>])
2659   fi
2660
2661   # If we have the headers, try and figure out which vendor it's from.
2662   #
2663   if test "$have_gl" = yes ; then
2664
2665     # We need to know whether it's MesaGL so that we know which libraries
2666     # to link against.
2667     #
2668     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
2669       [ac_cv_have_mesa_gl=no
2670        AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
2671       ])
2672     ac_have_mesa_gl=$ac_cv_have_mesa_gl
2673  
2674
2675     gl_lib_1=""
2676     GL_LIBS=""
2677
2678
2679     # Some versions of MesaGL are compiled to require -lpthread.
2680     # So if the Mesa headers exist, and -lpthread exists, then always
2681     # link -lpthread after the Mesa libs (be they named -lGL or -lMesaGL.)
2682     #
2683     if test "$ac_have_mesa_gl" = yes; then
2684       AC_CHECK_LIB(pthread, pthread_create, [GL_LIBS="-lpthread"], [],)
2685     fi
2686
2687
2688     # If we have Mesa headers, check to see if we can link against -lMesaGL.
2689     # If we don't have Mesa headers, or we don't have -lMesaGL, try -lGL.
2690     # Else, warn that GL is busted.  (We have the headers, but no libs.)
2691     #
2692
2693     if test "$ac_have_mesa_gl" = yes ; then
2694       AC_CHECK_X_LIB(MesaGL, glXCreateContext, 
2695                      [gl_lib_1="MesaGL"
2696                       GL_LIBS="-lMesaGL -lMesaGLU $VIDMODE_LIBS $GL_LIBS"],
2697                      [], -lMesaGLU $GL_LIBS -lX11 -lXext $VIDMODE_LIBS -lm)
2698     fi
2699
2700     if test "$gl_lib_1" = "" ; then
2701       AC_CHECK_X_LIB(GL, glXCreateContext, 
2702                      [gl_lib_1="GL"
2703                       GL_LIBS="-lGL -lGLU $VIDMODE_LIBS $GL_LIBS"],
2704                      [], -lGLU $GL_LIBS -lX11 -lXext $VIDMODE_LIBS -lm)
2705     fi
2706
2707     if test "$gl_lib_1" = "" ; then
2708       # we have headers, but no libs -- bail.
2709       have_gl=no
2710       ac_have_mesa_gl=no
2711       gl_halfassed=yes
2712     else
2713       # linking works -- we can build the GL hacks.
2714       AC_DEFINE(HAVE_GL)
2715       if test "$ac_have_mesa_gl" = yes ; then
2716         AC_DEFINE(HAVE_MESA_GL)
2717       fi
2718     fi
2719   fi
2720
2721
2722   # Now that we know we have GL headers and libs, do some more GL testing.
2723   #
2724
2725   if test "$have_gl" = yes ; then
2726     # If it's MesaGL, we'd like to issue a warning if the version number
2727     # is less than or equal to 2.6, because that version had a security bug.
2728     #
2729     if test "$ac_have_mesa_gl" = yes; then
2730
2731       AC_CACHE_CHECK([MesaGL version number], ac_cv_mesagl_version_string,
2732         [cat > conftest.$ac_ext <<EOF
2733 #line __oline__ "configure"
2734 #include "confdefs.h"
2735 #include <GL/gl.h>
2736 #ifndef MESA_MAJOR_VERSION
2737 # include <GL/xmesa.h>
2738 # ifdef XMESA_MAJOR_VERSION
2739    /* Around Mesa 3.2, they took out the Mesa version number, so instead,
2740       we have to check the XMesa version number (the number of the X protocol
2741       support, which seems to be the same as the Mesa version number.)
2742     */
2743 #  define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
2744 #  define MESA_MINOR_VERSION XMESA_MINOR_VERSION
2745 # else
2746    /* Oh great.  Some time after 3.4, they took out the xmesa.h header file,
2747       so we have no way of telling what version of Mesa this is at all.
2748       So, we'll guess that the osmesa version (the "offscreen protocol")
2749       is less than or equal to the real mesa version number.  Except that
2750       if OSmesa is 3.3, assume at least Mesa 3.4, since OSmesa was 3.3 in
2751       Mesa 3.4.  And Mesa 3.3 had xmesa.h.  What a complete load of shit!
2752     */
2753 # include <GL/osmesa.h>
2754 #  define MESA_MAJOR_VERSION OSMESA_MAJOR_VERSION
2755 #  define MESA_MINOR_VERSION OSMESA_MINOR_VERSION or newer, probably?
2756 #  if OSMESA_MAJOR_VERSION == 3 && OSMESA_MINOR_VERSION == 3
2757 #   undef MESA_MINOR_VERSION
2758 #   define MESA_MINOR_VERSION 4 or newer, probably?
2759 #  endif
2760 # endif
2761 #endif
2762 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
2763 EOF
2764
2765          ac_save_CPPFLAGS="$CPPFLAGS"
2766          if test \! -z "$includedir" ; then 
2767            CPPFLAGS="$CPPFLAGS -I$includedir"
2768          fi
2769          CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2770
2771          mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | grep configure:`
2772
2773          # M4 sucks!!
2774          changequote(X,Y)
2775           mglv=`echo "$mglv" | sed -n \
2776              's/^configure: *\([0-9][0-9]*\)  *\([0-9].*\)$/\1.\2/p'`
2777          changequote([,])
2778
2779          rm -f conftest.$ac_ext
2780
2781          CPPFLAGS="$ac_save_CPPFLAGS"
2782
2783          if test "$mglv" = ""; then
2784            ac_mesagl_version=unknown
2785            ac_mesagl_version_string=unknown
2786          else
2787            ac_mesagl_version_string="$mglv"
2788            # M4 sucks!!
2789            changequote(X,Y)
2790            maj=`echo "$mglv" | sed -n 's/^\([0-9][0-9]*\)\..*$/\1/p'`
2791            min=`echo "$mglv" | sed -n 's/^.*\.\([0-9][0-9]*\).*$/\1/p'`
2792            changequote([,])
2793            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
2794            if test -z "$ac_mesagl_version"; then
2795              ac_mesagl_version=unknown
2796              ac_mesagl_version_string=unknown
2797            fi
2798          fi
2799          ac_cv_mesagl_version=$ac_mesagl_version
2800          ac_cv_mesagl_version_string=$ac_mesagl_version_string
2801       ])
2802       ac_mesagl_version=$ac_cv_mesagl_version
2803       ac_mesagl_version_string=$ac_cv_mesagl_version_string
2804     fi
2805
2806
2807     # Check for OpenGL 1.1 features.
2808     #
2809     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
2810                    [true], $GL_LIBS -lX11 -lXext -lm)
2811   fi
2812
2813 elif test "$with_gl" != no; then
2814   echo "error: must be yes or no: --with-gl=$with_gl"
2815   exit 1
2816 fi
2817
2818
2819 ###############################################################################
2820 #
2821 #       Check for -lgle.
2822 #
2823 ###############################################################################
2824
2825 have_gle=no
2826 with_gle_req=unspecified
2827 gle_halfassed=no
2828 AC_ARG_WITH(gle,
2829 [  --with-gle              Build those demos which depend on GLE
2830                           (the OpenGL "extrusion" library.)],
2831   [with_gle="$withval"; with_gle_req="$withval"],[with_gle=yes])
2832
2833 HANDLE_X_PATH_ARG(with_gle, --with-gle, GLE)
2834
2835 GLE_LIBS=""
2836
2837 if test "$have_gl" = no ; then
2838  true
2839 elif test "$with_gle" = yes; then
2840
2841   AC_CHECK_X_HEADER(GL/gle.h, have_gle3=yes, have_gle3=no,
2842                     [#include <GL/gl.h>])
2843   if test "$have_gle3" = yes ; then
2844     have_gle=yes;
2845   else
2846     AC_CHECK_X_HEADER(GL/gutil.h, have_gle=yes, have_gle=no,
2847                     [#include <GL/gl.h>])
2848     if test "$have_gle" = yes ; then
2849       AC_CHECK_X_HEADER(GL/tube.h, have_gle=yes, have_gle=no,
2850                         [#include <GL/gl.h>])
2851     fi
2852   fi
2853
2854   if test "$have_gle" = yes ; then
2855     have_gle=no
2856     gle_halfassed=yes
2857     AC_CHECK_X_LIB(gle, gleCreateGC, 
2858                    [have_gle=yes; gle_halfassed=no; GLE_LIBS="-lgle"],
2859                    [], $GL_LIBS -lX11 -lXext -lm)
2860   fi
2861   if test "$have_gle" = yes ; then
2862     have_gle=no
2863     gle_halfassed=yes
2864
2865     # sometimes the libmatrix stuff is included in libgle.  look there first.
2866 #
2867 # I don't get it.  For some reason, this test passes on SGI, as if
2868 # uview_direction_d() was in libgle -- but it's not, it's in libmatrix.
2869 # Yet the link is succeeding.  Why???
2870 #
2871 #    AC_CHECK_X_LIB(gle, uview_direction_d, 
2872 #                   [have_gle=yes; gle_halfassed=no],
2873 #                   [], $GL_LIBS -lX11 -lXext -lm)
2874
2875     # As of GLE 3 this is in libgle, and has changed name to uview_direction!
2876     # *sigh*
2877     if test "$have_gle3" = yes ; then
2878       AC_CHECK_X_LIB(gle, uview_direction, 
2879                      [have_gle=yes; gle_halfassed=no],
2880                     [], $GL_LIBS -lX11 -lXext -lm)
2881     fi
2882     # if it wasn't in libgle, then look in libmatrix.
2883     if test "$have_gle" = no ; then
2884       AC_CHECK_X_LIB(matrix, uview_direction_d, 
2885                      [have_gle=yes; gle_halfassed=no;
2886                       GLE_LIBS="$GLE_LIBS -lmatrix"],
2887                     [], $GL_LIBS -lX11 -lXext -lm)
2888     fi
2889   fi
2890
2891   if test "$have_gle" = yes ; then
2892     AC_DEFINE(HAVE_GLE)
2893     if test "$have_gle3" = yes ; then
2894       AC_DEFINE(HAVE_GLE3)
2895     fi
2896   fi
2897
2898 elif test "$with_gle" != no; then
2899   echo "error: must be yes or no: --with-gle=$with_gle"
2900   exit 1
2901
2902 fi
2903
2904
2905 ###############################################################################
2906 #
2907 #       Check for -lgdk_pixbuf.
2908 #       These tests are for gdk_pixbuf usage of the hacks, 
2909 #       not xscreensaver-demo (thus we have to test again to get
2910 #       the libraries right: don't want to pull in all of GTK
2911 #       for the hacks.)
2912 #
2913 ###############################################################################
2914
2915 have_gdk_pixbuf=no
2916 with_gdk_pixbuf_req=unspecified
2917 AC_ARG_WITH(pixbuf,
2918 [  --with-pixbuf           Include support for the GDK-Pixbuf library in some
2919                           demos, which will make it possible for them to read
2920                           GIF, JPEG, and PNG files as well.],
2921   [with_gdk_pixbuf="$withval"; with_gdk_pixbuf_req="$withval"],
2922   [with_gdk_pixbuf=yes])
2923
2924 # if --with-pixbuf=/directory/ was specified, remember that directory so that
2925 # we can also look for the `gdk-pixbuf-config' program in that directory.
2926 case "$with_gdk_pixbuf" in
2927   /*)
2928     gdk_pixbuf_dir="$with_gdk_pixbuf"
2929     ;;
2930   *)
2931     gdk_pixbuf_dir=""
2932     ;;
2933 esac
2934
2935 HANDLE_X_PATH_ARG(with_gdk_pixbuf, --with-pixbuf, GDK_PIXBUF)
2936
2937 if test "$with_gdk_pixbuf" != yes -a "$with_gdk_pixbuf" != no ; then
2938   echo "error: must be yes or no: --with-pixbuf=$with_gdk_pixbuf"
2939   exit 1
2940 fi
2941
2942 if test "$with_gdk_pixbuf" = yes; then
2943   have_gdk_pixbuf=no
2944
2945   pkgs=''
2946   ok="yes"
2947
2948   pkg_check_version gdk-pixbuf-2.0      2.0.0
2949   pkg_check_version gdk-pixbuf-xlib-2.0 2.0.0
2950   have_gdk_pixbuf="$ok"
2951
2952   if test "$have_gdk_pixbuf" = yes; then
2953     AC_CACHE_CHECK([for gdk-pixbuf includes], ac_cv_gdk_pixbuf_config_cflags,
2954                [ac_cv_gdk_pixbuf_config_cflags=`$pkg_config --cflags $pkgs`])
2955     AC_CACHE_CHECK([for gdk-pixbuf libs], ac_cv_gdk_pixbuf_config_libs,
2956                [ac_cv_gdk_pixbuf_config_libs=`$pkg_config --libs $pkgs`])
2957   fi
2958   ac_gdk_pixbuf_config_cflags=$ac_cv_gdk_pixbuf_config_cflags
2959   ac_gdk_pixbuf_config_libs=$ac_cv_gdk_pixbuf_config_libs
2960
2961
2962   if test "$have_gdk_pixbuf" = yes; then
2963     #
2964     # we appear to have pixbuf; check for headers/libs to be sure.
2965     #
2966     ac_save_gdk_pixbuf_CPPFLAGS="$CPPFLAGS"
2967     CPPFLAGS="$CPPFLAGS $ac_gdk_pixbuf_config_cflags"
2968
2969     have_gdk_pixbuf=no
2970
2971     # check for header A...
2972     AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf.h, [have_gdk_pixbuf=yes])
2973
2974     # if that worked, check for header B...
2975     if test "$have_gdk_pixbuf" = yes; then
2976       have_gdk_pixbuf=no
2977       gdk_pixbuf_halfassed=yes
2978       AC_CHECK_X_HEADER(gdk-pixbuf/gdk-pixbuf-xlib.h,
2979                         [have_gdk_pixbuf=yes
2980                          gdk_pixbuf_halfassed=no])
2981
2982       # yay, it has a new name in Gtk 2.x...
2983       if test "$have_gdk_pixbuf" = no; then
2984         have_gdk_pixbuf=no
2985         gdk_pixbuf_halfassed=yes
2986         AC_CHECK_X_HEADER(gdk-pixbuf-xlib/gdk-pixbuf-xlib.h,
2987                           [have_gdk_pixbuf=yes
2988                            gdk_pixbuf_halfassed=no])
2989       fi
2990     fi
2991     CPPFLAGS="$ac_save_gdk_pixbuf_CPPFLAGS"
2992   fi
2993
2994   if test "$have_gdk_pixbuf" = yes; then
2995     # we have the headers, now check for the libraries
2996     have_gdk_pixbuf=no
2997     gdk_pixbuf_halfassed=yes
2998
2999     AC_MSG_RESULT(checking for gdk_pixbuf usability...)
3000
3001     # library A...
3002     AC_CHECK_X_LIB(c, gdk_pixbuf_new_from_file, [have_gdk_pixbuf=yes],,
3003                    $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
3004     # library B...
3005     if test "$have_gdk_pixbuf" = yes; then
3006       have_gdk_pixbuf=no
3007       AC_CHECK_X_LIB(c, gdk_pixbuf_xlib_init,
3008                      [have_gdk_pixbuf=yes
3009                       gdk_pixbuf_halfassed=no],,
3010                      $ac_gdk_pixbuf_config_libs -lX11 -lXext -lm)
3011     fi
3012   fi
3013
3014   if test "$have_gdk_pixbuf" = yes; then
3015     INCLUDES="$INCLUDES $ac_gdk_pixbuf_config_cflags"
3016     XPM_LIBS="$ac_gdk_pixbuf_config_libs"
3017     AC_DEFINE(HAVE_GDK_PIXBUF)
3018   else
3019     AC_MSG_RESULT(checking for gdk_pixbuf usability... no)
3020   fi
3021 fi
3022
3023
3024 ###############################################################################
3025 #
3026 #       Check for -lXpm.
3027 #
3028 ###############################################################################
3029
3030 have_xpm=no
3031 with_xpm_req=unspecified
3032 AC_ARG_WITH(xpm,
3033 [  --with-xpm              Include support for XPM files in some demos.
3034                           (Not needed if Pixbuf is used.)],
3035   [with_xpm="$withval"; with_xpm_req="$withval"],[with_xpm=yes])
3036
3037 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
3038
3039 if test "$with_xpm" = yes; then
3040   AC_CHECK_X_HEADER(X11/xpm.h,
3041                    [have_xpm=yes
3042                     AC_DEFINE(HAVE_XPM)
3043                     XPM_LIBS="-lXpm $XPM_LIBS"],,
3044                     [#include <X11/Xlib.h>])
3045 elif test "$with_xpm" != no; then
3046   echo "error: must be yes or no: --with-xpm=$with_xpm"
3047   exit 1
3048 fi
3049
3050 # See comment near $motif_requires_xpm, above.
3051 # Need to do this here, after both Motif and XPM have been checked for.
3052 #
3053 if test "$have_motif" = yes -a "$have_xpm" = yes ; then
3054   if test "$motif_requires_xpm" = yes ; then
3055     MOTIF_LIBS="$MOTIF_LIBS $XPM_LIBS"
3056   fi
3057 fi
3058
3059
3060 ###############################################################################
3061 #
3062 #       Check for -ljpeg
3063 #
3064 ###############################################################################
3065
3066 have_jpeg=no
3067 with_jpeg_req=unspecified
3068 jpeg_halfassed=no
3069 AC_ARG_WITH(jpeg,
3070 [  --with-jpeg             Include support for the JPEG library.],
3071   [with_jpeg="$withval"; with_jpeg_req="$withval"],
3072   [with_jpeg=yes])
3073
3074 HANDLE_X_PATH_ARG(with_jpeg, --with-jpeg, JPEG)
3075
3076 if test "$with_jpeg" != yes -a "$with_jpeg" != no ; then
3077   echo "error: must be yes or no: --with-jpeg=$with_jpeg"
3078   exit 1
3079 fi
3080
3081 if test "$with_jpeg" = yes; then
3082
3083   have_jpeg=no
3084   AC_CHECK_X_HEADER(jpeglib.h, [have_jpeg=yes])
3085
3086   if test "$have_jpeg" = yes; then
3087     # we have the header, now check for the library
3088     have_jpeg=no
3089     jpeg_halfassed=yes
3090     AC_CHECK_X_LIB(jpeg, jpeg_start_compress,
3091                    [have_jpeg=yes
3092                     jpeg_halfassed=no
3093                     JPEG_LIBS="-ljpeg"
3094                     AC_DEFINE(HAVE_JPEGLIB)])
3095   fi
3096 fi
3097
3098
3099 ###############################################################################
3100 #
3101 #       Check for pty support: this allows 'phosphor' and 'apple2'
3102 #       to run curses-based programs, or be used as terminal windows.
3103 #
3104 ###############################################################################
3105
3106 PTY_LIBS=
3107 AC_CHECK_HEADERS(pty.h util.h)
3108 AC_CHECK_X_LIB(util, forkpty,
3109                [PTY_LIBS="-lutil"
3110                 AC_DEFINE(HAVE_FORKPTY)])
3111
3112
3113 ###############################################################################
3114 #
3115 #       Check for the XSHM server extension.
3116 #
3117 ###############################################################################
3118
3119 have_xshm=no
3120 with_xshm_req=unspecified
3121 AC_ARG_WITH(xshm-ext,
3122 [  --with-xshm-ext         Include support for the Shared Memory extension.],
3123   [with_xshm="$withval"; with_xshm_req="$withval"],[with_xshm=yes])
3124
3125 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
3126
3127 if test "$with_xshm" = yes; then
3128
3129   # first check for Xshm.h.
3130   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes],,
3131                     [#include <X11/Xlib.h>])
3132
3133   # if that succeeded, then check for sys/ipc.h.
3134   if test "$have_xshm" = yes; then
3135     have_xshm=no
3136     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
3137   fi
3138
3139   # if that succeeded, then check for sys/shm.h.
3140   if test "$have_xshm" = yes; then
3141     have_xshm=no
3142     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
3143   fi
3144
3145   # AIX is pathological, as usual: apparently it's normal for the Xshm headers
3146   # to exist, but the library code to not exist.  And even better, the library
3147   # code is in its own library: libXextSam.a.  So, if we're on AIX, and that
3148   # lib doesn't exist, give up.  (This lib gets added to X_EXTRA_LIBS, and
3149   # that's not quite right, but close enough.)
3150   #
3151   case "$host" in
3152     *-aix*)
3153       if [ `uname -v` -eq 3 ]; then
3154         have_xshm=no
3155         AC_CHECK_X_LIB(XextSam, XShmQueryExtension,
3156                        [have_xshm=yes; X_EXTRA_LIBS="$X_EXTRA_LIBS -lXextSam"],
3157                        [true], -lX11 -lXext -lm)
3158       fi
3159     ;;
3160   esac
3161
3162   # if that succeeded, then we've really got it.
3163   if test "$have_xshm" = yes; then
3164     AC_DEFINE(HAVE_XSHM_EXTENSION)
3165   fi
3166
3167 elif test "$with_xshm" != no; then
3168   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
3169   exit 1
3170 fi
3171
3172
3173 ###############################################################################
3174 #
3175 #       Check for the DOUBLE-BUFFER server extension.
3176 #
3177 ###############################################################################
3178
3179 have_xdbe=no
3180 with_xdbe_req=unspecified
3181 AC_ARG_WITH(xdbe-ext,
3182 [  --with-xdbe-ext         Include support for the DOUBLE-BUFFER extension.],
3183   [with_xdbe="$withval"; with_xdbe_req="$withval"],[with_xdbe=yes])
3184
3185 HANDLE_X_PATH_ARG(with_xdbe, --with-xdbe-ext, DOUBLE-BUFFER)
3186
3187 if test "$with_xdbe" = yes; then
3188
3189   AC_CHECK_X_HEADER(X11/extensions/Xdbe.h, [have_xdbe=yes],,
3190                     [#include <X11/Xlib.h>])
3191   if test "$have_xdbe" = yes; then
3192     AC_DEFINE(HAVE_DOUBLE_BUFFER_EXTENSION)    
3193   fi
3194
3195 elif test "$with_xdbe" != no; then
3196   echo "error: must be yes or no: --with-xdbe-ext=$with_xshm"
3197   exit 1
3198 fi
3199
3200
3201 ###############################################################################
3202 #
3203 #       Check for the SGI XReadDisplay server extension.
3204 #
3205 #       Note: this has to be down here, rather than up with the other server
3206 #       extension tests, so that the output of `configure --help' is in the
3207 #       right order.  Arrgh!
3208 #
3209 ###############################################################################
3210
3211 have_readdisplay=no
3212 with_readdisplay_req=unspecified
3213 AC_ARG_WITH(readdisplay,
3214 [  --with-readdisplay      Include support for the XReadDisplay extension.],
3215   [with_readdisplay="$withval"; with_readdisplay_req="$withval"],
3216   [with_readdisplay=yes])
3217
3218 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
3219
3220 if test "$with_readdisplay" = yes; then
3221   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
3222                     AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION),,
3223                     [#include <X11/Xlib.h>])
3224 elif test "$with_readdisplay" != no; then
3225   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
3226   exit 1
3227 fi
3228
3229
3230 ###############################################################################
3231 #
3232 #       Check for a directory full of images to use as the default value
3233 #       of the "imageDirectory" preference.
3234 #
3235 ###############################################################################
3236
3237 have_imagedir=no
3238 with_imagedir_req=unspecified
3239
3240 AC_ARG_WITH(image-directory,
3241 [  --with-image-directory=DIR  By default, some demos may display random images
3242                           from this directory.],
3243   [with_imagedir="$withval"; with_imagedir_req="$withval"],
3244   [with_imagedir=yes])
3245 # no HANDLE_X_PATH_ARG for this one
3246
3247 case "$with_imagedir" in
3248   /*)
3249     # absolute path
3250     AC_MSG_CHECKING([for image directory $with_imagedir])
3251     if test -d "$with_imagedir" ; then
3252       AC_MSG_RESULT(yes)
3253     else
3254       AC_MSG_RESULT(no)
3255       with_imagedir=""
3256     fi
3257   ;;
3258   yes)
3259     with_imagedir=""
3260
3261     #### Could use some more defaults here...
3262     for dd in \
3263       "/usr/share/backgrounds/images/"          \
3264       "/usr/share/wallpapers/"                  \
3265       "/Library/Desktop Pictures/"              \
3266     ; do
3267       if test -z "$with_imagedir"; then
3268         AC_MSG_CHECKING([for image directory $dd])
3269         if test -d "$dd" ; then
3270           AC_MSG_RESULT(yes)
3271           with_imagedir="$dd"
3272         else
3273           AC_MSG_RESULT(no)
3274         fi
3275       fi
3276     done
3277
3278   ;;
3279   no)
3280     with_imagedir=""
3281   ;;
3282
3283   *)
3284     echo "error: must be an absolute path: --with-image-directory=$with_imagedir_req"
3285     exit 1
3286   ;;
3287 esac
3288 ac_cv_imagedir="$with_imagedir"
3289
3290 DEFAULT_IMAGES_P='True'
3291 DEFAULT_IMAGE_DIRECTORY="$ac_cv_imagedir"
3292
3293 if test -z "$DEFAULT_IMAGE_DIRECTORY" ; then
3294   DEFAULT_IMAGES_P='False'
3295 fi
3296
3297
3298 ###############################################################################
3299 #
3300 #       Pick a text file to use as the default of the "textFile" preference.
3301 #       Any old file will do, but preferably one that will make interesting
3302 #       shapes when displayed by "starwars" and "fontglide".
3303 #
3304 ###############################################################################
3305
3306 have_textfile=no
3307 with_textfile_req=unspecified
3308
3309 AC_ARG_WITH(text-file,
3310 [  --with-text-file=FILE   By default, some demos may display this file.],
3311   [with_textfile="$withval"; with_textfile_req="$withval"],
3312   [with_textfile=yes])
3313 # no HANDLE_X_PATH_ARG for this one
3314
3315 case "$with_textfile" in
3316   /*)
3317     # absolute path
3318     AC_MSG_CHECKING([for image directory $with_textfile])
3319     if test -d "$with_textfile" ; then
3320       AC_MSG_RESULT(yes)
3321     else
3322       AC_MSG_RESULT(no)
3323       with_textfile=""
3324     fi
3325   ;;
3326   yes)
3327     with_textfile=""
3328
3329     #### Could use some more defaults here...
3330     for f in \
3331       "/usr/X11R6/lib/X11/doc/README"           \
3332       "/usr/share/doc/xserver-common/copyright" \
3333       "/usr/X11R6/README"                       \
3334     ; do
3335       if test -z "$with_textfile"; then
3336         AC_MSG_CHECKING([for text file $f])
3337         if test -f "$f" ; then
3338           AC_MSG_RESULT(yes)
3339           with_textfile="$f"
3340         else
3341           AC_MSG_RESULT(no)
3342         fi
3343       fi
3344     done
3345
3346   ;;
3347   no)
3348     with_textfile=""
3349   ;;
3350
3351   *)
3352     echo "error: must be an absolute path: --with-image-directory=$with_textfile_req"
3353     exit 1
3354   ;;
3355 esac
3356 ac_cv_textfile="$with_textfile"
3357
3358 DEFAULT_TEXT_FILE="$ac_cv_textfile"
3359
3360
3361 ###############################################################################
3362 #
3363 #       Check whether it's ok to install some hacks as setuid (e.g., "sonar")
3364 #       This should be safe, but let's give people the option.
3365 #
3366 ###############################################################################
3367
3368 setuid_hacks_default=no
3369 setuid_hacks="$setuid_hacks_default"
3370 AC_ARG_WITH(setuid-hacks,
3371 [  --with-setuid-hacks     Allow some demos to be installed `setuid root'
3372                           (which is needed in order to ping other hosts.)
3373 ],
3374   [setuid_hacks="$withval"], [setuid_hacks="$setuid_hacks_default"])
3375
3376 HANDLE_X_PATH_ARG(setuid_hacks, --with-setuid-hacks, setuid hacks)
3377
3378 if test "$setuid_hacks" = yes; then
3379   true
3380 elif test "$setuid_hacks" != no; then
3381   echo "error: must be yes or no: --with-setuid-hacks=$setuid_hacks"
3382   exit 1
3383 fi
3384
3385
3386 ###############################################################################
3387 #
3388 #       Done testing.  Now, set up the various -I and -L variables,
3389 #       and decide which GUI program to build by default.
3390 #
3391 ###############################################################################
3392
3393 DEPEND=makedepend
3394 DEPEND_FLAGS=
3395 DEPEND_DEFINES=
3396
3397
3398 if test \! -z "$includedir" ; then 
3399   INCLUDES="$INCLUDES -I$includedir"
3400 fi
3401
3402 if test \! -z "$libdir" ; then
3403   LDFLAGS="$LDFLAGS -L$libdir"
3404 fi
3405
3406
3407 PREFERRED_DEMO_PROGRAM=''
3408 ALL_DEMO_PROGRAMS=
3409 if test "$have_motif" = yes; then
3410   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
3411   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3412 fi
3413 if test "$have_gtk" = yes; then
3414   PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
3415   ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3416 fi
3417
3418
3419 if test "$have_kerberos" = yes; then
3420   PASSWD_SRCS="$PASSWD_SRCS \$(KERBEROS_SRCS)"
3421   PASSWD_OBJS="$PASSWD_OBJS \$(KERBEROS_OBJS)"
3422 fi
3423 if test "$have_pam" = yes; then
3424   PASSWD_SRCS="$PASSWD_SRCS \$(PAM_SRCS)"
3425   PASSWD_OBJS="$PASSWD_OBJS \$(PAM_OBJS)"
3426   INSTALL_PAM="install-pam"
3427 fi
3428 if test "$have_passwd_helper" = yes; then
3429   PASSWD_SRCS="$PASSWD_SRCS \$(PWHELPER_SRCS)"
3430   PASSWD_OBJS="$PASSWD_OBJS \$(PWHELPER_OBJS)"
3431 fi
3432   PASSWD_SRCS="$PASSWD_SRCS \$(PWENT_SRCS)"
3433   PASSWD_OBJS="$PASSWD_OBJS \$(PWENT_OBJS)"
3434
3435
3436 if test "$enable_locking" = yes; then
3437   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
3438   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
3439 else
3440   LOCK_SRCS='$(NOLOCK_SRCS_1)'
3441   LOCK_OBJS='$(NOLOCK_OBJS_1)'
3442 fi
3443
3444 if test "$ac_macosx" = yes; then
3445   EXES_OSX='$(EXES_OSX)'
3446   SCRIPTS_OSX='$(SCRIPTS_OSX)'
3447   MEN_OSX='$(MEN_OSX)'
3448 else
3449   EXES_OSX=
3450   SCRIPTS_OSX=
3451   MEN_OSX=
3452 fi
3453
3454
3455 INSTALL_SETUID='$(INSTALL_PROGRAM) $(SUID_FLAGS)'
3456
3457 if test "$need_setuid" = yes; then
3458   NEED_SETUID=yes
3459 else
3460   NEED_SETUID=no
3461 fi
3462
3463 if test "$setuid_hacks" = yes; then
3464   SETUID_HACKS=yes
3465 else
3466   SETUID_HACKS=no
3467 fi
3468
3469 tab='   '
3470 if test "$have_gl" = yes; then
3471   GL_EXES='$(GL_EXES)'
3472   GL_UTIL_EXES='$(GL_UTIL_EXES)'
3473   GL_MEN='$(GL_MEN)'
3474   GL_KLUDGE="${tab}  "
3475 else
3476   GL_KLUDGE="-${tab}  "
3477 fi
3478
3479 if test "$have_gle" = yes; then
3480   GLE_EXES='$(GLE_EXES)'
3481   GLE_KLUDGE="${tab}   "
3482 else
3483   GLE_KLUDGE="-${tab}   "
3484 fi
3485
3486 if test "$have_jpeg" = yes -a "$have_gdk_pixbuf" = yes; then
3487  JPEG_EXES='$(JPEG_EXES)'
3488 fi
3489
3490
3491 # Another substitution in the XScreenSaver.ad.in file:
3492 #
3493 if test "$gnome_open_program" != ''; then
3494   GNOME24=''
3495   GNOME22='!    '
3496   NOGNOME='!    '
3497 elif test "$gnome_url_show_program" != ''; then
3498   GNOME24='!    '
3499   GNOME22=''
3500   NOGNOME='!    '
3501 else
3502   GNOME24='!    '
3503   GNOME22='!    '
3504   NOGNOME=''
3505 fi
3506
3507
3508 # Set PO_DATADIR to something sensible.
3509 #
3510 AC_MSG_CHECKING([for locale directory])
3511 if test -n "$GTK_DATADIR" ; then
3512   PO_DATADIR="$GTK_DATADIR"
3513 elif test "$have_gtk" = yes; then
3514   PO_DATADIR=`$pkg_config --variable=prefix gtk+-2.0`
3515   PO_DATADIR="$PO_DATADIR/share"
3516 fi
3517
3518 if test -z "$PO_DATADIR" ; then
3519   #
3520   # #### Total fucking kludge --
3521   # Map /build/prefix/usr/X11R6/share/ to /build/prefix/usr/share/
3522   # but of course we need to expand all the nested variables to do that...
3523   #
3524   dd=$datadir
3525   eval dd=${dd}
3526   eval dd=${dd}
3527   eval dd=${dd}
3528   eval dd=${dd}
3529   eval dd=${dd}
3530   PO_DATADIR=`echo $dd | sed 's@/X11R6/@/@'`
3531 fi
3532
3533 AC_MSG_RESULT($PO_DATADIR/locale)
3534
3535
3536 # canonicalize slashes.
3537 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
3538
3539 # gcc 3.0 likes to issue this warning for every file:
3540 #
3541 # cc1: warning: changing search order for system directory "/usr/local/include"
3542 # cc1: warning:   as it has already been specified as a non-system directory
3543 #
3544 # Yay.  We can only avoid that by deleting "-I${prefix}/include" from the list.
3545 # Which *should* be totally redundant, and thus an ok thing to delete?
3546 #
3547 INCLUDES=`echo "$INCLUDES" | sed 's@ -I${prefix}/include@@g;'`
3548
3549
3550 ###############################################################################
3551 #
3552 #       Perform substitutions and write Makefiles.
3553 #
3554 ###############################################################################
3555
3556 AC_SUBST(INCLUDES)
3557
3558 AC_SUBST(PREFERRED_DEMO_PROGRAM)
3559 AC_SUBST(ALL_DEMO_PROGRAMS)
3560 AC_SUBST(SAVER_LIBS)
3561 AC_SUBST(MOTIF_LIBS)
3562 AC_SUBST(GTK_LIBS)
3563 AC_SUBST(XML_LIBS)
3564 AC_SUBST(JPEG_LIBS)
3565 AC_SUBST(HACK_LIBS)
3566 AC_SUBST(XPM_LIBS)
3567 AC_SUBST(PTY_LIBS)
3568 AC_SUBST(GL_LIBS)
3569 AC_SUBST(GLE_LIBS)
3570 AC_SUBST(XDPMS_LIBS)
3571 AC_SUBST(XINERAMA_LIBS)
3572 AC_SUBST(PASSWD_LIBS)
3573 AC_SUBST(INSTALL_SETUID)
3574 AC_SUBST(SETUID_HACKS)
3575 AC_SUBST(INSTALL_DIRS)
3576 AC_SUBST(NEED_SETUID)
3577 AC_SUBST(INSTALL_PAM)
3578 AC_SUBST(NEW_LOGIN_COMMAND)
3579 AC_SUBST(NEW_LOGIN_COMMAND_P)
3580 AC_SUBST(DEFAULT_IMAGES_P)
3581 AC_SUBST(DEFAULT_IMAGE_DIRECTORY)
3582 AC_SUBST(DEFAULT_TEXT_FILE)
3583
3584 AC_SUBST(OBJCC)
3585 AC_SUBST(EXES_OSX)
3586 AC_SUBST(SCRIPTS_OSX)
3587 AC_SUBST(MEN_OSX)
3588
3589 AC_SUBST(PASSWD_SRCS)
3590 AC_SUBST(PASSWD_OBJS)
3591 AC_SUBST(XMU_SRCS)
3592 AC_SUBST(XMU_OBJS)
3593 AC_SUBST(XMU_LIBS)
3594 AC_SUBST(SAVER_GL_SRCS)
3595 AC_SUBST(SAVER_GL_OBJS)
3596 AC_SUBST(SAVER_GL_LIBS)
3597 AC_SUBST(LOCK_SRCS)
3598 AC_SUBST(LOCK_OBJS)
3599 AC_SUBST(JPEG_EXES)
3600 AC_SUBST(GL_EXES)
3601 AC_SUBST(GL_UTIL_EXES)
3602 AC_SUBST(GL_MEN)
3603 AC_SUBST(GL_KLUDGE)
3604 AC_SUBST(GLE_EXES)
3605 AC_SUBST(GLE_KLUDGE)
3606 AC_SUBST(GNOME24)
3607 AC_SUBST(GNOME22)
3608 AC_SUBST(NOGNOME)
3609 AC_SUBST(HACKDIR)
3610 AC_SUBST(GTK_DATADIR)
3611 AC_SUBST(PO_DATADIR)
3612 AC_SUBST(HACK_CONF_DIR)
3613 AC_SUBST(GTK_EXTRA_OBJS)
3614
3615 APPDEFAULTS=$ac_x_app_defaults
3616 AC_SUBST(APPDEFAULTS)
3617
3618 AC_SUBST(DEPEND)
3619 AC_SUBST(DEPEND_FLAGS)
3620 AC_SUBST(DEPEND_DEFINES)
3621 AC_SUBST(PERL)
3622
3623 AC_OUTPUT(Makefile
3624           utils/Makefile
3625           driver/Makefile
3626           hacks/Makefile
3627           hacks/glx/Makefile
3628           po/Makefile.in
3629           driver/XScreenSaver.ad)
3630
3631 ###############################################################################
3632 #
3633 #       Print some warnings at the end.
3634 #
3635 ###############################################################################
3636
3637 warn_prefix_1="    Warning:"
3638 warn_prefix_2="       Note:"
3639 warn_prefix="$warn_prefix_1"
3640
3641 warning=no
3642 warnsep='    #################################################################'
3643
3644 warnpre() {
3645   if test "$warning" = no ; then
3646     echo '' ; echo "$warnsep" ; echo ''
3647     warning=yes
3648   fi
3649 }
3650
3651 warn() {
3652   warnpre
3653   if test "$warning" = long ; then echo '' ; fi
3654   warning=yes
3655   rest="$@"
3656   echo "$warn_prefix $rest"
3657 }
3658
3659 warnL() {
3660   was=$warning
3661   warnpre
3662   warning=yes
3663   if test "$was" != no ; then echo '' ; fi
3664   rest="$@"
3665   echo "$warn_prefix $rest"
3666 }
3667
3668 warn2() {
3669   rest="$@"
3670   echo "             $rest"
3671   warning=long
3672 }
3673
3674 note() {
3675   warn_prefix="$warn_prefix_2"
3676   warn $@
3677   warn_prefix="$warn_prefix_1"
3678 }
3679
3680 noteL() {
3681   warn_prefix="$warn_prefix_2"
3682   warnL $@
3683   warn_prefix="$warn_prefix_1"
3684 }
3685
3686
3687 if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
3688   warn 'The SGI saver extension was requested, but was not found.'
3689 fi
3690
3691 if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
3692   warn 'The XIdle extension was requested, but was not found.'
3693 fi
3694
3695 if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
3696   warn 'The XSHM extension was requested, but was not found.'
3697 fi
3698
3699 if test "$with_xdbe_req" = yes -a "$have_xdbe" = no ; then
3700   warn 'The DOUBLE-BUFFER extension was requested, but was not found.'
3701 fi
3702
3703 if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
3704   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
3705 fi
3706
3707 if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
3708   warn 'The DPMS extension was requested, but was not found.'
3709 fi
3710
3711 if test "$with_xinerama_req" = yes -a "$have_xinerama" = no ; then
3712   warn 'The Xinerama extension was requested, but was not found.'
3713 fi
3714
3715 if test "$with_xf86vmode_req" = yes -a "$have_xf86vmode" = no ; then
3716   warn 'The XF86VMODE extension was requested, but was not found.'
3717 fi
3718
3719 if test "$with_randr_req" = yes -a "$have_randr" = no ; then
3720   warn 'The RANDR extension was requested, but was not found.'
3721 fi
3722
3723 if test "$with_proc_interrupts_req" = yes -a "$have_proc_interrupts" = no; then
3724   warn "Checking of /proc/interrupts was requested, but it's bogus."
3725 fi
3726
3727 if test "$pkg_config" = false ; then
3728   warnL 'The "pkg-config" program was not found.  Without that,'
3729   warn2 "detection of the various GTK libraries won't work."
3730 else
3731   pkgerr=`$pkg_config --list-all 2>&1 >/dev/null`
3732   if test "x$pkgerr" != "x" ; then
3733     warnL 'The "pkg-config" program produces errors.  This often causes'
3734     warn2 "detection of the various GTK libraries to malfunction."
3735     warn2 "The errors are:"
3736     echo ''
3737     echo "$pkgerr" | sed 's/^/             > /g'
3738   fi
3739 fi
3740
3741 if test "$gtk_halfassed" != no ; then
3742   warnL "GTK version $gtk_halfassed was found, but at least one supporting"
3743   warn2 "library ($gtk_halfassed_lib) was not, so GTK can't be used."
3744   warn2 "Perhaps some of the development packages are not installed?"
3745   if test "$have_gtk" = yes ; then
3746     v="$ac_gtk_version_string"
3747     warn2 "GTK $v is also installed, so it will be used instead."
3748     warn2 "Please read the above output and the \`config.log' file"
3749     warn2 "for more details."
3750   fi
3751 fi
3752
3753 motif_warn2() {
3754   warn2 'Though the Motif front-end to xscreensaver is still'
3755   warn2 'maintained, it is no longer being updated with new'
3756   warn2 'features: all new development on the xscreensaver-demo'
3757   warn2 'program is happening in the GTK version, and not in the'
3758   warn2 'Motif version.  It is recommended that you build against'
3759   warn2 'GTK instead of Motif.  See <http://www.gtk.org/>.'
3760 }
3761
3762 if test "$have_motif" = no -a "$have_gtk" = no; then
3763
3764   if test "$with_motif" = yes; then
3765     warnL "Neither the GTK nor Motif libraries were found; the"
3766     warn2 "\`xscreensaver-demo' program requires one of these."
3767     echo ''
3768     motif_warn2
3769   else
3770     warnL "The GTK libraries do not seem to be available; the"
3771     warn2 "\`xscreensaver-demo' program requires them."
3772 #   echo ''
3773 #   warn2 'You can use Motif or Lesstif instead of GTK (use the'
3774 #   warn2 "\`--with-motif' option) but that is NOT recommended."
3775 #   motif_warn2
3776   fi
3777
3778 elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
3779   warnL "Use of Motif was requested, but it wasn't found;"
3780   warn2 "Gtk will be used instead."
3781
3782 elif test "$jurassic_gtk" = yes ; then
3783
3784   pref_gtk=2.0
3785
3786   v="$ac_gtk_version_string"
3787   if test "$with_gtk_req" = yes -a "$ac_gtk_version" = "unknown" ; then
3788     warnL "Use of Gtk was requested, but its version number is unknown;"
3789   elif test "$with_gtk_req" = yes ; then
3790     warnL "Use of Gtk was requested, but it is version $v;"
3791   else
3792     warnL "Gtk was found on this system, but it is version $v;"
3793   fi
3794
3795   warn2 "Gtk $pref_gtk or newer is required."
3796
3797 elif test "$with_gtk_req" = yes -a "$have_gtk" = no ; then
3798   warnL "Use of Gtk was requested, but it wasn't found."
3799 fi
3800
3801
3802 if test "$have_gtk" = yes -a "$have_gdk_pixbuf" = no ; then
3803   warn  "GTK is being used, but the GDK-Pixbuf library and/or"
3804   warn2 "headers were not found.  That can't be good.  Please"
3805   warn2 "install the GDK-Pixbuf development kit and re-configure."
3806 fi
3807
3808 if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
3809
3810   preferred_lesstif=0.92
3811
3812   if test "$lesstif_version" = unknown; then
3813     warnL "Unable to determine the LessTif version number!"
3814     warn2 "Make sure you are using version $preferred_lesstif or newer."
3815     warn2 "See <http://www.lesstif.org/>."
3816
3817   elif test \! $lesstif_version -gt 82; then
3818     warnL "LessTif version $lesstif_version_string is being used."
3819     warn2 "LessTif versions 0.82 and earlier are too buggy to"
3820     warn2 "use with XScreenSaver; it is strongly recommended"
3821     warn2 "that you upgrade to at least version $preferred_lesstif!"
3822     warn2 "See <http://www.lesstif.org/>."
3823   fi
3824 fi
3825
3826
3827 if test "$have_motif" = yes -a "$have_gtk" = no ; then
3828   warn  'Motif is being used, and GTK is not.'
3829   echo  ''
3830   motif_warn2
3831 fi
3832
3833
3834 if test "$with_xpm_req" = yes -a "$have_xpm" = no; then
3835   warnL 'Use of XPM was requested, but it was not found.'
3836 fi
3837
3838 if test "$with_gdk_pixbuf_req" = yes  -a "$have_gdk_pixbuf" = no; then
3839   warnL 'Use of GDK-Pixbuf was requested, but it was not found.'
3840 fi
3841
3842 if test "$have_gdk_pixbuf" = no -o "$gdk_pixbuf_halfassed" = yes || \
3843    test "$have_gdk_pixbuf" = no -a "$have_xpm" = no ; then
3844
3845   if test "$with_gdk_pixbuf_req" = yes ; then
3846     true
3847   elif test "$with_gdk_pixbuf_req" = no ; then
3848     warnL 'The GDK-Pixbuf library is not being used.'
3849   else
3850     warnL 'The GDK-Pixbuf library was not found.'
3851   fi
3852
3853   if test "$with_xpm_req" = yes -o "$have_xpm" = yes ; then
3854     true
3855   elif test "$with_xpm_req" = no ; then
3856     warnL 'The XPM library is not being used.'
3857   else
3858     warnL 'The XPM library was not found.'
3859   fi
3860
3861   if test "$have_gdk_pixbuf" = no -a "$have_xpm" = yes ; then
3862     warn2 'The XPM library is being used instead.'
3863   fi
3864
3865   if test "$gdk_pixbuf_halfassed" = yes ; then
3866     echo ''
3867     warn2 'More specifically, we found the headers, but not the'
3868     warn2 'libraries; so either GDK-Pixbuf is half-installed on this'
3869     warn2 "system, or something else went wrong.  The \`config.log'"
3870     warn2 'file might contain some clues.'
3871   fi
3872
3873   echo ''
3874   warn2 'Some of the demos will not use images as much as they could.'
3875   warn2 'You should consider installing GDK-Pixbuf and re-running'
3876   warn2 'configure.  (GDK-Pixbuf is recommended over XPM, as it'
3877   warn2 'provides support for more image formats.)'
3878 fi
3879
3880
3881 if test "$have_jpeg" = no ; then
3882   if test "$with_jpeg_req" = yes ; then
3883     warnL 'Use of libjpeg was requested, but it was not found.'
3884   elif test "$with_jpeg_req" = no ; then
3885     noteL 'The JPEG library is not being used.'
3886   else
3887     noteL 'The JPEG library was not found.'
3888   fi
3889
3890   if test "$jpeg_halfassed" = yes ; then
3891     echo ''
3892     warn2 'More specifically, we found the headers, but not the'
3893     warn2 'library; so either JPEG is half-installed on this'
3894     warn2 "system, or something else went wrong.  The \`config.log'"
3895     warn2 'file might contain some clues.'
3896     echo ''
3897   fi
3898
3899   if test "$have_gdk_pixbuf" = no ; then
3900     warn2 "This means that it won't be possible for the image-manipulating"
3901     warn2 "display modes to load files from disk; and it also means that"
3902     warn2 "the \`webcollage' program will be much slower."
3903   else
3904     warn2 "This means the \`webcollage' program will be much slower."
3905   fi
3906 fi
3907
3908
3909 if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
3910   preferred_mesagl=3.4
3911   mgv="$ac_mesagl_version_string"
3912   pgl="$preferred_mesagl"
3913
3914   if test "$ac_mesagl_version" = unknown; then
3915     warnL "Unable to determine the MesaGL version number!"
3916     warn2 "Make sure you are using version $preferred_mesagl or newer."
3917
3918   elif test \! "$ac_mesagl_version" -gt 2006; then
3919     warnL "MesaGL version number is $mgv --"
3920     warn2 "MesaGL 2.6 and earlier have a security bug.  It is strongly"
3921     warn2 "recommended that you upgrade to at least version $preferred_mesagl."
3922
3923   elif test \! "$ac_mesagl_version" -gt 3003; then
3924     warnL "MesaGL version number is $mgv --"
3925     warn2 "MesaGL 3.3 and earlier have some bugs; it is recommended"
3926     warn2 "that you upgrade to $pgl or newer."
3927   fi
3928 fi
3929
3930 if test "$have_gl" = no ; then
3931   if test "$with_gl_req" = yes ; then
3932     warnL 'Use of GL was requested, but it was not found.'
3933   elif test "$with_gl_req" = no ; then
3934     noteL 'The OpenGL 3D library is not being used.'
3935   else
3936     noteL 'The OpenGL 3D library was not found.'
3937   fi
3938
3939   if test "$gl_halfassed" = yes ; then
3940     echo ''
3941     warn2 'More specifically, we found the headers, but not the'
3942     warn2 'libraries; so either GL is half-installed on this'
3943     warn2 "system, or something else went wrong.  The \`config.log'"
3944     warn2 'file might contain some clues.'
3945   fi
3946
3947   echo ''
3948   warn2 'Those demos which use 3D will not be built or installed.'
3949   warn2 'You might want to consider installing OpenGL and'
3950   warn2 "re-running configure.  If your vendor doesn't ship"
3951   warn2 'their own implementation of OpenGL, you can get a free'
3952   warn2 'version at <http://www.mesa3d.org/>.  For general OpenGL'
3953   warn2 'info, see <http://www.opengl.org/>.'
3954
3955 fi
3956
3957
3958 if test "$have_gl" = yes -a "$have_gle" = no ; then
3959
3960  # nobody cares about this; don't print the warning unless it was
3961  # requested and not found, or halfway-found.
3962  if test "$with_gle_req" = yes -o "$gle_halfassed" = yes ; then
3963
3964   if test "$with_gle_req" = yes ; then
3965     noteL 'Use of the GLE (GL Extrusion) library was requested, but'
3966     warn2 'it was not found (though the OpenGL library was found, and'
3967     warn2 'is being used.)'
3968   elif test "$with_gle_req" = no ; then
3969     noteL 'The OpenGL Library is being used, but the GLE (GL Extrusion)'
3970     warn2 'library is not.'
3971   else
3972     noteL 'The OpenGL Library was found, but the GLE (GL Extrusion)'
3973     warn2 'was not.'
3974   fi
3975
3976   if test "$gle_halfassed" = yes ; then
3977     echo ''
3978     warn2 'More specifically, we found the headers, but not the'
3979     warn2 'libraries; so either GLE is half-installed on this'
3980     warn2 "system, or something else went wrong.  The \`config.log'"
3981     warn2 'file might contain some clues.'
3982   fi
3983
3984   echo ''
3985   warn2 'Some of the OpenGL (3D) demos (those that depend on GLE)'
3986   warn2 'will not be built or installed.  You might want to consider'
3987   warn2 'installing GLE and re-running configure.  You can find the'
3988   warn2 'GLE library at <http://www.linas.org/gle/>.  For general'
3989   warn2 'OpenGL info, see <http://www.opengl.org/>.'
3990
3991  fi
3992 fi
3993
3994
3995 if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
3996   warn 'Use of XReadDisplay was requested, but it was not found.'
3997 fi
3998
3999 if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
4000   warn 'Use of Kerberos was requested, but it was not found.'
4001 fi
4002
4003 if test "$with_pam_req" = yes -a "$have_pam" = no ; then
4004   warn 'Use of PAM was requested, but it was not found.'
4005 fi
4006
4007 if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
4008   warn 'Use of shadow passwords was requested, but they were not found.'
4009 fi
4010
4011
4012 # You are in a twisty maze of namespaces and syntaxes, all alike.
4013 # Fuck the skull of Unix.
4014 #
4015 eval bindir=${bindir}
4016 eval bindir=${bindir}
4017 eval bindir=${bindir}
4018 eval bindir=${bindir}
4019 eval bindir=${bindir}
4020 eval bindir=${bindir}
4021 eval HACKDIR=${HACKDIR}
4022 eval HACKDIR=${HACKDIR}
4023 eval HACKDIR=${HACKDIR}
4024 eval HACKDIR=${HACKDIR}
4025 eval HACKDIR=${HACKDIR}
4026 eval HACKDIR=${HACKDIR}
4027 eval HACK_CONF_DIR=${HACK_CONF_DIR}
4028 eval HACK_CONF_DIR=${HACK_CONF_DIR}
4029 eval HACK_CONF_DIR=${HACK_CONF_DIR}
4030 eval HACK_CONF_DIR=${HACK_CONF_DIR}
4031 eval HACK_CONF_DIR=${HACK_CONF_DIR}
4032 eval HACK_CONF_DIR=${HACK_CONF_DIR}
4033
4034 # canonicalize slashes.
4035 bindir=`echo  "${bindir}"              | sed 's@/$@@;s@//*@/@g'`
4036 HACKDIR=`echo "${HACKDIR}"             | sed 's@/$@@;s@//*@/@g'`
4037 HACK_CONF_DIR=`echo "${HACK_CONF_DIR}" | sed 's@/$@@;s@//*@/@g'`
4038
4039
4040 # Sanity check the hackdir
4041 for bad_choice in xscreensaver xscreensaver-demo xscreensaver-command ; do
4042   if test "${HACKDIR}" = "${bindir}/${bad_choice}" ; then
4043     echo ""
4044     AC_MSG_ERROR([\"--with-hackdir=${bindir}/${bad_choice}\" won't work.
4045                    There will be an executable installed with that name, so
4046                    that can't be the name of a directory as well.  Please
4047                    re-configure with a different directory name.])
4048   fi
4049 done
4050
4051
4052 do_dir_warning=no
4053
4054 # Now let's warn if there's a previous RPM version already installed.
4055 # But don't bother with this test if we are currently *building* an RPM.
4056
4057 if test -z "$RPM_PACKAGE_VERSION" ; then
4058
4059   rpmnames="xscreensaver xscreensaver-base xscreensaver-extras"
4060
4061   # M4 sucks!!
4062   changequote(X,Y)
4063   rpmv=`(rpm -qv $rpmnames) 2>/dev/null | \
4064         sed -n 's/^[-a-z]*-\([0-9][0-9]*[.][0-9][0-9a-z]*\)-.*$/\1/p' | \
4065         head -1`
4066   changequote([,])
4067
4068   if test \! -z "$rpmv" ; then
4069     rpmbdir=`rpm -ql $rpmnames | sed -n 's@^\(.*\)/xscreensaver-demo$@\1@p'`
4070     rpmhdir=`rpm -ql $rpmnames | sed -n 's@^\(.*\)/attraction$@\1@p'`
4071
4072     warning=no
4073     warnL "There is already an installed RPM of xscreensaver $rpmv"
4074     warn2 'on this system.  You might want to remove it ("rpm -ve")'
4075     warn2 'before running "make install" in this directory.'
4076     echo ""
4077     warn2 "Alternately, you could build this version of xscreensaver"
4078     warn2 'as an RPM, and then install that.  An "xscreensaver.spec"'
4079     warn2 'file is included.  Try "rpmbuild -v -ba xscreensaver.spec".'
4080     warn2 "See the RPM documentation for more info."
4081     echo ""
4082
4083     if test "$rpmbdir" = "$rpmhdir" ; then
4084       warn2 "The RPM version was installed in $rpmbdir/."
4085       do_dir_warning=yes
4086     else
4087       warn2 "The RPM version was installed in $rpmbdir/,"
4088       warn2 "with demos in $rpmhdir/."
4089     fi
4090   fi
4091 fi
4092
4093 if test "${bindir}" = "${HACKDIR}" ; then
4094   do_dir_warning=yes
4095 fi
4096
4097 if test "$do_dir_warning" = yes; then
4098   echo ""
4099   echo "$warnsep"
4100   echo ""
4101   echo '      When you run "make install", the "xscreensaver",'
4102   echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
4103   echo "      will be installed in ${bindir}/."
4104   echo ""
4105   echo "      The various graphics demos (190+ different executables) will"
4106   echo "      be installed in ${HACKDIR}/."
4107   echo ""
4108   echo "      If you would prefer the demos to be installed elsewhere,"
4109   echo "      you should re-run configure with the --with-hackdir=DIR"
4110   echo "      option.  For more information, run \`./configure --help'."
4111   warning=yes
4112 fi
4113
4114 if test "$warning" != no; then
4115   echo '' ; echo "$warnsep" ; echo ''
4116 fi
4117
4118 if test "$do_dir_warning" = no; then
4119   if test "$warning" = no; then
4120     echo ''
4121   fi
4122   echo "User programs will be installed in ${bindir}/"
4123   echo "Screen savers will be installed in ${HACKDIR}/"
4124   echo "Configuration will be installed in ${HACK_CONF_DIR}/"
4125   echo ''
4126 fi