-include include.mk
-
-UNAME ?= $(shell uname)
-CYGWIN = $(findstring CYGWIN, $(UNAME))
-MINGW = $(findstring MINGW32, $(UNAME))
-
-CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing
-#turn on tons of warnings if clang is present
-# but also turn off the STUPID ONES
-ifeq ($(CC), clang)
- CFLAGS += \
- -Weverything \
- -Wno-padded \
- -Wno-format-nonliteral \
- -Wno-disabled-macro-expansion \
- -Wno-conversion \
- -Wno-float-equal \
- -Wno-unknown-warning-option \
- -Wno-cast-align \
- -pedantic-errors
-else
- ifneq ($(CC), g++)
- CFLAGS += -Wmissing-prototypes -Wstrict-prototypes
- endif
-
- ifneq ($(CC), tcc)
- CFLAGS += -pedantic-errors
- else
- CFLAGS += -Wno-pointer-sign -fno-common
- endif
-endif
-
-ifneq ($(shell git describe --always 2>/dev/null),)
- CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\""
-endif
-
-ifeq ($(shell valgrind --version 2>/dev/null),)
- CFLAGS += -DNVALGRIND
-endif
-
-# do this last otherwise there is whitespace in the command output and
-# it makes my OCD act up
-CFLAGS += $(OPTIONAL)
-
-#we have duplicate object files when dealing with creating a simple list
-#for dependinces. To combat this we use some clever recrusive-make to
-#filter the list and remove duplicates which we use for make depend
-RMDUP = $(if $1,$(firstword $1) $(call RMDUP,$(filter-out $(firstword $1),$1)))
-DEPS := $(call RMDUP, $(OBJ_P) $(OBJ_T) $(OBJ_C) $(OBJ_X))
-
-ifneq ("$(CYGWIN)", "")
- #nullify the common variables that
- #most *nix systems have (for windows)
- PREFIX :=
- BINDIR :=
- DATADIR :=
- MANDIR :=
- QCVM = qcvm.exe
- GMQCC = gmqcc.exe
- TESTSUITE = testsuite.exe
- PAK = gmqpak.exe
- CFLAGS += -DNVALGRIND
-else
-ifneq ("$(MINGW)", "")
- #nullify the common variables that
- #most *nix systems have (for windows)
- PREFIX :=
- BINDIR :=
- DATADIR :=
- MANDIR :=
- QCVM = qcvm.exe
- GMQCC = gmqcc.exe
- TESTSUITE = testsuite.exe
- PAK = gmqpak.exe
- CFLAGS += -DNVALGRIND
-else
- QCVM = qcvm
- GMQCC = gmqcc
- TESTSUITE = testsuite
- PAK = gmqpak
-endif
-endif
-
-#standard rules
-c.o:
- $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
-
-exec-standalone.o: exec.c
- $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) -DQCVM_EXECUTOR=1
-
-$(QCVM): $(OBJ_X)
- $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
-
-$(GMQCC): $(OBJ_C) $(OBJ_D)
- $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
-
-$(TESTSUITE): $(OBJ_T)
- $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
-
-$(PAK): $(OBJ_P)
- $(CC) -o $@ $^ $(LDFLAGS)
-
-all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK)
-
-check: all
- @ ./$(TESTSUITE)
-test: all
- @ ./$(TESTSUITE)
+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)