現在我正在研究一些計算機科學課程的練習題。一個我遇到的那些都涉及makefile和去如下:確定在C中使用makefile時將運行哪些命令?
You are working in a directory which contains the following files and no others:
makefile myscript one.c three.c two.h
------------------------------------
Here are the contents of makefile:
CC=gcc
CFLAGS=-ansi
myprogram: two.o three.o
gcc -o myprogram two.o three.o
two.c: one.c myscript
sed -rf myscript one.c >| two.c
three.o: two.h
------------------------------------
1.) If you type `make myprogram` in this directory, what commands will be run?
2.) After the commands are run, what new files will have been created?
3.) After this, you edit `two.h` (and no other files) and then type make `myprogram` again. What
commands will be run?
所以從我有限的瞭解Makefile
我知道,1.)
命令來運行將gcc -o myprogram two.o three.o
,因爲myprogram
不存在目錄。然而,two.o
和three.o
也不存在...這是我有點失落的地方,然後我會在two.c: one.c myscript
下運行命令,因爲它強制覆蓋?任何幫助非常感謝,謝謝!
好吧,「two.o」和「three.o」會因爲隱含的make規則而被「製造」? –
'two.o'在我的答案中;請仔細閱讀。 'three.o'有一個規則,但是有一個隱含的源文件(所以稱之爲Make使用「部分隱式規則」)。 – Evert
非常感謝您的幫助,我會盡我所能去理解您所展示的一切! –