|
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 # mozconfig2client-mk - Translates .mozconfig into options for client.mk. |
|
8 # Prints defines to stdout. |
|
9 # |
|
10 # See mozconfig2configure for more details |
|
11 |
|
12 print_header() { |
|
13 cat <<EOF |
|
14 # gmake |
|
15 # This file is automatically generated for client.mk. |
|
16 # Do not edit. Edit $FOUND_MOZCONFIG instead. |
|
17 |
|
18 EOF |
|
19 } |
|
20 |
|
21 ac_add_options() { |
|
22 for _opt |
|
23 do |
|
24 case "$_opt" in |
|
25 --target=*) |
|
26 echo $_opt | sed s/--target/CONFIG_GUESS/ |
|
27 ;; |
|
28 *) |
|
29 echo "# $_opt is used by configure (not client.mk)" |
|
30 ;; |
|
31 esac |
|
32 done |
|
33 } |
|
34 |
|
35 ac_add_app_options() { |
|
36 echo "# $* is used by configure (not client.mk)" |
|
37 } |
|
38 |
|
39 mk_add_options() { |
|
40 for _opt |
|
41 do |
|
42 # Escape shell characters, space, tab, dollar, quote, backslash, |
|
43 # and substitute '@<word>@' with '$(<word>)'. |
|
44 _opt=`echo "$_opt" | sed -e 's/\([\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'` |
|
45 echo $_opt; |
|
46 done |
|
47 } |
|
48 |
|
49 # Main |
|
50 #-------------------------------------------------- |
|
51 |
|
52 scriptdir=`dirname $0` |
|
53 topsrcdir=$1 |
|
54 |
|
55 # If the path changes, configure should be rerun |
|
56 echo "# PATH=$PATH" |
|
57 |
|
58 # If FOUND_MOZCONFIG isn't set, look for it and make sure the script doesn't error out |
|
59 isfoundset=${FOUND_MOZCONFIG+yes} |
|
60 if [ -z $isfoundset ]; then |
|
61 FOUND_MOZCONFIG=`$scriptdir/mozconfig-find $topsrcdir` |
|
62 if [ $? -ne 0 ]; then |
|
63 echo '$(error Fix above errors before continuing.)' |
|
64 else |
|
65 isfoundset=yes |
|
66 fi |
|
67 fi |
|
68 |
|
69 if [ -n $isfoundset ]; then |
|
70 if [ "$FOUND_MOZCONFIG" ] |
|
71 then |
|
72 print_header |
|
73 . "$FOUND_MOZCONFIG" |
|
74 echo "FOUND_MOZCONFIG := $FOUND_MOZCONFIG" |
|
75 fi |
|
76 fi |