X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=Makefile;h=3566bdc99d15c1d12c1f12ec5eaf82b801c49706;hp=268e2b4103e7f0b1479133ecf5b099295bd04cf5;hb=eb2d47877069169ff9dcfb1af35de0e4e66eb00e;hpb=044f8b396dceee3cd111623de7bcd1b36551a492 diff --git a/Makefile b/Makefile index 268e2b4..3566bdc 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,98 @@ -CC ?= clang -CFLAGS = -MD -Wall -Wextra -pedantic-errors -LDFLAGS = -lm +UNAME ?= $(shell uname) +CYGWIN = $(findstring CYGWIN, $(UNAME)) +MINGW = $(findstring MINGW, $(UNAME)) -CSRCS = ansi.c ast.c code.c conout.c fold.c fs.c ftepp.c hash.c intrin.c ir.c lexer.c main.c opts.c parser.c stat.c utf8.c util.c -TSRCS = ansi.c conout.c fs.c hash.c opts.c stat.c test.c util.c +ifneq ("$(CYGWIN)", "") +WINDOWS=1 +endif +ifneq ("$(MINGW)", "") +WINDOWS=1 +endif -COBJS = $(CSRCS:.c=.o) -TOBJS = $(TSRCS:.c=.o) +CXX ?= clang++ +CXXFLAGS = \ + -std=c++11 \ + -Wall \ + -Wextra \ + -fno-exceptions \ + -fno-rtti \ + -MD \ + -g3 -CDEPS = $(CSRCS:.c=.d) -TDEPS = $(TSRCS:.c=.d) +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 -all: $(CBIN) $(TBIN) +ifndef WINDOWS +all: $(CBIN) $(QCVM) $(TBIN) +else +all: $(CBIN) $(QCVM) +endif $(CBIN): $(COBJS) - $(CC) $(COBJS) $(LDFLAGS) -o $@ + $(CXX) $(COBJS) -o $@ -$(TBIN): $(TOBJS) - $(CC) $(TOBJS) $(LDFLAGS) -o $@ +$(VBIN): $(VOBJS) + $(CXX) $(VOBJS) -o $@ -.c.o: - $(CC) -c $(CFLAGS) $< -o $@ +ifndef WINDOWS +$(TBIN): $(TOBJS) + $(CXX) $(TOBJS) -o $@ -test: $(CBIN) $(TBIN) +test: $(CBIN) $(VBIN) $(TBIN) @./$(TBIN) +endif + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $< -o $@ clean: rm -f *.d rm -f $(COBJS) $(CDEPS) $(CBIN) - rm -f $(TOBJS) $(TDEPS) $(TBIN) + rm -f $(VOBJS) $(VDEPS) $(VBIN) +ifndef WINDOWS + rm -f $(TOBJS) $(TDEPS) $(TOBJS) +endif + +-include *.d