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.

111 lines
4.7KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_numeric_namedlevel.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_NUMERIC_NAMEDLEVEL(VARNAME [,FROMVAR [,DEFAULT [,YESLEVEL]]])
  8. #
  9. # DESCRIPTION
  10. #
  11. # The levelstring FROMVAR is expanded and checked for verbal names that
  12. # will map on to eight different levels - the VARNAME will receive this
  13. # numeric level where "all" maps to 7 (lower three bits set) higher levels
  14. # for 8 and 9 exist too. This macro is a nice helper to convert user input
  15. # of a --with-opt=level into a numeric form that can be simply pushed as a
  16. # #define like with AC_DEFINE:
  17. #
  18. # default YESLEVEL = 2 /* including unknown levelspec */
  19. # default DEFAULT = 0 /* when named level is empty */
  20. # default FROMVAR = VARNAME
  21. #
  22. # The DEFAULT value is used if the NAMED levelstring has become empty and
  23. # it is copied without further conversion - a default of "0" is used if
  24. # absent - identical to "no". A "yes" will be set to the YESLEVEL - and
  25. # note that "yes" has "2" as its default value not "1". (which comes from
  26. # its original use to set a "gcc -O2").
  27. #
  28. # the mnemonic names are:
  29. #
  30. # 9| insane |ultrasome|experimentalplus
  31. # 8| ultra |ultra|experimental)
  32. # 7| all |muchmore|somemanymore|manymoreplus
  33. # 6| most |manymore|most)
  34. # 5| strict |somemore|almost
  35. # 4| more |more
  36. # 3| extra |manyplus|plusmuch|somemany|plusmany
  37. # 2| many |many|much|(yes)
  38. # 1| some |some|plus
  39. #
  40. # note that a level can be constructed of (some|plus) = bit-0, (many|much)
  41. # = bit-1, (more) = bit-2, (ultra|experimental) = bit-3 at least in a
  42. # left-to-right order, ie. plusmanymore=7
  43. #
  44. # Example usage:
  45. #
  46. # AX_NUMERIC_NAMEDLEVEL(OPTLEVEL,with_optlevel,1,3)
  47. # AC_DEFINE(OPTLEVEL)
  48. # test "$GCC" = "yes" && CFLAGS="$CFLAGS -O$OPTLEVEL)
  49. #
  50. # LICENSE
  51. #
  52. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  53. #
  54. # This program is free software; you can redistribute it and/or modify it
  55. # under the terms of the GNU General Public License as published by the
  56. # Free Software Foundation; either version 3 of the License, or (at your
  57. # option) any later version.
  58. #
  59. # This program is distributed in the hope that it will be useful, but
  60. # WITHOUT ANY WARRANTY; without even the implied warranty of
  61. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  62. # Public License for more details.
  63. #
  64. # You should have received a copy of the GNU General Public License along
  65. # with this program. If not, see <https://www.gnu.org/licenses/>.
  66. #
  67. # As a special exception, the respective Autoconf Macro's copyright owner
  68. # gives unlimited permission to copy, distribute and modify the configure
  69. # scripts that are the output of Autoconf when processing the Macro. You
  70. # need not follow the terms of the GNU General Public License when using
  71. # or distributing such scripts, even though portions of the text of the
  72. # Macro appear in them. The GNU General Public License (GPL) does govern
  73. # all other use of the material that constitutes the Autoconf Macro.
  74. #
  75. # This special exception to the GPL applies to versions of the Autoconf
  76. # Macro released by the Autoconf Archive. When you make and distribute a
  77. # modified version of the Autoconf Macro, you may extend this special
  78. # exception to the GPL to apply to your modified version as well.
  79. #serial 10
  80. AU_ALIAS([AC_NUMERIC_NAMEDLEVEL], [AX_NUMERIC_NAMEDLEVEL])
  81. AC_DEFUN([AX_NUMERIC_NAMEDLEVEL],
  82. [dnl the names to be defined...
  83. $1="ifelse($1,,[$]$2,[$]$1)" ; $1="[$]$1"
  84. $1="[$]$1" ; $1="[$]$1"
  85. if test "_[$]$1" = "_" ; then
  86. $1="ifelse([$3],,0,[$3])"
  87. elif test "_[$]$1" = "_yes" ; then
  88. $1="ifelse([$4],,2,[$4])"
  89. else
  90. $1=`echo [$]$1 | sed -e 's,some,plus,' -e 's,experimental,ultra,' -e 's,over,ultra,' -e 's,much,many,'`
  91. case "[$]$1" in
  92. 0*|1*|2*|3*|4*|5*|6*|7*|8*|9*|-*|+*) ;; # leave as is
  93. insane|ultraplus|plusultra) $1="9" ;;
  94. ultra) $1="8" ;;
  95. manymoreplus|manyplusmore|plusmanymore|all) $1="7" ;;
  96. moremanyplus|moreplusmany|plusmoremany) $1="7" ;;
  97. manymore|moremany|most) $1="6" ;;
  98. somemore|moresome|almost) $1="5" ;;
  99. more) $1="4" ;;
  100. manyplus|plusmany|extra) $1="3" ;;
  101. many) $1="2" ;;
  102. plus) $1="1" ;;
  103. no) $1="0" ;;
  104. yes) $1="ifelse([$4],,2,[$4])" ;;
  105. *) $1="ifelse([$3],,1,[$3])" ;; # for other unkown stuff.
  106. esac
  107. fi
  108. ])