1# =========================================================================== 2# http://www.nongnu.org/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 = $CPPFLAGS $PACKAGE_CFLAGS (as set at the point in configure.ac) 18# $6 = $LDFLAGS $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# consequencd, 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 2 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 <http://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 61AC_DEFUN([AX_CREATE_PKGCONFIG_INFO],[dnl 62AS_VAR_PUSHDEF([PKGCONFIG_suffix],[ax_create_pkgconfig_suffix])dnl 63AS_VAR_PUSHDEF([PKGCONFIG_libdir],[ax_create_pkgconfig_libdir])dnl 64AS_VAR_PUSHDEF([PKGCONFIG_libfile],[ax_create_pkgconfig_libfile])dnl 65AS_VAR_PUSHDEF([PKGCONFIG_libname],[ax_create_pkgconfig_libname])dnl 66AS_VAR_PUSHDEF([PKGCONFIG_version],[ax_create_pkgconfig_version])dnl 67AS_VAR_PUSHDEF([PKGCONFIG_description],[ax_create_pkgconfig_description])dnl 68AS_VAR_PUSHDEF([PKGCONFIG_requires],[ax_create_pkgconfig_requires])dnl 69AS_VAR_PUSHDEF([PKGCONFIG_pkglibs],[ax_create_pkgconfig_pkglibs])dnl 70AS_VAR_PUSHDEF([PKGCONFIG_libs],[ax_create_pkgconfig_libs])dnl 71AS_VAR_PUSHDEF([PKGCONFIG_ldflags],[ax_create_pkgconfig_ldflags])dnl 72AS_VAR_PUSHDEF([PKGCONFIG_cppflags],[ax_create_pkgconfig_cppflags])dnl 73AS_VAR_PUSHDEF([PKGCONFIG_generate],[ax_create_pkgconfig_generate])dnl 74AS_VAR_PUSHDEF([PKGCONFIG_src_libdir],[ax_create_pkgconfig_src_libdir])dnl 75AS_VAR_PUSHDEF([PKGCONFIG_src_headers],[ax_create_pkgconfig_src_headers])dnl 76 77# we need the expanded forms... 78test "x$prefix" = xNONE && prefix=$ac_default_prefix 79test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' 80 81AC_MSG_CHECKING(our pkgconfig libname) 82test ".$PKGCONFIG_libname" != "." || \ 83PKGCONFIG_libname="ifelse($1,,${PACKAGE_NAME},`basename $1 .pc`)" 84test ".$PKGCONFIG_libname" != "." || \ 85PKGCONFIG_libname="$PACKAGE" 86PKGCONFIG_libname=`eval echo "$PKGCONFIG_libname"` 87PKGCONFIG_libname=`eval echo "$PKGCONFIG_libname"` 88AC_MSG_RESULT($PKGCONFIG_libname) 89 90AC_MSG_CHECKING(our pkgconfig version) 91test ".$PKGCONFIG_version" != "." || \ 92PKGCONFIG_version="${PACKAGE_VERSION}" 93test ".$PKGCONFIG_version" != "." || \ 94PKGCONFIG_version="$VERSION" 95PKGCONFIG_version=`eval echo "$PKGCONFIG_version"` 96PKGCONFIG_version=`eval echo "$PKGCONFIG_version"` 97AC_MSG_RESULT($PKGCONFIG_version) 98 99AC_MSG_CHECKING(our pkgconfig_libdir) 100test ".$pkgconfig_libdir" = "." && \ 101pkgconfig_libdir='${libdir}/pkgconfig' 102PKGCONFIG_libdir=`eval echo "$pkgconfig_libdir"` 103PKGCONFIG_libdir=`eval echo "$PKGCONFIG_libdir"` 104PKGCONFIG_libdir=`eval echo "$PKGCONFIG_libdir"` 105AC_MSG_RESULT($pkgconfig_libdir) 106test "$pkgconfig_libdir" != "$PKGCONFIG_libdir" && ( 107AC_MSG_RESULT(expanded our pkgconfig_libdir... $PKGCONFIG_libdir)) 108AC_SUBST([pkgconfig_libdir]) 109 110AC_MSG_CHECKING(our pkgconfig_libfile) 111test ".$pkgconfig_libfile" != "." || \ 112pkgconfig_libfile="ifelse($1,,$PKGCONFIG_libname.pc,`basename $1`)" 113PKGCONFIG_libfile=`eval echo "$pkgconfig_libfile"` 114PKGCONFIG_libfile=`eval echo "$PKGCONFIG_libfile"` 115AC_MSG_RESULT($pkgconfig_libfile) 116test "$pkgconfig_libfile" != "$PKGCONFIG_libfile" && ( 117AC_MSG_RESULT(expanded our pkgconfig_libfile... $PKGCONFIG_libfile)) 118AC_SUBST([pkgconfig_libfile]) 119 120AC_MSG_CHECKING(our package / suffix) 121PKGCONFIG_suffix="$program_suffix" 122test ".$PKGCONFIG_suffix" != .NONE || PKGCONFIG_suffix="" 123AC_MSG_RESULT(${PACKAGE_NAME} / ${PKGCONFIG_suffix}) 124 125AC_MSG_CHECKING(our pkgconfig description) 126PKGCONFIG_description="ifelse($4,,$PACKAGE_SUMMARY,$4)" 127test ".$PKGCONFIG_description" != "." || \ 128PKGCONFIG_description="$PKGCONFIG_libname Library" 129PKGCONFIG_description=`eval echo "$PKGCONFIG_description"` 130PKGCONFIG_description=`eval echo "$PKGCONFIG_description"` 131AC_MSG_RESULT($PKGCONFIG_description) 132 133AC_MSG_CHECKING(our pkgconfig requires) 134PKGCONFIG_requires="ifelse($2,,$PACKAGE_REQUIRES,$2)" 135PKGCONFIG_requires=`eval echo "$PKGCONFIG_requires"` 136PKGCONFIG_requires=`eval echo "$PKGCONFIG_requires"` 137AC_MSG_RESULT($PKGCONFIG_requires) 138 139AC_MSG_CHECKING(our pkgconfig ext libs) 140PKGCONFIG_pkglibs="$PACKAGE_LIBS" 141test ".$PKGCONFIG_pkglibs" != "." || PKGCONFIG_pkglibs="-l$PKGCONFIG_libname" 142PKGCONFIG_libs="ifelse($3,,$PKGCONFIG_pkglibs $LIBS,$3)" 143PKGCONFIG_libs=`eval echo "$PKGCONFIG_libs"` 144PKGCONFIG_libs=`eval echo "$PKGCONFIG_libs"` 145AC_MSG_RESULT($PKGCONFIG_libs) 146 147AC_MSG_CHECKING(our pkgconfig cppflags) 148PKGCONFIG_cppflags="ifelse($5,,$CPPFLAGS $PACKAGE_CFLAGS,$5)" 149PKGCONFIG_cppflags=`eval echo "$PKGCONFIG_cppflags"` 150PKGCONFIG_cppflags=`eval echo "$PKGCONFIG_cppflags"` 151AC_MSG_RESULT($PKGCONFIG_cppflags) 152 153AC_MSG_CHECKING(our pkgconfig ldflags) 154PKGCONFIG_ldflags="ifelse($6,,$LDFLAGS $PACKAGE_LDFLAGS,$5)" 155PKGCONFIG_ldflags=`eval echo "$PKGCONFIG_ldflags"` 156PKGCONFIG_ldflags=`eval echo "$PKGCONFIG_ldflags"` 157AC_MSG_RESULT($PKGCONFIG_ldflags) 158 159test ".$PKGCONFIG_generate" != "." || \ 160PKGCONFIG_generate="ifelse($1,,$PKGCONFIG_libname.pc,$1)" 161PKGCONFIG_generate=`eval echo "$PKGCONFIG_generate"` 162PKGCONFIG_generate=`eval echo "$PKGCONFIG_generate"` 163test "$pkgconfig_libfile" != "$PKGCONFIG_generate" && ( 164AC_MSG_RESULT(generate the pkgconfig later... $PKGCONFIG_generate)) 165 166if test ".$PKGCONFIG_src_libdir" = "." ; then 167PKGCONFIG_src_libdir=`pwd` 168PKGCONFIG_src_libdir=`AS_DIRNAME("$PKGCONFIG_src_libdir/$PKGCONFIG_generate")` 169test ! -d $PKGCONFIG_src_libdir/src || \ 170PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/src" 171case ".$objdir" in 172*libs) PKGCONFIG_src_libdir="$PKGCONFIG_src_libdir/$objdir" ;; esac 173AC_MSG_RESULT(noninstalled pkgconfig -L $PKGCONFIG_src_libdir) 174fi 175 176if test ".$PKGCONFIG_src_headers" = "." ; then 177PKGCONFIG_src_headers=`pwd` 178v="$ac_top_srcdir" ; 179test ".$v" != "." || v="$ax_spec_dir" 180test ".$v" != "." || v="$srcdir" 181case "$v" in /*) PKGCONFIG_src_headers="" ;; esac 182PKGCONFIG_src_headers=`AS_DIRNAME("$PKGCONFIG_src_headers/$v/x")` 183test ! -d $PKGCONFIG_src_headers/incl[]ude || \ 184PKGCONFIG_src_headers="$PKGCONFIG_src_headers/incl[]ude" 185AC_MSG_RESULT(noninstalled pkgconfig -I $PKGCONFIG_src_headers) 186fi 187 188 189dnl AC_CONFIG_COMMANDS crap disallows to use $PKGCONFIG_libfile here... 190AC_CONFIG_COMMANDS([$ax_create_pkgconfig_generate],[ 191pkgconfig_generate="$ax_create_pkgconfig_generate" 192if test ! -f "$pkgconfig_generate.in" 193then generate="true" 194elif grep ' generated by configure ' $pkgconfig_generate.in >/dev/null 195then generate="true" 196else generate="false"; 197fi 198if $generate ; then 199AC_MSG_NOTICE(creating $pkgconfig_generate.in) 200cat > $pkgconfig_generate.in <<AXEOF 201# generated by configure / remove this line to disable regeneration 202prefix=@prefix@ 203exec_prefix=@exec_prefix@ 204bindir=@bindir@ 205libdir=@libdir@ 206datarootdir=@datarootdir@ 207datadir=@datadir@ 208sysconfdir=@sysconfdir@ 209includedir=@includedir@ 210package=@PACKAGE@ 211suffix=@suffix@ 212 213Name: @PACKAGE_NAME@ 214Description: @PACKAGE_DESCRIPTION@ 215Version: @PACKAGE_VERSION@ 216Requires: @PACKAGE_REQUIRES@ 217Libs: -L\${libdir} @LDFLAGS@ @LIBS@ 218Cflags: -I\${includedir} @CPPFLAGS@ 219AXEOF 220fi # DONE generate $pkgconfig_generate.in 221AC_MSG_NOTICE(creating $pkgconfig_generate) 222cat >conftest.sed <<AXEOF 223s|@prefix@|${pkgconfig_prefix}| 224s|@exec_prefix@|${pkgconfig_execprefix}| 225s|@bindir@|${pkgconfig_bindir}| 226s|@libdir@|${pkgconfig_libdir}| 227s|@datarootdir@|${pkgconfig_datarootdir}| 228s|@datadir@|${pkgconfig_datadir}| 229s|@sysconfdir@|${pkgconfig_sysconfdir}| 230s|@includedir@|${pkgconfig_includedir}| 231s|@suffix@|${pkgconfig_suffix}| 232s|@PACKAGE@|${pkgconfig_package}| 233s|@PACKAGE_NAME@|${pkgconfig_libname}| 234s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}| 235s|@PACKAGE_VERSION@|${pkgconfig_version}| 236s|@PACKAGE_REQUIRES@|${pkgconfig_requires}| 237s|@LIBS@|${pkgconfig_libs}| 238s|@LDFLAGS@|${pkgconfig_ldflags}| 239s|@CPPFLAGS@|${pkgconfig_cppflags}| 240AXEOF 241sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_generate 242if test ! -s $pkgconfig_generate ; then 243 AC_MSG_ERROR([$pkgconfig_generate is empty]) 244fi ; rm conftest.sed # DONE generate $pkgconfig_generate 245pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.pc/'` 246AC_MSG_NOTICE(creating $pkgconfig_uninstalled) 247cat >conftest.sed <<AXEOF 248s|@prefix@|${pkgconfig_prefix}| 249s|@exec_prefix@|${pkgconfig_execprefix}| 250s|@bindir@|${pkgconfig_bindir}| 251s|@libdir@|${pkgconfig_src_libdir}| 252s|@datarootdir@|${pkgconfig_datarootdir}| 253s|@datadir@|${pkgconfig_datadir}| 254s|@sysconfdir@|${pkgconfig_sysconfdir}| 255s|@includedir@|${pkgconfig_src_headers}| 256s|@suffix@|${pkgconfig_suffix}| 257s|@PACKAGE@|${pkgconfig_package}| 258s|@PACKAGE_NAME@|${pkgconfig_libname}| 259s|@PACKAGE_DESCRIPTION@|${pkgconfig_description}| 260s|@PACKAGE_VERSION@|${pkgconfig_version}| 261s|@PACKAGE_REQUIRES@|${pkgconfig_requires}| 262s|@LIBS@|${pkgconfig_libs}| 263s|@LDFLAGS@|${pkgconfig_ldflags}| 264s|@CPPFLAGS@|${pkgconfig_cppflags}| 265AXEOF 266sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled 267if test ! -s $pkgconfig_uninstalled ; then 268 AC_MSG_ERROR([$pkgconfig_uninstalled is empty]) 269fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled 270 pkgconfig_requires_add=`echo ${pkgconfig_requires}` 271if test ".$pkgconfig_requires_add" != "." ; then 272 pkgconfig_requires_add="pkg-config $pkgconfig_requires_add" 273 else pkgconfig_requires_add=":" ; fi 274pkgconfig_uninstalled=`echo $pkgconfig_generate |sed 's/.pc$/-uninstalled.sh/'` 275AC_MSG_NOTICE(creating $pkgconfig_uninstalled) 276cat >conftest.sed <<AXEOF 277s|@prefix@|\"${pkgconfig_prefix}\"| 278s|@exec_prefix@|\"${pkgconfig_execprefix}\"| 279s|@bindir@|\"${pkgconfig_bindir}\"| 280s|@libdir@|\"${pkgconfig_src_libdir}\"| 281s|@datarootdir@|\"${pkgconfig_datarootdir}\"| 282s|@datadir@|\"${pkgconfig_datadir}\"| 283s|@sysconfdir@|\"${pkgconfig_sysconfdir}\"| 284s|@includedir@|\"${pkgconfig_src_headers}\"| 285s|@suffix@|\"${pkgconfig_suffix}\"| 286s|@PACKAGE@|\"${pkgconfig_package}\"| 287s|@PACKAGE_NAME@|\"${pkgconfig_libname}\"| 288s|@PACKAGE_DESCRIPTION@|\"${pkgconfig_description}\"| 289s|@PACKAGE_VERSION@|\"${pkgconfig_version}\"| 290s|@PACKAGE_REQUIRES@|\"${pkgconfig_requires}\"| 291s|@LIBS@|\"${pkgconfig_libs}\"| 292s|@LDFLAGS@|\"${pkgconfig_ldflags}\"| 293s|@CPPFLAGS@|\"${pkgconfig_cppflags}\"| 294s>Name:>for option\\; do case \"\$option\" in --list-all|--name) echo > 295s>Description: *>\\;\\; --help) pkg-config --help \\; echo Buildscript Of > 296s>Version: *>\\;\\; --modversion|--version) echo > 297s>Requires:>\\;\\; --requires) echo $pkgconfig_requires_add> 298s>Libs: *>\\;\\; --libs) echo > 299s>Cflags: *>\\;\\; --cflags) echo > 300/--libs)/a\\ 301 $pkgconfig_requires_add 302/--cflags)/a\\ 303 $pkgconfig_requires_add\\ 304;; --variable=*) eval echo '\$'\`echo \$option | sed -e 's/.*=//'\`\\ 305;; --uninstalled) exit 0 \\ 306;; *) ;; esac done 307AXEOF 308sed -f conftest.sed $pkgconfig_generate.in > $pkgconfig_uninstalled 309if test ! -s $pkgconfig_uninstalled ; then 310 AC_MSG_ERROR([$pkgconfig_uninstalled is empty]) 311fi ; rm conftest.sed # DONE generate $pkgconfig_uninstalled 312],[ 313dnl AC_CONFIG_COMMANDS crap, the AS_PUSHVAR defines are invalid here... 314ax_create_pkgconfig_generate="$ax_create_pkgconfig_generate" 315pkgconfig_prefix='$prefix' 316pkgconfig_execprefix='$exec_prefix' 317pkgconfig_bindir='$bindir' 318pkgconfig_libdir='$libdir' 319pkgconfig_includedir='$includedir' 320pkgconfig_datarootdir='$datarootdir' 321pkgconfig_datadir='$datadir' 322pkgconfig_sysconfdir='$sysconfdir' 323pkgconfig_suffix='$ax_create_pkgconfig_suffix' 324pkgconfig_package='$PACKAGE_NAME' 325pkgconfig_libname='$ax_create_pkgconfig_libname' 326pkgconfig_description='$ax_create_pkgconfig_description' 327pkgconfig_version='$ax_create_pkgconfig_version' 328pkgconfig_requires='$ax_create_pkgconfig_requires' 329pkgconfig_libs='$ax_create_pkgconfig_libs' 330pkgconfig_ldflags='$ax_create_pkgconfig_ldflags' 331pkgconfig_cppflags='$ax_create_pkgconfig_cppflags' 332pkgconfig_src_libdir='$ax_create_pkgconfig_src_libdir' 333pkgconfig_src_headers='$ax_create_pkgconfig_src_headers' 334])dnl 335AS_VAR_POPDEF([PKGCONFIG_suffix])dnl 336AS_VAR_POPDEF([PKGCONFIG_libdir])dnl 337AS_VAR_POPDEF([PKGCONFIG_libfile])dnl 338AS_VAR_POPDEF([PKGCONFIG_libname])dnl 339AS_VAR_POPDEF([PKGCONFIG_version])dnl 340AS_VAR_POPDEF([PKGCONFIG_description])dnl 341AS_VAR_POPDEF([PKGCONFIG_requires])dnl 342AS_VAR_POPDEF([PKGCONFIG_pkglibs])dnl 343AS_VAR_POPDEF([PKGCONFIG_libs])dnl 344AS_VAR_POPDEF([PKGCONFIG_ldflags])dnl 345AS_VAR_POPDEF([PKGCONFIG_cppflags])dnl 346AS_VAR_POPDEF([PKGCONFIG_generate])dnl 347AS_VAR_POPDEF([PKGCONFIG_src_libdir])dnl 348AS_VAR_POPDEF([PKGCONFIG_src_headers])dnl 349]) 350