Makefile模板(C++)

來源:互聯網
上載者:User

標籤:not   clu   test   col   color   run   client   nbsp   結果   

Makefile的C++的一個模板,可用於根據不同源檔案,產生多個可執行檔 。

CC = g++DIR_INC = ./includeDIR_SRC = ./srcDIR_OBJ = ./objDIR_BIN = ./bin# SRC = $(wildcard ${DIR_SRC}/*.cpp )SRC_Server = $(wildcard ${DIR_SRC}/server.cpp ${DIR_SRC}/test1.cpp)SRC_Client = $(wildcard ${DIR_SRC}/client.cpp  ${DIR_SRC}/test1.cpp)OBJ_server = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC_Server} ))OBJ_client = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC_Client} ))TARGET_Server = tcp_serverTARGET_Client = tcp_clientBIN_TARGET_Server = ${DIR_BIN}/${TARGET_Server} BIN_TARGET_Client = ${DIR_BIN}/${TARGET_Client}TARGET = ${DIR_BIN}/${TARGET_Server}  ${DIR_BIN}/${TARGET_Client}  all: $(TARGET)  CFLAGS = -g -O2 -Wall -I${DIR_INC}${DIR_OBJ}/%.o : ${SRC_Server} ${SRC_Client}    @echo 開始編譯檔案    $(CC) ${CFLAGS} -c $?    -mv *.o $(DIR_OBJ)/    @echo 編譯檔案完成${BIN_TARGET_Client} : ${OBJ_client}@echo 連結組建檔案目標檔案${CC} ${CFLAGS} ${OBJ_client}  -o [email protected]  ${BIN_TARGET_Server} : ${OBJ_server}    @echo 連結組建檔案目標檔案    ${CC} ${CFLAGS} ${OBJ_server}  -o [email protected]  .PHONY : clean runclean:    @echo 刪除編譯結果檔案    -rm -f ${DIR_OBJ}/*.o ${BIN_TARGET_Server} ${BIN_TARGET_Client}run:    @echo 執行檔案    ${BIN_TARGET}

 

Makefile模板(C++)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.