标签:
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)
标签:
原文地址:http://www.cnblogs.com/superPerfect/p/4300705.html