Last active
November 14, 2018 11:56
-
-
Save liberaid2/e1a5b35d73648b55c8547887d0a98c6a to your computer and use it in GitHub Desktop.
Common makefile
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++ | |
CFLAGS=-c -Wall -std=c++17 -g -O0 | |
LDFLAGS= | |
LIBS= | |
SRCDIR=src | |
OBJDIR=obj | |
SOURCES=$(wildcard $(SRCDIR)/*.cpp) | |
OBJECTS=$(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SOURCES)) | |
EXEC=main | |
.SILENT: | |
all: $(SOURCES) $(EXEC) | |
$(EXEC): $(OBJECTS) | |
$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS) | |
@echo LINK $@ | |
$(OBJECTS): $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | |
mkdir -p $(OBJDIR) | |
$(CC) $(CFLAGS) -o $@ $^ | |
@echo C $^ | |
clean: | |
rm -rf $(OBJDIR) | |
rm $(EXEC) | |
@echo Cleaned | |
memcheck: $(EXEC) | |
valgrind --leak-check=full --show-leak-kinds=all ./$(EXEC) | |
threadscheck: $(EXEC) | |
valgrind --tool=helgrind ./$(EXEC) | |
debug: $(EXEC) | |
gdb ./$(EXEC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment