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