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