Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Last active Nov 14, 2015
Embed
What would you like to do?
Makefile template for MacOS/brew
DEBUG?=1
SRCS=$(wildcard *.cpp)
OBJS=$(SRCS:.cpp=.o)
DEPENDS=Makefile.depends
BOOST_PATH=$(shell brew --prefix boost)
CXXFLAGS=-std=c++14 -W -Wall -I$(BOOST_PATH)
LDFLAGS=-L$(BOOST_PATH)/lib
ifeq ($(DEBUG),0)
CXXFLAGS+=-O2
else
CXXFLAGS+=-O0 -g
LDFLAGS+=-g
endif
.PHONY: all clean distclean depend
all: depend $(TARGET)
clean:
$(RM) $(TARGET) $(OBJS)
distclean: clean
$(RM) $(DEPENDS)
depend: $(DEPENDS)
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(DEPENDS): $(SRCS)
$(CXX) $(CXXFLAGS) -E -MM -w $(SRCS) > $(DEPENDS)
-include $(DEPENDS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment