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