Indicator "include", "-include" and "Sinclude"
If the file specified by the indicator "include" does not start with a slash (absolute path, such as/usr/src/makefile ...). , and the file is not present in the current directory; make will try to find in the following directories based on the filename: first, find the directory specified using the command-line option "I" or "--include-dir", and use this file if you find the specified file Otherwise, continue searching for the following directories (if they exist): "/usr/gnu/include", "/usr/local/include", and "/usr/include".
When a file specified by "include" is not found in these directories, make prompts for an alert that contains the file not found, but does not exit immediately. Instead, it continues to process makefile's subsequent content. When the entire makefile is read, make attempts to use the rule to create a file that is specified by the indicator "include" but not found, and when it cannot be created (no rules for creating the file), make prompts for a fatal error and exits. An error message similar to the following is output:
Makefile: Wrong number of lines: FileName not found: prompt (no such file or directory)
Make: * * * to make target ' <filename> '. Stop
In general, we can use "-include" instead of "include" in makefile to ignore error prompts ("-") because the containing file does not exist or cannot be created ("-"), which means to tell make to ignore the error of this operation. Make continues to execute). Like the bottom:
-include FILENAMES ...
When you use this method, there is no error prompt and make does not exit when the file you want to include does not exist, and in addition, it works the same way as the first. The following is a comparison of the two approaches:
Using "include FILENAMES...", when the Make program is processed, if "FILENAMES" If any of the files in the list are not read correctly and there is no rule to create this file, the make program prompts for an error and exits.
Use "-include FILENAMES..." The situation is that when the contained file does not exist or there is no rule to create it, the make program continues to execute, and only if the actual reconstruction of the ultimate goal cannot be done correctly (some of the required targets cannot find the correct rebuild rule in the contents of the currently read makefile file), will prompt for fatal errors and exit.
For compatibility with other make programs. You can also use "sinclude" instead of "-include" (The way GNU supports it).