2017-11-26 05:46:30 +00:00
|
|
|
# Source http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
|
|
|
|
|
|
|
|
SRCDIR := .
|
|
|
|
#LIBDIR := ../nas2d-core/build/lib
|
|
|
|
BUILDDIR := .
|
|
|
|
OBJDIR := $(BUILDDIR)/obj
|
|
|
|
DEPDIR := $(BUILDDIR)/deps
|
|
|
|
#EXE := $(BINDIR)/OPHD
|
|
|
|
EXE := ripple
|
|
|
|
|
2017-11-27 23:10:19 +00:00
|
|
|
CFLAGS := -std=c++11 -O2 -fopenmp -Wall -Wno-unknown-pragmas -I/usr/include/glm -I/usr/include/eigen3 $(shell pkg-config --cflags glew)
|
2017-11-26 05:46:30 +00:00
|
|
|
CFLAGS += $(shell pkg-config --cflags sdl2)
|
2017-11-27 05:11:42 +00:00
|
|
|
LDFLAGS := -fopenmp -lstdc++ -lm -lglfw -lGLEW -lGL
|
2017-11-26 05:46:30 +00:00
|
|
|
LDFLAGS += $(shell pkg-config --libs sdl2)
|
|
|
|
|
|
|
|
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
|
|
|
|
|
|
|
|
COMPILE.cpp = $(CXX) $(DEPFLAGS) $(CFLAGS) $(TARGET_ARCH) -c
|
|
|
|
POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
|
|
|
|
|
|
|
|
SRCS := $(shell find $(SRCDIR) -name '*.cpp')
|
|
|
|
OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
|
|
|
|
OBJS := $(filter-out $(OBJDIR)/glm/% $(OBJDIR)/glew/% $(OBJDIR)/glfw/% $(OBJDIR)/ObjParser/Global% $(OBJDIR)/ObjParser/Main%,$(OBJS)) # Filter ui_builder
|
|
|
|
FOLDERS := $(sort $(dir $(SRCS)))
|
|
|
|
|
|
|
|
all: $(EXE)
|
|
|
|
|
|
|
|
$(EXE): $(OBJS)
|
|
|
|
@mkdir -p ${@D}
|
|
|
|
$(CXX) $^ $(LDFLAGS) -o $@
|
|
|
|
|
|
|
|
$(OBJS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp $(DEPDIR)/%.d | build-folder
|
|
|
|
$(COMPILE.cpp) $(OUTPUT_OPTION) $<
|
|
|
|
$(POSTCOMPILE)
|
|
|
|
|
|
|
|
.PHONY:build-folder
|
|
|
|
build-folder:
|
|
|
|
@mkdir -p $(patsubst $(SRCDIR)/%,$(OBJDIR)/%, $(FOLDERS))
|
|
|
|
@mkdir -p $(patsubst $(SRCDIR)/%,$(DEPDIR)/%, $(FOLDERS))
|
|
|
|
|
|
|
|
$(DEPDIR)/%.d: ;
|
|
|
|
.PRECIOUS: $(DEPDIR)/%.d
|
|
|
|
|
|
|
|
include $(wildcard $(patsubst $(SRCDIR)/%.cpp,$(DEPDIR)/%.d,$(SRCS)))
|
|
|
|
|
|
|
|
.PHONY:clean, clean-deps, clean-all
|
|
|
|
clean:
|
|
|
|
-rm -fr $(OBJDIR)
|
|
|
|
-rm -fr $(DEPDIR)
|
|
|
|
-rm -f $(EXE)
|
|
|
|
clean-deps:
|
|
|
|
-rm -fr $(DEPDIR)
|
|
|
|
clean-all:
|
|
|
|
-rm -rf $(BUILDDIR)
|