编写Makefile单项目模板

CC = gcc
CXX = g++
TARGET = process
INSTALLDIR = ~/work/
COMMON_PATH := /home/shengkaishan/tmp

INCLUDES := -I./
INCLUDES += -I$(COMMON_PATH)/libev/include 
INCLUDES += -I/usr/local/ocilib/include 
INCLUDES += -I/usr/local/log4cplus/include 
INCLUDES += -I$(COMMON_PATH)/libiconv/include
INCLUDES += -I$(COMMON_PATH)/librdkafka/include
INCLUDES += -I/home/shengkaishan/code/Risk/gtja/out/include
INCLUDES += -I/home/shengkaishan/code/Risk/gtja/Trial_Server/src
INCLUDES += -I$(COMMON_PATH)/libcurl/include
INCLUDES += -I$(COMMON_PATH)/libprotobuf/include
#INCLUDES += -I$(NAUT_ROOTDIR)/out/include

LIBS := 
#LIBS += -L$(COMMON_PATH)/libev/lib -lev
#LIBS += -L/usr/local/ocilib -L/usr/local/instantclient_12_2 -lclntsh -locilib 
#LIBS += -L/usr/local/log4cplus/lib -llog4cplus
#LIBS += -L$(COMMON_PATH)/libiconv/lib -lcharset -liconv
#LIBS += -L$(NAUT_ROOTDIR)/out/lib/debug -lbase
#LIBS += -L$(COMMON_PATH)/librdkafka/lib -lrdkafka -lrdkafka++
#LIBS += -L$(COMMON_PATH)/libcurl/lib -lcurl
LIBS += -L$(COMMON_PATH)/libprotobuf/lib/static -lprotobuf
LIBS += -lrt -pthread -static

CPPFLAGS := -g -O0
CPPFLAGS += -std=c++11

#add macro
#CPPFLAGS += -D __linux__
##

SRCDIRS := .
SRCEXTS := .cpp .cc
CPP_SOURCES = $(foreach d,$(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
CPP_OBJS = $(patsubst %.cpp, %.o, $(CPP_SOURCES))

all: $(TARGET)
$(TARGET): $(CPP_SOURCES)
    $(CXX) $(CPPFLAGS) $^ -o $(TARGET) $(INCLUDES) $(LIBS)

install:
    mkdir -p $(INSTALLDIR)
    cp -f $(TARGET) $(INSTALLDIR)
ifneq ($(wildcard *.conf), )
    cp -f *.conf $(INSTALLDIR)
endif

clean:
#    rm -f $(CPP_OBJS) $(C_OBJS)
    rm -f $(TARGET)

rebuild: clean all

 

转载于:https://www.cnblogs.com/kaishan1990/p/7156775.html

你可能感兴趣的:(编写Makefile单项目模板)