rpm-build/scripts/pkgconfig.req.in

112 lines
3.5 KiB
Plaintext
Raw Normal View History

#!/bin/sh -efu
#
# Copyright (C) 2006 Dmitry V. Levin <ldv@altlinux.org>
# Copyright (C) 2007 Alexey Tourbin <at@altlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
. @RPMCONFIGDIR@/functions
[ -n "${RPM_LIBDIR-}" ] || RPM_LIBDIR=`rpm --eval %_libdir`
PKG_CONFIG_PATH=$RPM_LIBDIR/pkgconfig:/usr/share/pkgconfig
[ -z "${RPM_BUILD_ROOT-}" ] ||
PKG_CONFIG_PATH=$RPM_BUILD_ROOT$RPM_LIBDIR/pkgconfig:$RPM_BUILD_ROOT/usr/share/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH
PkgconfigReq()
{
local f="$1" out=; shift
out=$(pkg-config --print-errors --print-requires "$f") ||
Fatal "failed to process $f"
[ -n "$out" ] || return 0
echo "$out" |while read -r line; do
set -- $line
case $# in
1) echo "pkgconfig($1)" ;;
3) echo "pkgconfig($1) $2 $3" ;;
*) Fatal "$f: invalid pkg-config output: $line"
esac
done
}
PkgconfigProv()
{
local f="$1" out=; shift
out=$(pkg-config --print-errors --print-provides "$f") ||
Fatal "failed to process $f"
[ -n "$out" ] || return 0
echo "$out" |while read -r line; do
set -- $line
case $# in
1) echo "pkgconfig($1)" ;;
3) echo "pkgconfig($1) $2 $3" ;;
*) Fatal "$f: invalid pkg-config output: $line"
esac
done
}
pkgconfiglib.req: new pkgconfig.req mode (makes dependencies on Libs) This will grab libraries from ^Libs: clause and map each library to rpm dependency, which is typically lib*-devel package. $ grep ^Libs: /usr/lib/pkgconfig/directfb.pc Libs: -ldirectfb -lpthread -ldl -lz $ It works like this: $ ln -s pkgconfig.req.in scripts/pkgconfiglib.req.in $ scripts/pkgconfiglib.req.in -v /usr/lib/pkgconfig/directfb.pc pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirectfb.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libz.so -> zlib-devel zlib-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libfusion.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirect.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libpthread.so -> glibc-devel (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdl.so -> glibc-devel (skip) $ Some minor problems: $ scripts/pkgconfiglib.req.in /usr/lib/pkgconfig/*.pc >/dev/null pkgconfiglib.req.in: /usr/lib/pkgconfig/avahi-qt3.pc: cannot find libavahi-qt3.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/libgdiplus.pc: cannot find libexif.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libcoregrind.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libvex.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libgcc.so library path (skip) $
2007-08-28 20:10:35 +04:00
PkgconfigLibReq()
{
local f="$1" l L; shift
l=$(pkg-config --print-errors --libs-only-l "$f") || Fatal "failed to process $f"
L=$(pkg-config --print-errors --libs-only-L "$f") || Fatal "failed to process $f"
l=$(echo '' $l |sed -e 's/ -l/ /g')
L=$(echo '' $L |sed -e 's/ -L/ /g')
local lib libdir
for lib in $l; do
lib=lib$lib.so
if [ -n "${RPM_BUILD_ROOT-}" ]; then
for libdir in $L "$RPM_LIBDIR"; do
[ -f "$RPM_BUILD_ROOT$libdir/$lib" ] || continue
# The library is under RPM_BUILD_ROOT.
# Nothing is required. Do next lib.
Verbose "$f: $lib -> \$RPM_BUILD_ROOT$libdir/$lib (skip)"
continue 2
done
fi
for libdir in $L "$RPM_LIBDIR"; do
[ -f "$libdir/$lib" ] || continue
# The library is found in the host system.
# Generate rpm dependency and do next lib.
libdir=$(CanonPath "$libdir")
pkgconfiglib.req: new pkgconfig.req mode (makes dependencies on Libs) This will grab libraries from ^Libs: clause and map each library to rpm dependency, which is typically lib*-devel package. $ grep ^Libs: /usr/lib/pkgconfig/directfb.pc Libs: -ldirectfb -lpthread -ldl -lz $ It works like this: $ ln -s pkgconfig.req.in scripts/pkgconfiglib.req.in $ scripts/pkgconfiglib.req.in -v /usr/lib/pkgconfig/directfb.pc pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirectfb.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libz.so -> zlib-devel zlib-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libfusion.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirect.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libpthread.so -> glibc-devel (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdl.so -> glibc-devel (skip) $ Some minor problems: $ scripts/pkgconfiglib.req.in /usr/lib/pkgconfig/*.pc >/dev/null pkgconfiglib.req.in: /usr/lib/pkgconfig/avahi-qt3.pc: cannot find libavahi-qt3.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/libgdiplus.pc: cannot find libexif.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libcoregrind.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libvex.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libgcc.so library path (skip) $
2007-08-28 20:10:35 +04:00
local pkg n
pkg=$(rpmquery --whatprovides --queryformat='%{NAME}\n' "$libdir/$lib" |sort -u)
n=$(set -- $pkg; echo $#)
if [ "$pkg" = glibc-devel ]; then
Verbose "$f: $lib -> $pkg (skip)"
elif [ $n -eq 1 ]; then
Verbose "$f: $lib -> $pkg"
printf '%s\n' "$pkg"
elif [ $n -gt 1 ]; then
Info "$f: $libdir/$lib provided by:$(echo '' $pkg)"
Info "$f: $lib -> $libdir/$lib (raw, ambiguous)"
printf '%s\n' "$libdir/$lib"
else
2007-08-29 02:19:10 +04:00
Info "$f: cannot map $libdir/$lib to rpm dependency (skip)"
pkgconfiglib.req: new pkgconfig.req mode (makes dependencies on Libs) This will grab libraries from ^Libs: clause and map each library to rpm dependency, which is typically lib*-devel package. $ grep ^Libs: /usr/lib/pkgconfig/directfb.pc Libs: -ldirectfb -lpthread -ldl -lz $ It works like this: $ ln -s pkgconfig.req.in scripts/pkgconfiglib.req.in $ scripts/pkgconfiglib.req.in -v /usr/lib/pkgconfig/directfb.pc pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirectfb.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libz.so -> zlib-devel zlib-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libfusion.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirect.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libpthread.so -> glibc-devel (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdl.so -> glibc-devel (skip) $ Some minor problems: $ scripts/pkgconfiglib.req.in /usr/lib/pkgconfig/*.pc >/dev/null pkgconfiglib.req.in: /usr/lib/pkgconfig/avahi-qt3.pc: cannot find libavahi-qt3.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/libgdiplus.pc: cannot find libexif.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libcoregrind.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libvex.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libgcc.so library path (skip) $
2007-08-28 20:10:35 +04:00
fi
continue 2
done
Info "$f: cannot find $lib library path (skip)"
done
}
case "${0##*/}" in
pkgconfig.req*) ArgvFileAction PkgconfigReq "$@" ;;
pkgconfig.prov*) ArgvFileAction PkgconfigProv "$@" ;;
pkgconfiglib.req: new pkgconfig.req mode (makes dependencies on Libs) This will grab libraries from ^Libs: clause and map each library to rpm dependency, which is typically lib*-devel package. $ grep ^Libs: /usr/lib/pkgconfig/directfb.pc Libs: -ldirectfb -lpthread -ldl -lz $ It works like this: $ ln -s pkgconfig.req.in scripts/pkgconfiglib.req.in $ scripts/pkgconfiglib.req.in -v /usr/lib/pkgconfig/directfb.pc pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirectfb.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libz.so -> zlib-devel zlib-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libfusion.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdirect.so -> libdirectfb-devel libdirectfb-devel pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libpthread.so -> glibc-devel (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/directfb.pc: libdl.so -> glibc-devel (skip) $ Some minor problems: $ scripts/pkgconfiglib.req.in /usr/lib/pkgconfig/*.pc >/dev/null pkgconfiglib.req.in: /usr/lib/pkgconfig/avahi-qt3.pc: cannot find libavahi-qt3.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/libgdiplus.pc: cannot find libexif.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libcoregrind.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libvex.so library path (skip) pkgconfiglib.req.in: /usr/lib/pkgconfig/valgrind.pc: cannot find libgcc.so library path (skip) $
2007-08-28 20:10:35 +04:00
pkgconfiglib.req*) ArgvFileAction PkgconfigLibReq "$@" ;;
*) Fatal "req/prov method not recognized" ;;
esac