Note: The distinctive features of clearmake, such as build auditing, derived object sharing, and build avoidance, are supported in dynamic views only. In addition, while parallel building is supported in ClearCase snapshot views, it is not supported in ClearCase LT.
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.)
The list of dependencies may 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.
A build script ends at the first nonempty line that does not begin with a <TAB> or number sign (#); this begins a new target/dependencies line or a make macro definition.
Build scripts must use standard pathnames only. Do not include view-extended or version-extended pathnames in a build script.
Executing a build script updates the target and is called a target rebuild. The commands in a build script are executed one at a time, each in its own instances of the subshell or command interpreter.
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 UNIX sed(1) insert command:
You can use macros in makefiles or in BOS files. For more information, see “BOS File Entries”.
A build options specification (BOS) file is a text file that contains macro definitions and/or ClearCase special targets. We recommend that you place in a BOS file the temporary macros—such as CFLAGS=–g (UNIX) and CFLAGS=/Zi (Windows)—and others macros that are not to be included in a makefile permanently, rather than specify them on the clearmake command line.
By default, clearmake reads BOS files in this order:
If you specify –N, clearmake does not read default BOS files.
clearmake displays the names of the BOS files it reads if you specify the –v or –d option, or if CCASE_VERBOSITY is set to 1.
For information about the contents of BOS files, see “BOS File Entries”
The following sections describe the special considerations for using makefiles with clearmake.
If a target or dependency name contains parentheses, it is assumed to be an archive (library) created by ar(1) (UNIX), lib (Windows), or some other librarian. The string within parentheses refers to a member (object module) within the library. Use of function names within parentheses is not supported.
Thus, lib.a(mod1.o) refers to an archive that contains object module mod1.o. The expression lib.a(mod1.o mod2.o) is not valid.
hello.lib(mod1.obj) refers to an archive that contains mod1.obj. The expression hello.lib(mod1.obj mod2.obj) is not valid.
Inference rules for archive libraries have the form
where sfx is the file name extension (suffix) from which the archive member is to be made.
The way in which clearmake handles incremental archive construction differs from other make variants.
Note: On UNIX, the u key for ar is not reliable within a ClearCase environment. Do not use it.
You can control the echoing of commands and the handling of errors that occur during command execution on a line-by-line basis, or on a global basis.
You can prefix one or two characters to any command, as follows:
The –k option provides for partial recovery from errors. If an error occurs, execution of the current target (that is, the set of commands for the current target) stops, but execution continues on other targets that do not depend on that target.
—File name extensions (suffixes) and their associated rules in the makefile override any identical file name extensions in the built-in rules. clearmake reads built-in rules from the file builtin.mk when you run in standard compatibility mode. In other compatibility modes, other files are read.
—If a line in a makefile starts with the string include or sinclude followed by white space (at least one <SPACE> or <TAB> character), the rest of the line is assumed to be a file name. (This name can contain macros.) The contents of the file are placed at the current location in the makefile.
For include, a fatal error occurs if the file is not readable. For sinclude, a nonreadable file is silently ignored.
By default, the order of precedence of macros and environment variables is as follows:
For example, target-dependent macro definitions override all other macro definitions, and macros specified on the clearmake command line override those set in a BOS file.
If you use the –e option to clearmake, environment variables override macro definitions in the makefile.
All BOS file macros (except those overridden on the command line) are placed in the build script's environment. If a build script recursively invokes clearmake:
For a list of build-related environment variables, see Building Software.
A macro definition takes this form:
Macros can appear in the makefile, on the command line, or in a build options specification file. (See “Build Options Specification Files”.)
Macro definitions require no quotes or delimiters, except for the equal sign (=), which separates the macro name from the value. Leading and trailing white space characters are stripped. Lines can be continued using a \<NL> sequence; this sequence and all surrounding white space is effectively converted to a single <SPACE> character. macro_name cannot include white space, but string can; it includes all characters up to an unescaped <NL> character.
clearmake performs macro substitution whenever it encounters either of the following in the makefile:
It substitutes string for the macro invocation. In the latter form, clearmake performs an additional substitution within string: all occurrences of subst1 at the end of a word within string are replaced by subst2. If subst1 is empty, subst2 is appended to each word in the value of macro_name. If subst2 is empty, subst1 is removed from each word in the value of macro_name.
For example, on UNIX:
% cat Makefile
C_SOURCES = one.c two.c three.c four.c
test:
echo "OBJECT FILES are: $(C_SOURCES:.c=.o)"
echo "EXECUTABLES are: $(C_SOURCES:.c=)"
% clearmake test
OBJECT FILES are: one.o two.o three.o four.o
EXECUTABLES are: one two three four
And on Windows:
z:\myvob> type Makefile
C_SOURCES = one.c two.c three.c four.c
test:
echo OBJECT FILES are: $(C_SOURCES:.c=.obj)
echo EXECUTABLES are: $(C_SOURCES:.c=.exe)
z:\myvob> clearmake test
OBJECT FILES are: one.obj two.obj three.obj four.obj
EXECUTABLES are: one.exe two.exe three.exe four.exe
Note: UNIX and Windows object files have different file extension naming conventions: .o for UNIX and .obj for Windows. Where this distinction is not important for the purposes of these discussions, .o is sometimes used to designate any object file in this reference page.
clearmake maintains these macros internally. They are useful in rules for building targets.
The VPATH macro specifies a search path for targets and dependencies. clearmake searches directories in VPATH when it fails to find a target or dependency in the current working directory. clearmake searches only in the current view. The value of VPATH can be one directory pathname or a list of directory pathnames separated by colons (UNIX) or semicolons (Windows). (In Gnu compatibility mode, you can also use spaces as separators.)
Configuration lookup is VPATH-sensitive when qualifying makefile dependencies (explicit dependencies in the makefile). Thus, if a newer version of a dependent file appears in a directory on the search path before the pathname in the CR (the version used in the previous build), clearmake rejects the previous build and rebuilds the target with the new file.
The VPATH setting may affect the expansion of internal macros, such as $<.
Like other build tools, clearmake interprets certain target names as declarations. Some of these special targets accept lists of patterns as their dependents, as noted in the description of the target. Pattern lists may contain the pattern character, %. When evaluating whether a name matches a pattern, the tail of the prefix of the name (subtracting directory names as appropriate) must match the part of the pattern before the %; the file-name extension of the name must match the part of the pattern after the %. For example:
Name | Matches | Does not match |
---|---|---|
(UNIX)/dir/subdir/x.o | %.o | /dir/subdir/otherdir/x.o |
(Windows)\dir\subdir\x.obj | %.obj | \dir\subdir\otherdir\x.obj |
The following targets accept lists of patterns:
You can use the following special targets in the makefile.
You can use the following special targets either in the makefile itself or in a build options specification file. See “Build Options Specification Files”.
You can specify the list of files with a tail-matching pattern; for example, Templates.DB/%.module (UNIX) or %.module (Windows).
Unlike the files listed in most special targets, the files on this list refer to the names of dependencies and not the names of targets. As such, the special target may apply to the dependencies of many targets at once. This special target is most useful when identifying a class of dependencies found in a particular toolset for which common behavior is desired across all targets that have that dependency.
You can specify the list of files with a tail-matching pattern; for example, %.pdb.
Unlike the files listed in most special targets, the files on this list refer to the names of sibling objects and not the names of targets. As such, the special target may apply to the siblings of many targets at once. This special target is most useful when identifying a class of siblings found in a particular toolset for which common behavior is desired across all targets that have that sibling.
You can specify the list of files with a tail-matching pattern; for example, %.a or %.lib.
Note: .INCREMENTAL_TARGET applies only to makefile targets built incrementally using a single make rule. Do not use it for the following kinds of files:
The general guideline is that if you're not building a library in a single makefile rule and you're not building an executable using an incremental linker, then you should not use .INCREMENTAL_TARGET.
You can specify the list of files with a tail-matching pattern; for example, %.o.
You can specify the list of files with a tail-matching pattern; for example, %.o.
You can specify the list of files with a tail-matching pattern; for example, %.o.
You can specify the list of files with a tail-matching pattern; for example, ptrepository/_% (UNIX) or %.tmp (Windows).
Unlike the files listed in most special targets, the files on this list refer to the names of sibling objects and not to the names of targets. As such, the special target may apply to the siblings of many targets at once. This special target is most useful when identifying a class of siblings found in a particular toolset for which common behavior is desired across all targets that have that sibling.
You can specify the list of files with a tail-matching pattern; for example, %.o.
You can specify the list of files with a tail-matching pattern; for example, Templates.DB/%.module (UNIX) or %.sbr (Windows).
Unlike the files listed in most special targets, the files on this list refer to the names of sibling objects and not the names of targets. As such, the special target may apply to the siblings of many targets at once. This directive is most useful when identifying a class of siblings found in a particular toolset for which common behavior is desired across all targets that have that sibling.
You can use the following target only in UNIX makefiles or BOS files.
.NOTPARALLEL:%.a
NOTPARALLEL:foobar
clearmake does not build any .a file in parallel with any other .a file, and foo is not built in parallel with bar. However, clearmake may build .a files in parallel with foo or bar.
.NOTPARALLEL does not affect lower-level builds in a recursive make, unless you specify it in the makefiles for those builds or include it in a BOS file.
You can specify the list of files with a tail-matching pattern; for example, %.a.
Because snapshot views do not make use of the MVFS, absolute VOB pathnames (for example, /vobs/tools/foo.h) are not supported in snapshot views on UNIX. For that reason, your makefiles must not include absolute VOB pathnames.
To eliminate absolute VOB pathnames from makefiles, use the pwv –root command to get the value of the current view-root directory. Use that value in one of the following methods:
The method shown in this example works for any clearmake compatibility mode. There are also methods specific to each compatibility mode. See your make documentation for more information.
clearmake is available on both UNIX and Windows NT. In principle, you can write portable makefiles, but in practice, the obstacles are substantial. The variations in tool and argument names between systems makes writing portable build scripts particularly challenging. If you choose to pursue portable makefiles, use the following general procedures to produce usable results:
There are several rules to follow when constructing, or converting, makefiles for use by clearmake on a Windows host. Note that, as a general rule, your makefiles must match the syntax required by clearmake on UNIX.
The following sections describe how you must specify build macros, targets, and dependencies in makefiles to avoid case problems.
clearmake is case-sensitive with respect to makefile macros. Consider a makefile macro reference, $(CPU). There are numerous input sources from which to satisfy this macro:
For any macro to be expanded correctly from any of these sources, the macro definition and macro reference must be in the same case. For example, $(CPU) is not replaced by the value of an EV named CPU.
When you write makefiles, you must be aware of the MVFS setting on your computer and specify targets and dependencies accordingly. If the MVFS is case-preserving, you must use case-correct pathnames in makefiles to guarantee the consistency of the resulting config records. Even if your MVFS is not case-preserving, we recommend that you use case-correct pathnames so that users on case-preserving computers can share the makefile.
Note: The –d option to clearmake warns you when case is the only difference in pathnames in the makefile and on the file system.
Table 7 describes makefile requirements for the different MVFS settings.
Table 7. MVFS Settings and Case Requirements for Makefiles
It is possible, but not trivial, to prepare makefiles that can be used with either omake or clearmake. The general approach is to supply omake-specific macro definitions in the makefile, and to supply clearmake-specific macro overrides in a build options specification (BOS) file; clearmake reads the BOS file, but omake does not. When clearmake executes, it looks for macro definitions in two locations:
BOS files at other locations can be passed to clearmake with the –A option.
On Windows, clearmake accepts either slashes ( / ) or backslashes ( \ ) in pathnames. However, clearmake uses a backslash as the separator in any pathnames that it constructs in build scripts (for example, as a result of VPATH directory searching). This can cause problems with command shells that require slashes in any pathnames supplied to them in command lines.
If you are using such a shell (for example, by setting the SHELL makefile variable accordingly), you can force clearmake to use slashes when constructing pathnames. To do this, set the CMAKE_PNAME_SEP variable:
CMAKE_PNAME_SEP = /
You can set CMAKE_PNAME_SEP in the makefile, in the BOS file, on the command line, or as an environment variable.
The following sections describe the entries you can put in BOS files.
A standard macro definition has the same form as a make macro defined in a makefile:
For example, on UNIX:
and on Windows:
A target-dependent macro definition takes this form:
Any standard macro definition can follow the := operator; the definition takes effect only when targets matching patterns in target-pattern-list and their dependencies are processed. Patterns in the target-pattern-list must be separated by white space. For example on UNIX:
On Windows:
Two or more higher-level targets can have a common dependency. If the targets have different target-dependent macro definitions, the dependency is built using the macros for the first higher-level target clearmake considered building (whether or not clearmake actually built it).
A shell command macro definition replaces a macro name with the output of a shell command:
This defines the value of macro_name to be the output of string, any shell command. In command output, <NL> characters are replaced by <SPACE> characters. For example, on UNIX:
On Windows:
You can use some ClearCase special targets in a build options spec. See “Special Targets”.
To include one BOS file in another, use the include or sinclude (silent include) directive. For example, on UNIX:
On Windows:
clearmake, clearmake.options, makefile_aix, makefile_gnu, makefile_pmake, makefile_smake, makefile_sun, omake, Building Software
Copyright© 2003 Rational Software. All Rights Reserved.