http://packetstormsecurity.org/UNIX/admin/xscreensaver-3.29.tar.gz
[xscreensaver] / configure.in
index c6688070bf6646bba305ae7d07de19987aad6c09..5e95dd60ec3c8faae440e967128eb3806a74e24d 100644 (file)
@@ -1,4 +1,4 @@
-# configure.in --- xscreensaver, Copyright (c) 1997 Jamie Zawinski.
+# configure.in --- xscreensaver, Copyright (c) 1997-2000 Jamie Zawinski.
 #
 
 AC_INIT(driver/subprocs.c)
@@ -66,8 +66,6 @@ AC_DEFUN(AC_PROG_CC_ANSI,
   if test -n "$GCC"; then
     AC_MSG_RESULT(Turning on gcc compiler warnings.)
     CC="$CC -Wall -Wstrict-prototypes -Wnested-externs -Wno-format"
-    AC_MSG_RESULT(Disabling C++ comments in ANSI C code.)
-    CC="$CC -Wp,-lang-c89"
   else
     case "$host" in
       *-irix5* |*-irix6.[0-3]* )
@@ -85,6 +83,63 @@ AC_DEFUN(AC_PROG_CC_ANSI,
 ])
 
 
+###############################################################################
+#
+#       Functions to figure out how to disable // comments in ANSI C code.
+#
+#       (With recent gcc, this is done with "-std=c89".  With older gcc, this
+#       is done by passing "-lang-c89" to cpp, by passing "-Wp,-lang-c89" to
+#       gcc.  Old gcc doesn't support -std, and new gcc doesn't support -lang.
+#       so much for compatibility!)
+#
+###############################################################################
+
+AC_DEFUN(AC_GCC_ACCEPTS_STD,
+ [if test -n "$GCC"; then
+   AC_CACHE_CHECK([whether gcc accepts -std],
+     ac_cv_gcc_accepts_std,
+    [if ( gcc -E -std=c89 - </dev/null 2>&1 >/dev/null | \
+          grep unrecognized >/dev/null ); then
+       ac_cv_gcc_accepts_std=no
+     else
+       ac_cv_gcc_accepts_std=yes
+     fi])
+   ac_gcc_accepts_std="$ac_cv_gcc_accepts_std"
+  fi
+])
+
+AC_DEFUN(AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE,
+ [if test -n "$GCC"; then
+   AC_GCC_ACCEPTS_STD
+   AC_MSG_RESULT(Disabling C++ comments in ANSI C code.)
+   #
+   # The reason that // comments are banned from xscreensaver is that gcc is
+   # basically the only compiler in the world that supports them in C code.
+   # All other vendors support them only in their C++ compilers, not in their
+   # ANSI C compilers.  This means that it's a portability problem: every time
+   # these comments have snuck into the xscreensaver source code, I've gotten
+   # complaints about it the next day.  So we turn off support for them in gcc
+   # as well to prevent them from accidentially slipping in.
+   #
+   if test "$ac_gcc_accepts_std" = yes ; then
+     #
+     # -std=c89 defines __STRICT_ANSI__, which we don't want.
+     # (That appears to be the only additional preprocessor symbol
+     # it defines, in addition to the syntax changes it makes.)
+     #
+     # -std=gnu89 is no good, because // comments were a GNU extension
+     # before they were in the ANSI C 99 spec...  (gcc 2.96 permits //
+     # with -std=gnu89 but not with -std=c89.)
+     #
+     CC="$CC -std=c89 -U__STRICT_ANSI__"
+   else
+     # The old way:
+     CC="$CC -Wp,-lang-c89"
+   fi
+  fi
+])
+
+
 ###############################################################################
 #
 #       Function to figure out how to create directory trees.
@@ -250,7 +305,12 @@ AC_DEFUN(AC_CHECK_ICMP,
                    i.icmp_id = 0;
                    i.icmp_seq = 0;
                    si.sin_family = AF_INET;
-                   ip.ip_hl = 0;],
+                   #if defined(__DECC) || defined(_IP_VHL)
+                   ip.ip_vhl = 0;
+                   #else
+                   ip.ip_hl = 0;
+                   #endif
+                   ],
                   [ac_cv_have_icmp=yes],
                   [ac_cv_have_icmp=no])])
  if test "$ac_cv_have_icmp" = yes ; then
@@ -674,6 +734,7 @@ AC_DEFUN(HANDLE_X_PATH_ARG, [
 # random compiler setup
 AC_CANONICAL_HOST
 AC_PROG_CC_ANSI
+AC_NO_CPLUSPLUS_COMMENTS_IN_C_CODE
 AC_PROG_CPP
 AC_C_CONST
 AC_C_INLINE
@@ -997,14 +1058,22 @@ if test "$with_dpms" = yes; then
   # first check for dpms.h
   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
 
-  # if that succeeded, then check for the -lXdpms
+  # if that succeeded, then check for the DPMS code in the libraries
   if test "$have_dpms" = yes; then
+
+    # first look in -lXext (this is where it is with XFree86 4.0)
     have_dpms=no
-    AC_CHECK_X_LIB(Xdpms, DPMSInfo,
-                  [have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"], [true],
-                  -lXext -lX11)
+    AC_CHECK_X_LIB(Xext, DPMSInfo, [have_dpms=yes], [true], -lXext -lX11)
+
+    # if that failed, look in -lXdpms (this is where it was in XFree86 3.x)
+    if test "$have_dpms" = no; then
+      AC_CHECK_X_LIB(Xdpms, DPMSInfo,
+                    [have_dpms=yes; XDPMS_LIBS="-lXdpms"], [true],
+                    -lXext -lX11)
+    fi
   fi
 
+
   # if that succeeded, then we've really got it.
   if test "$have_dpms" = yes; then
     AC_DEFINE(HAVE_DPMS_EXTENSION)
@@ -1619,8 +1688,8 @@ if test "$with_gtk" = yes; then
     gtk_path="$gnome_dir:$gtk_path"
   fi
 
-  AC_PATH_PROGS(glib_config,  glib-config,,  $gtk_path)
-  AC_PATH_PROGS(gtk_config,   gtk-config,,   $gtk_path)
+  AC_PATH_PROGS(glib_config,  glib12-config glib-config,,  $gtk_path)
+  AC_PATH_PROGS(gtk_config,   gtk12-config  gtk-config,,   $gtk_path)
 
   if test "$with_gnome" = yes; then
     AC_PATH_PROGS(gnome_config, gnome-config,, $gtk_path)
@@ -1635,7 +1704,7 @@ if test "$with_gtk" = yes; then
 
   if test "$have_gtk" = yes; then
     AC_CACHE_CHECK([Gtk version number], ac_cv_gtk_version_string,
-                   [ac_cv_gtk_version_string=`$glib_config --version`])
+                   [ac_cv_gtk_version_string=`$gtk_config --version`])
     ac_gtk_version_string=$ac_cv_gtk_version_string
     # M4 sucks!!
     changequote(X,Y)
@@ -1671,7 +1740,7 @@ if test "$with_gtk" = yes; then
     AC_MSG_CHECKING(for Gnome capplet includes)
     AC_CACHE_VAL(ac_cv_gnome_config_cflags,
       [if ( $gnome_config --cflags $gnome_config_libs 2>&1 >/dev/null | \
-            grep -q Unknown ) ; then
+            grep Unknown >/dev/null ) ; then
          ac_cv_gnome_config_cflags=''
        else
          ac_cv_gnome_config_cflags=`$gnome_config --cflags $gnome_config_libs`
@@ -1689,7 +1758,7 @@ if test "$with_gtk" = yes; then
     AC_MSG_CHECKING(for Gnome capplet libs)
     AC_CACHE_VAL(ac_cv_gnome_config_libs,
       [if ( $gnome_config --libs $gnome_config_libs 2>&1 >/dev/null |
-            grep -q Unknown ) ; then
+            grep Unknown >/dev/null ) ; then
          ac_cv_gnome_config_libs=''
        else
          ac_cv_gnome_config_libs=`$gnome_config --libs $gnome_config_libs`
@@ -1906,7 +1975,7 @@ if test "$with_gl" = yes; then
     #
     AC_CACHE_CHECK([whether GL is really MesaGL], ac_cv_have_mesa_gl,
       [ac_cv_have_mesa_gl=no
-       AC_EGREP_X_HEADER(Mesa, GL/glx.h, [ac_cv_have_mesa_gl=yes])
+       AC_EGREP_X_HEADER(Mesa|MESA, GL/glx.h, [ac_cv_have_mesa_gl=yes])
       ])
     ac_have_mesa_gl=$ac_cv_have_mesa_gl
  
@@ -1972,6 +2041,11 @@ if test "$with_gl" = yes; then
 #line __oline__ "configure"
 #include "confdefs.h"
 #include <GL/gl.h>
+#ifndef MESA_MAJOR_VERSION
+# include <GL/xmesa.h>
+# define MESA_MAJOR_VERSION XMESA_MAJOR_VERSION
+# define MESA_MINOR_VERSION XMESA_MINOR_VERSION
+#endif
 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
 EOF
 
@@ -2016,28 +2090,6 @@ EOF
     #
     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
                    [true], $GL_LIBS -lX11 -lXext -lm)
-
-
-    # Check whether the `xscreensaver' executable should link against GL.
-    # See comments in utils/visual-gl.c for why this is sometimes necessary.
-    #
-    AC_MSG_CHECKING(whether drastic GL measures must be taken)
-    case "$host" in
-      *-sgi*)
-        AC_MSG_RESULT([yes -- hello, SGI.])
-        AC_DEFINE(DAEMON_USE_GL)
-        SAVER_GL_SRCS='$(UTILS_SRC)/visual-gl.c'
-        SAVER_GL_OBJS='$(UTILS_BIN)/visual-gl.o'
-        SAVER_GL_LIBS="$GL_LIBS"
-      ;;
-      *)
-        AC_MSG_RESULT([no -- non-SGI.])
-        SAVER_GL_SRCS=''
-        SAVER_GL_OBJS=''
-        SAVER_GL_LIBS=''
-      ;;
-    esac
-
   fi
 
 elif test "$with_gl" != no; then
@@ -2564,6 +2616,7 @@ AC_SUBST(HACK_LIBS)
 AC_SUBST(XPM_LIBS)
 AC_SUBST(GL_LIBS)
 AC_SUBST(GLE_LIBS)
+AC_SUBST(XDPMS_LIBS)
 AC_SUBST(PASSWD_LIBS)
 AC_SUBST(INSTALL_SETUID)
 AC_SUBST(INSTALL_DIRS)
@@ -2629,7 +2682,8 @@ warn() {
   warnpre
   if test "$warning" = long ; then echo '' ; fi
   warning=yes
-  echo "$warn_prefix $@"
+  rest="$@"
+  echo "$warn_prefix $rest"
 }
 
 warnL() {
@@ -2637,11 +2691,13 @@ warnL() {
   warnpre
   warning=yes
   if test "$was" != no ; then echo '' ; fi
-  echo "$warn_prefix $@"
+  rest="$@"
+  echo "$warn_prefix $rest"
 }
 
 warn2() {
-  echo "             $@"
+  rest="$@"
+  echo "             $rest"
   warning=long
 }