码迷,mamicode.com
首页 > 其他好文 > 详细

编写Makefile单项目模板

时间:2017-07-12 18:55:41      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:includes   ddp   tmp   make   log   rebuild   flags   bsp   src   

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

INCLUDES := -I$(COMMON_PATH)/libev/include -I./
LIBS := -L$(COMMON_PATH)/libev/lib -lev -lrt -lpthread

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

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

SRCDIRS := .
SRCEXTS := .cpp
C_SOURCES = $(wildcard *.c)
C_OBJS = $(patsubst %.c, %.o, $(C_SOURCES))
#CPP_SOURCES = $(wildcard *.cpp)
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

 

编写Makefile单项目模板

标签:includes   ddp   tmp   make   log   rebuild   flags   bsp   src   

原文地址:http://www.cnblogs.com/kaishan1990/p/7156775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!