X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=Makefile;h=c9070d02b9d64f1e77e1f28cd54696e7eac32068;hp=855dd4b54dbe0af02a07e1746de7fe6b8b966bae;hb=5d8c18dcab931a740b6696811b889077aae2d15a;hpb=1ad849d9391c55c85bb51b6a07237aa2185123af diff --git a/Makefile b/Makefile index 855dd4b..c9070d0 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +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 +CVIN = 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: $(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