记录一个简单包含mk的makefile

 CC=gcc
CXX=g++
CFLAGS+= -Wall -O -g
LIB += -pthread -lpthread -lutil -lmysqlclient -lz -ldl -lrt

TARGET = hehe

%.o:%.c
	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
%.o:%.cpp
	$(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@



SOURCES = $(wildcard *.c *.cpp)
OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))

$(TARGET) : $(OBJS)
	$(CXX) $(CFLAGS) $(OBJS) $(LIB) -o $(TARGET)


clean:
	rm  -rf *.o $(TARGET)
#=======================================================================
include /home/daipeixian/leveldb/leveldb-master/leveldb.mk
INCLUDE += -I/home/chenwei/snappy-1.1.1/include
LIB     += -L/home/chenwei/snappy-1.1.1/lib
LIB += -lsnappy
#===============================================================

leveldb.mk的内容如下:

INCLUDE += -I/home/daipeixian/leveldb/leveldb-master/include/leveldb
LIB += -L/home/daipeixian/leveldb/leveldb-master/out-static
LIB += -lleveldb

这样便可以引入第三方的库了

参考文章:

资料1

资料2

资料3


你可能感兴趣的:(记录一个简单包含mk的makefile)