Bug 1040009 - Run mozilla-central's configure from the objdir, not objdir/mozilla, r=Standard8 CLOSED TREE.
authorJoshua Cranmer <Pidgeot18@gmail.com>
Wed, 27 Aug 2014 10:09:55 -0500
changeset 16519 8f57b03404285702405cfb4516765e5ad83e4193
parent 16518 200a55b73ed0329af84705907ab0b29c1079554c
child 16520 148e7a1145c4b1c5e087074e57c032a8c2c8ac28
push id1234
push usermbanner@mozilla.com
push dateMon, 13 Oct 2014 17:59:18 +0000
treeherdercomm-esr52@b5a0add9fb18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1040009
Bug 1040009 - Run mozilla-central's configure from the objdir, not objdir/mozilla, r=Standard8 CLOSED TREE. This bug moves the objdir from the current location of MOZ_OBJDIR/mozilla to MOZ_OBJDIR, which fixes a series of longstanding bugs about mozconfigs not working due to the presence of two distinct objdirs. A temporary workaround to keep automation working is included. An important implication of this change is that mozconfigs are now required for comm-central: if they are not provided, Firefox, not Thunderbird, will be built.
aclocal.m4
client.mk
configure.in
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -21,9 +21,9 @@ builtin(include, mozilla/build/autoconf/
 builtin(include, mozilla/build/autoconf/python-virtualenv.m4)dnl
 
 MOZ_PROG_CHECKMSYS()
 
 # Read the user's .mozconfig script.  We can't do this in
 # configure.in: autoconf puts the argument parsing code above anything
 # expanded from configure.in, and we need to get the configure options
 # from .mozconfig in place before that argument parsing code.
-MOZ_READ_MOZCONFIG(mozilla)
+dnl MOZ_READ_MOZCONFIG(mozilla)
--- a/client.mk
+++ b/client.mk
@@ -155,16 +155,22 @@ endif
 
 else # MOZ_BUILD_PROJECTS
 
 OBJDIR = $(MOZ_OBJDIR)
 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
 
 endif # MOZ_BUILD_PROJECTS
 
+# If we have a MOZ_OBJDIR that's set from the environment, ensure that it is an
+# absolute path.
+ifdef MOZ_OBJDIR
+MOZ_OBJDIR := $(shell $(PYTHON) -c "import os.path; print(os.path.join(\"$(TOPSRCDIR)\", \"$(MOZ_OBJDIR)\").replace('\\\\','/'))")
+endif
+
 # 'configure' scripts generated by autoconf.
 CONFIGURES := $(TOPSRCDIR)/configure
 CONFIGURES += $(TOPSRCDIR)/mozilla/configure
 CONFIGURES += $(TOPSRCDIR)/mozilla/js/src/configure
 
 #######################################################################
 # Rules
 
--- a/configure.in
+++ b/configure.in
@@ -5,277 +5,26 @@ dnl License, v. 2.0. If a copy of the MP
 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 dnl Process this file with autoconf to produce a configure script.
 dnl ========================================================
 
 AC_PREREQ(2.13)
 AC_INIT(config/config.mk)
 MOZILLA_SRCDIR=$srcdir/mozilla
-AC_CONFIG_AUX_DIR(${MOZILLA_SRCDIR}/build/autoconf)
-AC_CANONICAL_SYSTEM
 
-dnl comm-central-specific options
-dnl (MOZILLA_SRCDIR would fit here, but is needed to find autoconf tools)
-export COMM_BUILD=1
-
-dnl Get mozconfig output for configure in a config.site we'll pass to
-dnl the mozilla configure. Then unset MOZCONFIG and MOZ_OBJDIR to avoid
-dnl confusing the mozilla configure.
-$(dirname $0)/mozilla/mach environment --format=configure > config.site
-COMM_MOZCONFIG=`$srcdir/build/autoconf/mozconfig-find $srcdir`
-unset MOZCONFIG
-unset MOZ_OBJDIR
-
-dnl Do not allow a separate objdir build if a srcdir build exists.
-dnl ==============================================================
-_topsrcdir=`cd \`dirname $0\`; pwd`
-_objdir=`pwd`
-
-if test "$_topsrcdir" != "$_objdir"
-then
-  # Check for a couple representative files in the source tree
-  _conflict_files=
-  for file in $_topsrcdir/Makefile $_topsrcdir/config/autoconf.mk; do
-    if test -f $file; then
-      _conflict_files="$_conflict_files $file"
-    fi
-  done
-  if test "$_conflict_files"; then
-    echo "***"
-    echo "*   Your source tree contains these files:"
-    for file in $_conflict_files; do
-      echo "*         $file"
-    done
-    cat 1>&2 <<-EOF
-	*   This indicates that you previously built in the source tree.
-	*   A source tree build can confuse the separate objdir build.
-	*
-	*   To clean up the source tree:
-	*     1. cd $_topsrcdir
-	*     2. gmake distclean
-	***
-	EOF
-    exit 1
-    break
-  fi
-fi
-
-MOZ_BUILD_ROOT=`pwd`
-MOZILLA_CENTRAL_PATH=$_topsrcdir/mozilla
-MOZ_PYTHON
-
-
-MOZ_ARG_WITH_STRING(l10n-base,
-[  --with-l10n-base=DIR     path to l10n repositories],
-    L10NBASEDIR=$withval)
-if test -n "$L10NBASEDIR"; then
-    if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
-        AC_MSG_ERROR([--with-l10n-base must specify a path])
-    elif test -d "$L10NBASEDIR"; then
-        dnl Ensure to use an absolute path.
-        L10NBASEDIR=`cd "$L10NBASEDIR" && pwd`
-    else
-        AC_MSG_ERROR([Invalid value --with-l10n-base, $L10NBASEDIR doesn't exist])
-    fi
-fi
-
-MOZ_ARG_WITH_STRING(unify-dist,
-[  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)],
-    UNIFY_DIST=$withval)
-if test -n "$UNIVERSAL_BINARY"; then
-    if test -z "$UNIFY_DIST"; then
-        AC_MSG_ERROR([You need to provide the --with-unify-dist=dir argument when performing a universal build])
-    fi
-    case "$UNIFY_DIST" in
-    /*)
-        ;;
-    *)
-        UNIFY_DIST="${MOZ_BUILD_ROOT}/${UNIFY_DIST}"
-        ;;
-    esac
-fi
-
-dnl ========================================================
-dnl =
-dnl = Application
-dnl =
-dnl ========================================================
-
-MOZ_ARG_HEADER(Application)
-
-MOZ_BRANDING_DIRECTORY=
-
-MOZ_ARG_ENABLE_STRING(application,
-[  --enable-application=APP
-                          Options include:
-                            suite (SeaMonkey)
-                            mail (Thunderbird)],
-[ MOZ_BUILD_APP=$enableval ] )
-
-AC_MSG_CHECKING([for application to build])
-if test -z "$MOZ_BUILD_APP"; then
-  AC_MSG_RESULT([mail])
-  echo "Building Thunderbird by default. Set --enable-application to build a different application."
-  MOZ_BUILD_APP=mail
-else
-  # We have a valid application only if it has a build.mk file in its top
-  # directory.
-  if test ! -f "${srcdir}/${MOZ_BUILD_APP}/build.mk" ; then
-    AC_MSG_RESULT([none])
-    AC_MSG_ERROR([--enable-application value not recognized (${MOZ_BUILD_APP}/build.mk does not exist).])
-  else
-    AC_MSG_RESULT([$MOZ_BUILD_APP])
-  fi
-fi
-
-# Allow the application to influence configure with a confvars.sh script. We
-# still need this for MOZ_BRANDING_DIRECTORY.
-
-AC_MSG_CHECKING([if app-specific confvars.sh exists])
-if test -f "${srcdir}/${MOZ_BUILD_APP}/confvars.sh" ; then
-  AC_MSG_RESULT([${srcdir}/${MOZ_BUILD_APP}/confvars.sh])
-  . "${srcdir}/${MOZ_BUILD_APP}/confvars.sh"
-else
-  AC_MSG_RESULT([no])
+# If MOZCONFIG isn't set, use the .mozconfig from the current directory. This
+# overrides the lookup in mozilla-central's configure, which looks in the wrong
+# directory for this file.
+if test -z "$MOZCONFIG" -a -f $(dirname $0)/.mozconfig; then
+    export MOZCONFIG=$(dirname $0)/.mozconfig
 fi
 
-dnl ========================================================
-dnl = Trademarked Branding 
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(official-branding,
-[  --enable-official-branding Enable Official mozilla.org Branding
-                          Do not distribute builds with
-                          --enable-official-branding unless you have
-                          permission to use trademarks per
-                          http://www.mozilla.org/foundation/trademarks/ .],
-[
-  if test -z "$MOZ_OFFICIAL_BRANDING_DIRECTORY"; then
-    AC_MSG_ERROR([You must specify MOZ_OFFICIAL_BRANDING_DIRECTORY to use --enable-official-branding.])
-  else
-    MOZ_BRANDING_DIRECTORY=${MOZ_OFFICIAL_BRANDING_DIRECTORY}
-  fi
-])
-
-MOZ_ARG_WITH_STRING(branding,
-[  --with-branding=dir    Use branding from the specified directory.],
-    MOZ_BRANDING_DIRECTORY=$withval)
-
-REAL_BRANDING_DIRECTORY="${MOZ_BRANDING_DIRECTORY}"
-if test -z "$REAL_BRANDING_DIRECTORY"; then
-  REAL_BRANDING_DIRECTORY=${MOZ_BUILD_APP}/branding/nightly
-fi
-
-if test -f "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"; then
-  . "${_topsrcdir}/$REAL_BRANDING_DIRECTORY/configure.sh"
+# Our automation expects to find things in $MOZ_OBJDIR/mozilla. Oblige it by
+# symlinking the directories together.
+if test "$MOZ_AUTOMATION" -eq 1; then
+    ln -s $PWD mozilla
 fi
 
-case "$host_os" in
-mingw*)
-    WIN_TOP_SRC=`cd $srcdir; pwd -W`
-    ;;
-esac
-
-# These lines do no useful work, but if we don't have them, then the output
-# configure script is really messed up.
-touch confdefs.pytmp
-AC_OUTPUT([])
-
-# Build the config.status for comm-central
-changequote(<<<,>>>)dnl
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#!${PYTHON}
-
-import os
-topsrcdir = '''${WIN_TOP_SRC:-$srcdir}'''
-if not os.path.isabs(topsrcdir):
-    rel = os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir)
-    topsrcdir = os.path.normpath(os.path.abspath(rel))
-
-topobjdir = os.path.dirname(<<<__file__>>>)
-
-from mozbuild.backend.configenvironment import BuildConfig
-mozfile = os.path.join(topobjdir, 'mozilla', 'config.status')
-mozbuildcfg = BuildConfig.from_config_status(mozfile)
-
-dnl No need to tweak these from mozilla-central
-defines = mozbuildcfg.defines
-non_global_defines = mozbuildcfg.non_global_defines
-
-dnl Fix up substitutitons
-def remap_subst(pair):
-    name, value = pair
-    if isinstance(value, set) or isinstance(value, list):
-        return name, value
-    value = value.replace('\$(DEPTH)', '\$(DEPTH)/mozilla')
-    value = value.replace('\$(topsrcdir)', '\$(topsrcdir)/mozilla')
-    if name == 'ac_configure_args':
-        value = r''' $ac_configure_args '''[1:-1]
-    elif name in ['MOZ_BRANDING_DIRECTORY', 'MOZ_BUILD_APP']:
-        value = value[3:] # Strip off ../ from the beginning
-    elif name in ['top_srcdir', 'MOZ_BUILD_ROOT', 'WIN_TOP_SRC']:
-        value = value[:-8] # Strip off /mozilla from the end
-    return name, value
-
-substs = map(remap_subst, mozbuildcfg.substs)
-substs.append(('COMM_BUILD', '1'))
-
-__all__ = ['topobjdir', 'topsrcdir', 'defines', 'non_global_defines', 'substs']
+# Execute the mozilla configure script in the current directory, adding the
+# parameter we need to run comm-central.
+exec ${MOZILLA_SRCDIR}/configure "$@" --with-external-source-dir="$(dirname $0)"
 
-dnl Do the actual work
-if __name__ == '__main__':
-    args = dict([(name, globals()[name]) for name in __all__])
-    import sys
-dnl Don't rely on virtualenv here. Standalone js doesn't use it.
-    sys.path.append(os.path.join(topsrcdir, ${extra_python_path}'build'))
-    from mozbuild.config_status import config_status
-    config_status(**args)
-EOF
-changequote([,])dnl
-
-# Make the config.status file executable
-chmod +x $CONFIG_STATUS
-
-_SUBDIR_CONFIG_ARGS="$ac_configure_args"
-if test -n "$UNIFY_DIST"; then
-    # Make --with-unify-dist point to the right path
-    _SUBDIR_CONFIG_ARGS="$_SUBDIR_CONFIG_ARGS --with-unify-dist=$UNIFY_DIST"
-fi
-
-# build Mozilla first
-#
-# the subdir may not yet have been created in the build tree.
-#
-if test ! -d "mozilla"; then
-    mkdir "mozilla"
-fi
-
-external_topsrcdir=$_topsrcdir
-
-if test "$msyshost"; then
-    external_topsrcdir=`cd $_topsrcdir && pwd -W $_topsrcdir`
-fi
-
-# --enable-application needs to find confvars.sh, build.mk, etc in the gived dir, so add ../
-# --external-source-dir is so the build system doesn't reject files outside known locations.
-# --disable-official-branding disables all checks for official branding, as we're doing this ourselves in our own repo
-ac_configure_args="$_SUBDIR_CONFIG_ARGS --enable-application=../$MOZ_BUILD_APP --with-external-source-dir=$external_topsrcdir --disable-official-branding --with-branding=$REAL_BRANDING_DIRECTORY"
-if test -n "$L10NBASEDIR"; then
-    dnl Override the initial value with the new one which is guaranteed to be an absolute path.
-    ac_configure_args="$ac_configure_args --with-l10n-base=$L10NBASEDIR"
-fi
-
-# for Mac universal builds, we need to call the Mozilla configure with MOZ_BUILD_APP=[i386|x86_64]
-MOZ_BUILD_APP_CACHED="$MOZ_BUILD_APP"
-if test -n "$MOZ_CURRENT_PROJECT"; then
-    export MOZ_BUILD_APP="$MOZ_CURRENT_PROJECT"
-fi
-
-# Files listed in $CONFIG_SITE are sourced by configure near the beginning.
-export CONFIG_SITE="$(pwd)/config.site $CONFIG_SITE"
-AC_OUTPUT_SUBDIRS(mozilla)
-MOZ_BUILD_APP="$MOZ_BUILD_APP_CACHED"
-
-# Build the comm-central files with config.status
-test "$no_create" = yes || MOZCONFIG="$COMM_MOZCONFIG" WRITE_MOZINFO=1 ${PYTHON} $CONFIG_STATUS || exit 1