From: Rudolf Polzer Date: Mon, 10 Apr 2017 15:20:06 +0000 (-0400) Subject: Fix some more shell madness. ./all compile now works from a directory with spaces. X-Git-Tag: xonotic-v0.8.5~2839 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=35e6231f19b5bab89de9584e5fd3509725f11f9e;p=xonotic%2Fxonotic-data.pk3dir.git Fix some more shell madness. ./all compile now works from a directory with spaces. --- diff --git a/qcsrc/Makefile b/qcsrc/Makefile index 903d8537e..c660a7e94 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -1,7 +1,7 @@ CPP := cc -xc -E QCC ?= gmqcc -PROGS_OUT ?= $(CURDIR)/.. +PROGS_OUT ?= .. WORKDIR ?= ../.tmp QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty='~') @@ -102,15 +102,15 @@ export QCCFLAGS $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) @ echo make[1]: Entering directory \`$(CURDIR)/client\' - @ ./tools/qcc.sh client $@ $< + ./tools/qcc.sh client $@ $< -include $(WORKDIR)/client.d $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) @ echo make[1]: Entering directory \`$(CURDIR)/server\' - @ ./tools/qcc.sh server $@ $< + ./tools/qcc.sh server $@ $< -include $(WORKDIR)/server.d $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) @ echo make[1]: Entering directory \`$(CURDIR)/menu\' - @ ./tools/qcc.sh menu $@ $< + ./tools/qcc.sh menu $@ $< -include $(WORKDIR)/menu.d diff --git a/qcsrc/tools/qcc.sh b/qcsrc/tools/qcc.sh index 9951ec2fd..38c5c8634 100755 --- a/qcsrc/tools/qcc.sh +++ b/qcsrc/tools/qcc.sh @@ -20,31 +20,39 @@ function qpp() { server) DEFS="-DGAMEQC -DSVQC" ;; esac - >&2 echo + ${CPP} ${@:3} ${DEFS} ${IN} + >&2 echo + ${CPP} "${@:3}" ${DEFS} "${IN}" set +e # additional information - ${CPP} ${@:3} ${DEFS} \ - -dM 1>${WORKDIR}/${MODE}_macros.txt \ - -H 2>${WORKDIR}/${MODE}_includes.txt \ - ${IN} + ${CPP} "${@:3}" ${DEFS} \ + -dM 1>"${WORKDIR}/${MODE}_macros.txt" \ + -H 2>"${WORKDIR}/${MODE}_includes.txt" \ + "${IN}" # main step - ${CPP} ${@:3} ${DEFS} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror ${IN} -o ${WORKDIR}/${MODE}.txt + ${CPP} "${@:3}" ${DEFS} -MMD -MP -MT "${OUT}" -Wall -Wundef -Werror "${IN}" -o "${WORKDIR}/${MODE}.txt" err=$? set -e if [ ${err} -ne 0 ]; then return ${err}; fi - sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ${WORKDIR}/${MODE}.txt + sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' "${WORKDIR}/${MODE}.txt" } function qcc() { >&2 echo + $(basename ${QCC}) $@ # FIXME: relative compiler path is too deep - (cd tools && ${QCC} $@) + (cd tools && ${QCC} "$@") } $(return >/dev/null 2>&1) || { MODE=$1 OUT=$2 IN=$3 - qpp ${IN} ${OUT} -I. ${QCCIDENT} ${QCCDEFS} > ${WORKDIR}/${MODE}.qc - qcc ${QCCFLAGS} -o ${OUT} ../${WORKDIR}/${MODE}.qc + case "${OUT}" in + /*) + ;; + *) + OUT=${PWD}/${OUT} + ;; + esac + set -x + qpp "${IN}" "${OUT}" -I. ${QCCIDENT} ${QCCDEFS} > "${WORKDIR}/${MODE}.qc" + qcc ${QCCFLAGS} -o "${OUT}" "../${WORKDIR}/${MODE}.qc" }