Skip to content
Search

Make:MacroRule

lastmod 2018-08-17created 2018-06-181 edits

A description of Make's macro rules.

About

Macros are defined the same way as setting environment variables in a shell script. By convention, macros use only uppercase letters and underscores (_). To use a macro, use $(...).

Macro substitution

To change only part of a macro's contents, use the form $(MACRO_NAME:OLD=NEW).

OBJS = main.o read.o write.o
SRCS = $(OBJS:.o=.c)

In the example above, .o in OBJS is changed to .c. That is, it becomes the following.

SRCS = main.c read.c write.c

See also