X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=Makefile;h=3566bdc99d15c1d12c1f12ec5eaf82b801c49706;hp=c800ecaf6200af9d98b8002999e290736522e713;hb=9821b6a0753ffa490874203e59d1fb8ac6d11740;hpb=f0750209b73c2e2caa0ebb0201f1bbe666093ac7 diff --git a/Makefile b/Makefile index c800eca..3566bdc 100644 --- a/Makefile +++ b/Makefile @@ -1,61 +1,98 @@ -CC ?= clang -CFLAGS += -Wall -I. -fomit-frame-pointer -fno-stack-protector -O3 -#turn on tons of warnings if clang is present -ifeq ($(CC), clang) - CFLAGS += \ - -Weverything \ - -Wno-missing-prototypes \ - -Wno-unused-parameter \ - -Wno-sign-compare \ - -Wno-implicit-fallthrough \ - -Wno-sign-conversion \ - -Wno-conversion \ - -Wno-disabled-macro-expansion \ - -Wno-padded \ - -Wno-format-nonliteral +UNAME ?= $(shell uname) +CYGWIN = $(findstring CYGWIN, $(UNAME)) +MINGW = $(findstring MINGW, $(UNAME)) +ifneq ("$(CYGWIN)", "") +WINDOWS=1 endif -ifeq ($(track), no) - CFLAGS += -DNOTRACK +ifneq ("$(MINGW)", "") +WINDOWS=1 endif -OBJ = \ - util.o \ - code.o \ - ast.o \ - ir.o \ - error.o \ - con.o -OBJ_A = test/ast-test.o -OBJ_I = test/ir-test.o -OBJ_C = main.o lexer.o parser.o -OBJ_X = exec-standalone.o util.o - -#default is compiler only -default: gmqcc -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) - -exec-standalone.o: exec.c - $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1 - -# test targets -test_ast: $(OBJ_A) $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) -test_ir: $(OBJ_I) $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) -qcvm: $(OBJ_X) - $(CC) -o $@ $^ $(CFLAGS) -lm -test: test_ast test_ir - -# compiler target -gmqcc: $(OBJ_C) $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) - -#all target is test and all -all: test gmqcc +CXX ?= clang++ +CXXFLAGS = \ + -std=c++11 \ + -Wall \ + -Wextra \ + -fno-exceptions \ + -fno-rtti \ + -MD \ + -g3 + +CSRCS = \ + ast.cpp \ + code.cpp \ + conout.cpp \ + fold.cpp \ + ftepp.cpp \ + intrin.cpp \ + ir.cpp \ + lexer.cpp \ + main.cpp \ + opts.cpp \ + parser.cpp \ + stat.cpp \ + utf8.cpp \ + util.cpp + +TSRCS = \ + conout.cpp \ + opts.cpp \ + stat.cpp \ + test.cpp \ + util.cpp + +VSRCS = \ + exec.cpp \ + stat.cpp \ + util.cpp + +COBJS = $(CSRCS:.cpp=.o) +TOBJS = $(TSRCS:.cpp=.o) +VOBJS = $(VSRCS:.cpp=.o) + +CDEPS = $(CSRCS:.cpp=.d) +TDEPS = $(TSRCS:.cpp=.d) +VDEPS = $(VSRCS:.cpp=.d) + +ifndef WINDOWS +CBIN = gmqcc +VBIN = qcvm +TBIN = testsuite +else +CBIN = gmqcc.exe +VBIN = qcvm.exe +endif + +ifndef WINDOWS +all: $(CBIN) $(QCVM) $(TBIN) +else +all: $(CBIN) $(QCVM) +endif + +$(CBIN): $(COBJS) + $(CXX) $(COBJS) -o $@ + +$(VBIN): $(VOBJS) + $(CXX) $(VOBJS) -o $@ + +ifndef WINDOWS +$(TBIN): $(TOBJS) + $(CXX) $(TOBJS) -o $@ + +test: $(CBIN) $(VBIN) $(TBIN) + @./$(TBIN) +endif + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $< -o $@ clean: - rm -f *.o gmqcc qcvm test_ast test_ir test/*.o - + rm -f *.d + rm -f $(COBJS) $(CDEPS) $(CBIN) + rm -f $(VOBJS) $(VDEPS) $(VBIN) +ifndef WINDOWS + rm -f $(TOBJS) $(TDEPS) $(TOBJS) +endif +-include *.d