From ff80ee06e682a697d4386f6d411bb7ab9394707f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 25 Oct 2015 10:09:36 +0100 Subject: [PATCH] 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. --- common/wrappers/cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/common/wrappers/cc b/common/wrappers/cc index d3d9a857ca3..559257602c6 100644 --- a/common/wrappers/cc +++ b/common/wrappers/cc @@ -1,14 +1,19 @@ -#!/bin/sh +#!/bin/bash # compiler wrapper to get rid of -I/usr/include and -L/usr/lib, that fucks up # cross compilation badly. -MYARGS= +declare -a MYARGS -for i in $@; do - if [ $i = "-L/usr/lib" -o $i = "-I/usr/include" ]; then - continue +ARGS=("$@") +i=0 +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 - MYARGS+="$i " + MYARGS+=("${arg}") fi + i=$((i+1)) done -exec @BIN@ ${MYARGS} +#echo "[cc-wrapper] ${MYARGS[@]}" +exec @BIN@ "${MYARGS[@]}"