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.

352 lines
14KB

  1. # =============================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_create_pkgconfig_info.html
  3. # =============================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CREATE_PKGCONFIG_INFO [(outputfile, [requires [,libs [,summary [,cflags [, ldflags]]]]])]
  8. #
  9. # DESCRIPTION
  10. #
  11. # Defaults:
  12. #
  13. # $1 = $PACKAGE_NAME.pc
  14. # $2 = (empty)
  15. # $3 = $PACKAGE_LIBS $LIBS (as set at that point in configure.ac)
  16. # $4 = $PACKAGE_SUMMARY (or $1 Library)
  17. # $5 = $PACKAGE_CFLAGS (as set at the point in configure.ac)
  18. # $6 = $PACKAGE_LDFLAGS (as set at the point in configure.ac)
  19. #
  20. # PACKAGE_NAME defaults to $PACKAGE if not set.
  21. # PACKAGE_LIBS defaults to -l$PACKAGE_NAME if not set.
  22. #
  23. # The resulting file is called $PACKAGE.pc.in / $PACKAGE.pc
  24. #
  25. # You will find this macro most useful in conjunction with
  26. # ax_spec_defaults that can read good initializers from the .spec file. In
  27. # consequence, most of the generatable installable stuff can be made from
  28. # information being updated in a single place for the whole project.
  29. #
  30. # LICENSE
  31. #
  32. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  33. # Copyright (c) 2008 Sven Verdoolaege <skimo@kotnet.org>
  34. #
  35. # This program is free software; you can redistribute it and/or modify it
  36. # under the terms of the GNU General Public License as published by the
  37. # Free Software Foundation; either version 3 of the License, or (at your
  38. # option) any later version.
  39. #
  40. # This program is distributed in the hope that it will be useful, but
  41. # WITHOUT ANY WARRANTY; without even the implied warranty of
  42. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  43. # Public License for more details.
  44. #
  45. # You should have received a copy of the GNU General Public License along
  46. # with this program. If not, see <https://www.gnu.org/licenses/>.
  47. #
  48. # As a special exception, the respective Autoconf Macro's copyright owner
  49. # gives unlimited permission to copy, distribute and modify the configure
  50. # scripts that are the output of Autoconf when processing the Macro. You
  51. # need not follow the terms of the GNU General Public License when using
  52. # or distributing such scripts, even though portions of the text of the
  53. # Macro appear in them. The GNU General Public License (GPL) does govern
  54. # all other use of the material that constitutes the Autoconf Macro.
  55. #
  56. # This special exception to the GPL applies to versions of the Autoconf
  57. # Macro released by the Autoconf Archive. When you make and distribute a
  58. # modified version of the Autoconf Macro, you may extend this special
  59. # exception to the GPL to apply to your modified version as well.
  60. #serial 16
  61. AC_DEFUN([AX_CREATE_PKGCONFIG_INFO],[dnl
  62. AS_VAR_PUSHDEF([PKGCONFIG_suffix],[ax_create_pkgconfig_suffix])dnl
  63. AS_VAR_PUSHDEF([PKGCONFIG_libdir],[ax_create_pkgconfig_libdir])dnl
  64. AS_VAR_PUSHDEF([PKGCONFIG_libfile],[ax_create_pkgconfig_libfile])dnl
  65. AS_VAR_PUSHDEF([PKGCONFIG_libname],[ax_create_pkgconfig_libname])dnl
  66. AS_VAR_PUSHDEF([PKGCONFIG_version],[ax_create_pkgconfig_version])dnl
  67. AS_VAR_PUSHDEF([PKGCONFIG_description],[ax_create_pkgconfig_description])dnl
  68. AS_VAR_PUSHDEF([PKGCONFIG_requires],[ax_create_pkgconfig_requires])dnl
  69. AS_VAR_PUSHDEF([PKGCONFIG_pkglibs],[ax_create_pkgconfig_pkglibs])dnl
  70. AS_VAR_PUSHDEF([PKGCONFIG_libs],[ax_create_pkgconfig_libs])dnl
  71. AS_VAR_PUSHDEF([PKGCONFIG_ldflags],[ax_create_pkgconfig_ldflags])dnl
  72. AS_VAR_PUSHDEF([PKGCONFIG_cppflags],[ax_create_pkgconfig_cppflags])dnl
  73. AS_VAR_PUSHDEF([PKGCONFIG_generate],[ax_create_pkgconfig_generate])dnl
  74. AS_VAR_PUSHDEF([PKGCONFIG_src_libdir],[ax_create_pkgconfig_src_libdir])dnl
  75. AS_VAR_PUSHDEF([PKGCONFIG_src_headers],[ax_create_pkgconfig_src_headers])dnl
  76. # we need the expanded forms...
  77. test "x$prefix" = xNONE && prefix=$ac_default_prefix
  78. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
  79. AC_MSG_CHECKING(our pkgconfig libname)
  80. test ".$PKGCONFIG_libname" != "." || \
  81. PKGCONFIG_libname="ifelse($1,,${PACKAGE_NAME},`basename $1 .pc`)"
  82. test ".$PKGCONFIG_libname" != "." || \
  83. PKGCONFIG_libname="$PACKAGE"
  84. PKGCONFIG_libname=`eval echo "$PKGCONFIG_libname"`
  85. PKGCONFIG_libname=`eval echo "$PKGCONFIG_libname"`
  86. AC_MSG_RESULT($PKGCONFIG_libname)
  87. AC_MSG_CHECKING(our pkgconfig version)
  88. test ".$PKGCONFIG_version" != "." || \
  89. PKGCONFIG_version="${PACKAGE_VERSION}"
  90. test ".$PKGCONFIG_version" != "." || \
  91. PKGCONFIG_version="$VERSION"
  92. PKGCONFIG_version=`eval echo "$PKGCONFIG_version"`
  93. PKGCONFIG_version=`eval echo "$PKGCONFIG_version"`
  94. AC_MSG_RESULT($PKGCONFIG_version)
  95. AC_MSG_CHECKING(our pkgconfig_libdir)
  96. test ".$pkgconfig_libdir" = "." && \
  97. pkgconfig_libdir='${libdir}/pkgconfig'
  98. PKGCONFIG_libdir=`eval echo "$pkgconfig_libdir"`
  99. PKGCONFIG_libdir=`eval echo "$PKGCONFIG_libdir"`
  100. PKGCONFIG_libdir=`eval echo "$PKGCONFIG_libdir"`
  101. AC_MSG_RESULT($pkgconfig_libdir)
  102. test "$pkgconfig_libdir" != "$PKGCONFIG_libdir" && (
  103. AC_MSG_RESULT(expanded our pkgconfig_libdir... $PKGCONFIG_libdir))
  104. AC_SUBST([pkgconfig_libdir])
  105. AC_MSG_CHECKING(our pkgconfig_libfile)
  106. test ".$pkgconfig_libfile" != "." || \
  107. pkgconfig_libfile="ifelse($1,,$PKGCONFIG_libname.pc,`basename $1`)"
  108. PKGCONFIG_libfile=`eval echo "$pkgconfig_libfile"`
  109. PKGCONFIG_libfile=`eval echo "$PKGCONFIG_libfile"`
  110. AC_MSG_RESULT($pkgconfig_libfile)
  111. test "$pkgconfig_libfile" != "$PKGCONFIG_libfile" && (
  112. AC_MSG_RESULT(expanded our pkgconfig_libfile... $PKGCONFIG_libfile))
  113. AC_SUBST([pkgconfig_libfile])
  114. AC_MSG_CHECKING(our package / suffix)
  115. PKGCONFIG_suffix="$program_suffix"
  116. test ".$PKGCONFIG_suffix" != .NONE || PKGCONFIG_suffix=""
  117. AC_MSG_RESULT(${PACKAGE_NAME} / ${PKGCONFIG_suffix})
  118. AC_MSG_CHECKING(our pkgconfig description)
  119. PKGCONFIG_description="ifelse($4,,$PACKAGE_SUMMARY,$4)"
  120. test ".$PKGCONFIG_description" != "." || \
  121. PKGCONFIG_description="$PKGCONFIG_libname Library"
  122. PKGCONFIG_description=`eval echo "$PKGCONFIG_description"`
  123. PKGCONFIG_description=`eval echo "$PKGCONFIG_description"`
  124. AC_MSG_RESULT($PKGCONFIG_description)
  125. AC_MSG_CHECKING(our pkgconfig requires)
  126. PKGCONFIG_requires="ifelse($2,,$PACKAGE_REQUIRES,$2)"
  127. PKGCONFIG_requires=`eval echo "$PKGCONFIG_requires"`
  128. PKGCONFIG_requires=`eval echo "$PKGCONFIG_requires"`
  129. AC_MSG_RESULT($PKGCONFIG_requires)
  130. AC_MSG_CHECKING(our pkgconfig ext libs)
  131. PKGCONFIG_pkglibs="$PACKAGE_LIBS"
  132. test ".$PKGCONFIG_pkglibs" != "." || PKGCONFIG_pkglibs="-l$PKGCONFIG_libname"
  133. PKGCONFIG_libs="ifelse($3,,$PKGCONFIG_pkglibs $LIBS,$3)"
  134. PKGCONFIG_libs=`eval echo "$PKGCONFIG_libs"`
  135. PKGCONFIG_libs=`eval echo "$PKGCONFIG_libs"`
  136. AC_MSG_RESULT($PKGCONFIG_libs)
  137. AC_MSG_CHECKING(our pkgconfig cppflags)
  138. PKGCONFIG_cppflags="ifelse($5,,$PACKAGE_CFLAGS,$5)"
  139. PKGCONFIG_cppflags=`eval echo "$PKGCONFIG_cppflags"`
  140. PKGCONFIG_cppflags=`eval echo "$PKGCONFIG_cppflags"`
  141. AC_MSG_RESULT($PKGCONFIG_cppflags)
  142. AC_MSG_CHECKING(our pkgconfig ldflags)
  143. PKGCONFIG_ldflags="ifelse($6,,$PACKAGE_LDFLAGS,$6)"
  144. PKGCONFIG_ldflags=`eval echo "$PKGCONFIG_ldflags"`
  145. PKGCONFIG_ldflags=`eval echo "$PKGCONFIG_ldflags"`
  146. AC_MSG_RESULT($PKGCONFIG_ldflags)
  147. test ".$PKGCONFIG_generate" != "." || \
  148. PKGCONFIG_generate="ifelse($1,,$PKGCONFIG_libname.pc,$1)"
  149. PKGCONFIG_generate=`eval echo "$PKGCONFIG_generate"`
  150. PKGCONFIG_generate=`eval echo "$PKGCONFIG_generate"`
  151. test "$pkgconfig_libfile" != "$PKGCONFIG_generate" && (
  152. AC_MSG_RESULT(generate the pkgconfig later... $PKGCONFIG_generate))
  153. if test ".$PKGCONFIG_src_libdir" = "." ; then
  154. PKGCONFIG_src_libdir=`pwd`
  155. PKGCONFIG_src_libdir=`AS_DIRNAME("$PKGCONFIG_src_libdir/$PKGCONFIG_generate")`
  156. test ! -d $PKGCONFIG_src_libdir/src || \
  157. PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/src"
  158. case ".$objdir" in
  159. *libs) PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/$objdir" ;; esac
  160. AC_MSG_RESULT(noninstalled pkgconfig -L $PKGCONFIG_src_libdir)
  161. fi
  162. if test ".$PKGCONFIG_src_headers" = "." ; then
  163. PKGCONFIG_src_headers=`pwd`
  164. v="$ac_top_srcdir" ;
  165. test ".$v" != "." || v="$ax_spec_dir"
  166. test ".$v" != "." || v="$srcdir"
  167. case "$v" in /*) PKGCONFIG_src_headers="" ;; esac
  168. PKGCONFIG_src_headers=`AS_DIRNAME("$PKGCONFIG_src_headers/$v/x")`
  169. test ! -d $PKGCONFIG_src_headers/incl[]ude || \
  170. PKGCONFIG_src_headers="$PKGCONFIG_src_headers/incl[]ude"
  171. AC_MSG_RESULT(noninstalled pkgconfig -I $PKGCONFIG_src_headers)
  172. fi
  173. dnl AC_CONFIG_COMMANDS crap disallows to use $PKGCONFIG_libfile here...
  174. AC_CONFIG_COMMANDS([$ax_create_pkgconfig_generate],[
  175. pkgconfig_generate="$ax_create_pkgconfig_generate"
  176. if test ! -f "$pkgconfig_generate.in"
  177. then generate="true"
  178. elif grep ' generated by configure ' $pkgconfig_generate.in >/dev/null
  179. then generate="true"
  180. else generate="false";
  181. fi
  182. if $generate ; then
  183. AC_MSG_NOTICE(creating $pkgconfig_generate.in)
  184. cat > $pkgconfig_generate.in <<AXEOF
  185. # generated by configure / remove this line to disable regeneration
  186. prefix=@prefix@
  187. exec_prefix=@exec_prefix@
  188. bindir=@bindir@
  189. libdir=@libdir@
  190. datarootdir=@datarootdir@
  191. datadir=@datadir@
  192. sysconfdir=@sysconfdir@
  193. includedir=@includedir@
  194. package=@PACKAGE@
  195. suffix=@suffix@
  196. Name: @PACKAGE_NAME@
  197. Description: @PACKAGE_DESCRIPTION@
  198. Version: @PACKAGE_VERSION@
  199. Requires: @PACKAGE_REQUIRES@
  200. Libs: -L\${libdir} @LDFLAGS@ @LIBS@
  201. Cflags: -I\${includedir} @CPPFLAGS@
  202. AXEOF
  203. fi # DONE generate $pkgconfig_generate.in
  204. AC_MSG_NOTICE(creating $pkgconfig_generate)
  205. cat >conftest.sed <<AXEOF
  206. s|@prefix@|${pkgconfig_prefix}|
  207. s|@exec_prefix@|${pkgconfig_execprefix}|
  208. s|@bindir@|${pkgconfig_bindir}|
  209. s|@libdir@|${pkgconfig_libdir}|
  210. s|@datarootdir@|${pkgconfig_datarootdir}|
  211. s|@datadir@|${pkgconfig_datadir}|
  212. s|@sysconfdir@|${pkgconfig_sysconfdir}|
  213. s|@includedir@|${pkgconfig_includedir}|
  214. s|@suffix@|${pkgconfig_suffix}|
  215. s|@PACKAGE@|${pkgconfig_package}|
  216. s|@PACKAGE_NAME@|${pkgconfig_libname}|
  217. s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|
  218. s|@PACKAGE_VERSION@|${pkgconfig_version}|
  219. s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|
  220. s|@LIBS@|${pkgconfig_libs}|
  221. s|@LDFLAGS@|${pkgconfig_ldflags}|
  222. s|@CPPFLAGS@|${pkgconfig_cppflags}|
  223. AXEOF
  224. sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_generate
  225. if test ! -s $pkgconfig_generate ; then
  226. AC_MSG_ERROR([$pkgconfig_generate is empty])
  227. fi ; rm conftest.sed # DONE generate $pkgconfig_generate
  228. pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.pc/'`
  229. AC_MSG_NOTICE(creating $pkgconfig_uninstalled)
  230. cat >conftest.sed <<AXEOF
  231. s|@prefix@|${pkgconfig_prefix}|
  232. s|@exec_prefix@|${pkgconfig_execprefix}|
  233. s|@bindir@|${pkgconfig_bindir}|
  234. s|@libdir@|${pkgconfig_src_libdir}|
  235. s|@datarootdir@|${pkgconfig_datarootdir}|
  236. s|@datadir@|${pkgconfig_datadir}|
  237. s|@sysconfdir@|${pkgconfig_sysconfdir}|
  238. s|@includedir@|${pkgconfig_src_headers}|
  239. s|@suffix@|${pkgconfig_suffix}|
  240. s|@PACKAGE@|${pkgconfig_package}|
  241. s|@PACKAGE_NAME@|${pkgconfig_libname}|
  242. s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}|
  243. s|@PACKAGE_VERSION@|${pkgconfig_version}|
  244. s|@PACKAGE_REQUIRES@|${pkgconfig_requires}|
  245. s|@LIBS@|${pkgconfig_libs}|
  246. s|@LDFLAGS@|${pkgconfig_ldflags}|
  247. s|@CPPFLAGS@|${pkgconfig_cppflags}|
  248. AXEOF
  249. sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled
  250. if test ! -s $pkgconfig_uninstalled ; then
  251. AC_MSG_ERROR([$pkgconfig_uninstalled is empty])
  252. fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled
  253. pkgconfig_requires_add=`echo ${pkgconfig_requires}`
  254. if test ".$pkgconfig_requires_add" != "." ; then
  255. pkgconfig_requires_add="pkg-config $pkgconfig_requires_add"
  256. else pkgconfig_requires_add=":" ; fi
  257. pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.sh/'`
  258. AC_MSG_NOTICE(creating $pkgconfig_uninstalled)
  259. cat >conftest.sed <<AXEOF
  260. s|@prefix@|\"${pkgconfig_prefix}\"|
  261. s|@exec_prefix@|\"${pkgconfig_execprefix}\"|
  262. s|@bindir@|\"${pkgconfig_bindir}\"|
  263. s|@libdir@|\"${pkgconfig_src_libdir}\"|
  264. s|@datarootdir@|\"${pkgconfig_datarootdir}\"|
  265. s|@datadir@|\"${pkgconfig_datadir}\"|
  266. s|@sysconfdir@|\"${pkgconfig_sysconfdir}\"|
  267. s|@includedir@|\"${pkgconfig_src_headers}\"|
  268. s|@suffix@|\"${pkgconfig_suffix}\"|
  269. s|@PACKAGE@|\"${pkgconfig_package}\"|
  270. s|@PACKAGE_NAME@|\"${pkgconfig_libname}\"|
  271. s|@PACKAGE_DESCRIPTION@|\"${pkgconfig_description}\"|
  272. s|@PACKAGE_VERSION@|\"${pkgconfig_version}\"|
  273. s|@PACKAGE_REQUIRES@|\"${pkgconfig_requires}\"|
  274. s|@LIBS@|\"${pkgconfig_libs}\"|
  275. s|@LDFLAGS@|\"${pkgconfig_ldflags}\"|
  276. s|@CPPFLAGS@|\"${pkgconfig_cppflags}\"|
  277. s>Name:>for option\\; do case \"\$option\" in --list-all|--name) echo >
  278. s>Description: *>\\;\\; --help) pkg-config --help \\; echo Buildscript Of >
  279. s>Version: *>\\;\\; --modversion|--version) echo >
  280. s>Requires:>\\;\\; --requires) echo $pkgconfig_requires_add>
  281. s>Libs: *>\\;\\; --libs) echo >
  282. s>Cflags: *>\\;\\; --cflags) echo >
  283. /--libs)/a\\
  284. $pkgconfig_requires_add
  285. /--cflags)/a\\
  286. $pkgconfig_requires_add\\
  287. ;; --variable=*) eval echo '\$'\`echo \$option | sed -e 's/.*=//'\`\\
  288. ;; --uninstalled) exit 0 \\
  289. ;; *) ;; esac done
  290. AXEOF
  291. sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled
  292. if test ! -s $pkgconfig_uninstalled ; then
  293. AC_MSG_ERROR([$pkgconfig_uninstalled is empty])
  294. fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled
  295. ],[
  296. dnl AC_CONFIG_COMMANDS crap, the AS_PUSHVAR defines are invalid here...
  297. ax_create_pkgconfig_generate="$ax_create_pkgconfig_generate"
  298. pkgconfig_prefix='$prefix'
  299. pkgconfig_execprefix='$exec_prefix'
  300. pkgconfig_bindir='$bindir'
  301. pkgconfig_libdir='$libdir'
  302. pkgconfig_includedir='$includedir'
  303. pkgconfig_datarootdir='$datarootdir'
  304. pkgconfig_datadir='$datadir'
  305. pkgconfig_sysconfdir='$sysconfdir'
  306. pkgconfig_suffix='$ax_create_pkgconfig_suffix'
  307. pkgconfig_package='$PACKAGE_NAME'
  308. pkgconfig_libname='$ax_create_pkgconfig_libname'
  309. pkgconfig_description='$ax_create_pkgconfig_description'
  310. pkgconfig_version='$ax_create_pkgconfig_version'
  311. pkgconfig_requires='$ax_create_pkgconfig_requires'
  312. pkgconfig_libs='$ax_create_pkgconfig_libs'
  313. pkgconfig_ldflags='$ax_create_pkgconfig_ldflags'
  314. pkgconfig_cppflags='$ax_create_pkgconfig_cppflags'
  315. pkgconfig_src_libdir='$ax_create_pkgconfig_src_libdir'
  316. pkgconfig_src_headers='$ax_create_pkgconfig_src_headers'
  317. ])dnl
  318. AS_VAR_POPDEF([PKGCONFIG_suffix])dnl
  319. AS_VAR_POPDEF([PKGCONFIG_libdir])dnl
  320. AS_VAR_POPDEF([PKGCONFIG_libfile])dnl
  321. AS_VAR_POPDEF([PKGCONFIG_libname])dnl
  322. AS_VAR_POPDEF([PKGCONFIG_version])dnl
  323. AS_VAR_POPDEF([PKGCONFIG_description])dnl
  324. AS_VAR_POPDEF([PKGCONFIG_requires])dnl
  325. AS_VAR_POPDEF([PKGCONFIG_pkglibs])dnl
  326. AS_VAR_POPDEF([PKGCONFIG_libs])dnl
  327. AS_VAR_POPDEF([PKGCONFIG_ldflags])dnl
  328. AS_VAR_POPDEF([PKGCONFIG_cppflags])dnl
  329. AS_VAR_POPDEF([PKGCONFIG_generate])dnl
  330. AS_VAR_POPDEF([PKGCONFIG_src_libdir])dnl
  331. AS_VAR_POPDEF([PKGCONFIG_src_headers])dnl
  332. ])