Last active
September 12, 2017 02:59
-
-
Save Rio6/13c454043ec5995732d349400d13943b 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
SRCDIR:=src | |
BUILDDIR:=build | |
CXXFLAGS:=-O2 -Wall | |
LIBS:=-llibs | |
SRCS:=$(wildcard $(SRCDIR)/*.cpp) | |
HDRS:=$(wildcard $(SRCDIR)/*.hpp) | |
OBJS:= $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRCS)) | |
TGT:=name | |
all: $(BUILDDIR) $(TGT) | |
$(TGT): $(OBJS) | |
$(CXX) $(CXXFLAGS) $(LIBS) $(OBJS) -o $(TGT) | |
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp | |
$(CXX) $(CXXFLAGS) -c $< -o $@ | |
$(BUILDDIR): | |
mkdir -p $(BUILDDIR) | |
clean: | |
$(RM) -r build | |
depend: .depend | |
.depend: $(SRCS) $(HDRS) | |
$(CXX) $(CXXFLAGS) -MM $^ | sed 's|[a-zA-Z0-9_-]*\.o|$(BUILDDIR)/&|' > .depend | |
include .depend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment