Created
June 22, 2013 15:07
-
-
Save simonwagner/5841223 to your computer and use it in GitHub Desktop.
Nearly perfect automatic Makefile for C++11. Simply drop it into your source folder and you are done.
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
TARGET = program | |
CXXFLAGS += -g -std=c++11 | |
.PHONY: default all clean | |
default: $(TARGET) | |
all: default | |
SOURCES = $(wildcard **/*.cpp) $(wildcard *.cpp) | |
OBJECTS = $(patsubst %.cpp, %.o, $(SOURCES)) | |
DEPENDENCIES := $(OBJECTS:.o=.d) | |
-include $(DEPENDENCIES) | |
%.o: %.cpp | |
$(CXX) $(CXXFLAGS) -MMD -c -o $@ $< | |
.PRECIOUS: $(TARGET) $(OBJECTS) | |
$(TARGET): $(OBJECTS) | |
$(CXX) $(CXXFLAGS) $(OBJECTS) -Wall -o $@ | |
clean: | |
rm -f $(OBJECTS) | |
rm -f $(TARGET) | |
rm -f $(DEPENDENCIES) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment