- 1 year ago
Does GNU make prepend a "./" to the path of included makefiles?
Yes, GNU Make typically prepends a "./" (current directory indicator) to the path of included makefiles to ensure that it is searched for in the current directory.
When you include a makefile using the include
directive in GNU Make, it searches for the included file in the following order:
Current Directory: GNU Make first searches for the included makefile in the current directory, assuming a relative path is provided.
Directories in
VPATH
Variable: If the makefile is not found in the current directory, GNU Make checks the directories specified in theVPATH
variable. TheVPATH
variable allows you to specify additional directories to search for included makefiles.Implicit Rules: If the makefile is still not found, GNU Make applies any implicit rules it has defined to try to create the included makefile.
By prepending a "./" to the path of the included makefile, GNU Make ensures that it is searched for in the current directory, even if a relative path is provided.
Here's an example of including a makefile with a relative path:
makefileinclude ./path/to/included.makefile
In this case, GNU Make will search for the included makefile in the "path/to" directory relative to the current directory.
If you want to include a makefile without the "./" prefix, you can specify an absolute path or modify the VPATH
variable to include the desired directory.
It's worth noting that the behavior of GNU Make can be customized through variables and options, so the exact behavior may vary depending on your specific Makefile and configuration.