Makefile overview

A makefile contains a sequence of entries, each of which specifies a build target, some dependencies, and the build scripts of commands to be executed.

A makefile can also contain make macro definitions, target-dependent macro definitions, and build directives (special targets.)

  • Target/dependencies line: The first line of an entry is a white-space-separated, non-null list of targets, followed by a colon (:) or a double colon (::), and a (possibly empty) list of dependencies. Both targets and dependencies might contain HCL VersionVault path name patterns. (See the wildcards_ccase reference page.)

    The list of dependencies might not need to include source objects, such as header files, because clearmake detects these dependencies. However, the list must include build-order dependencies, for example, object modules and libraries that must be built before executables. (For more information, see Build-order dependencies.)

  • Build script: Text that follows a semicolon (;) on the same line and all subsequent lines that begin with a <TAB> character constitute a build script: a set of shell commands to be executed. A shell command can be continued onto the next text line with a \<NL> sequence. Any line beginning with a number sign (#) is a comment.

    A build script ends at the first nonempty line that does not begin with a <TAB> or number sign (#); this begins a new target or dependencies line or a make macro definition.

    Build scripts must use standard path names only. Do not include view-extended or version-extended path names in a build script.

    Executing a build script updates the target, and is called a target rebuild. The shell commands in a build script are executed one at a time, each in its own instances of the subshell.

    Note that clearmake always completely eliminates a \<NL> sequence, even in its compatibility modes. Some other make programs sometimes preserve such a sequence--for example, in a sed(1) insert command:

    target: depdcy
    sed -e '/xxx=0/i\
    yyy=xxx;' depdcy > target
  • Make macro: A make macro is an assignment of a character-string value to a simple name. By convention, all letters in the name are uppercase (for example, CFLAGS).
  • Target-dependent macro definitions: A target-dependent macro definition takes the form target-list := macro_name = string.

    You can use macros in makefiles or in BOS files. For more information, see Target-dependent macro definitions.

  • Special targets: A line that begins with a dot (.) is a special target, which acts as a directive to clearmake.
  • Special characters in target names: You can use special characters in target names by immediately preceding each special character with a backslash (\).