X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=Makefile;h=c6a6327ed02269a35d0146662a6edac6007ccbbc;hp=b2d65805d0a3ca7c0b67877b8fca386d90fc3f9d;hb=1826971301dae48a9920ea4e331205371c48cc6b;hpb=2e84cc0b418500a57d95315c0376c13a10d60142 diff --git a/Makefile b/Makefile index b2d6580..c6a6327 100644 --- a/Makefile +++ b/Makefile @@ -1,60 +1,74 @@ -CC ?= clang -CFLAGS += -Wall -I. -fomit-frame-pointer -fno-stack-protector -#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 - -endif -ifeq ($(track), no) - CFLAGS += -DNOTRACK -endif - -OBJ = \ - util.o \ - code.o \ - ast.o \ - ir.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 con.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) + +CBIN = gmqcc +TBIN = testsuite +VBIN = qcvm + +all: $(CBIN) $(TBIN) $(VBIN) + +$(CBIN): $(COBJS) + $(CXX) $(COBJS) -o $@ + +$(TBIN): $(TOBJS) + $(CXX) $(TOBJS) -o $@ + +$(VBIN): $(VOBJS) + $(CXX) $(VOBJS) -o $@ + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $< -o $@ + +test: $(CBIN) $(TBIN) $(VBIN) + @./$(TBIN) clean: - rm -f *.o gmqcc qcvm test_ast test_ir test/*.o - + rm -f *.d + rm -f $(COBJS) $(CDEPS) $(CBIN) + rm -f $(TOBJS) $(TDEPS) $(TBIN) + rm -f $(VOBJS) $(VDEPS) $(VBIN) +-include *.d