典型的Linux C/C++的makefile写法,其它的应用可根据此template修改
(注意每一行的前面若有空格,是tab,不是space)
#Source file(源文件) SRC = ThreadQueue.cpp #Object file(目标文件) OBJ = $(SRC:.cpp=.o) #Output execution file(输出的可执行文件) PROGRAM = ThreadQueue #Compiler(编译器) CC = gcc/g++ #Include(头文件) INCLUDE = -I/usr/include/ncurses -I/usr/include/ #Linker Parameter(连接器参数) LINKPARAM = -lpthread -lncurses #Options for development(开发选项) CFLAGS/CXXFLAGS = -ansi -g -Wall #Options for release(屏蔽选项/预处理参数) CPPFLAGS = -ansi -O -w #(最终目标) all: $(PROGRAM) #(可执行文件) $(PROGRAM): $(OBJ) $(CC) -o $(PROGRAM) $(LINKPARAM) $(OBJ) # (定义后缀) .SUFFIXES : .cpp # (老式风格的后缀规则) .cpp.o: $(CC) $(INCLUDE) $(CFLAGS) -c $< # (重载内建隐含规则) %.o : %.cpp $(CC) $(INCLUDE) $(CFLAGS) -c $< # (伪目标) .PHONY : clean clean: -rm *.o