Created
February 7, 2018 10:05
-
-
Save dangkhoasdc/d4f35fcdde2be6b148ca0419be8368c9 to your computer and use it in GitHub Desktop.
Makefile Template
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
CC := g++ # This is the main compiler | |
# CC := clang --analyze # and comment out the linker last line for sanity | |
SRCDIR := src | |
BUILDDIR := build | |
TARGET := bin/runner | |
SRCEXT := cpp | |
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) | |
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) | |
CFLAGS := -g # -Wall | |
LIB := -pthread -lmongoclient -L lib -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt | |
INC := -I include | |
$(TARGET): $(OBJECTS) | |
@echo " Linking..." | |
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) | |
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) | |
@mkdir -p $(BUILDDIR) | |
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< | |
clean: | |
@echo " Cleaning..."; | |
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET) | |
# Tests | |
tester: | |
$(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester | |
# Spikes | |
ticket: | |
$(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket | |
.PHONY: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment