vp-build/common/hooks/pre-configure/02-script-wrapper.sh

57 lines
1.6 KiB
Bash

# This hook creates wrappers for foo-config scripts in cross builds.
#
# Wrappers are created in ${wrksrc}/.xbps/bin and this path is appended
# to make configure scripts find them.
WRAPPERDIR="${wrksrc}/.xbps/bin"
generic_wrapper() {
local wrapper="$1"
[ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
[ -x ${WRAPPERDIR}/${wrapper} ] && return 0
echo "#!/bin/sh" >> ${WRAPPERDIR}/${wrapper}
echo "exec ${XBPS_CROSS_BASE}/usr/bin/${wrapper} --prefix=${XBPS_CROSS_BASE}/usr \"\$@\"" >> ${WRAPPERDIR}/${wrapper}
chmod 755 ${WRAPPERDIR}/${wrapper}
}
generic_wrapper2() {
local wrapper="$1" incdir="$2"
[ ! -x ${XBPS_CROSS_BASE}/usr/bin/${wrapper} ] && return 0
[ -x ${WRAPPERDIR}/${wrapper} ] && return 0
cat >>${WRAPPERDIR}/${wrapper}<<_EOF
#!/bin/sh
if [ "\$1" = "--prefix" ]; then
echo "${XBPS_CROSS_BASE}/usr"
elif [ "\$1" = "--cflags" ]; then
${XBPS_CROSS_BASE}/usr/bin/${wrapper} --libs | sed -e "s,-I/usr,-I${XBPS_CROSS_BASE}/usr,g;s,-L/usr,-L${XBPS_CROSS_BASE}/usr,g"
elif [ "\$1" = "--libs" ]; then
${XBPS_CROSS_BASE}/usr/bin/${wrapper} --libs | sed -e "s,-L/usr,-L${XBPS_CROSS_BASE}/usr,g"
else
exec ${XBPS_CROSS_BASE}/usr/bin/${wrapper} "\$@"
fi
exit \$?
_EOF
chmod 755 ${WRAPPERDIR}/${wrapper}
}
hook() {
[ -z "$CROSS_BUILD" ] && return 0
mkdir -p ${WRAPPERDIR}
# create wrapers
generic_wrapper icu-config
generic_wrapper libgcrypt-config
generic_wrapper freetype-config
generic_wrapper sdl-config
generic_wrapper sdl2-config
generic_wrapper gpgme-config
generic_wrapper2 libpng-config libpng16
generic_wrapper2 ncurses5-config ncurses
export PATH=${WRAPPERDIR}:$PATH
}