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.

261 lines
9.9KB

  1. # ============================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_spec_package_version.html
  3. # ============================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_SPEC_PACKAGE_AND_VERSION ([specfile])
  8. # AX_SPEC_PACKAGE_NAME ([shellvar],[defaultvalue])
  9. # AX_SPEC_PACKAGE_VERSION ([shellvar],[defaultvalue])
  10. # AX_SPEC_PACKAGE_SUMMARY ([shellvar],[defaultvalue])
  11. # AX_SPEC_PACKAGE_LICENSE ([shellvar],[defaultvalue])
  12. # AX_SPEC_PACKAGE_CATEGORY ([shellvar],[defaultvalue])
  13. # AX_SPEC_PACKAGE_ICON ([shellvar],[defaultvalue])
  14. # AX_SPEC_DEFAULTS([specfile])
  15. #
  16. # DESCRIPTION
  17. #
  18. # set PACKAGE from the given specfile - default to basename of the
  19. # rpmspecfile if no "name:" could be found in the spec file.
  20. #
  21. # set VERSION from the given specfile - default to a date-derived value if
  22. # no "version:" could be found in the spec file.
  23. #
  24. # this macro builds on top of AX_SPEC_FILE / AX_SPEC_EXTRACT
  25. #
  26. # more specific: if not "name:" or "%define name" was found in the
  27. # myproject.spec file then the PACKAGE var is set to the basename
  28. # "myproject". When no spec file was present then it will usually default
  29. # to "TODO".
  30. #
  31. # The version spec looks for "version:" or "%define version" in the spec
  32. # file. When no such value was seen or no spec file had been present then
  33. # the value is set to `date +0.%y.%W%w`.
  34. #
  35. # the version value itself is sanitized somewhat with making it to always
  36. # carry at least three digits (1.2.3) and cleansing superfluous "0" chars
  37. # around from generating numbers elsewhere.
  38. #
  39. # additional macros are provided that extract a specific value from the
  40. # spec file, among these:
  41. #
  42. # set PACKAGE_SUMMARY from the given specfile - default to package and try
  43. # to detect a type suffix if "summary:" was not in the spec file
  44. #
  45. # set PACKAGE_LICENSE from the given specfile - if no "license:" tag was
  46. # given in the spec file then various COPYING files are grepped to have a
  47. # guess and the final fallback will be GNU GPL (or GNU LGPL).
  48. #
  49. # set PACKAGE_ICON from the given specfile - if no "icon:" tag was given
  50. # in the spec file then we default to $PACKAGE-icon.png
  51. #
  52. # the final AX_SPEC_INIT(specfile) will initialize all variables to its
  53. # defaults according to the spec file given.
  54. #
  55. # LICENSE
  56. #
  57. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  58. #
  59. # This program is free software; you can redistribute it and/or modify it
  60. # under the terms of the GNU General Public License as published by the
  61. # Free Software Foundation; either version 3 of the License, or (at your
  62. # option) any later version.
  63. #
  64. # This program is distributed in the hope that it will be useful, but
  65. # WITHOUT ANY WARRANTY; without even the implied warranty of
  66. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  67. # Public License for more details.
  68. #
  69. # You should have received a copy of the GNU General Public License along
  70. # with this program. If not, see <https://www.gnu.org/licenses/>.
  71. #
  72. # As a special exception, the respective Autoconf Macro's copyright owner
  73. # gives unlimited permission to copy, distribute and modify the configure
  74. # scripts that are the output of Autoconf when processing the Macro. You
  75. # need not follow the terms of the GNU General Public License when using
  76. # or distributing such scripts, even though portions of the text of the
  77. # Macro appear in them. The GNU General Public License (GPL) does govern
  78. # all other use of the material that constitutes the Autoconf Macro.
  79. #
  80. # This special exception to the GPL applies to versions of the Autoconf
  81. # Macro released by the Autoconf Archive. When you make and distribute a
  82. # modified version of the Autoconf Macro, you may extend this special
  83. # exception to the GPL to apply to your modified version as well.
  84. #serial 12
  85. AC_DEFUN([AX_SPEC_PACKAGE_LICENSE],[AC_REQUIRE([AX_SPEC_FILE])dnl
  86. AS_VAR_PUSHDEF([VAR],[PACKAGE_LICENSE])dnl
  87. AC_MSG_CHECKING([for spec license type])
  88. if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
  89. then k="(w/o spec)"
  90. else k=""
  91. AX_SPEC_EXTRACT(VAR,[license],m4_ifval($1,$1))
  92. VAR=`echo $VAR | sed -e 's/ *License//g'`
  93. fi fi
  94. test ".$VAR" = "." && k="(fallback)"
  95. ifelse($2,,[dnl here the defaults for LICENSE / COPYRIGHT
  96. if test ".$VAR" = "." ; then
  97. for ac_file in "$srcdir/COPYING" "$srcdir/COPYING" "$srcdir/LICENSE" ; do
  98. test -f "$ac_file" || continue
  99. dnl http://www.ibiblio.org/osrt/omf/omf_elements "16. Rights"
  100. if grep "GNU LESSER GENERAL PUBLIC LICENSE" "$ac_file" >/dev/null
  101. then VAR="GNU LGPL" ; break
  102. elif grep "GNU GENERAL PUBLIC LICENSE" "$ac_file" >/dev/null
  103. then VAR="GNU GPL" ; break
  104. elif grep "MOZILLA PUBLIC LICENSE" "$ac_file" >/dev/null
  105. then VAR="MPL" ; break
  106. elif grep "Mozilla Public License" "$ac_file" >/dev/null
  107. then VAR="MPL" ; break
  108. elif grep -i "artistic license" "$ac_file" >/dev/null
  109. then VAR="Artistic" ; break
  110. elif grep -i "artistic control" "$ac_file" >/dev/null
  111. then VAR="Artistic" ; break
  112. elif grep -i "semblance of artistic" "$ac_file" >/dev/null
  113. then VAR="Artistic" ; break
  114. elif grep -i "above copyright notice" "$ac_file" >/dev/null
  115. then VAR="BSD" ; break
  116. fi
  117. done
  118. if test ".$VAR" = "." ; then
  119. if test "$srcdir/COPYING.LIB" ; then VAR="GNU LGPL"
  120. elif test ".$ltmain" != "." ; then VAR="GNU LGPL"
  121. else VAR="GNU GPL"
  122. fi
  123. fi
  124. fi
  125. ],[test ".$VAR" = "." && VAR="$2"])
  126. test "$VAR" = "GPL" && VAR="GNU GPL"
  127. test "$VAR" = "LGPL" && VAR="GNU LGPL"
  128. AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
  129. AS_VAR_POPDEF([VAR])dnl
  130. ])
  131. AC_DEFUN([AX_SPEC_PACKAGE_SUMMARY],[AC_REQUIRE([AX_SPEC_FILE])dnl
  132. AS_VAR_PUSHDEF([VAR],[PACKAGE_SUMMARY])dnl
  133. AC_MSG_CHECKING([for spec summary])
  134. if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
  135. then k="(w/o spec)"
  136. else k=""
  137. AX_SPEC_EXTRACT(VAR,[summary],m4_ifval($1,$1))
  138. fi fi
  139. test ".$VAR" = "." && k="(fallback)"
  140. ifelse($2,,[dnl here the defaults for SUMMARY
  141. if test ".$VAR" = "." ; then VAR="$PACKAGE"
  142. test ".$VAR" = "." && VAR="foo"
  143. test ".$ltmain" != "." && VAR="$VAR library"
  144. fi
  145. ],[test ".$VAR" = "." && VAR="$2"])
  146. AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
  147. AS_VAR_POPDEF([VAR])dnl
  148. ])
  149. AC_DEFUN([AX_SPEC_PACKAGE_ICON],[AC_REQUIRE([AX_SPEC_FILE])dnl
  150. AS_VAR_PUSHDEF([VAR],[PACKAGE_ICON])dnl
  151. AC_MSG_CHECKING([for spec icon])
  152. if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
  153. then k="(w/o spec)"
  154. else k=""
  155. AX_SPEC_EXTRACT(VAR,[icon],m4_ifval($1,$1))
  156. fi fi
  157. test ".$VAR" = "." && k="(fallback)"
  158. ifelse($2,,[dnl here the defaults for ICON
  159. if test ".$VAR" = "." ; then VAR="$PACKAGE-icon.png" ; fi
  160. ],[test ".$VAR" = "." && VAR="$2"])
  161. AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
  162. AS_VAR_POPDEF([VAR])dnl
  163. ])
  164. AC_DEFUN([AX_SPEC_PACKAGE_CATEGORY],[AC_REQUIRE([AX_SPEC_FILE])dnl
  165. AS_VAR_PUSHDEF([VAR],[PACKAGE_CATEGORY])dnl
  166. AC_MSG_CHECKING([for spec category])
  167. if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
  168. then k="(w/o spec)"
  169. else k=""
  170. AX_SPEC_EXTRACT(VAR,[group],m4_ifval($1,$1))
  171. VAR=`echo $VAR | sed -e 's/ /-/g'`
  172. fi fi
  173. test ".$VAR" = "." && k="(fallback)"
  174. ifelse($2,,[dnl here the defaults for CATEGORY
  175. if test ".$VAR" = "." ; then if test ".$ltmain" != "."
  176. then VAR="Development/Library"
  177. else VAR="Development/Other"
  178. fi fi
  179. ],[test ".$VAR" = "." && VAR="$2"])
  180. AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
  181. AS_VAR_POPDEF([VAR])dnl
  182. ])
  183. AC_DEFUN([AX_SPEC_PACKAGE_NAME],[AC_REQUIRE([AX_SPEC_FILE])dnl
  184. AS_VAR_PUSHDEF([VAR],[PACKAGE_NAME])dnl
  185. AC_MSG_CHECKING([for spec package])
  186. if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
  187. then k="(w/o spec)"
  188. else k=""
  189. AX_SPEC_EXTRACT(VAR,[name],m4_ifval($1,$1))
  190. VAR=`echo $VAR | sed -e 's/ /-/g'`
  191. fi fi
  192. test ".$VAR" = "." && k="(fallback)"
  193. ifelse($2,,[dnl here the defaults for PACKAGE
  194. test ".$VAR" = "." && VAR=`basename $ax_spec_file .spec`
  195. test ".$VAR" = ".README" && VAR="TODO"
  196. test ".$VAR" = ".TODO" && VAR="foo"
  197. ],[test ".$VAR" = "." && VAR="$2"])
  198. test "VAR" = "PACKAGE_NAME" && test ".$PACKAGE" = "." && PACKAGE="$VAR"
  199. AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
  200. AS_VAR_POPDEF([VAR])dnl
  201. ])
  202. AC_DEFUN([AX_SPEC_PACKAGE_VERSION_],[AC_REQUIRE([AX_SPEC_FILE])dnl
  203. AS_VAR_PUSHDEF([VAR],[PACKAGE_VERSION])dnl
  204. AC_MSG_CHECKING([for spec version])
  205. if test ".$VAR" = "." ; then if test ! -f $ax_spec_file
  206. then k="(w/o spec)"
  207. else k=""
  208. AX_SPEC_EXTRACT(VAR,[version],m4_ifval($1,$1))
  209. VAR=`echo $VAR | sed -e 's/ /-/g'`
  210. fi fi
  211. test ".$VAR" = "." && k="(fallback)"
  212. ifelse($2,,[dnl here the defaults for VERSION
  213. test ".$VAR" = "." && VAR=`date +0.%y.%W%w`
  214. ],[test ".$VAR" = "." && VAR="$2"])
  215. test "VAR" = "PACKAGE_VERSION" && test ".$VERSION" = "." && VERSION="$VAR"
  216. case "$VAR" in # note we set traditional VERSION before cleaning things up
  217. *.*.) VAR="$VAR"`date +%W%w` ;;
  218. *.*.*) ;;
  219. *.) VAR="$VAR"`date +%y.%W%w` ;;
  220. *.*) VAR="$VAR.0" ;;
  221. *) VAR=AS_TR_SH([$VAR]) ; VAR="$VAR.`date +%y.%W%w`" ;;
  222. esac
  223. VAR=`echo $VAR | sed -e "s/[[.]][0]\\([0-9]\\)/.\\1/g"`
  224. AC_MSG_RESULT([m4_ifval([$1],[$1 = ])$VAR $k])
  225. AS_VAR_POPDEF([VAR])dnl
  226. ])
  227. dnl for compatibility, we define ax_spec_package_version
  228. dnl to do all of ax_spec_package_name as well.
  229. AC_DEFUN([AX_SPEC_PACKAGE_VERSION],[AC_REQUIRE([AX_SPEC_FILE])dnl
  230. ifelse($1,,
  231. AC_MSG_WARN([please use ax_spec_package_AND_version now!]),
  232. AC_MSG_ERROR([please use ax_spec_package_AND_version now!]))
  233. AX_SPEC_PACKAGE_NAME
  234. AX_SPEC_PACKAGE_VERSION_
  235. ])
  236. AC_DEFUN([AX_SPEC_PACKAGE_AND_VERSION],[
  237. m4_ifset([m4_ax_spec_file],,[AX_SPEC_FILE($1)])
  238. AX_SPEC_PACKAGE_NAME
  239. AX_SPEC_PACKAGE_VERSION_
  240. ])
  241. AC_DEFUN([AX_SPEC_DEFAULTS],[
  242. m4_ifset([m4_ax_spec_file],,[AX_SPEC_FILE($1)])
  243. AX_SPEC_PACKAGE_NAME
  244. AX_SPEC_PACKAGE_VERSION_
  245. AX_SPEC_PACKAGE_LICENSE
  246. AX_SPEC_PACKAGE_SUMMARY
  247. AX_SPEC_PACKAGE_CATEGORY
  248. AX_SPEC_PACKAGE_ICON
  249. ])