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.

100 lines
3.5KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_var_pop.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_VAR_POPVALUE(VARIABLE)
  8. #
  9. # DESCRIPTION
  10. #
  11. # Restores a variable's previous value. Compile, link and running tests
  12. # usually require the programmer to provide additional flags. However, it
  13. # is strongly recommended not to override flags defined by the user
  14. # through the configure command. AX_VAR_PUSHVALUE and AX_VAR_POPVALUE are
  15. # clean way to temporarily store a variable's value and restore it later,
  16. # using a stack-like behaviour. This macro supports nesting.
  17. #
  18. # Example:
  19. #
  20. # AX_VAR_PUSHVALUE([CXXFLAGS],["my test flags"])
  21. # perform some checks with CXXFLAGS...
  22. # CXXFLAGS value will be "my test flags"
  23. # AX_VAR_POPVALUE([CXXFLAGS])
  24. # CXXFLAGS is restored to its original value
  25. #
  26. # LICENSE
  27. #
  28. # Copyright (c) 2015 Jorge Bellon <jbelloncastro@gmail.com>
  29. #
  30. # This program is free software: you can redistribute it and/or modify it
  31. # under the terms of the GNU General Public License as published by the
  32. # Free Software Foundation, either version 3 of the License, or (at your
  33. # option) any later version.
  34. #
  35. # This program is distributed in the hope that it will be useful, but
  36. # WITHOUT ANY WARRANTY; without even the implied warranty of
  37. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  38. # Public License for more details.
  39. #
  40. # You should have received a copy of the GNU General Public License along
  41. # with this program. If not, see <https://www.gnu.org/licenses/>.
  42. #
  43. # As a special exception, the respective Autoconf Macro's copyright owner
  44. # gives unlimited permission to copy, distribute and modify the configure
  45. # scripts that are the output of Autoconf when processing the Macro. You
  46. # need not follow the terms of the GNU General Public License when using
  47. # or distributing such scripts, even though portions of the text of the
  48. # Macro appear in them. The GNU General Public License (GPL) does govern
  49. # all other use of the material that constitutes the Autoconf Macro.
  50. #
  51. # This special exception to the GPL applies to versions of the Autoconf
  52. # Macro released by the Autoconf Archive. When you make and distribute a
  53. # modified version of the Autoconf Macro, you may extend this special
  54. # exception to the GPL to apply to your modified version as well.
  55. #serial 2
  56. # Main macros
  57. AC_DEFUN([AX_VAR_PUSHVALUE],[
  58. increment([$1_counter])
  59. AS_VAR_PUSHDEF([variable],[$1]) dnl
  60. AS_VAR_PUSHDEF([backup],[save_$1_]$1_counter) dnl
  61. AS_VAR_SET(backup,$variable) dnl
  62. AS_VAR_SET(variable,["]m4_default($2,$variable)["]) dnl
  63. AS_VAR_POPDEF([variable]) dnl
  64. AS_VAR_POPDEF([backup]) dnl
  65. ])dnl AX_PUSH_VAR
  66. AC_DEFUN([AX_VAR_POPVALUE],[
  67. AS_VAR_PUSHDEF([variable],[$1]) dnl
  68. AS_VAR_PUSHDEF([backup],[save_$1_]$1_counter) dnl
  69. AS_VAR_SET(variable,$backup) dnl
  70. decrement([$1_counter])
  71. AS_VAR_POPDEF([variable]) dnl
  72. AS_VAR_POPDEF([backup]) dnl
  73. ])dnl AX_POP_VAR
  74. # -------------------------
  75. # Auxiliary macro
  76. # -------------------------
  77. # decrement(counter_name)
  78. #
  79. # Decrement the value of a named counter.
  80. # Throws an error if counter not defined
  81. # or value reaches zero.
  82. # -------------------------
  83. m4_define([decrement],[dnl
  84. m4_ifdef([$1],dnl
  85. [m4_if(m4_eval($1 > 0),
  86. [1],m4_define([$1],m4_decr($1)),dnl
  87. [m4_fatal([Missing call to AX_VAR_PUSHVALUE with var $1])]dnl
  88. )],dnl
  89. [m4_fatal([Missing call to AX_VAR_PUSHVALUE with var $1])])dnl
  90. ])dnl