2013-01-10 33 views
0

假設我有一個頭文件,它包含在許多源文件中,可能具有非常深的層次結構。在每個源對象的先決條件中列出這個公共頭文件是非常無聊的,並且不確定是否有優雅的解決方案。謝謝!關於Makefile中的深度頭文件

回答

1

您可以使用gcc -M生成這樣的依賴關係。從TFM

-M Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.

另見Generating Prerequisites Automatically