#includes是为其他文件夹里的头文件准备的 至于.c和.o文件,还是老老实实带上路径吧。
INCLUDES=-I../protocol -I../link
server:../protocol/protocol.o ../link/link.o main.o server.o
gcc $(INCLUDES) ../protocol/protocol.o ../link/link.o main.o server.o -o server -pthread
../protocol/protocol.o:../protocol/protocol.c
gcc -c ../protocol/protocol.c -o ../protocol/protocol.o -pthread
#protocol.o:protocol.c#与上一行形成对比,此写法不行。
# gcc -c $(INCLUDES) protocol.c -o protocol.o -pthread
../link/link.o:../link/link.c
gcc -c ../link/link.c -o ../link/link.o -pthread
main.o:main.c
gcc -c $(INCLUDES) main.c -o main.o -pthread
server.o:server.c
gcc -c $(INCLUDES) server.c -o server.o -pthread
clean:
rm *.o server ../protocol/*.o ../link/*.o
网友评论