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