The difference between indicator "include", "-include" and "Sinclude" in Makefile

Source: Internet
Author: User

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).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.