1,源文件依赖关系
defs.h command.h buffer.h main.cpp * util.cpp * kde.cpp * * command.cpp * * display.cpp * * insert.cpp * * search.cpp * * files.cpp * * *
2, 源文件
因为这里只是想做一下简单测试,所以很多源文件的内容都是空的。
[[email protected] 1-makefile]#head *.h ==> buffer.h <== #pragma once #define BUFFER "BUFFER" ==> command.h <== #pragma once #define COMMAND "COMMAND" ==> defs.h <== #pragma once #define DEFS "DEFS"
[[email protected] 1-makefile]#head *.cpp ==> command.cpp <== ==> display.cpp <== ==> files.cpp <== ==> insert.cpp <== ==> kde.cpp <== ==> main.cpp <== #include <stdio.h> int main() { printf("Hello World\n"); return 0; } ==> search.cpp <== ==> utils.cpp <== [[email protected] 1-makefile]#
3,makefile 内容(最最原始的)
[[email protected] 1-makefile]#cat makefile edit : main.o kde.o command.o display.o insert.o search.o utils.o files.o g++ -o edit main.o kde.o command.o display.o insert.o search.o utils.o files.o main.o : main.cpp defs.h g++ -c main.cpp kde.o : kde.cpp defs.h command.h g++ -c kde.cpp command.o : command.cpp defs.h command.h g++ -c command.cpp display.o : display.cpp defs.h buffer.h g++ -c display.cpp insert.o : insert.cpp defs.h buffer.h g++ -c insert.cpp search.o : search.cpp defs.h buffer.h g++ -c search.cpp files.o : files.cpp defs.h buffer.h command.h g++ -c files.cpp utils.o : utils.cpp defs.h g++ -c utils.cpp clean : rm edit main.o kde.o command.o display.o insert.o search.o files.o utils.o -rf
4,执行make
[[email protected] 1-makefile]#make clean rm edit main.o kde.o command.o display.o insert.o search.o files.o utils.o -rf
5,运行结果
[[email protected] 1-makefile]#./edit Hello World
6,执行清理
[[email protected] 1-makefile]#make clean rm edit main.o kde.o command.o display.o insert.o search.o files.o utils.o -rf
时间: 2024-10-08 15:28:44