michael@0: dnl This Source Code Form is subject to the terms of the Mozilla Public michael@0: dnl License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: dnl For use in AC_SUBST replacement michael@0: define([MOZ_DIVERSION_SUBST], 11) michael@0: michael@0: dnl Replace AC_SUBST to store values in a format suitable for python. michael@0: dnl The necessary comma after the tuple can't be put here because it michael@0: dnl can mess around with things like: michael@0: dnl AC_SOMETHING(foo,AC_SUBST(),bar) michael@0: define([AC_SUBST], michael@0: [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])], michael@0: [ifdef([AC_SUBST_LIST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])], michael@0: [ifdef([AC_SUBST_$1], , michael@0: [define([AC_SUBST_$1], )dnl michael@0: AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl michael@0: (''' $1 ''', r''' [$]$1 ''') michael@0: AC_DIVERT_POP()dnl michael@0: ])])])]) michael@0: michael@0: dnl Like AC_SUBST, but makes the value available as a set in python, michael@0: dnl with values got from the value of the environment variable, split on michael@0: dnl whitespaces. michael@0: define([AC_SUBST_SET], michael@0: [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])], michael@0: [ifdef([AC_SUBST_LIST$1], [m4_fatal([Cannot use AC_SUBST_LIST and AC_SUBST_SET on the same variable ($1)])], michael@0: [ifdef([AC_SUBST_SET_$1], , michael@0: [define([AC_SUBST_SET_$1], )dnl michael@0: AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl michael@0: (''' $1 ''', set(r''' [$]$1 '''.split())) michael@0: AC_DIVERT_POP()dnl michael@0: ])])])]) michael@0: michael@0: dnl Like AC_SUBST, but makes the value available as a list in python, michael@0: dnl with values got from the value of the environment variable, split on michael@0: dnl whitespaces. michael@0: define([AC_SUBST_LIST], michael@0: [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])], michael@0: [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST_SET and AC_SUBST_LIST on the same variable ($1)])], michael@0: [ifdef([AC_SUBST_LIST_$1], , michael@0: [define([AC_SUBST_LIST_$1], )dnl michael@0: AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl michael@0: (''' $1 ''', list(r''' [$]$1 '''.split())) michael@0: AC_DIVERT_POP()dnl michael@0: ])])])]) michael@0: michael@0: dnl Wrap AC_DEFINE to store values in a format suitable for python. michael@0: dnl autoconf's AC_DEFINE still needs to be used to fill confdefs.h, michael@0: dnl which is #included during some compile checks. michael@0: dnl The necessary comma after the tuple can't be put here because it michael@0: dnl can mess around with things like: michael@0: dnl AC_SOMETHING(foo,AC_DEFINE(),bar) michael@0: define([_MOZ_AC_DEFINE], defn([AC_DEFINE])) michael@0: define([AC_DEFINE], michael@0: [cat >> confdefs.pytmp <<\EOF michael@0: (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 ')) michael@0: EOF michael@0: ifelse($#, 2, _MOZ_AC_DEFINE([$1], [$2]), $#, 3, _MOZ_AC_DEFINE([$1], [$2], [$3]),_MOZ_AC_DEFINE([$1]))dnl michael@0: ]) michael@0: michael@0: dnl Wrap AC_DEFINE_UNQUOTED to store values in a format suitable for michael@0: dnl python. michael@0: define([_MOZ_AC_DEFINE_UNQUOTED], defn([AC_DEFINE_UNQUOTED])) michael@0: define([AC_DEFINE_UNQUOTED], michael@0: [cat >> confdefs.pytmp <>>)dnl michael@0: echo creating $CONFIG_STATUS michael@0: michael@0: extra_python_path=${COMM_BUILD:+"'mozilla', "} michael@0: michael@0: cat > $CONFIG_STATUS <>>), topsrcdir) michael@0: topsrcdir = os.path.abspath(rel) michael@0: topsrcdir = os.path.normpath(topsrcdir) michael@0: michael@0: topobjdir = os.path.abspath(os.path.dirname(<<<__file__>>>)) michael@0: michael@0: dnl All defines and substs are stored with an additional space at the beginning michael@0: dnl and at the end of the string, to avoid any problem with values starting or michael@0: dnl ending with quotes. michael@0: defines = [(name[1:-1], value[1:-1]) for name, value in [ michael@0: EOF michael@0: michael@0: dnl confdefs.pytmp contains AC_DEFINEs, in the expected format, but michael@0: dnl lacks the final comma (see above). michael@0: sed 's/$/,/' confdefs.pytmp >> $CONFIG_STATUS michael@0: rm confdefs.pytmp confdefs.h michael@0: michael@0: cat >> $CONFIG_STATUS <<\EOF michael@0: ] ] michael@0: michael@0: substs = [(name[1:-1], value[1:-1] if isinstance(value, types.StringTypes) else value) for name, value in [ michael@0: EOF michael@0: michael@0: dnl The MOZ_DIVERSION_SUBST output diversion contains AC_SUBSTs, in the michael@0: dnl expected format, but lacks the final comma (see above). michael@0: sed 's/$/,/' >> $CONFIG_STATUS <> $CONFIG_STATUS michael@0: done michael@0: michael@0: cat >> $CONFIG_STATUS <<\EOF michael@0: ] ] michael@0: michael@0: dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES michael@0: non_global_defines = [ michael@0: EOF michael@0: michael@0: if test -n "$_NON_GLOBAL_ACDEFINES"; then michael@0: for var in $_NON_GLOBAL_ACDEFINES; do michael@0: echo " '$var'," >> $CONFIG_STATUS michael@0: done michael@0: fi michael@0: michael@0: cat >> $CONFIG_STATUS <> $CONFIG_STATUS <