About Mflags and Makeflags

Source: Internet
Author: User
Tags posix

Options for communicating with child make

Flags such as '-s ' and '-K ' are automatically passed to the child make through the variable makeflags. This variable is created automatically by make and contains the letter of the logo that you received. So, if you are using the ' make–ks ' variable makeflags you get the value ' KS '.

As a result, either child make assigns a value to the variable makeflags in its running environment, and in response, make uses the value as a flag and processes it as if it were given as a parameter. See Summary of Options .

Similarly, variables defined on the command line are passed to the child make with the help of the variable makeflags. The words in the variable makeflags value can contain ' = ', and make will handle them as variable definitions, with the same procedure as variables defined on the command line. See variable overloading .

Options `-C‘ , `-f‘ , `-o‘ , and ' -W’不能放入 variable makeflags; These options cannot be passed down.

The '-j ' option is a special example (see Parallel execution ). If you set it to some numeric ' n ', and your operating system supports it (most UNIX systems support, other operating systems do not), parent make and all of the child do traffic guarantee that only ' N ' tasks are running in between them. Note that any task that contains recursive calls (see instead of executing commands ) cannot be counted in the total task number (otherwise, we can only get ' N ' sub-make to run without the extra time slices running the actual work).

If your operating system does not support the above communication mechanism, then '-j 1 ' will be placed in the variable makeflags instead of the value you specify. This is because if the '-j ' option is passed to child make, you may get a much larger number of tasks running in parallel than you require. If you give the '-j ' option without a numeric parameter, it means to handle as many tasks as possible in parallel, so that it is passed down, because the multiplier is unrestricted and is at most 1.

If you do not want the other flags to pass down, you must change the value of the variable makeflags, which is changed in the following way:

Subsystem

CD SubDir && $ (make) makeflags=

The variable that is defined in the command line actually appears in the variable makeoverrides, and the variable makeflags contains the reference value of the variable. If you want to pass the flag down without passing the variable defined in the command line down, you can set the value of the variable makeoverrides to NULL, in the following format:

Makeoverrides =

This is not very useful. However, some systems have a fixed limit on the size of the environment, and the value is small, and it may exceed that limit by placing so much information in the value of the variable makeflags. If you see Arg list too long‘的错误信息,很可能就是由于该问题造成的。(按照严格的 the ' posix.2 ' rule, define a special target in the makefile file. POSIX ', changing the value of the variable makeoverrides does not affect the variable makeflags. Maybe you don't care about that. )

For compatibility with earlier versions, variable mflags with the same functionality also exists. Except that it cannot contain a command-line definition variable, it has the same value as the variable makeflags, and unless it is a null value, its value always begins with a dash (Makeflags only starts with a dash when used with the multi-character option, such as and '--warn-undefined-variables’连用)。变量MFLAGS传统的使用在明确的递归调用make的命令中,例如:

Subsystem

CD SubDir && $ (make) $ (mflags)

But now, the variable makeflags makes this usage redundant. Use this method if you want your makefile files to be compatible with older versions of make programs, which works well in modern version make.

Variable makeflags is useful if you want to use the specific options you want to set each time you run make, such as the '-k ' option (see Summary of Options ). You can simply assign a value to the variable makeflags in the environment, or set the variable makeflags in the makefile file, and the specified additional flag can work for the entire makefile file. (Note: You cannot use variable mflags in this way, the variable mflags exists only for compatibility with earlier versions, and setting the variable in other ways will not be interpreted.) )

When make interprets the variable makeflags value (whether defined in the environment or defined in the makefile file), if the value does not start with a short line, make first assumes a short line for the value, then divides the value into words, separates the characters with spaces, and then parses the words. As if they were the options given in the command line. ( ‘-C‘ ,,, ‘-f‘ ‘-h‘ ‘-o‘ , ‘-W‘ options, and their long-name versions are ignored, and no error message is generated for invalid options.) )

If you define variable makeflags in your environment, you should not use the intent to severely affect make run, destroy the makefile file, and make your own options. For example, ‘-t‘ ‘-n‘ , and ‘-q‘选项,如果将它们中的一个放到 variable makeflags values, can have disastrous consequences, or at least produce annoying results.

About Mflags and Makeflags

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.