build/autoconf/mozconfig2configure

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

mercurial