unos-repository

APK repository for unos
git clone git://git.finwo.net/misc/unos-repository
Log | Files | Refs | README

pc-fixup.sh (1078B)


      1 #!/bin/sh
      2 # mk/pc-fixup.sh - rewrite .pc prefix/libdir/includedir to point at SYSROOT.
      3 #
      4 # Usage: ./mk/pc-fixup.sh [sysroot]
      5 #   sysroot defaults to build/sysroot when run from repo root.
      6 #
      7 # This is the sole implementation; mk/build.sh and mk/sysroot.sh both call it.
      8 # Rewriting only prefix= is insufficient: many upstream .pc files spell
      9 # libdir=/includedir= literally (efivar does; efibootmgr then picks host
     10 # headers). Fix every level, every .pc, every build. Idempotent.
     11 set -eu
     12 
     13 HERE=$(cd "$(dirname "$0")" && pwd)
     14 ROOT=$(cd "${HERE}/.." && pwd)
     15 
     16 SYSROOT="${1:-${SYSROOT:-${ROOT}/build/sysroot}}"
     17 
     18 [ -d "${SYSROOT}" ] || exit 0
     19 
     20 for _pc in "${SYSROOT}"/usr/lib/pkgconfig/*.pc "${SYSROOT}"/usr/lib64/pkgconfig/*.pc; do
     21   [ -e "${_pc}" ] || continue
     22   # Only fix if it looks like a sysroot pc (prefix=/usr or similar); leave
     23   # host pkgconfigs alone when SYSROOT happens to be /.
     24   sed -i \
     25     -e "s|^prefix=.*|prefix=${SYSROOT}/usr|" \
     26     -e "s|^libdir=.*|libdir=${SYSROOT}/usr/lib|" \
     27     -e "s|^includedir=.*|includedir=${SYSROOT}/usr/include|" \
     28     "${_pc}"
     29 done