Conflict resolution

Learn how to resolve conflicts that can occur in specifications of make macros and environment variables.

Conflicts can occur in specifications of make macros and environment variables. For example, the same make macro might be specified both in a makefile and on the command line; or the same name might be specified both as a make macro and as an environment variable.

clearmake resolves such conflicts similarly to other make variants; it uses the following priority order, from highest to lowest:

  1. Target-specific macros specified in a BOS file.
  2. Target-specific macros specified in a makefile.
  3. Make macros specified on the command line.
  4. Make macros specified in a BOS file.
  5. Make macros specified in a makefile.
  6. Environment variables
  7. Built-in macros

Using the -e option gives environment variables higher priority than make macros specified in a makefile.

Conflict resolution details: The following discussion treats this topic more precisely but less concisely.

clearmake starts by converting all EVs in its environment to make macros. (SHELL is an exception.) These EVs are also placed in the environment of the shell process in which a build script executes. Then, it adds in the make macros declared in the makefile. If this produces name conflicts, they are resolved as follows:

  • If clearmake was not invoked with the -e option, the macro value overwrites the EV value in the environment.
  • If clearmake was invoked with the -e option, the EV value becomes the value of the make macro.

Finally, clearmake adds make macros specified on the command line or in a BOS file; these settings are also added to the environment. These assignments always override any others that conflict. (A command-line assignment overrides a BOS setting of the same macro.)