void-packages/common/wrappers/cross-cc
Érico Rolim 520be3a5de common/wrappers: add -L/usr/lib{32,64} to arguments ignored by cross-cc.
Detected when cross building timg after rebuilding GraphicsMagick with
new libdir directories. Could be fixed in all offending packages, but
it's easier to fix it in one place, and arguably more correct.
2021-02-09 23:01:46 -03:00

41 lines
1,002 B
Bash

#!/bin/bash
# compiler wrapper to get rid of -I/usr/include and -L/usr/lib, that fucks up
# cross compilation badly.
declare -a MYARGS
ARGS=("$@")
i=0
while [ $i -lt ${#ARGS[@]} ]; do
arg="${ARGS[$i]}"
if [ "$incpath" ]; then
if [ "$arg" = "/usr/include" ]; then
echo "[cc-wrapper] ignoring -I $arg"
else
MYARGS+=("-I${arg}")
fi
unset incpath
elif [ "$libpath" ]; then
# XXX: avoid so much repetition
if [ "$arg" = "/usr/lib" -o "$arg" = "/usr/lib32" -o "$arg" = "/usr/lib64" -o "$arg" = "/lib" ]; then
echo "[cc-wrapper] ignoring -L $arg"
else
MYARGS+=("-L${arg}")
fi
unset libpath
elif [ "$arg" = "-I" ]; then
incpath=1
elif [ "$arg" = "-L" ]; then
libpath=1
elif [ "$arg" = "-I/usr/include" -o "$arg" = "-L/usr/lib" \
-o "$arg" = "-L/usr/lib32" -o "$arg" = "-L/usr/lib64" \
-o "$arg" = "-L/lib" ]; then
echo "[cc-wrapper] ignoring $arg"
else
MYARGS+=("${arg}")
fi
i=$((i+1))
done
#echo "[cc-wrapper] @BIN@ ${MYARGS[@]}"
exec @BIN@ "${MYARGS[@]}"