mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 10:53:11 +00:00
7249b8a2f3
A function to generate pkg-config files for Nix packages that need to create them ad hoc, like blas and lapack. Inspiration taken from `makeDesktopItem`.
47 lines
1.4 KiB
Bash
47 lines
1.4 KiB
Bash
# shellcheck shell=bash
|
|
|
|
# Setup hook that installs specified pkgconfig items.
|
|
#
|
|
# Example usage in a derivation:
|
|
#
|
|
# { …, makePkgconfigItem, copyPkgconfigItems, … }:
|
|
#
|
|
# let pkgconfigItem = makePkgconfigItem { … }; in
|
|
# stdenv.mkDerivation {
|
|
# …
|
|
# nativeBuildInputs = [ copyPkgconfigItems ];
|
|
#
|
|
# pkgconfigItems = [ pkgconfigItem ];
|
|
# …
|
|
# }
|
|
#
|
|
# This hook will copy files which are either given by full path
|
|
# or all '*.pc' files placed inside the 'lib/pkgconfig'
|
|
# folder of each `pkgconfigItems` argument.
|
|
|
|
postInstallHooks+=(copyPkgconfigItems)
|
|
|
|
copyPkgconfigItems() {
|
|
if [ "${dontCopyPkgconfigItems-}" = 1 ]; then return; fi
|
|
|
|
if [ -z "$pkgconfigItems" ]; then
|
|
return
|
|
fi
|
|
|
|
pkgconfigdir="${!outputDev}/lib/pkgconfig"
|
|
for pkgconfigItem in $pkgconfigItems; do
|
|
if [[ -f "$pkgconfigItem" ]]; then
|
|
substituteAllInPlace "$pkgconfigItem"
|
|
echo "Copying '$pkgconfigItem' into '${pkgconfigdir}'"
|
|
install -D -m 444 -t "${pkgconfigdir}" "$pkgconfigItem"
|
|
substituteAllInPlace "${pkgconfigdir}"/*
|
|
else
|
|
for f in "$pkgconfigItem"/lib/pkgconfig/*.pc; do
|
|
echo "Copying '$f' into '${pkgconfigdir}'"
|
|
install -D -m 444 -t "${pkgconfigdir}" "$f"
|
|
substituteAllInPlace "${pkgconfigdir}"/*
|
|
done
|
|
fi
|
|
done
|
|
}
|