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