Created
May 23, 2019 06:54
-
-
Save r8d8/bed93452ea339ba1fd7496ffd17fb182 to your computer and use it in GitHub Desktop.
This file contains 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
# Determine the platform | |
UNAME_S := $(shell uname -s) | |
CC := clang++ | |
# Folders | |
SRCDIR := ./ | |
BUILDDIR := build | |
TARGETDIR := bin | |
# Targets | |
EXECUTABLE := BulletManager | |
TARGET := $(TARGETDIR)/$(EXECUTABLE) | |
# Final Paths | |
INSTALLBINDIR := /usr/local/bin | |
# Code Lists | |
SRCEXT := cpp | |
SOURCES := $(shell find $(SRCDIR) -type f -name '*.$(SRCEXT)') | |
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) | |
# Folder Lists | |
# Note: Intentionally excludes the root of the include folder so the lists are clean | |
INCDIRS := $(shell find $(SRCDIR) -name '*.h' -exec dirname {} \; | sort | uniq) | |
INCLIST := $(patsubst $(SRCDIR)%,-I $(SRCDIR)%,$(INCDIRS)) | |
BUILDLIST := $(patsubst $(SRCDIR)%,$(BUILDDIR)/%,$(INCDIRS)) | |
# Shared Compiler Flags | |
CFLAGS := -Wall | |
INC := -I include $(INCLIST) -I /usr/local/include -I /usr/include/SDL2 | |
LIB := -L /usr/local/lib | |
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) | |
@mkdir -p $(BUILDLIST) | |
@echo "Compiling $<..."; $(CC) $(CFLAGS) $(INC) -c -o $@ $< | |
$(TARGET): $(OBJECTS) | |
@mkdir -p $(TARGETDIR) | |
@echo "Linking..." | |
@echo " Linking $(TARGET)"; $(CC) $^ -o $(TARGET) $(LIB) | |
clean: | |
@echo "Cleaning $(TARGET)..."; $(RM) -r $(BUILDDIR) $(TARGET) | |
install: | |
@echo "Installing $(EXECUTABLE)..."; cp $(TARGET) $(INSTALLBINDIR) | |
distclean: | |
@echo "Removing $(EXECUTABLE)"; rm $(INSTALLBINDIR)/$(EXECUTABLE) | |
.PHONY: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment