[PATCH] Switch to kinder, gentler autoconf errors

David Shea dshea at redhat.com
Thu Jul 24 21:44:40 UTC 2014


(this version makes gobject-introspection-devel optional)

The usual paradigm in autoconf is to fail configure if a dependency is
not found, but this is unhelpful in an environment that has 47 zillion
make targets that aren't directly connected to compling a program.
Instead of failing, print a message about missing dependencies at the
end of the ./configure with some ***'s, but still exit with a status 0
and let the Makefiles be generated. Any missing dependencies will cause
a failure during `make', and other targets like `make dist' will still
work.
---
 acinclude.m4         | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac         | 17 +++++++-----
 widgets/acinclude.m4 |  1 +
 widgets/configure.ac | 31 +++++++++++++++-------
 4 files changed, 107 insertions(+), 17 deletions(-)
 create mode 100644 acinclude.m4
 create mode 120000 widgets/acinclude.m4

diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644
index 0000000..61eb1a8
--- /dev/null
+++ b/acinclude.m4
@@ -0,0 +1,75 @@
+dnl autoconf macros for anaconda
+dnl
+dnl Copyright (C) 2014  Red Hat, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU Lesser General Public License as published
+dnl by the Free Software Foundation; either version 2.1 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
+dnl Author: David Shea <dshea at redhat.com>
+
+dnl ANACONDA_SOFT_FAILURE(MESSAGE)
+dnl
+dnl Store a message that in some contexts could be considered indicative
+dnl of a failure, but in other contexts could be indicative of who cares.
+dnl
+dnl For example, the anaconda widgets require a version of gtk3-devel of
+dnl particular newness, and the widgets will fail to build if this library
+dnl and headers are not available. On the other hand, gtk3 isn't required at
+dnl all for most everything else, so it would be nice if a missing or old
+dnl gtk3-devel didn't halt the configure script.
+dnl
+dnl Any message sent to this macro will be stored, and they can all be
+dnl displayed at the end of configure using the ANACONDA_FAILURES macro.
+AC_DEFUN([ANACONDA_SOFT_FAILURE], [dnl
+AS_IF([test x"$anaconda_failure_messages" = x],
+    [anaconda_failure_messages="[$1]"],
+    [anaconda_failure_messages="$anaconda_failure_messages
+[$1]"
+])])dnl
+
+dnl ANACONDA_PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES)
+dnl
+dnl Check whether a module is available, using pkg-config. Instead of failing
+dnl if a module is not found, store the failure in a message that can be
+dnl printed using the ANACONDA_FAILURES macro.
+dnl
+dnl The syntax and behavior of VARIABLE-PREFIX and MODULES is the same as for
+dnl PKG_CHECK_MODULES.
+AC_DEFUN([ANACONDA_PKG_CHECK_MODULES], [dnl
+PKG_CHECK_MODULES([$1], [$2], [], [ANACONDA_SOFT_FAILURE($[$1]_PKG_ERRORS)])
+])dnl
+
+dnl ANACONDA_PKG_CHECK_EXISTS(MODULES)
+dnl
+dnl Check whether a module exists, using pkg-config. Instead of failing
+dnl if a module is not found, store the failure in a message that can be
+dnl printed using the ANACONDA_FAILURES macro.
+dnl
+dnl The syntax and behavior of MOUDLES is the same as for
+dnl PKG_CHECK_EXISTS.
+AC_DEFUN([ANACONDA_PKG_CHECK_EXISTS], [dnl
+PKG_CHECK_EXISTS([$1], [], [ANACONDA_SOFT_FAILURE([Check for $1 failed])])
+])dnl
+
+dnl ANACONDA_FAILURES
+dnl
+dnl Print the failure messages collected by ANACONDA_SOFT_FAILURE and
+dnl ANACONDA_PKG_CHECK_MODULES
+AC_DEFUN([ANACONDA_FAILURES], [dnl
+AS_IF([test x"$anaconda_failure_messages" = x], [], [dnl
+echo ""
+echo "*** Anaconda encountered the following issues during configuration:"
+echo "$anaconda_failure_messages"
+echo ""
+echo "*** Anaconda will not successfully build without these missing dependencies"
+])])dnl
diff --git a/configure.ac b/configure.ac
index d9bf184..e537da2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ AC_PROG_MKDIR_P
 AC_PATH_PROG([INTLTOOL_EXTRACT], [intltool-extract])
 AC_PATH_PROG([INTLTOOL_MERGE], [intltool-merge])
 AS_IF([test -z "$INTLTOOL_EXTRACT" -o -z "$INTLTOOL_MERGE"],
-      [AC_MSG_ERROR([*** intltool not found])])
+      [ANACONDA_SOFT_FAILURE([intltool not found])])
 
 # Add the bits for Makefile rules
 INTLTOOL_V_MERGE='$(INTLTOOL__v_MERGE_$(V))'
@@ -70,7 +70,7 @@ AM_GNU_GETTEXT_VERSION([0.18.3])
 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h],
                  [],
-                 [AC_MSG_FAILURE([*** Header file $ac_header not found.])],
+                 [ANACONDA_SOFT_FAILURE([Header file $ac_header not found.])],
                  [])
 
 # Checks for typedefs, structures, and compiler characteristics.
@@ -84,7 +84,7 @@ AC_TYPE_INT64_T
 AC_FUNC_FORK
 AC_CHECK_FUNCS([getcwd memset mkdir strchr strdup],
                [],
-               [AC_MSG_FAILURE([*** Required function $ac_func not found.])])
+               [ANACONDA_SOFT_FAILURE([Function $ac_func not found.])])
 
 AM_PATH_PYTHON(python_required_version)
 
@@ -96,14 +96,14 @@ PKG_CHECK_MODULES([PYTHON], [python], [
     AC_TRY_LINK_FUNC([Py_Initialize], 
                      [AC_MSG_RESULT([yes])], 
                      [AC_MSG_RESULT([no])
-                      AC_MSG_FAILURE([*** Unable to use python library])])
+                      ANACONDA_SOFT_FAILURE([Unable to use python library])])
     LIBS="$LIBS_save"
     ],
-    [AC_MSG_FAILURE([*** Unable to find python library])])
+    [ANACONDA_SOFT_FAILURE([Unable to find python library])])
 
 # Check for libraries we need that provide pkg-config scripts
-PKG_CHECK_MODULES([RPM], [rpm >= 4.10.0])
-PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.0.4])
+ANACONDA_PKG_CHECK_MODULES([RPM], [rpm >= 4.10.0])
+ANACONDA_PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.0.4])
 
 # GCC likes to bomb out on some ridiculous warnings.  Add your favorites
 # here.
@@ -176,3 +176,6 @@ AC_CONFIG_FILES([Makefile
                  utils/Makefile
                  utils/dd/Makefile])
 AC_OUTPUT
+
+# Gently advise the user about the build failures they are about to encounter
+ANACONDA_FAILURES
diff --git a/widgets/acinclude.m4 b/widgets/acinclude.m4
new file mode 120000
index 0000000..d84c32a
--- /dev/null
+++ b/widgets/acinclude.m4
@@ -0,0 +1 @@
+../acinclude.m4
\ No newline at end of file
diff --git a/widgets/configure.ac b/widgets/configure.ac
index cbdc079..73a6151 100644
--- a/widgets/configure.ac
+++ b/widgets/configure.ac
@@ -40,21 +40,29 @@ AM_GNU_GETTEXT([external])
 
 dnl Make sure that autoconf fails if the gobject-introspection macro
 dnl is not expanded.
-m4_pattern_forbid([GOBJECT_INTROSPECTION_CHECK])dnl
-GOBJECT_INTROSPECTION_CHECK([0.6.7])
+m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
+[GOBJECT_INTROSPECTION_CHECK([0.6.7])],
+[found_introspection=no
+AM_CONDITIONAL(HAVE_INTROSPECTION, false)])
  
-# Fail if introspection was not enabled
+# Complain if introspection was not enabled
 AS_IF([test "x$found_introspection" = xyes], [:],
-      [AC_MSG_ERROR([*** GObject introspection must be enabled])])
+      [ANACONDA_SOFT_FAILURE([GObject introspection must be enabled])])
 
-PKG_CHECK_MODULES([GLADEUI], [gladeui-2.0 >= 3.10])
-PKG_CHECK_MODULES([GTK], [gtk+-x11-3.0 >= 3.11.3])
-PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier >= 5.2.1])
-PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.30])
+ANACONDA_PKG_CHECK_MODULES([GLADEUI], [gladeui-2.0 >= 3.10])
+ANACONDA_PKG_CHECK_MODULES([GTK], [gtk+-x11-3.0 >= 3.11.3])
+ANACONDA_PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier >= 5.2.1])
+ANACONDA_PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.30])
 
-AC_CHECK_HEADERS([libintl.h stdlib.h string.h unistd.h locale.h])
+AC_CHECK_HEADERS([libintl.h stdlib.h string.h unistd.h locale.h],
+                 [],
+                 [ANACONDA_SOFT_FAILURE([Header file $ac_header not found.])],
+                 [])
+
+AC_CHECK_FUNCS([setenv setlocale],
+               [],
+               [ANACONDA_SOFT_FAILURE([Function $ac_func not found.])])
 
-AC_CHECK_FUNCS([setenv setlocale])
 AC_CONFIG_FILES([Makefile
                  glade/Makefile
                  src/Makefile
@@ -62,3 +70,6 @@ AC_CONFIG_FILES([Makefile
                  data/Makefile
                  data/pixmaps/Makefile])
 AC_OUTPUT
+
+# Gently advise the user about the build failures they are about to encounter
+ANACONDA_FAILURES
-- 
1.9.3



More information about the anaconda-patches mailing list