Skip to content

Instantly share code, notes, and snippets.

@xjia1
Last active August 29, 2015 14:08
Show Gist options
  • Save xjia1/ce72dfa8407abab1ccd3 to your computer and use it in GitHub Desktop.
Save xjia1/ce72dfa8407abab1ccd3 to your computer and use it in GitHub Desktop.
C++ Makefile
TARGET = my_program.exe
RM = rm -f
CXX = g++
CXXFLAGS = -std=c++11 -m64 -g -I"." -I".." -I"${BOOST_ROOT}" -I"${MYSQL_ROOT}/include" -I"${PROTOBUF_ROOT}/include"
LDFLAGS = -L"${BOOST_ROOT}/stage/lib" -L"${MYSQL_ROOT}/lib" -L"${PROTOBUF_ROOT}/lib"
LDLIBS = -lboost_system -lmysqlclient -lprotobuf
SRCS = $(wildcard *.cpp ../common/*.cc)
OBJS = $(subst .cc,.o,$(subst .cpp,.o,$(SRCS)))
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
depend: .depend
.depend: $(SRCS)
$(RM) $@
$(CXX) $(CXXFLAGS) -MM $^ > $@
clean:
$(RM) $(OBJS)
dist-clean: clean
$(RM) .depend $(TARGET)
-include .depend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment