Created
April 30, 2019 13:39
-
-
Save kiarina/9ca0b76640bf77c3b777e09998a36e57 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
CXX = g++ | |
CXXFLAGS = -std=c++11 -g -MMD -MP | |
SRC_DIR = ./src | |
OBJ_DIR = ./build | |
SOURCES = $(shell ls $(SRC_DIR)/*.cpp) | |
OBJS = $(subst $(SRC_DIR), $(OBJ_DIR), $(SOURCES:.cpp=.o)) | |
TARGET = build/main | |
DEPENDS = $(OBJS:.o=.d) | |
.PHONY: all | |
all: $(TARGET) | |
$(TARGET): $(OBJS) | |
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) | |
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | |
@if [ ! -d $(OBJ_DIR) ]; then mkdir -p $(OBJ_DIR); fi | |
$(CXX) $(CXXFLAGS) -o $@ -c $< | |
.PHONY: clean | |
clean: | |
rm $(OBJS) $(TARGET) $(DEPENDS) | |
-include $(DEPENDS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment