Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
michael@0 | 1 | #! /bin/sh |
michael@0 | 2 | # |
michael@0 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | |
michael@0 | 7 | # mozconfig2configure - Loads options from .mozconfig onto configure's |
michael@0 | 8 | # command-line. See mozconfig-find for how the config file is |
michael@0 | 9 | # found |
michael@0 | 10 | # |
michael@0 | 11 | # The options from .mozconfig are inserted into the command-line |
michael@0 | 12 | # before the real command-line options. This way the real options |
michael@0 | 13 | # will override any .mozconfig options. |
michael@0 | 14 | # |
michael@0 | 15 | # .mozconfig is a shell script. To add an option to configure's |
michael@0 | 16 | # command-line use the pre-defined function, ac_add_options, |
michael@0 | 17 | # |
michael@0 | 18 | # ac_add_options <configure-option> [<configure-option> ... ] |
michael@0 | 19 | # |
michael@0 | 20 | # For example, |
michael@0 | 21 | # |
michael@0 | 22 | # ac_add_options --with-pthreads --enable-debug |
michael@0 | 23 | # |
michael@0 | 24 | # ac_add_options can be called multiple times in .mozconfig. |
michael@0 | 25 | # Each call adds more options to configure's command-line. |
michael@0 | 26 | |
michael@0 | 27 | # Note: $_AUTOCONF_TOOLS_DIR must be defined in the script that includes this. |
michael@0 | 28 | |
michael@0 | 29 | ac_add_options() { |
michael@0 | 30 | for _opt |
michael@0 | 31 | do |
michael@0 | 32 | # Escape shell characters, space, tab, dollar, quote, backslash, parentheses. |
michael@0 | 33 | _opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\\(\)]\)/\\\\\1/g;s/@\([^@]*\)@/\$\1/g;'` |
michael@0 | 34 | _opt=`echo $_opt | sed -e 's/@\([^@]*\)@/\$(\1)/g'` |
michael@0 | 35 | |
michael@0 | 36 | # Avoid adding duplicates |
michael@0 | 37 | case "$ac_options" in |
michael@0 | 38 | # Note that all options in $ac_options are enclosed in quotes, |
michael@0 | 39 | # so there will always be a last character to match [^-A-Za-z0-9_] |
michael@0 | 40 | *"\"$_opt[^-A-Za-z0-9_]"* ) ;; |
michael@0 | 41 | * ) mozconfig_ac_options="$mozconfig_ac_options $_opt" ;; |
michael@0 | 42 | esac |
michael@0 | 43 | done |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | ac_add_app_options() { |
michael@0 | 47 | APP=$1 |
michael@0 | 48 | shift; |
michael@0 | 49 | if [ "$APP" = "$MOZ_BUILD_APP" ]; then |
michael@0 | 50 | ac_add_options "$*"; |
michael@0 | 51 | fi |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | mk_add_options() { |
michael@0 | 55 | # These options are for client.mk |
michael@0 | 56 | # configure can safely ignore them. |
michael@0 | 57 | : |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | ac_echo_options() { |
michael@0 | 61 | echo "Adding configure options from $FOUND_MOZCONFIG:" |
michael@0 | 62 | eval "set -- $mozconfig_ac_options" |
michael@0 | 63 | for _opt |
michael@0 | 64 | do |
michael@0 | 65 | echo " $_opt" |
michael@0 | 66 | done |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | # Main |
michael@0 | 70 | #-------------------------------------------------- |
michael@0 | 71 | topsrcdir=$(cd `dirname $0`; pwd -W 2>/dev/null || pwd) |
michael@0 | 72 | ac_options= |
michael@0 | 73 | mozconfig_ac_options= |
michael@0 | 74 | |
michael@0 | 75 | # Save the real command-line options |
michael@0 | 76 | for _opt |
michael@0 | 77 | do |
michael@0 | 78 | # Escape shell characters, space, tab, dollar, quote, backslash. |
michael@0 | 79 | _opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'` |
michael@0 | 80 | ac_options="$ac_options \"$_opt\"" |
michael@0 | 81 | done |
michael@0 | 82 | |
michael@0 | 83 | |
michael@0 | 84 | # If FOUND_MOZCONFIG isn't set, look for it and make sure the script doesn't error out |
michael@0 | 85 | isfoundset=${FOUND_MOZCONFIG+yes} |
michael@0 | 86 | if [ -z $isfoundset ]; then |
michael@0 | 87 | FOUND_MOZCONFIG=`$_AUTOCONF_TOOLS_DIR/mozconfig-find $topsrcdir` |
michael@0 | 88 | if [ $? -ne 0 ]; then |
michael@0 | 89 | echo "Fix above errors before continuing." 1>&2 |
michael@0 | 90 | exit 1 |
michael@0 | 91 | fi |
michael@0 | 92 | fi |
michael@0 | 93 | |
michael@0 | 94 | if [ "$FOUND_MOZCONFIG" ]; then |
michael@0 | 95 | . "$FOUND_MOZCONFIG" |
michael@0 | 96 | fi |
michael@0 | 97 | export FOUND_MOZCONFIG |
michael@0 | 98 | |
michael@0 | 99 | if [ "$mozconfig_ac_options" ]; then |
michael@0 | 100 | ac_echo_options 1>&2 |
michael@0 | 101 | fi |
michael@0 | 102 | |
michael@0 | 103 | eval "set -- $mozconfig_ac_options $ac_options" |