CPP := cc -xc -E
QCC ?= gmqcc
-PROGS_OUT ?= $(CURDIR)/..
+PROGS_OUT ?= ..
WORKDIR ?= ../.tmp
QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty='~')
$(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
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"
}