Created
March 2, 2014 19:39
-
-
Save sguzman/9312589 to your computer and use it in GitHub Desktop.
Useful 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
CXX=clang++ | |
FILE=prog2 | |
SRCEXT=cpp | |
HEADEXT=hpp | |
WARNINGS=-Weverything -Werror -pedantic -pedantic-errors -Wno-c++98-compat -Wno-unused-macros | |
CXXFLAGS=-std=c++11 -g -O0 $(WARNINGS) | |
PCH=-x c++-header | |
HPPFILES=$(shell find . -type f -name '*.$(HEADEXT)' | xargs) | |
PCHFILES=$(HPPFILES:=.pch) | |
LOOP=$(foreach pc, $(PCHFILES), $(shell echo -e -include-pch $(pc))) | |
all: $(FILE) | |
$(FILE): $(FILE).o | |
$(CXX) $(CXXFLAGS) $(OBJ) $< -o $@ | |
$(FILE).o: $(FILE).$(SRCEXT) $(PCHFILES) | |
$(CXX) $(CXXFLAGS) $(LOOP) -c $< | |
def.hpp.pch: Pair.hpp | |
%.$(HEADEXT).pch: %.$(HEADEXT) | |
$(CXX) $(CXXFLAGS) $(PCH) -o $@ $< | |
analyze: | |
$(CXX) $(CXXFLAGS) --analyze -o /dev/null $(FILE).$(SRCEXT) | |
syntax: | |
$(CXX) $(CXXFLAGS) -fsyntax-only $(FILE).$(SRCEXT) | |
clean-all: clean | |
rm -f *.pch | |
clean: | |
rm -f $(FILE) *.o a.out | |
.PHONY: clean all clean-all syntax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment