[Autotools] Rework the build target selection
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Sep 2013 15:09:34 +0000 (15:09 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Sep 2013 15:09:34 +0000 (15:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121703

Reviewed by Gustavo Noronha Silva.

Replace the --with-target configuration flag with target-specific --enable-*-target flags:
- --enable-x11-target
- --enable-wayland-target
- --enable-win32-target
- --enable-quartz-target
- --enable-directfb-target

By default, the X11 target is enabled. This default is preserved only if no --enable-*-target flag
is passed on the command line. When that occurs, the newly-constructed list of build targets is
used to determine what build targets should actually be built. So for instance, executing just
`./configure` would only enable the X11 target as that's the default, and executing
`./configure --enable-wayland-target` would only enable the Wayland target, as the defaults are
completely ignored.

* Source/autotools/CheckSystemAndBasicDependencies.m4: Abort if grep was not found, just in case.
* Source/autotools/CustomMacros.m4: The new file that contains helpful custom macros.
* Source/autotools/FindDependencies.m4: Use the appropriate 'enable_*_target' references instead of 'with_*target'.
* Source/autotools/PrintBuildConfiguration.m4: Use the new AM_APPEND_TO_DESCRIPTION macro to construct a pretty-looking
description string of what targets will be built.
* Source/autotools/ReadCommandLineArguments.m4: Replace the --with-target configuration flag and the related
hacks with the set of --enable-*-target flags. The new AM_DETERMINE_BUILD_TARGET_STATUS macro is used to determine
whether to enable specific build targets, based indirectly on the passed-in --enable-*-target flags.
* Source/autotools/SetupAutoconfHeader.m4: Use the appropriate 'enable_*_target' references instead of 'with_*target'.
* Source/autotools/SetupAutomake.m4: Use the appropriate 'enable_*_target' references instead of 'with_*target'.
* configure.ac: Include the new CustomMacros.m4 file.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156271 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/autotools/CheckSystemAndBasicDependencies.m4
Source/autotools/CustomMacros.m4 [new file with mode: 0644]
Source/autotools/FindDependencies.m4
Source/autotools/PrintBuildConfiguration.m4
Source/autotools/ReadCommandLineArguments.m4
Source/autotools/SetupAutoconfHeader.m4
Source/autotools/SetupAutomake.m4
configure.ac

index fa04ee1..8b2844e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2013-09-23  Zan Dobersek  <zdobersek@igalia.com>
+
+        [Autotools] Rework the build target selection
+        https://bugs.webkit.org/show_bug.cgi?id=121703
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Replace the --with-target configuration flag with target-specific --enable-*-target flags:
+        - --enable-x11-target
+        - --enable-wayland-target
+        - --enable-win32-target
+        - --enable-quartz-target
+        - --enable-directfb-target
+
+        By default, the X11 target is enabled. This default is preserved only if no --enable-*-target flag
+        is passed on the command line. When that occurs, the newly-constructed list of build targets is
+        used to determine what build targets should actually be built. So for instance, executing just
+        `./configure` would only enable the X11 target as that's the default, and executing
+        `./configure --enable-wayland-target` would only enable the Wayland target, as the defaults are
+        completely ignored.
+
+        * Source/autotools/CheckSystemAndBasicDependencies.m4: Abort if grep was not found, just in case.
+        * Source/autotools/CustomMacros.m4: The new file that contains helpful custom macros.
+        * Source/autotools/FindDependencies.m4: Use the appropriate 'enable_*_target' references instead of 'with_*target'.
+        * Source/autotools/PrintBuildConfiguration.m4: Use the new AM_APPEND_TO_DESCRIPTION macro to construct a pretty-looking
+        description string of what targets will be built.
+        * Source/autotools/ReadCommandLineArguments.m4: Replace the --with-target configuration flag and the related
+        hacks with the set of --enable-*-target flags. The new AM_DETERMINE_BUILD_TARGET_STATUS macro is used to determine
+        whether to enable specific build targets, based indirectly on the passed-in --enable-*-target flags.
+        * Source/autotools/SetupAutoconfHeader.m4: Use the appropriate 'enable_*_target' references instead of 'with_*target'.
+        * Source/autotools/SetupAutomake.m4: Use the appropriate 'enable_*_target' references instead of 'with_*target'.
+        * configure.ac: Include the new CustomMacros.m4 file.
+
 2013-09-23  Claudio Saavedra  <csaavedra@igalia.com>
 
         [GTK] Bump version
index a8490b0..d08b486 100644 (file)
@@ -49,6 +49,11 @@ if test -z "$MV"; then
     AC_MSG_ERROR([You need 'mv' to compile WebKit])
 fi
 
+AC_PATH_PROG(GREP, grep)
+if test -z "$GREP"; then
+    AC_MSG_ERROR([You need 'grep' to compile WebKit])
+fi
+
 AC_PATH_PROG(GPERF, gperf)
 if test -z "$GPERF"; then
     AC_MSG_ERROR([You need the 'gperf' hash function generator to compile WebKit])
diff --git a/Source/autotools/CustomMacros.m4 b/Source/autotools/CustomMacros.m4
new file mode 100644 (file)
index 0000000..53357e2
--- /dev/null
@@ -0,0 +1,26 @@
+dnl AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS
+dnl
+dnl Usage:
+dnl AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([BUILD_TARGET], [OUTPUT_TARGET_VARIABLE], [BUILD_TARGETS])
+AC_DEFUN([AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS], [
+  AC_MSG_CHECKING([whether to enable the $1 target])
+  AS_IF([echo "$$3" | grep -qE "$1=yes"; test $? -eq 0], [$2=yes],
+    [echo "$$3" | grep -qE "$1=no"; test $? -eq 0], [$2=no],
+    [echo "$$3" | grep -qE "$1="; test $? -eq 0], [$2=auto],
+    [$2=no])
+  AC_MSG_RESULT([$$2])
+]) dnl AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS
+
+dnl AM_APPEND_TO_DESCRIPTION
+dnl Appends the given string to the description variable,
+dnl using a separator if the description variable is not empty.
+dnl
+dnl Usage:
+dnl AM_APPEND_TO_DESCRIPTION([DESCRIPTION], [STRING])
+AC_DEFUN([AM_APPEND_TO_DESCRIPTION], [
+  if test "$$1" != ""; then
+    $1="${$1}, "
+  fi
+
+  $1="${$1}$2"
+]) dnl AM_APPEND_TO_DESCRIPTION
index 1046c22..5f03807 100644 (file)
@@ -150,21 +150,26 @@ if test "$enable_spellcheck" = "yes"; then
     AC_SUBST(ENCHANT_LIBS)
 fi
 
-# Check for target-specific dependencies.
-if test "$with_target" = "directfb"; then
-    PKG_CHECK_MODULES(CAIRO, cairo-directfb >= cairo_required_version)
-    PKG_CHECK_MODULES(GTK, gtk+-directfb-2.0 >= $GTK_REQUIRED_VERSION)
-else
-    PKG_CHECK_MODULES(CAIRO, cairo >= cairo_required_version)
-    PKG_CHECK_MODULES(GTK, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION)
-    GTK_ACTUAL_VERSION=`pkg-config --modversion gtk+-$GTK_API_VERSION`
+PKG_CHECK_MODULES(CAIRO, cairo >= cairo_required_version)
+PKG_CHECK_MODULES(GTK, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED_VERSION)
+GTK_ACTUAL_VERSION=`pkg-config --modversion gtk+-$GTK_API_VERSION`
+
+if test "$enable_directfb_target" = "yes"; then
+    PKG_CHECK_MODULES(CAIRO_DIRECTFB, cairo-directfb >= cairo_required_version)
+    CAIRO_CFLAGS="$CAIRO_CFLAGS $CAIRO_DIRECTFB_CFLAGS"
+    CAIRO_LIBS="$CAIRO_LIBS $CAIRO_DIRECTFB_LIBS"
+
+    PKG_CHECK_MODULES(GTK_DIRECTFB, gtk+-directfb-2.0 >= $GTK_REQUIRED_VERSION)
+    GTK_CFLAGS="$GTK_CFLAGS $GTK_DIRECTFB_CFLAGS"
+    GTK_LIBS="$GTK_LIBS $GTK_DIRECTFB_LIBS"
 fi
+
 AC_SUBST(GTK_CFLAGS)
 AC_SUBST(GTK_LIBS)
 AC_SUBST(CAIRO_CFLAGS)
 AC_SUBST(CAIRO_LIBS)
 
-if test "$with_x11_target" = "yes"; then
+if test "$enable_x11_target" = "yes"; then
     # The GTK+ X11 target dependency should match the version of the master GTK+ dependency.
     PKG_CHECK_MODULES(GTK_X11, gtk+-x11-$GTK_API_VERSION = $GTK_ACTUAL_VERSION)
 
@@ -186,7 +191,7 @@ if test "$with_x11_target" = "yes"; then
 
     # Check for XRender under Linux/Unix. Some linkers require explicit linkage (like GNU Gold),
     # so we cannot rely on GTK+ pulling XRender.
-    if test "$with_x11_target" = "yes"; then
+    if test "$enable_x11_target" = "yes"; then
         PKG_CHECK_MODULES([XRENDER], [xrender])
         AC_SUBST([XRENDER_CFLAGS])
         AC_SUBST([XRENDER_LIBS])
@@ -196,7 +201,7 @@ elif test "enable_glx" != "no"; then
     enable_glx=no
 fi
 
-if test "$with_wayland_target" = "yes"; then
+if test "$enable_wayland_target" = "yes"; then
     # The GTK+ Wayland target dependency should match the version of the master GTK+ dependency.
     PKG_CHECK_MODULES(GTK_WAYLAND, gtk+-wayland-$GTK_API_VERSION = $GTK_ACTUAL_VERSION)
 fi
@@ -267,7 +272,7 @@ else
     AC_CHECK_HEADERS([GL/gl.h], [found_opengl="yes"], [])
 fi
 
-if test "$with_x11_target" = "yes" && test "$found_opengl" = "yes"; then
+if test "$enable_x11_target" = "yes" && test "$found_opengl" = "yes"; then
     PKG_CHECK_MODULES([XCOMPOSITE], [xcomposite])
     PKG_CHECK_MODULES([XDAMAGE], [xdamage])
     AC_SUBST(XCOMPOSITE_CFLAGS)
@@ -287,7 +292,7 @@ if test "$enable_webgl" != "no"; then
     fi
 fi
 
-if test "$with_x11_target" != "yes" && test "$with_wayland_target" = "yes" && test "enable_accelerated_compositing" != "no"; then
+if test "$enable_x11_target" != "yes" && test "$enable_wayland_target" = "yes" && test "enable_accelerated_compositing" != "no"; then
     AC_MSG_WARN([Accelerated compositing for Wayland is not yet implemented, disabling due to the Wayland-only target.])
     enable_accelerated_compositing=no
 fi
@@ -364,7 +369,7 @@ if test "$enable_credential_storage" = "yes"; then
 fi
 
 # Check if FreeType/FontConfig are available.
-if test "$with_target" = "directfb"; then
+if test "$enable_directfb_target" = "yes"; then
     PKG_CHECK_MODULES([FREETYPE],
         [fontconfig >= fontconfig_required_version freetype2 >= freetype2_required_version harfbuzz >= harfbuzz_required_version])
 else
index 1e388b0..49a40ca 100644 (file)
@@ -1,3 +1,10 @@
+target_description=""
+AS_IF([test "$enable_x11_target" = "yes"], [AM_APPEND_TO_DESCRIPTION(target_description, "x11")], [])
+AS_IF([test "$enable_wayland_target" = "yes"], [AM_APPEND_TO_DESCRIPTION(target_description, "wayland")], [])
+AS_IF([test "$enable_win32_target" = "yes"], [AM_APPEND_TO_DESCRIPTION(target_description, "win32")], [])
+AS_IF([test "$enable_quartz_target" = "yes"], [AM_APPEND_TO_DESCRIPTION(target_description, "quartz")], [])
+AS_IF([test "$enable_directfb_target" = "yes"], [AM_APPEND_TO_DESCRIPTION(target_description, "directfb")], [])
+
 AC_OUTPUT
 
 echo "
@@ -34,7 +41,7 @@ Features:
 
 GTK+ configuration:
  GTK+ version                                             : $with_gtk
- GDK targets                                              : $with_target
+ GDK targets                                              : $target_description
  Introspection support                                    : $enable_introspection
  Generate documentation                                   : $enable_gtk_doc
 "
index 63ee98b..f08b522 100644 (file)
@@ -58,35 +58,33 @@ AC_ARG_WITH([gtk],
     [with_gtk=3.0])
 AC_MSG_RESULT([$with_gtk])
 
-AC_MSG_CHECKING([the target windowing system])
-AC_ARG_WITH(target,
-    AC_HELP_STRING([--with-target=@<:@x11/wayland/x11,wayland/win32/quartz/directfb@:>@], [Select webkit target [default=x11]]),
-    [
-        case "$with_target" in
-            x11|wayland|x11,wayland|win32|quartz|directfb) ;;
-            *) AC_MSG_ERROR([Invalid target: must be x11, wayland, both x11 and wayland (x11,wayland), quartz, win32, or directfb.]) ;;
-        esac
-    ],
-    [with_target="x11"])
-AC_MSG_RESULT([$with_target])
-
-# To support building for X11 and Wayland targets concurrently, the $with_target value is checked for this
-# special case and two additional variables are introduced that denote specifically whether we're building
-# the X11 target, the Wayland target, both of these or neither.
-if test "$with_target" = "x11,wayland"; then
-    with_x11_target=yes
-    with_wayland_target=yes
-elif test "$with_target" = "x11"; then
-    with_x11_target=yes
-    with_wayland_target=no
-elif test "$with_target" = "wayland"; then
-    with_x11_target=no
-    with_wayland_target=yes
-else
-    with_x11_target=no
-    with_wayland_target=no
+default_build_targets="x11=yes wayland=no win32=no quartz=no directfb=no"
+build_targets=""
+
+AC_ARG_ENABLE([x11-target], [AC_HELP_STRING([--enable-x11-target], [enable building for the X11 target [default=yes]])],
+    [build_targets="$build_targets x11=$enable_x11_target"], [])
+AC_ARG_ENABLE([wayland-target], [AC_HELP_STRING([--enable-wayland-target], [enable building for the Wayland target [default=auto]])],
+    [build_targets="$build_targets wayland=$enable_wayland_target"], [])
+AC_ARG_ENABLE([win32-target], [AC_HELP_STRING([--enable-win32-target], [enable building for the Win32 target [default=no]])],
+    [build_targets="$build_targets win32=$enable_win32_target"], [])
+AC_ARG_ENABLE([quartz-target], [AC_HELP_STRING([--enable-quartz-target], [enable building for the Quartz target [default=no]])],
+    [build_targets="$build_targets quartz=$enable_quartz_target"], [])
+AC_ARG_ENABLE([directfb-target], [AC_HELP_STRING([--enable-directfb-target], [enable building for the DirectFB target [default=no]])],
+    [build_targets="$build_targets directfb=$enable_directfb_target"], [])
+
+if test "$build_targets" = ""; then
+    build_targets="$default_build_targets"
 fi
 
+AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([x11], [enable_x11_target], [build_targets])
+AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([wayland], [enable_wayland_target], [build_targets])
+AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([win32], [enable_win32_target], [build_targets])
+AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([quartz], [enable_quartz_target], [build_targets])
+AM_WEBKIT_DETERMINE_BUILD_TARGET_STATUS([directfb], [enable_directfb_target], [build_targets])
+
+AC_MSG_CHECKING([whether to build for the Win32 target])
+AC_MSG_RESULT([$enable_wayland_target])
+
 AC_MSG_CHECKING([whether to enable spellcheck support])
 AC_ARG_ENABLE([spellcheck],
     [AS_HELP_STRING([--enable-spellcheck],[enable support for spellcheck])],
index 384cedf..b872f9d 100644 (file)
@@ -31,16 +31,16 @@ if test "$os_win32" = "yes"; then
     AC_DEFINE([XP_WIN], [1], [ ])
     AC_DEFINE([UNICODE], [1], [ ])
     AC_DEFINE([_UNICODE], [1], [ ])
-elif test "$with_x11_target" = "yes" || test "$with_wayland_target" != "yes"; then
+elif test "$enable_x11_target" = "yes" || test "$enable_wayland_target" != "yes"; then
     AC_DEFINE([XP_UNIX], [1], [ ])
 fi
 
-if test "$with_x11_target" = "yes"; then
+if test "$enable_x11_target" = "yes"; then
     AC_DEFINE([MOZ_X11], [1], [ ])
     AC_DEFINE([WTF_PLATFORM_X11], [1], [Define if target is X11])
 fi
 
-if test "$with_wayland_target" = "yes"; then
+if test "$enable_wayland_target" = "yes"; then
     AC_DEFINE([WTF_PLATFORM_WAYLAND], [1], [Define if target is Wayland])
 fi
 
index 8519565..050e55c 100644 (file)
@@ -23,12 +23,12 @@ AM_CONDITIONAL([OS_DARWIN],[test "$os_darwin" = "yes"])
 AM_CONDITIONAL([OS_FREEBSD],[test "$os_freebsd" = "yes"])
 
 # Target conditionals.
-AM_CONDITIONAL([TARGET_X11], [test "$with_x11_target" = "yes"])
-AM_CONDITIONAL([TARGET_WAYLAND], [test "$with_wayland_target" = "yes"])
-AM_CONDITIONAL([TARGET_X11_OR_WAYLAND], [test "$with_x11_target" = "yes" || test "$with_wayland_target" = "yes"])
-AM_CONDITIONAL([TARGET_WIN32], [test "$with_target" = "win32"])
-AM_CONDITIONAL([TARGET_QUARTZ], [test "$with_target" = "quartz"])
-AM_CONDITIONAL([TARGET_DIRECTFB], [test "$with_target" = "directfb"])
+AM_CONDITIONAL([TARGET_X11], [test "$enable_x11_target" = "yes"])
+AM_CONDITIONAL([TARGET_WAYLAND], [test "$enable_wayland_target" = "yes"])
+AM_CONDITIONAL([TARGET_X11_OR_WAYLAND], [test "$enable_x11_target" = "yes" || test "$enable_wayland_target" = "yes"])
+AM_CONDITIONAL([TARGET_WIN32], [test "$enable_win32_target" = "yes"])
+AM_CONDITIONAL([TARGET_QUARTZ], [test "$enable_quartz_target" = "yes"])
+AM_CONDITIONAL([TARGET_DIRECTFB], [test "$enable_directfb_target" = "yes"])
 
 # GStreamer feature conditionals.
 AM_CONDITIONAL([USE_GSTREAMER], [test "$enable_video" = "yes" || test "$enable_web_audio" = "yes"])
index ddedec7..7a9e34e 100644 (file)
@@ -22,6 +22,7 @@ AC_SUBST(WEBKIT_USER_AGENT_MINOR_VERSION)
 AC_DEFINE([USER_AGENT_GTK_MAJOR_VERSION], [webkit_user_agent_major_version], [The major version used in user agent string])
 AC_DEFINE([USER_AGENT_GTK_MINOR_VERSION], [webkit_user_agent_minor_version], [The minor version used in user agent string])
 
+m4_include([Source/autotools/CustomMacros.m4])
 m4_include([Source/autotools/CheckSystemAndBasicDependencies.m4])
 m4_include([Source/autotools/SetupLibtool.m4])
 m4_include([Source/autotools/ReadCommandLineArguments.m4])