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