michael@0: #! /bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # mozconfig2configure - Loads options from .mozconfig onto configure's michael@0: # command-line. See mozconfig-find for how the config file is michael@0: # found michael@0: # michael@0: # The options from .mozconfig are inserted into the command-line michael@0: # before the real command-line options. This way the real options michael@0: # will override any .mozconfig options. michael@0: # michael@0: # .mozconfig is a shell script. To add an option to configure's michael@0: # command-line use the pre-defined function, ac_add_options, michael@0: # michael@0: # ac_add_options [ ... ] michael@0: # michael@0: # For example, michael@0: # michael@0: # ac_add_options --with-pthreads --enable-debug michael@0: # michael@0: # ac_add_options can be called multiple times in .mozconfig. michael@0: # Each call adds more options to configure's command-line. michael@0: michael@0: # Note: $_AUTOCONF_TOOLS_DIR must be defined in the script that includes this. michael@0: michael@0: ac_add_options() { michael@0: for _opt michael@0: do michael@0: # Escape shell characters, space, tab, dollar, quote, backslash, parentheses. michael@0: _opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\\(\)]\)/\\\\\1/g;s/@\([^@]*\)@/\$\1/g;'` michael@0: _opt=`echo $_opt | sed -e 's/@\([^@]*\)@/\$(\1)/g'` michael@0: michael@0: # Avoid adding duplicates michael@0: case "$ac_options" in michael@0: # Note that all options in $ac_options are enclosed in quotes, michael@0: # so there will always be a last character to match [^-A-Za-z0-9_] michael@0: *"\"$_opt[^-A-Za-z0-9_]"* ) ;; michael@0: * ) mozconfig_ac_options="$mozconfig_ac_options $_opt" ;; michael@0: esac michael@0: done michael@0: } michael@0: michael@0: ac_add_app_options() { michael@0: APP=$1 michael@0: shift; michael@0: if [ "$APP" = "$MOZ_BUILD_APP" ]; then michael@0: ac_add_options "$*"; michael@0: fi michael@0: } michael@0: michael@0: mk_add_options() { michael@0: # These options are for client.mk michael@0: # configure can safely ignore them. michael@0: : michael@0: } michael@0: michael@0: ac_echo_options() { michael@0: echo "Adding configure options from $FOUND_MOZCONFIG:" michael@0: eval "set -- $mozconfig_ac_options" michael@0: for _opt michael@0: do michael@0: echo " $_opt" michael@0: done michael@0: } michael@0: michael@0: # Main michael@0: #-------------------------------------------------- michael@0: topsrcdir=$(cd `dirname $0`; pwd -W 2>/dev/null || pwd) michael@0: ac_options= michael@0: mozconfig_ac_options= michael@0: michael@0: # Save the real command-line options michael@0: for _opt michael@0: do michael@0: # Escape shell characters, space, tab, dollar, quote, backslash. michael@0: _opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'` michael@0: ac_options="$ac_options \"$_opt\"" michael@0: done michael@0: michael@0: michael@0: # If FOUND_MOZCONFIG isn't set, look for it and make sure the script doesn't error out michael@0: isfoundset=${FOUND_MOZCONFIG+yes} michael@0: if [ -z $isfoundset ]; then michael@0: FOUND_MOZCONFIG=`$_AUTOCONF_TOOLS_DIR/mozconfig-find $topsrcdir` michael@0: if [ $? -ne 0 ]; then michael@0: echo "Fix above errors before continuing." 1>&2 michael@0: exit 1 michael@0: fi michael@0: fi michael@0: michael@0: if [ "$FOUND_MOZCONFIG" ]; then michael@0: . "$FOUND_MOZCONFIG" michael@0: fi michael@0: export FOUND_MOZCONFIG michael@0: michael@0: if [ "$mozconfig_ac_options" ]; then michael@0: ac_echo_options 1>&2 michael@0: fi michael@0: michael@0: eval "set -- $mozconfig_ac_options $ac_options"