Created
October 22, 2017 10:56
-
-
Save planaria/b202a76d371ab9373fedb2b794c20fc9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXX ?= clang++ | |
CFLAGS = -std=c++14 -MMD -MP -Wall -Wextra | |
CFLAGS_DEBUG = -g -O0 | |
CFLAGS_RELEASE = -O3 | |
LDFLAGS = -lpthread -lboost_system | |
buildtype := release | |
ifeq ($(buildtype), debug) | |
CFLAGS += $(CFLAGS_DEBUG) | |
else ifeq ($(buildtype), release) | |
CFLAGS += $(CFLAGS_RELEASE) | |
else | |
$(error buildtype must be debug or release) | |
endif | |
LIBS = | |
INCLUDE = -I./include -I./ext/cereal/include -I./ext/Catch/include | |
TARGETDIR = ./bin/$(buildtype) | |
TARGET = $(TARGETDIR)/ox_test | |
SRCDIR = ./tests | |
SOURCES = $(shell find $(SRCDIR) -name *.cpp) | |
OBJDIR = ./obj/$(buildtype) | |
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:$(SRCDIR)/%.cpp=%.o)) | |
DEPENDS = $(OBJECTS:.o=.d) | |
.PHONY: all | |
all: $(TARGET) | |
$(TARGET): $(OBJECTS) $(LIBS) | |
-mkdir -p $(@D) | |
$(CXX) -o $@ $^ $(LDFLAGS) | |
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | |
-mkdir -p $(@D) | |
$(CXX) $(CFLAGS) $(INCLUDE) -o $@ -c $< | |
.PHONY: clean | |
clean: | |
-rm -f $(OBJECTS) $(DEPENDS) $(TARGET) | |
-include $(DEPENDS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment