Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
5.6KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_subst_with.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_SUBST_WITH([varname])
  8. #
  9. # DESCRIPTION
  10. #
  11. # a very simple macro but also very helpful - the varname is usually the
  12. # one from an AC_ARG_ENABLE or AC_ARG_WITH option. it is transliterated
  13. # into uppercase and a prefix WITH_ and WITHOUT_ that are both _SUBSTed.
  14. #
  15. # Only one of these is set to "#" while the other is empty. In other words
  16. # a call like AC_WITHNONE(enable-call) will create two SUBST-symbols as
  17. # WITH_ENABLE_CALL and WITHOUT_ENABLE_CALL. When the varname had been set
  18. # to something not "no" or "0" or ":" or "false" then it results in
  19. #
  20. # WITH_ENABLE_CALL="" ; WITHOUT_ENABLE_CALL="#"
  21. #
  22. # which you can use in your Makefile quite easily as if using an
  23. # AM_CONDITIONAL but which can be also parsed by normal make
  24. #
  25. # USE = @WITH_ENABLE_CALL@ -Denabled USE = @WITHOUT_ENABLE_CALL@
  26. # -Dnot_enabled
  27. #
  28. # LICENSE
  29. #
  30. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  31. #
  32. # This program is free software; you can redistribute it and/or modify it
  33. # under the terms of the GNU General Public License as published by the
  34. # Free Software Foundation; either version 3 of the License, or (at your
  35. # option) any later version.
  36. #
  37. # This program is distributed in the hope that it will be useful, but
  38. # WITHOUT ANY WARRANTY; without even the implied warranty of
  39. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  40. # Public License for more details.
  41. #
  42. # You should have received a copy of the GNU General Public License along
  43. # with this program. If not, see <https://www.gnu.org/licenses/>.
  44. #
  45. # As a special exception, the respective Autoconf Macro's copyright owner
  46. # gives unlimited permission to copy, distribute and modify the configure
  47. # scripts that are the output of Autoconf when processing the Macro. You
  48. # need not follow the terms of the GNU General Public License when using
  49. # or distributing such scripts, even though portions of the text of the
  50. # Macro appear in them. The GNU General Public License (GPL) does govern
  51. # all other use of the material that constitutes the Autoconf Macro.
  52. #
  53. # This special exception to the GPL applies to versions of the Autoconf
  54. # Macro released by the Autoconf Archive. When you make and distribute a
  55. # modified version of the Autoconf Macro, you may extend this special
  56. # exception to the GPL to apply to your modified version as well.
  57. #serial 8
  58. dnl AX_SUBST_WITH_IF(flag,cond) - not unlike AM_CONDITIONAL
  59. AC_DEFUN([AX_SUBST_WITH_IF],[dnl
  60. pushdef([VAR_WITH], patsubst(translit([with_$1], [a-z], [A-Z]), -, _))dnl
  61. pushdef([VAR_WITHOUT], patsubst(translit([without_$1], [a-z], [A-Z]), -, _))dnl
  62. AC_SUBST(VAR_WITH)
  63. AC_SUBST(VAR_WITHOUT)
  64. if $2; then
  65. VAR_WITH=""
  66. VAR_WITHOUT="#"
  67. else
  68. VAR_WITH="#"
  69. VAR_WITHOUT=""
  70. fi
  71. popdef([VAR_WITHOUT])dnl
  72. popdef([VAR_WITH])dnl
  73. ])
  74. dnl AX_SUBST_WITH(varname [,default]) - not unlike AM_CONDITIONAL
  75. AC_DEFUN([AX_SUBST_WITH],[dnl
  76. pushdef([VAR], patsubst(translit([with_$1], [A-Z], [a-z]), -, _))dnl
  77. pushdef([VAR_WITH], patsubst(translit([with_$1], [a-z], [A-Z]), -, _))dnl
  78. pushdef([VAR_WITHOUT], patsubst(translit([without_$1], [a-z], [A-Z]), -, _))dnl
  79. pushdef([VAR_WITHVAL], patsubst(translit([withval_$1], [a-z], [A-Z]), -, _))dnl
  80. AC_SUBST(VAR_WITH)
  81. AC_SUBST(VAR_WITHOUT)
  82. VAR_WITHVAL=`echo "$VAR"`
  83. test ".$VAR_WITHVAL" = "." && VAR_WITHVAL="m4_ifval([$2],[$2],no)"
  84. test ".$VAR_WITHVAL" = ".:" && VAR_WITHVAL="no"
  85. test ".$VAR_WITHVAL" = ".0" && VAR_WITHVAL="no"
  86. test ".$VAR_WITHVAL" = ".no" && VAR_WITHVAL="no"
  87. test ".$VAR_WITHVAL" = ".false" && VAR_WITHVAL="no"
  88. if test ".$VAR_WITHVAL" != ".no" ; then
  89. VAR_WITH=""
  90. VAR_WITHOUT="#"
  91. else
  92. VAR_WITH="#"
  93. VAR_WITHOUT=""
  94. fi
  95. popdef([VAR_WITHVAL])dnl
  96. popdef([VAR_WITHOUT])dnl
  97. popdef([VAR_WITH])dnl
  98. popdef([VAR])dnl
  99. ])
  100. dnl AX_SUBST_WITH_DEFINE(varname [,default]) - not unlike AM_CONDITIONAL
  101. AC_DEFUN([AX_SUBST_WITH_DEFINE],[dnl
  102. pushdef([VAR], patsubst(translit([with_$1], [A-Z], [a-z]), -, _))dnl
  103. pushdef([VAR_WITH], patsubst(translit([with_$1], [a-z], [A-Z]), -, _))dnl
  104. pushdef([VAR_WITHOUT], patsubst(translit([without_$1], [a-z], [A-Z]), -, _))dnl
  105. pushdef([VAR_WITHVAL], patsubst(translit([withval_$1], [a-z], [A-Z]), -, _))dnl
  106. AC_SUBST(VAR_WITH)
  107. AC_SUBST(VAR_WITHOUT)
  108. VAR_WITHVAL=`echo "$VAR"`
  109. test ".$VAR_WITHVAL" = "." && VAR_WITHVAL="m4_ifval([$2],[$2],no)"
  110. test ".$VAR_WITHVAL" = ".:" && VAR_WITHVAL="no"
  111. test ".$VAR_WITHVAL" = ".0" && VAR_WITHVAL="no"
  112. test ".$VAR_WITHVAL" = ".no" && VAR_WITHVAL="no"
  113. test ".$VAR_WITHVAL" = ".false" && VAR_WITHVAL="no"
  114. if test ".$VAR_WITHVAL" != ".no" ; then
  115. VAR_WITH=""
  116. VAR_WITHOUT="#"
  117. case "$VAR_WITHVAL" in
  118. [[0123456789]]*) ;;
  119. [yes)] VAR_WITHVAL="1" ;;
  120. [*)] VAR_WITHVAL=`echo "\"$VAR_WITHVAL\"" | sed -e 's,"",",g'` ;;
  121. esac
  122. else
  123. VAR_WITH="#"
  124. VAR_WITHOUT=""
  125. fi
  126. if test ".$VAR_WITHVAL" != ".no" ; then
  127. AC_DEFINE_UNQUOTED(VAR_WITH, $VAR_WITHVAL,
  128. [whether $1 feature is enabled])
  129. fi dnl
  130. popdef([VAR_WITHVAL])dnl
  131. popdef([VAR_WITHOUT])dnl
  132. popdef([VAR_WITH])dnl
  133. popdef([VAR])dnl
  134. ])
  135. dnl backward compatibility helpers
  136. AC_DEFUN([AX_SUBST_WITH_ARG],[dnl
  137. pushdef([VAR], patsubst(translit([with_$1], [A-Z], [a-z]), -, _))dnl
  138. m4_ifvaln([$2],[test ".$VAR" = "." && VAR="$2"])dnl
  139. AX_SUBST_WITH([$1],[$2])
  140. popdef([VAR])dnl
  141. ])
  142. AC_DEFUN([AX_SUBST_WITH_DEFINE_ARG],[dnl
  143. pushdef([VAR], patsubst(translit([with_$1], [A-Z], [a-z]), -, _))dnl
  144. m4_ifvaln([$2],[test ".$VAR" = "." && VAR="$2"])dnl
  145. AX_SUBST_WITH_DEFINE([$1],[$2])
  146. popdef([VAR])dnl
  147. ])