|
1 dnl This Source Code Form is subject to the terms of the Mozilla Public |
|
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 |
|
5 dnl For use in AC_SUBST replacement |
|
6 define([MOZ_DIVERSION_SUBST], 11) |
|
7 |
|
8 dnl Replace AC_SUBST to store values in a format suitable for python. |
|
9 dnl The necessary comma after the tuple can't be put here because it |
|
10 dnl can mess around with things like: |
|
11 dnl AC_SOMETHING(foo,AC_SUBST(),bar) |
|
12 define([AC_SUBST], |
|
13 [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])], |
|
14 [ifdef([AC_SUBST_LIST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])], |
|
15 [ifdef([AC_SUBST_$1], , |
|
16 [define([AC_SUBST_$1], )dnl |
|
17 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl |
|
18 (''' $1 ''', r''' [$]$1 ''') |
|
19 AC_DIVERT_POP()dnl |
|
20 ])])])]) |
|
21 |
|
22 dnl Like AC_SUBST, but makes the value available as a set in python, |
|
23 dnl with values got from the value of the environment variable, split on |
|
24 dnl whitespaces. |
|
25 define([AC_SUBST_SET], |
|
26 [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])], |
|
27 [ifdef([AC_SUBST_LIST$1], [m4_fatal([Cannot use AC_SUBST_LIST and AC_SUBST_SET on the same variable ($1)])], |
|
28 [ifdef([AC_SUBST_SET_$1], , |
|
29 [define([AC_SUBST_SET_$1], )dnl |
|
30 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl |
|
31 (''' $1 ''', set(r''' [$]$1 '''.split())) |
|
32 AC_DIVERT_POP()dnl |
|
33 ])])])]) |
|
34 |
|
35 dnl Like AC_SUBST, but makes the value available as a list in python, |
|
36 dnl with values got from the value of the environment variable, split on |
|
37 dnl whitespaces. |
|
38 define([AC_SUBST_LIST], |
|
39 [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])], |
|
40 [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST_SET and AC_SUBST_LIST on the same variable ($1)])], |
|
41 [ifdef([AC_SUBST_LIST_$1], , |
|
42 [define([AC_SUBST_LIST_$1], )dnl |
|
43 AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl |
|
44 (''' $1 ''', list(r''' [$]$1 '''.split())) |
|
45 AC_DIVERT_POP()dnl |
|
46 ])])])]) |
|
47 |
|
48 dnl Wrap AC_DEFINE to store values in a format suitable for python. |
|
49 dnl autoconf's AC_DEFINE still needs to be used to fill confdefs.h, |
|
50 dnl which is #included during some compile checks. |
|
51 dnl The necessary comma after the tuple can't be put here because it |
|
52 dnl can mess around with things like: |
|
53 dnl AC_SOMETHING(foo,AC_DEFINE(),bar) |
|
54 define([_MOZ_AC_DEFINE], defn([AC_DEFINE])) |
|
55 define([AC_DEFINE], |
|
56 [cat >> confdefs.pytmp <<\EOF |
|
57 (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 ')) |
|
58 EOF |
|
59 ifelse($#, 2, _MOZ_AC_DEFINE([$1], [$2]), $#, 3, _MOZ_AC_DEFINE([$1], [$2], [$3]),_MOZ_AC_DEFINE([$1]))dnl |
|
60 ]) |
|
61 |
|
62 dnl Wrap AC_DEFINE_UNQUOTED to store values in a format suitable for |
|
63 dnl python. |
|
64 define([_MOZ_AC_DEFINE_UNQUOTED], defn([AC_DEFINE_UNQUOTED])) |
|
65 define([AC_DEFINE_UNQUOTED], |
|
66 [cat >> confdefs.pytmp <<EOF |
|
67 (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 ')) |
|
68 EOF |
|
69 ifelse($#, 2, _MOZ_AC_DEFINE_UNQUOTED($1, $2), $#, 3, _MOZ_AC_DEFINE_UNQUOTED($1, $2, $3),_MOZ_AC_DEFINE_UNQUOTED($1))dnl |
|
70 ]) |
|
71 |
|
72 dnl Replace AC_OUTPUT to create and call a python config.status |
|
73 define([MOZ_CREATE_CONFIG_STATUS], |
|
74 [dnl Top source directory in Windows format (as opposed to msys format). |
|
75 WIN_TOP_SRC= |
|
76 encoding=utf-8 |
|
77 case "$host_os" in |
|
78 mingw*) |
|
79 WIN_TOP_SRC=`cd $srcdir; pwd -W` |
|
80 encoding=mbcs |
|
81 ;; |
|
82 esac |
|
83 AC_SUBST(WIN_TOP_SRC) |
|
84 |
|
85 dnl Used in all Makefile.in files |
|
86 top_srcdir=$srcdir |
|
87 AC_SUBST(top_srcdir) |
|
88 |
|
89 dnl Picked from autoconf 2.13 |
|
90 trap '' 1 2 15 |
|
91 AC_CACHE_SAVE |
|
92 |
|
93 test "x$prefix" = xNONE && prefix=$ac_default_prefix |
|
94 # Let make expand exec_prefix. |
|
95 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' |
|
96 |
|
97 trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 |
|
98 : ${CONFIG_STATUS=./config.status} |
|
99 |
|
100 dnl We're going to need [ ] for python syntax. |
|
101 changequote(<<<, >>>)dnl |
|
102 echo creating $CONFIG_STATUS |
|
103 |
|
104 extra_python_path=${COMM_BUILD:+"'mozilla', "} |
|
105 |
|
106 cat > $CONFIG_STATUS <<EOF |
|
107 #!${PYTHON} |
|
108 # coding=$encoding |
|
109 |
|
110 import os |
|
111 import types |
|
112 dnl topsrcdir is the top source directory in native form, as opposed to a |
|
113 dnl form suitable for make. |
|
114 topsrcdir = '''${WIN_TOP_SRC:-$srcdir}''' |
|
115 if not os.path.isabs(topsrcdir): |
|
116 rel = os.path.join(os.path.dirname(<<<__file__>>>), topsrcdir) |
|
117 topsrcdir = os.path.abspath(rel) |
|
118 topsrcdir = os.path.normpath(topsrcdir) |
|
119 |
|
120 topobjdir = os.path.abspath(os.path.dirname(<<<__file__>>>)) |
|
121 |
|
122 dnl All defines and substs are stored with an additional space at the beginning |
|
123 dnl and at the end of the string, to avoid any problem with values starting or |
|
124 dnl ending with quotes. |
|
125 defines = [(name[1:-1], value[1:-1]) for name, value in [ |
|
126 EOF |
|
127 |
|
128 dnl confdefs.pytmp contains AC_DEFINEs, in the expected format, but |
|
129 dnl lacks the final comma (see above). |
|
130 sed 's/$/,/' confdefs.pytmp >> $CONFIG_STATUS |
|
131 rm confdefs.pytmp confdefs.h |
|
132 |
|
133 cat >> $CONFIG_STATUS <<\EOF |
|
134 ] ] |
|
135 |
|
136 substs = [(name[1:-1], value[1:-1] if isinstance(value, types.StringTypes) else value) for name, value in [ |
|
137 EOF |
|
138 |
|
139 dnl The MOZ_DIVERSION_SUBST output diversion contains AC_SUBSTs, in the |
|
140 dnl expected format, but lacks the final comma (see above). |
|
141 sed 's/$/,/' >> $CONFIG_STATUS <<EOF |
|
142 undivert(MOZ_DIVERSION_SUBST)dnl |
|
143 EOF |
|
144 |
|
145 dnl Add in the output from the subconfigure script |
|
146 for ac_subst_arg in $_subconfigure_ac_subst_args; do |
|
147 variable='$'$ac_subst_arg |
|
148 echo " (''' $ac_subst_arg ''', r''' `eval echo $variable` ''')," >> $CONFIG_STATUS |
|
149 done |
|
150 |
|
151 cat >> $CONFIG_STATUS <<\EOF |
|
152 ] ] |
|
153 |
|
154 dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES |
|
155 non_global_defines = [ |
|
156 EOF |
|
157 |
|
158 if test -n "$_NON_GLOBAL_ACDEFINES"; then |
|
159 for var in $_NON_GLOBAL_ACDEFINES; do |
|
160 echo " '$var'," >> $CONFIG_STATUS |
|
161 done |
|
162 fi |
|
163 |
|
164 cat >> $CONFIG_STATUS <<EOF |
|
165 ] |
|
166 |
|
167 __all__ = ['topobjdir', 'topsrcdir', 'defines', 'non_global_defines', 'substs'] |
|
168 EOF |
|
169 |
|
170 # We don't want js/src/config.status to do anything in gecko builds. |
|
171 if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then |
|
172 |
|
173 cat >> $CONFIG_STATUS <<EOF |
|
174 dnl Do the actual work |
|
175 if __name__ == '__main__': |
|
176 args = dict([(name, globals()[name]) for name in __all__]) |
|
177 from mozbuild.config_status import config_status |
|
178 config_status(**args) |
|
179 EOF |
|
180 |
|
181 fi |
|
182 |
|
183 changequote([, ]) |
|
184 ]) |
|
185 |
|
186 define([MOZ_RUN_CONFIG_STATUS], |
|
187 [ |
|
188 chmod +x $CONFIG_STATUS |
|
189 rm -fr confdefs* $ac_clean_files |
|
190 dnl Execute config.status, unless --no-create was passed to configure. |
|
191 if test "$no_create" != yes && ! ${PYTHON} $CONFIG_STATUS; then |
|
192 trap '' EXIT |
|
193 exit 1 |
|
194 fi |
|
195 ]) |
|
196 |
|
197 define([m4_fatal],[ |
|
198 errprint([$1 |
|
199 ]) |
|
200 m4exit(1) |
|
201 ]) |
|
202 |
|
203 define([AC_OUTPUT], [ifelse($#_$1, 1_, [MOZ_CREATE_CONFIG_STATUS() |
|
204 MOZ_RUN_CONFIG_STATUS()], |
|
205 [m4_fatal([Use CONFIGURE_SUBST_FILES in moz.build files to create substituted files.])] |
|
206 )]) |
|
207 |
|
208 define([AC_CONFIG_HEADER], |
|
209 [m4_fatal([Use CONFIGURE_DEFINE_FILES in moz.build files to produce header files.]) |
|
210 ]) |
|
211 |
|
212 AC_SUBST([MOZ_PSEUDO_DERECURSE]) |