Skip to content

Instantly share code, notes, and snippets.

@clckwrkbdgr
Created May 22, 2014 11:48
Show Gist options
  • Save clckwrkbdgr/5adf430a8925ed7d194a to your computer and use it in GitHub Desktop.
Save clckwrkbdgr/5adf430a8925ed7d194a to your computer and use it in GitHub Desktop.
Simple makefile template for C++ project
BIN = wted
LIBS = -lchthon2
SOURCES = $(wildcard *.cpp)
OBJ = $(addprefix tmp/,$(SOURCES:.cpp=.o))
#WARNINGS = -pedantic -Werror -Wall -Wextra -Wformat=2 -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wuninitialized -Wunused -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wcast-qual -Wcast-align -Wconversion -Wsign-conversion -Wlogical-op -Wmissing-declarations -Wno-multichar -Wredundant-decls -Wunreachable-code -Winline -Winvalid-pch -Wvla -Wdouble-promotion -Wzero-as-null-pointer-constant -Wuseless-cast -Wvarargs -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=format
CXXFLAGS = -MD -MP -std=c++0x $(WARNINGS)
all: $(BIN)
run: $(BIN)
./$(BIN)
$(BIN): $(OBJ)
$(CXX) $(LIBS) -o $@ $^
tmp/%.o: %.cpp
@echo Compiling $<...
@$(CXX) $(CXXFLAGS) -c $< -o $@
.PHONY: clean Makefile
clean:
$(RM) -rf tmp/* $(BIN)
$(shell mkdir -p tmp)
-include $(OBJ:%.o=%.d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment