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.

134 lines
4.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_spec_file.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_SPEC_FILE [(rpmspecfile [,subdirpath])]
  8. #
  9. # DESCRIPTION
  10. #
  11. # set the specfile - if no argument has been given then check whether the
  12. # ac_unique_file looks like a .spec file and use it. This macro is
  13. # ac_REQUIRED by many AX_SPEC_ routines.
  14. #
  15. # the AX_SPEC_EXTRACT macro is a helper used by many AX_SPEC_ routines and
  16. # therefore placed here to be automatically included in the macro set of
  17. # (older) aclocal/acinclude.
  18. #
  19. # AX_SPEC_EXTRACT(shellvar [,specvar [,defaultvalue]])
  20. #
  21. # LICENSE
  22. #
  23. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  24. #
  25. # This program is free software; you can redistribute it and/or modify it
  26. # under the terms of the GNU General Public License as published by the
  27. # Free Software Foundation; either version 3 of the License, or (at your
  28. # option) any later version.
  29. #
  30. # This program is distributed in the hope that it will be useful, but
  31. # WITHOUT ANY WARRANTY; without even the implied warranty of
  32. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  33. # Public License for more details.
  34. #
  35. # You should have received a copy of the GNU General Public License along
  36. # with this program. If not, see <https://www.gnu.org/licenses/>.
  37. #
  38. # As a special exception, the respective Autoconf Macro's copyright owner
  39. # gives unlimited permission to copy, distribute and modify the configure
  40. # scripts that are the output of Autoconf when processing the Macro. You
  41. # need not follow the terms of the GNU General Public License when using
  42. # or distributing such scripts, even though portions of the text of the
  43. # Macro appear in them. The GNU General Public License (GPL) does govern
  44. # all other use of the material that constitutes the Autoconf Macro.
  45. #
  46. # This special exception to the GPL applies to versions of the Autoconf
  47. # Macro released by the Autoconf Archive. When you make and distribute a
  48. # modified version of the Autoconf Macro, you may extend this special
  49. # exception to the GPL to apply to your modified version as well.
  50. #serial 10
  51. AC_DEFUN([AX_SPEC_FILE],
  52. [ AC_MSG_CHECKING([rpm spec file])
  53. if test ".$1" != "." ; then
  54. ax_spec_file_="$1"
  55. ax_spec_file=`basename $1`
  56. else
  57. case ".$ac_unique_file" in
  58. *.spec) ax_spec_file="$ac_unique_file"
  59. ax_spec_file_="$ac_unique_file" ;;
  60. *) ax_spec_file="TODO"
  61. if test ".$PACKAGE" != "."
  62. then ax_spec_file_="$PACKAGE.spec"
  63. else ax_spec_file_="README"
  64. fi
  65. cat m4_ifset([AS_MESSAGE_LOG_FD],[>&AS_MESSAGE_LOG_FD],[>>config.log]) <<EOF
  66. no ax_spec_file argument has been given, using defaults of
  67. (1) $ax_spec_file_
  68. (2) $ax_spec_file
  69. EOF
  70. ;;
  71. esac
  72. fi
  73. # find specfile
  74. for i in ifelse($2,,,$2) . $srcdir $srcdir/.. .. ; do
  75. if test -f "$i/$ax_spec_file_" ; then
  76. ax_spec_dir="$i"
  77. ax_spec_file="$ax_spec_dir/$ax_spec_file_"
  78. break
  79. fi
  80. if test -f "$i/$ax_spec_file" ; then
  81. ax_spec_dir="$i"
  82. ax_spec_file="$ax_spec_dir/$ax_spec_file"
  83. break
  84. fi
  85. done
  86. case "$ax_spec_file" in
  87. ./*) if test "$ax_spec_file" = "./$ax_spec_file_" ; then
  88. ax_spec_file="$ax_spec_file_"
  89. fi
  90. AC_MSG_RESULT([$ax_spec_file]) ;;
  91. */*) AC_MSG_RESULT([$ax_spec_file]) ;;
  92. *) AC_MSG_ERROR([no rpm spec file found]) ;;
  93. esac
  94. m4_define([m4_ax_spec_file],[ax_spec_file])
  95. ])
  96. dnl AX_SPEC_EXTRACT(shellvar [,specvar [,defaultvalue]])
  97. AC_DEFUN([AX_SPEC_EXTRACT],
  98. [
  99. if test ".$[]$1" = "." ; then
  100. $1=`grep -i '^[[ ]]*m4_ifval([$2],[$2],[$1])[[ ]]*:' dnl
  101. "$ax_spec_file" | sed -e 's/.*:[[ ]]*//' dnl
  102. -e 's/[[ ]][[ ]]*/ /g' -e 's/^ //' -e 's/ $[]//' -e 'q'`
  103. if test ".$[]$1" = "." ; then
  104. for $1 in $2 $1 m4_tolower([$1]) ; do
  105. $1=`echo "$[]$1" | sed -e 's/^%//g'`
  106. $1=`sed dnl
  107. -e "/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]/!d" dnl
  108. -e "s/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]*//" dnl
  109. -e 's/[[ ]][[ ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file`
  110. test ".$1" != "." && break
  111. done
  112. fi
  113. case ".$[]$1" in
  114. .%{*)
  115. $1=`echo "$[]$1" | sed -e 's/%{//' -e 's/}$[]//'`
  116. $1=`sed dnl
  117. -e "/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]/!d" dnl
  118. -e "s/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]*//" dnl
  119. -e 's/[[ ]][[ ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file` ;;
  120. .%*)
  121. $1=`echo "$[]$1" | sed -e 's/%//'`
  122. $1=`sed dnl
  123. -e "/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]/!d" dnl
  124. -e "s/^%[[ ]]*def[]ine[[ ]][[ ]]*$[]$1[[ ]]*//" dnl
  125. -e 's/[[ ]][[ ]]*/ /' -e 's/ $[]//' -e 'q' $ax_spec_file` ;;
  126. esac
  127. m4_ifval([$3],[test ".$[]$1" = "." && $1="$3"])
  128. fi # test ".$[]$1" = "."
  129. ])