common/wrapper/cc: make this work with args containing whitespaces in quoted strings.

like -DFOO="foo blah". This fixes cross compilation in libsodium, tk and
others.
This commit is contained in:
Juan RP 2015-10-25 10:09:36 +01:00
parent afbeba04d4
commit ff80ee06e6

View file

@ -1,14 +1,19 @@
#!/bin/sh #!/bin/bash
# compiler wrapper to get rid of -I/usr/include and -L/usr/lib, that fucks up # compiler wrapper to get rid of -I/usr/include and -L/usr/lib, that fucks up
# cross compilation badly. # cross compilation badly.
MYARGS= declare -a MYARGS
for i in $@; do ARGS=("$@")
if [ $i = "-L/usr/lib" -o $i = "-I/usr/include" ]; then i=0
continue while [ $i -lt ${#ARGS[@]} ]; do
arg="${ARGS[$i]}"
if [ "$arg" = "-I/usr/include" -o "$arg" = "-L/usr/lib" ]; then
echo "[cc-wrapper] ignoring $arg"
else else
MYARGS+="$i " MYARGS+=("${arg}")
fi fi
i=$((i+1))
done done
exec @BIN@ ${MYARGS} #echo "[cc-wrapper] ${MYARGS[@]}"
exec @BIN@ "${MYARGS[@]}"