config.status.m4 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. dnl For use in AC_SUBST replacement
  5. define([MOZ_DIVERSION_SUBST], 11)
  6. dnl Replace AC_SUBST to store values in a format suitable for python.
  7. dnl The necessary comma after the tuple can't be put here because it
  8. dnl can mess around with things like:
  9. dnl AC_SOMETHING(foo,AC_SUBST(),bar)
  10. define([AC_SUBST],
  11. [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
  12. [ifdef([AC_SUBST_LIST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])],
  13. [ifdef([AC_SUBST_$1], ,
  14. [define([AC_SUBST_$1], )dnl
  15. AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
  16. (''' $1 ''', r''' [$]$1 ''')
  17. AC_DIVERT_POP()dnl
  18. ])])])])
  19. dnl Like AC_SUBST, but makes the value available as a set in python,
  20. dnl with values got from the value of the environment variable, split on
  21. dnl whitespaces.
  22. define([AC_SUBST_SET],
  23. [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_SET on the same variable ($1)])],
  24. [ifdef([AC_SUBST_LIST$1], [m4_fatal([Cannot use AC_SUBST_LIST and AC_SUBST_SET on the same variable ($1)])],
  25. [ifdef([AC_SUBST_SET_$1], ,
  26. [define([AC_SUBST_SET_$1], )dnl
  27. AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
  28. (''' $1 ''', unique_list(r''' [$]$1 '''.split()))
  29. AC_DIVERT_POP()dnl
  30. ])])])])
  31. dnl Like AC_SUBST, but makes the value available as a list in python,
  32. dnl with values got from the value of the environment variable, split on
  33. dnl whitespaces.
  34. define([AC_SUBST_LIST],
  35. [ifdef([AC_SUBST_$1], [m4_fatal([Cannot use AC_SUBST and AC_SUBST_LIST on the same variable ($1)])],
  36. [ifdef([AC_SUBST_SET_$1], [m4_fatal([Cannot use AC_SUBST_SET and AC_SUBST_LIST on the same variable ($1)])],
  37. [ifdef([AC_SUBST_LIST_$1], ,
  38. [define([AC_SUBST_LIST_$1], )dnl
  39. AC_DIVERT_PUSH(MOZ_DIVERSION_SUBST)dnl
  40. (''' $1 ''', list(r''' [$]$1 '''.split()))
  41. AC_DIVERT_POP()dnl
  42. ])])])])
  43. dnl Ignore AC_SUBSTs for variables we don't have use for but that autoconf
  44. dnl itself exports.
  45. define([AC_SUBST_CFLAGS], )
  46. define([AC_SUBST_CPPFLAGS], )
  47. define([AC_SUBST_CXXFLAGS], )
  48. define([AC_SUBST_FFLAGS], )
  49. define([AC_SUBST_DEFS], )
  50. define([AC_SUBST_LDFLAGS], )
  51. define([AC_SUBST_LIBS], )
  52. dnl Wrap AC_DEFINE to store values in a format suitable for python.
  53. dnl autoconf's AC_DEFINE still needs to be used to fill confdefs.h,
  54. dnl which is #included during some compile checks.
  55. dnl The necessary comma after the tuple can't be put here because it
  56. dnl can mess around with things like:
  57. dnl AC_SOMETHING(foo,AC_DEFINE(),bar)
  58. define([_MOZ_AC_DEFINE], defn([AC_DEFINE]))
  59. define([AC_DEFINE],
  60. [cat >> confdefs.pytmp <<\EOF
  61. (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
  62. EOF
  63. ifelse($#, 2, _MOZ_AC_DEFINE([$1], [$2]), $#, 3, _MOZ_AC_DEFINE([$1], [$2], [$3]),_MOZ_AC_DEFINE([$1]))dnl
  64. ])
  65. dnl Wrap AC_DEFINE_UNQUOTED to store values in a format suitable for
  66. dnl python.
  67. define([_MOZ_AC_DEFINE_UNQUOTED], defn([AC_DEFINE_UNQUOTED]))
  68. define([AC_DEFINE_UNQUOTED],
  69. [cat >> confdefs.pytmp <<EOF
  70. (''' $1 ''', ifelse($#, 2, [r''' $2 '''], $#, 3, [r''' $2 '''], ' 1 '))
  71. EOF
  72. ifelse($#, 2, _MOZ_AC_DEFINE_UNQUOTED($1, $2), $#, 3, _MOZ_AC_DEFINE_UNQUOTED($1, $2, $3),_MOZ_AC_DEFINE_UNQUOTED($1))dnl
  73. ])
  74. dnl Replace AC_OUTPUT to create and call a python config.status
  75. define([MOZ_CREATE_CONFIG_STATUS],
  76. [dnl Top source directory in Windows format (as opposed to msys format).
  77. WIN_TOP_SRC=
  78. case "$host_os" in
  79. mingw*)
  80. WIN_TOP_SRC=`cd $srcdir; pwd -W`
  81. ;;
  82. esac
  83. AC_SUBST(WIN_TOP_SRC)
  84. dnl Used in all Makefile.in files
  85. top_srcdir=$srcdir
  86. AC_SUBST(top_srcdir)
  87. dnl Picked from autoconf 2.13
  88. trap '' 1 2 15
  89. AC_CACHE_SAVE
  90. trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
  91. : ${CONFIG_STATUS=./config.data}
  92. dnl We're going to need [ ] for python syntax.
  93. changequote(<<<, >>>)dnl
  94. echo creating $CONFIG_STATUS
  95. cat > $CONFIG_STATUS <<EOF
  96. def unique_list(l):
  97. result = []
  98. for i in l:
  99. if l not in result:
  100. result.append(i)
  101. return result
  102. dnl All defines and substs are stored with an additional space at the beginning
  103. dnl and at the end of the string, to avoid any problem with values starting or
  104. dnl ending with quotes.
  105. defines = [
  106. EOF
  107. dnl confdefs.pytmp contains AC_DEFINEs, in the expected format, but
  108. dnl lacks the final comma (see above).
  109. sed 's/$/,/' confdefs.pytmp >> $CONFIG_STATUS
  110. rm confdefs.pytmp confdefs.h
  111. cat >> $CONFIG_STATUS <<\EOF
  112. ]
  113. substs = [
  114. EOF
  115. dnl The MOZ_DIVERSION_SUBST output diversion contains AC_SUBSTs, in the
  116. dnl expected format, but lacks the final comma (see above).
  117. sed 's/$/,/' >> $CONFIG_STATUS <<EOF
  118. undivert(MOZ_DIVERSION_SUBST)dnl
  119. EOF
  120. dnl Add in the output from the subconfigure script
  121. for ac_subst_arg in $_subconfigure_ac_subst_args; do
  122. variable='$'$ac_subst_arg
  123. echo " (''' $ac_subst_arg ''', r''' `eval echo $variable` ''')," >> $CONFIG_STATUS
  124. done
  125. cat >> $CONFIG_STATUS <<\EOF
  126. ]
  127. dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES
  128. non_global_defines = [
  129. EOF
  130. if test -n "$_NON_GLOBAL_ACDEFINES"; then
  131. for var in $_NON_GLOBAL_ACDEFINES; do
  132. echo " '$var'," >> $CONFIG_STATUS
  133. done
  134. fi
  135. cat >> $CONFIG_STATUS <<EOF
  136. ]
  137. flags = [
  138. undivert(MOZ_DIVERSION_ARGS)dnl
  139. ]
  140. EOF
  141. changequote([, ])
  142. ])
  143. define([m4_fatal],[
  144. errprint([$1
  145. ])
  146. m4exit(1)
  147. ])
  148. define([AC_OUTPUT], [ifelse($#_$1, 1_, [MOZ_CREATE_CONFIG_STATUS()
  149. MOZ_RUN_CONFIG_STATUS()],
  150. [m4_fatal([Use CONFIGURE_SUBST_FILES in moz.build files to create substituted files.])]
  151. )])
  152. define([AC_CONFIG_HEADER],
  153. [m4_fatal([Use CONFIGURE_DEFINE_FILES in moz.build files to produce header files.])
  154. ])