Using wmake
From Open Watcom
The following text is intended for users who are familiar with other make utilities but unfamiliar with wmake. It assumes knowledge of make concepts and is not a wmake tutorial.
Contents |
Similarities
The Open Watcom make utility, wmake, uses the same concepts as other make tools, such as Microsoft NMAKE or GNU make. It is intended as an aid in maintaining programming (or other) projects. It uses the concepts of targets to be updated, a list of dependents (or prerequisites) that must be uptodate before the target is updated, and a list of commands that will bring the target up to date. Maintenance of makefiles is made much easier through a macro facility which supports simple text replacement. Users who have experience using other make tools should have no trouble adapting to wmake.
Differences
That said, there is a number of differences between wmake and other tools. The most important ones are:
- Line continuation
- The line continuation character in wmake is the ampersand (&), not backslash (\).
- Case sensitivity
- Macro names in wmake are case insensitive. That is,
$(foo)is equivalent to$(FOO)in wmake.
- Environment variables
- Unlike many other make tools, macros in wmake are considered separate from environment variables. To access environment variables as if they were macros, the name must be prefixed with the % character, for instance
$(%ENV_VAR).
- Targets are files
- By default, wmake considers every target to be a file. After a command list is executed, wmake will check to make sure that the target really exists. This can be often useful, as other make tools make it relatively easy to write makefiles that result in uptodate targets without truly updating them. Since makefiles are notoriously difficult to debug, the additional checks are helpful. To tell wmake that a target is not a file, the
.SYMBOLICdirective may be used.
- Macro evaluation
- Different make utilities evaluate macros at different points. Consider the following makefile:
foo = $(bar)
bar = hello
target : prereq .symbolic
@echo $(foo)
bar = hi
prereq : .symbolic
@echo $(foo)
When processed with wmake, the result will be
hi hi
This happens to correspond to GNU make behaviour (with the .symbolic directives removed of course). Some versions of Microsoft and IBM NMAKE, on the other hand, will print
hi hello
because they evaluate macros earlier.
- Non-parenthesized macros
- In most make tools,
$HELLOis equivalent to$(H)ELLO. In wmake, it is equivalent to$(HELLO). It is highly recommended to always use the parentheses except for special macros.
- The
$<special macro - In other make utilities, the
$<special macro used in the command list of an implicit rule evaluates to the target that caused the rule to be selected. In wmake, the macro evaluates to the list of all dependents (prerequisites).
- Preprocessing
- Just like Microsoft/IBM NMAKE but unlike UNIX make tools, wmake uses preprocessing directives prefixed with an exclamation mark. For example:
!include header.mk !ifeq flag yes ! define build debug !else ! define build release !endif
- Directory searches
- Open Watcom make supports suffix search paths in the format
suffix : path. This is analogous to the vpath mechanism used by GNU make and allows wmake to search for prerequisites in other directories. The GNU make directive
vpath %.c ..
- is equivalent to
.c : ..
- in wmake.
Special Features
Open Watcom make includes several special features not found in most other make utilities.
- Automatic dependency checks
- With wmake and the Open Watcom compilers, it is trivial to use automatic dependency checks. All the user needs to do is specify the
.AUTODEPENDdirective with the appropriate rules. The C/C++ compilers as well as the Windows and OS/2 resource compiler automatically emit dependency information in object files where wmake will read it from. There is no need for additional files or compiler switches.
- DLL tools
- The Windows and OS/2 versions of wmake support the use of DLL tools (C/C++ compiler, linker, librarian) through the
!loaddlldirective. Instead of spawning a new process when executing a command, wmake executes the code in a dynamic link library. This method is faster and can speed up builds by 10-30%.
- Built-in commands
- Some frequently used commands, such as echo, are built into wmake. As a result, there is no need to spawn the shell to execute these commands. This may noticeably speed up certain operations, especially on non-UNIX platforms.
Further Reading
Refer to the Tools User's Guide for additional information on wmake. It is one of the manuals shipped with Open Watcom.

