2.10 Directives

Makefile directives control the makefile lines omake reads at read time. The following makefile uses conditional directives (%if, %elif, %else, and %endif) to support both Borland and Microsoft compilers. Comments have been added for documentation.

# This makefile compiles for the configuration specified
# in the CFG macro.

CFG

= Release

OBJS

= main.obj io.obj

# Configuration-dependent section

%if $(CFG)

== Release

CFLAGS

= /O1

LINK_FLAGS

=

%elif $(CFG)

== Debug

CFLAGS

= /Od /Zi

LINK_FLAGS

= /debug

%else

%abort Unsupported configuration $(CFG)

%endif

project.exe: $(OBJS)

link /out:$(.TARGET) $(LINK_FLAGS) $(OBJS)

%.obj: %.c

cl $(CFLAGS) /c $(.SOURCE)

The layout of this makefile is fairly traditional; macros are defined first, and the primary target follows the macros.

This example also uses the %abort directive to abort omake if the makefile does not support a particular compiler. Directives can also be used at run time, to control the build scripts omake executes. For more information, see Makefile Directives.