X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=Makefile;h=c6a6327ed02269a35d0146662a6edac6007ccbbc;hb=1826971301dae48a9920ea4e331205371c48cc6b;hp=6014e311f0771971d4c6af3c44710d23ad23c1cc;hpb=911c2bddb661b0b8c788ed6c564f08680c6f8125;p=xonotic%2Fgmqcc.git diff --git a/Makefile b/Makefile index 6014e31..c6a6327 100644 --- a/Makefile +++ b/Makefile @@ -1,59 +1,74 @@ -CC ?= clang -CFLAGS += -Wall -I. -pedantic-errors -std=c90 - -#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-undef \ - -Wno-conditional-uninitialized \ - -Wno-missing-noreturn \ - -Wno-ignored-qualifiers \ - -Wno-unused-macros \ - -Wno-format-nonliteral - -endif -OBJ = lex.o \ - error.o \ - parse.o \ - typedef.o \ - util.o \ - code.o \ - asm.o \ - ast.o \ - ir.o -OBJ_A = test/ast-test.o -OBJ_I = test/ir-test.o -OBJ_C = main.o - -#default is compiler only -default: gmqcc -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) - -# test targets -test_ast: $(OBJ_A) $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) -test_ir: $(OBJ_I) $(OBJ) - $(CC) -o $@ $^ $(CFLAGS) -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 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