]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - Makefile
Add CMakeLists.txt
[xonotic/gmqcc.git] / Makefile
index c261b4e687b41aaeac5b757df03d4b54b3912eff..3566bdc99d15c1d12c1f12ec5eaf82b801c49706 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,63 +1,98 @@
-CC     ?= clang
-CFLAGS += -Wall -I. -fomit-frame-pointer -fno-stack-protector -fno-common
-#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        \
-          con.o
-          
-OBJ_T = test.o util.o con.o
-OBJ_C = main.o lexer.o parser.o
-OBJ_X = exec-standalone.o util.o con.o
+CXX ?= clang++
+CXXFLAGS = \
+       -std=c++11 \
+       -Wall \
+       -Wextra \
+       -fno-exceptions \
+       -fno-rtti \
+       -MD \
+       -g3
 
-#default is compiler only
-default: gmqcc
-%.o: %.c
-       $(CC) -c $< -o $@ $(CFLAGS)
+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
 
-exec-standalone.o: exec.c
-       $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
+TSRCS = \
+       conout.cpp \
+       opts.cpp \
+       stat.cpp \
+       test.cpp \
+       util.cpp
 
-qcvm: $(OBJ_X)
-       $(CC) -o $@ $^ $(CFLAGS) -lm
+VSRCS = \
+       exec.cpp \
+       stat.cpp \
+       util.cpp
 
-gmqcc: $(OBJ_C) $(OBJ)
-       $(CC) -o $@ $^ $(CFLAGS)
+COBJS = $(CSRCS:.cpp=.o)
+TOBJS = $(TSRCS:.cpp=.o)
+VOBJS = $(VSRCS:.cpp=.o)
 
-test: $(OBJ_T)
-       $(CC) -o $@ $^ $(CFLAGS)
-       
-runtests:
-       ./test
+CDEPS = $(CSRCS:.cpp=.d)
+TDEPS = $(TSRCS:.cpp=.d)
+VDEPS = $(VSRCS:.cpp=.d)
 
-#all target is test and all
-all: gmqcc qcvm test
+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 *.dat
-       
-$(OBJ) $(OBJ_C) $(OBJ_X): gmqcc.h
-main.o: lexer.h
-parser.o: ast.h lexer.h
-ast.o: ast.h ir.h
-ir.o: ir.h
+       rm -f *.d
+       rm -f $(COBJS) $(CDEPS) $(CBIN)
+       rm -f $(VOBJS) $(VDEPS) $(VBIN)
+ifndef WINDOWS
+       rm -f $(TOBJS) $(TDEPS) $(TOBJS)
+endif
+
+-include *.d