Last active
July 24, 2016 21:42
-
-
Save joshuamabina/d380947c2c2d81df5787c1cf46e2c1c7 to your computer and use it in GitHub Desktop.
GNU Make unicorns.
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
# GNU Make unicorns. | |
# TODO: Tests - Solve the problem first, then write the code | |
# TODO: Lints - Enforce Google's C++ style guide | |
# The main C+ compiler | |
CC = g++ | |
# The main Shell environment | |
SHELL = /bin/bash | |
# -Wall prints "all" warning messages | |
# -g generates additional information for use with gdb | |
# -std - compiles sources in both the C++03 and the C++11 standard | |
CFLAGS += -Wall -g -std=c++0x -O3 | |
# The output executable file | |
EXE = app | |
SOURCE_EXT = cc | |
SOURCE = src | |
BUILD = build | |
INCLUDE = include | |
TARGET = $(BUILD)/bin | |
SOURCES = $(shell find $(SOURCE) -type f -name *.$(SOURCE_EXT)) | |
OBJECTS = $(patsubst $(SOURCE)/%,$(BUILD)/%,$(SOURCES:.$(SOURCE_EXT)=.o)) | |
# Include boost libraries. | |
LIBS += -L lib -lboost_program_options -lboost_filesystem -lboost_system | |
$(TARGET): $(OBJECTS) | |
@echo "" | |
@echo " Linking..." | |
@mkdir -p $(TARGET) | |
@echo " $(CC) $^ -o $(TARGET)/$(EXE) $(LIBS)"; $(CC) $^ -o $(TARGET)/$(EXE) $(LIBS) | |
@echo "" | |
@echo " Symlinking..." | |
@echo " $(TARGET)/$(EXE)" | |
@ln -s $(TARGET)/$(EXE) ./$(EXE) | |
$(BUILD)/%.o: $(SOURCE)/%.$(SOURCE_EXT) | |
@echo "" | |
@echo " Building..." | |
@mkdir -p $(BUILD) | |
@echo " $(CC) -I $(INCLUDE) -c -o $@ $<"; $(CC) -I $(INCLUDE) -c -o $@ $< | |
clean: | |
@echo " Cleaning..." | |
@echo " $(RM) -r $(BUILD) $(TARGET)/$(EXE) $(EXE)"; $(RM) -r $(BUILD) $(TARGET)/$(EXE) $(EXE) | |
.PHONY: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment