From 40070e2c93b534829fb18a0f8c886d3f8aa9712b Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 20 Oct 2017 19:32:03 -0700 Subject: [PATCH 1/7] qb: Find working compilers with zsh. --- qb/qb.comp.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qb/qb.comp.sh b/qb/qb.comp.sh index fe97bdbedd..30e8314781 100644 --- a/qb/qb.comp.sh +++ b/qb/qb.comp.sh @@ -14,7 +14,7 @@ cc_works=0 if [ "$CC" ]; then "$CC" -o "$TEMP_EXE" "$TEMP_C" >/dev/null 2>&1 && cc_works=1 else - for CC in ${CC:=$(which ${CROSS_COMPILE}gcc ${CROSS_COMPILE}cc ${CROSS_COMPILE}clang 2>/dev/null)} ''; do + for CC in $(printf %s "${CC:=$(which ${CROSS_COMPILE}gcc ${CROSS_COMPILE}cc ${CROSS_COMPILE}clang 2>/dev/null)}") ''; do "$CC" -o "$TEMP_EXE" "$TEMP_C" >/dev/null 2>&1 && cc_works=1 && break done fi @@ -45,7 +45,7 @@ cxx_works=0 if [ "$CXX" ]; then "$CXX" -o "$TEMP_EXE" "$TEMP_CXX" >/dev/null 2>&1 && cxx_works=1 else - for CXX in ${CXX:=$(which ${CROSS_COMPILE}g++ ${CROSS_COMPILE}c++ ${CROSS_COMPILE}clang++ 2>/dev/null)} ''; do + for CXX in $(printf %s "${CXX:=$(which ${CROSS_COMPILE}g++ ${CROSS_COMPILE}c++ ${CROSS_COMPILE}clang++ 2>/dev/null)}") ''; do "$CXX" -o "$TEMP_EXE" "$TEMP_CXX" >/dev/null 2>&1 && cxx_works=1 && break done fi From cca4a25757687599d22e4dbacba60b7bd4199ab2 Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 20 Oct 2017 19:34:53 -0700 Subject: [PATCH 2/7] qb: path is a special variable in zsh so avoid setting it. --- qb/qb.comp.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qb/qb.comp.sh b/qb/qb.comp.sh index 30e8314781..4636d990eb 100644 --- a/qb/qb.comp.sh +++ b/qb/qb.comp.sh @@ -78,9 +78,9 @@ fi [ -n "$PKG_CONF_PATH" ] || { PKG_CONF_PATH="none" - for path in $(which "${CROSS_COMPILE}pkg-config" 2>/dev/null) ''; do - [ -n "$path" ] && { - PKG_CONF_PATH=$path; + for p in $(which "${CROSS_COMPILE}pkg-config" 2>/dev/null) ''; do + [ -n "$p" ] && { + PKG_CONF_PATH=$p; break; } done From 514391b4d8ed1de938a271375b5e95696584368c Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 20 Oct 2017 20:44:28 -0700 Subject: [PATCH 3/7] qb: Remove the leading whitespace from $INCLUDE_DIRS and $LIBRARY_DIRS. --- qb/qb.libs.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index b0ce0bd1e8..8c52ac01c1 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -14,10 +14,14 @@ add_define_make() { echo "$1=$2" >> "$MAKEFILE_DEFINES";} add_include_dirs() -{ while [ "$1" ]; do INCLUDE_DIRS="$INCLUDE_DIRS -I$1"; shift; done;} +{ while [ "$1" ]; do INCLUDE_DIRS="$INCLUDE_DIRS -I$1"; shift; done + INCLUDE_DIRS="${INCLUDE_DIRS#* }" +} add_library_dirs() -{ while [ "$1" ]; do LIBRARY_DIRS="$LIBRARY_DIRS -L$1"; shift; done;} +{ while [ "$1" ]; do LIBRARY_DIRS="$LIBRARY_DIRS -L$1"; shift; done + LIBRARY_DIRS="${LIBRARY_DIRS#* }" +} check_lib() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = headers { tmpval="$(eval echo \$HAVE_$1)" From a943fabe1ed554b46762c2488e7ff2630a4e9773 Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 20 Oct 2017 21:28:11 -0700 Subject: [PATCH 4/7] qb: Fix $VARS for zsh. --- qb/config.libs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index af4d80f9b1..8089123e82 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -520,6 +520,6 @@ fi # Creates config.mk and config.h. add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" -VARS=$(eval set | grep ^HAVE_ | sed s/=.*// | sed s/^HAVE_//) -create_config_make config.mk $VARS -create_config_header config.h $VARS +VARS=$(eval set | grep ^HAVE_ | sed 's/=.*//' | sed 's/^HAVE_//') +create_config_make config.mk $(printf %s "$VARS") +create_config_header config.h $(printf %s "$VARS") From 0ff7e829f069bc9cacb6c41f2cd11f09fea2ed68 Mon Sep 17 00:00:00 2001 From: orbea Date: Sat, 21 Oct 2017 12:54:19 -0700 Subject: [PATCH 5/7] qb: Explicitly word split libs and extralibs --- qb/qb.libs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 8c52ac01c1..93c5d81ed0 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -40,7 +40,7 @@ check_lib() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = head fi answer='no' # echo -n "$ECHOBUF" - "$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS $LIBRARY_DIRS $4 $CFLAGS $LDFLAGS $2 >>config.log 2>&1 && answer='yes' + "$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS $LIBRARY_DIRS $(printf %s "$4") $CFLAGS $LDFLAGS $(printf %s "$2") >>config.log 2>&1 && answer='yes' eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1 @@ -65,7 +65,7 @@ check_lib_cxx() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = fi answer='no' # echo -n "$ECHOBUF" - "$CXX" -o "$TEMP_EXE" "$TEMP_CXX" $INCLUDE_DIRS $LIBRARY_DIRS $4 $CFLAGS $LDFLAGS $2 >>config.log 2>&1 && answer='yes' + "$CXX" -o "$TEMP_EXE" "$TEMP_CXX" $INCLUDE_DIRS $LIBRARY_DIRS $(printf %s "$4") $CFLAGS $LDFLAGS $(printf %s "$2") >>config.log 2>&1 && answer='yes' eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" rm "$TEMP_CXX" "$TEMP_EXE" >/dev/null 2>&1 [ "$answer" = 'no' ] && { From b733807099447786e8b4f6ae1687b2f419215b6c Mon Sep 17 00:00:00 2001 From: orbea Date: Sat, 21 Oct 2017 14:28:23 -0700 Subject: [PATCH 6/7] qb: Remove trailing white spaces from config.mk. --- qb/qb.libs.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 93c5d81ed0..a04ce25dc2 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -266,8 +266,10 @@ create_config_make() case "$PKG_CONF_USED" in *$1*) - echo "$1_CFLAGS = $(eval echo \$$1_CFLAGS)" - echo "$1_LIBS = $(eval echo \$$1_LIBS)" + FLAGS="$(eval echo \$$1_CFLAGS)" + LIBS="$(eval echo \$$1_LIBS)" + echo "$1_CFLAGS = ${FLAGS%"${FLAGS##*[! ]}"}" + echo "$1_LIBS = ${LIBS%"${LIBS##*[! ]}"}" ;; esac shift From 79ee19e2a506f497da465a842d0377c4092fa62e Mon Sep 17 00:00:00 2001 From: orbea Date: Sat, 21 Oct 2017 13:13:42 -0700 Subject: [PATCH 7/7] qb: Clean up long lines in check_lib and check_lib_cxx --- qb/qb.libs.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index a04ce25dc2..0697cb0379 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -40,7 +40,15 @@ check_lib() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = head fi answer='no' # echo -n "$ECHOBUF" - "$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS $LIBRARY_DIRS $(printf %s "$4") $CFLAGS $LDFLAGS $(printf %s "$2") >>config.log 2>&1 && answer='yes' + "$CC" -o \ + "$TEMP_EXE" \ + "$TEMP_C" \ + $INCLUDE_DIRS \ + $LIBRARY_DIRS \ + $(printf %s "$4") \ + $CFLAGS \ + $LDFLAGS \ + $(printf %s "$2") >>config.log 2>&1 && answer='yes' eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1 @@ -65,7 +73,15 @@ check_lib_cxx() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = fi answer='no' # echo -n "$ECHOBUF" - "$CXX" -o "$TEMP_EXE" "$TEMP_CXX" $INCLUDE_DIRS $LIBRARY_DIRS $(printf %s "$4") $CFLAGS $LDFLAGS $(printf %s "$2") >>config.log 2>&1 && answer='yes' + "$CXX" -o \ + "$TEMP_EXE" \ + "$TEMP_CXX" \ + $INCLUDE_DIRS \ + $LIBRARY_DIRS \ + $(printf %s "$4") \ + $CFLAGS \ + $LDFLAGS \ + $(printf %s "$2") >>config.log 2>&1 && answer='yes' eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" rm "$TEMP_CXX" "$TEMP_EXE" >/dev/null 2>&1 [ "$answer" = 'no' ] && {