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

自己写的一个多应用程序多目录的Makefile

时间:2015-02-26 11:21:03      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

DIR_INC = ./include
DIR_SRC = ./src
DIR_OBJ = ./obj
DIR_BIN = ./bin
INCLUDES = -I${DIR_INC} -I.
CC => SRV_SRC = $(wildcard ${DIR_SRC}/srv/*.cpp)  
CLI_SRC = $(wildcard ${DIR_SRC}/cli/*.cpp)  
SRV_OBJ = $(patsubst %.cpp,${DIR_OBJ}/srv/%.o,$(notdir ${SRV_SRC})) 
CLI_OBJ = $(patsubst %.cpp,${DIR_OBJ}/cli/%.o,$(notdir ${CLI_SRC})) 
OBJ = ${SRV_OBJ} ${CLI_OBJ}
SRC = ${SRV_SRC} ${CLI_SRC}
     
SRV_BIN = ${DIR_BIN}/srvMain
CLI_BIN = ${DIR_BIN}/cliMain
   
BIN_TARGET = ${SRV_BIN} ${CLI_BIN}
   
all:${BIN_TARGET}
${SRV_BIN}:${SRV_OBJ}
 $(CC) $(SRV_OBJ) -o $@
 
${CLI_BIN}:${CLI_OBJ}
 $(CC) $(CLI_OBJ) -o $@
${DIR_OBJ}/srv/%.o:${DIR_SRC}/srv/%.cpp
 $(CC) $(CFLAGS) -c  $< -o $@
${DIR_OBJ}/cli/%.o:${DIR_SRC}/cli/%.cpp
 $(CC) $(CFLAGS) -c  $< -o $@
.PHONY:clean
clean:
 > SUBDIRS += serverDir
.PHONY:default> 

$(SUBDIRS):
        $(MAKE) -C $@ $(TARGET)


子目录
.PHONY:clean> CFLAGS  = -Wall -g
BIN             => OBJ = $(patsubst %.c, %.o, $(SRC))


all:$(BIN)


$(BIN) : $(OBJ) 
        $(CC) $(CFLAGS) -o $(BIN) $(OBJ)


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


clean:
        rm -f $(BIN) $(OBJ)

自己写的一个多应用程序多目录的Makefile

标签:

原文地址:http://www.cnblogs.com/superPerfect/p/4300705.html

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