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