zoukankan      html  css  js  c++  java
  • 自己写的一个多应用程序多目录的Makefile

    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)

  • 相关阅读:
    hdu 1176 免费馅饼
    算法竞赛入门经典训练指南-做题详细记录(更新中)
    poj-3250 Bad Hair Day
    poj-2823 Sliding Window
    2019.7.15-7.20暑假集训总结
    hdu 1754 I hate it
    poj 1611 The Suspects
    hdu 3038 How Many Answers Are Wrong
    hdu 1213 How Many Tables
    POJ 1182 食物链
  • 原文地址:https://www.cnblogs.com/superPerfect/p/4300705.html
Copyright © 2011-2022 走看看