diff --git a/makefile b/makefile
index 7fa632b..e3a36a4 100644
--- a/makefile
+++ b/makefile
@@ -1,69 +1,70 @@
-#Copyright 2018 Rexy712 of Rexy & Co
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
-#
+
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
-#
+
#You should have received a copy of the GNU General Public License
-#along with this program. If not, see .
+#along with this program. If not, see .
+
+#Copyright 2018 rexy712
-#Makefile for project
-#Project directory and file setup
SOURCE_DIRS:=src
OBJDIR:=obj
-DEPDIR:=obj/dep
+DEPDIR:=$(OBJDIR)/dep
INCLUDE_DIRS:=include
-EXT:=c
-MAIN_EXECUTABLE:=rex-edid
+EXT:=cpp
+MAIN_EXECUTABLE:=tester
-#Compiler/Linker setup
-CC:=gcc
-CFLAGS:=-x c -g -std=c11 -Wall -pedantic -Wextra
-release: CFLAGS+=-O2
+CXX:=g++
+CXXFLAGS:=-g -std=c++17 -Wall -pedantic -Wextra
+all: CXXFLAGS+=-O0
+release: CXXFLAGS+=-O2
LDFLAGS=
-LDLIBS:=-lxcb -lxcb-randr
+LDLIBS:=
STRIP:=strip
-#Windows workarounds
+memchk:LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls
+memchk:CXXFLAGS+=-O0 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls
+
ifeq ($(OS),Windows_NT)
- mkdir=mkdir $(subst /,\,$(1)) > NUL 2>&1
- rm=del /F $(1) > NUL 2>&1
- rmdir=rd /s /q $(1) > NUL 2>&1
- move=move /y $(subst /,\,$(1)) $(subst /,\,$(2)) > NUL 2>&1
- MAIN_EXECUTABLE:=$(MAIN_EXECUTABLE).exe
- LDLIBS:=
+ mkdir=mkdir $(subst /,\,$(1)) > NUL 2>&1
+ rm=del /F $(1) > NUL 2>&1
+ rmdir=rd /s /q $(1) > NUL 2>&1
+ move=move /y $(subst /,\,$(1)) $(subst /,\,$(2)) > NUL 2>&1
+ MAIN_EXECUTABLE:=$(MAIN_EXECUTABLE).exe
+ LDLIBS:=-lglfw3 -lSOIL -lgl3w -lm -lopengl32 -lglu32 -lgdi32 -lkernel32
else
- mkdir=mkdir -p $(1)
- rm=rm -f $(1)
- rmdir=rm -rf $(1)
- move=mv $(1) $(2)
+ mkdir=mkdir -p $(1)
+ rm=rm -f $(1)
+ rmdir=rm -rf $(1)
+ move=mv $(1) $(2)
endif
-#Internal management of sources/objects and additional cflags
-INTERNAL_CFLAGS=-c $(foreach dir,$(INCLUDE_DIRS),-I"$(dir)") -MMD -MP -MF"$(DEPDIR)/$(notdir $(subst .o,.d,$@))"
+INTERNAL_CXXFLAGS=-c $(foreach dir,$(INCLUDE_DIRS),-I"$(dir)") -MMD -MP -MF"$(DEPDIR)/$(notdir $(patsubst %.o,%.d,$@))"
SOURCES:=$(foreach source,$(SOURCE_DIRS),$(foreach ext,$(EXT),$(wildcard $(source)/*.$(ext))))
OBJECTS:=$(addprefix $(OBJDIR)/,$(subst \,.,$(subst /,.,$(addsuffix .o,$(SOURCES)))))
all: $(MAIN_EXECUTABLE)
+memchk: $(MAIN_EXECUTABLE)
$(MAIN_EXECUTABLE): $(OBJECTS)
- $(CC) $(LDFLAGS) $^ -o "$(basename $@)" $(LDLIBS)
+ $(CXX) $(LDFLAGS) $^ -o "$(basename $@)" $(LDLIBS)
.PHONY: release
release: $(OBJECTS)
- $(CC) $(LDFLAGS) $^ -o "$(basename $(MAIN_EXECUTABLE))" $(LDLIBS)
+ $(CXX) $(LDFLAGS) $^ -o "$(basename $(MAIN_EXECUTABLE))" $(LDLIBS)
$(STRIP) --strip-all "$(MAIN_EXECUTABLE)"
define GENERATE_OBJECTS
$$(OBJDIR)/$(subst \,.,$(subst /,.,$(1))).%.o: $(1)/%
- $$(CC) $$(CFLAGS) $$(INTERNAL_CFLAGS) "$$<" -o "$$@"
+ $$(CXX) $$(CXXFLAGS) $$(INTERNAL_CXXFLAGS) "$$<" -o "$$@"
endef