Understanding how the make command uses environment variables
Each time the make command runs, it reads the current environment variables and adds them to its defined macros.
Using the MAKEFLAGS macro or the MFLAGS macro, the user can specify flags to be passed to the make command. If both are set, the MAKEFLAGS macro overrides the MFLAGS macro. The flags specified using these variables are passed to the make command along with any command-line options. In the case of recursive calls to the make command, using the $(MAKE) macro in the description file, the make command passes all flags with each invocation.
When the make command runs, it assigns macro definitions in the following order:
- Reads the MAKEFLAGS environment
variable.
If the MAKEFLAGS environment variable is not present or null, the make command checks for a non-null value in the MFLAGS environment variable. If one of these variables has a value, the make command assumes that each letter in the value is an input flag. The make command uses these flags (except for the -f, -p, and -d flags, which cannot be set from the MAKEFLAGS or MFLAGS environment variable) to determine its operating conditions.
- Reads and sets the input flags from the command line. The command line adds to the previous settings from the MAKEFLAGS or MFLAGS environment variable.
- Reads macro definitions from the command line. Themake command ignores any further assignments to these names.
- Reads the internal macro definitions.
- Reads the environment. The make command treats the environment variables as macro definitions and passes them to other shell programs.