PERL ?= perl
QCCFLAGS_WATERMARK ?= -DWATERMARK='"$(shell git describe)"'
QCC ?= gmqcc
+QCCDEFS_EXTRA ?= -DGMQCC
NDEBUG ?= 1
+BUILD_MOD ?= 0
QCCVERSIONFILE := qccversion.$(shell (cd server && $(QCC) --version) > qccversion.txt && git hash-object qccversion.txt)
QCCFLAGS_WTFS ?= \
-Wno-field-redeclared
-QCCFLAGS_FEATURES ?= \
- -DBUILD_MOD=$(BUILD_MOD)
+QCCDEFS ?= \
+ $(QCCFLAGS_WATERMARK) \
+ -DNDEBUG=$(NDEBUG) \
+ -DBUILD_MOD=$(BUILD_MOD) \
+ $(QCCDEFS_EXTRA)
# -Ooverlap-locals is required
QCCFLAGS ?= \
-std=gmqcc \
-Ooverlap-locals \
-O3 \
- -Werror -Wall -Wcpp \
+ -Werror -Wall \
$(QCCFLAGS_WTFS) \
- -fftepp -flno -futf8 -fno-bail-on-werror -fftepp-predefs \
+ -flno -futf8 -fno-bail-on-werror \
-frelaxed-switch -freturn-assignments \
- $(QCCFLAGS_WATERMARK) \
- -DNDEBUG=$(NDEBUG) \
- $(QCCFLAGS_FEATURES) \
$(QCCFLAGS_EXTRA)
# xonotic build system overrides this by command line argument to turn off the update-cvarcount step
.PHONY: clean
clean:
rm -f ../progs.dat ../menu.dat ../csprogs.dat
- rm -f progs.d menu.d csprogs.d
+ rm -f tmp/*.qc tmp/*.d tmp/*.txt
$(QCCVERSIONFILE):
$(RM) qccversion.*
echo This file intentionally left blank. > $@
../csprogs.dat: client/progs.inc $(QCCVERSIONFILE)
- @$(CC) -MM -MP -MF csprogs.d -MT $@ -x c -DCSQC -o $@ $<
+ @$(CC) -xc $(QCCDEFS) -DCSQC -E -dM 1>tmp/client_macros.txt -H 2>tmp/client_includes.txt $<
+ $(CC) -xc $(QCCDEFS) -DCSQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/client.qc $<
+ @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/client.qc
@echo make[1]: Entering directory \`$(PWD)/client\'
- cd client && $(QCC) $(QCCFLAGS) -DCSQC -o ../$@ ../$<
--include csprogs.d
+ cd client && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/client.qc
+-include tmp/client.d
../progs.dat: server/progs.inc $(QCCVERSIONFILE)
- @$(CC) -MM -MP -MF progs.d -MT $@ -x c -DSVQC -o $@ $<
+ @$(CC) -xc $(QCCDEFS) -DSVQC -E -dM 1>tmp/server_macros.txt -H 2>tmp/server_includes.txt $<
+ $(CC) -xc $(QCCDEFS) -DSVQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/server.qc $<
+ @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/server.qc
@echo make[1]: Entering directory \`$(PWD)/server\'
- cd server && $(QCC) $(QCCFLAGS) -DSVQC -o ../$@ ../$<
--include progs.d
+ cd server && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/server.qc
+-include tmp/server.d
../menu.dat: menu/progs.inc $(QCCVERSIONFILE)
- @$(CC) -MM -MP -MF menu.d -MT $@ -x c -DMENUQC -o $@ $<
+ @$(CC) -xc $(QCCDEFS) -DMENUQC -E -dM 1>tmp/menu_macros.txt -H 2>tmp/menu_includes.txt $<
+ $(CC) -xc $(QCCDEFS) -DMENUQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/menu.qc $<
+ @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/menu.qc
@echo make[1]: Entering directory \`$(PWD)/menu\'
- cd menu && $(QCC) $(QCCFLAGS) -DMENUQC -o ../$@ ../$<
--include menu.d
+ cd menu && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/menu.qc
+-include tmp/menu.d
.PHONY: testcase
testcase:
- cd testcase && $(QCC) $(QCCFLAGS) -DTESTCASE="$$TESTCASE"
+ cd testcase && $(QCC) $(QCCDEFS) $(QCCFLAGS) -DTESTCASE="$$TESTCASE"
#ifndef MISC_H
#define MISC_H
-#ifdef GMQCC
- #define EVAL(...) __VA_ARGS__
-
- #define OVERLOAD_(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
- #define OVERLOAD(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
-#else
+#ifdef __STDC__
#define EMPTY()
#define DEFER(id) id EMPTY()
#define OVERLOAD__(F, ...) OVERLOAD___(F,##__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define OVERLOAD_(...) DEFER(OVERLOAD__(__VA_ARGS__))
#define OVERLOAD(F, ...) OVERLOAD_(F,##__VA_ARGS__)(__VA_ARGS__)
+#else
+ #define EVAL(...) __VA_ARGS__
+
+ #define OVERLOAD_(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
+ #define OVERLOAD(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
#endif
#if defined(CSQC)
// The parameter is used across [[accumulate]] functions
// Macros to hide this implementation detail:
-#ifdef GMQCC
- #define NEW(cname, ...) \
- OVERLOAD(spawn##cname, new_pure(cname),##__VA_ARGS__)
-
- #define CONSTRUCT(cname, ...) \
- OVERLOAD(spawn##cname, this,##__VA_ARGS__)
-#else
+#ifdef __STDC__
#define NEW_(cname, ...) \
OVERLOAD_(spawn##cname, __VA_ARGS__)
#define NEW(cname, ...) \
OVERLOAD_(spawn##cname, __VA_ARGS__)
#define CONSTRUCT(cname, ...) \
CONSTRUCT_(cname, this,##__VA_ARGS__)(this,##__VA_ARGS__)
+#else
+ #define NEW(cname, ...) \
+ OVERLOAD(spawn##cname, new_pure(cname),##__VA_ARGS__)
+
+ #define CONSTRUCT(cname, ...) \
+ OVERLOAD(spawn##cname, this,##__VA_ARGS__)
#endif
#define CONSTRUCTOR(cname, ...) \
--- /dev/null
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore