acinclude.m4 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl
  2. AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl
  3. AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl
  4. AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl
  5. AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl
  6. AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl
  7. AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl
  8. AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl
  9. AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl
  10. m4_pushdef([_script],[conftest.prefix])dnl
  11. m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl
  12. _OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)`
  13. _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"`
  14. _PKG=`echo ifelse($2, , $PACKAGE, $2)`
  15. _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"`
  16. _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"`
  17. _INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'`
  18. if test ".$_INP" = "."; then
  19. for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue
  20. case "$ac_file" in
  21. *.h) _INP=$ac_file ;;
  22. *)
  23. esac
  24. test ".$_INP" != "." && break
  25. done
  26. fi
  27. if test ".$_INP" = "."; then
  28. case "$_OUT" in
  29. */*) _INP=`basename "$_OUT"`
  30. ;;
  31. *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"`
  32. ;;
  33. *) _INP=config.h
  34. ;;
  35. esac
  36. fi
  37. if test -z "$_PKG" ; then
  38. AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H])
  39. else
  40. if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then
  41. _INP="$srcdir/$_INP"
  42. fi fi
  43. AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines)
  44. if test -f $_INP ; then
  45. echo "s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script
  46. echo "s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script
  47. echo "s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script
  48. echo "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script
  49. echo "@%:@endif/" >>_script
  50. echo "s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script
  51. echo "@%:@define $_LOW""_\\1 \\2 \\" >> _script
  52. echo "@%:@endif/" >> _script
  53. # now executing _script on _DEF input to create _OUT output file
  54. echo "@%:@ifndef $_DEF" >$tmp/pconfig.h
  55. echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h
  56. echo ' ' >>$tmp/pconfig.h
  57. echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h
  58. sed -f _script $_INP >>$tmp/pconfig.h
  59. echo ' ' >>$tmp/pconfig.h
  60. echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h
  61. echo "@%:@endif" >>$tmp/pconfig.h
  62. if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then
  63. AC_MSG_NOTICE([$_OUT is unchanged])
  64. else
  65. ac_dir=`AS_DIRNAME(["$_OUT"])`
  66. AS_MKDIR_P(["$ac_dir"])
  67. rm -f "$_OUT"
  68. mv $tmp/pconfig.h "$_OUT"
  69. fi
  70. cp _script _configs.sed
  71. else
  72. AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT])
  73. fi
  74. rm -f conftest.*
  75. fi
  76. m4_popdef([_symbol])dnl
  77. m4_popdef([_script])dnl
  78. AS_VAR_POPDEF([_INP])dnl
  79. AS_VAR_POPDEF([_UPP])dnl
  80. AS_VAR_POPDEF([_LOW])dnl
  81. AS_VAR_POPDEF([_PKG])dnl
  82. AS_VAR_POPDEF([_DEF])dnl
  83. AS_VAR_POPDEF([_OUT])dnl
  84. ],[PACKAGE="$PACKAGE"])])
  85. dnl implementation note: a bug report (31.5.2005) from Marten Svantesson points
  86. dnl out a problem where `echo "\1"` results in a Control-A. The unix standard
  87. dnl http://www.opengroup.org/onlinepubs/000095399/utilities/echo.html
  88. dnl defines all backslash-sequences to be inherently non-portable asking
  89. dnl for replacement mit printf. Some old systems had problems with that
  90. dnl one either. However, the latest libtool (!) release does export an $ECHO
  91. dnl (and $echo) that does the right thing - just one question is left: what
  92. dnl was the first version to have it? Is it greater 2.58 ?