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