Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Last active November 14, 2015 07:37
Show Gist options
  • Save yohhoy/900d17255a088830ac27 to your computer and use it in GitHub Desktop.
Save yohhoy/900d17255a088830ac27 to your computer and use it in GitHub Desktop.
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