makefile GNU Pattern Rules Basic Pattern Rule

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

A pattern rule is indicated by a single % character in the target. The % matches a non-empty string called the stem. The stem is then substituted for every % that appears in the prerequisite list.

For example, this rule:

%.o: %.c
    $(CC) $(CFLAGS) -c $< -o $@

Will match any target ending in .o. If the target was foo.o, the stem would be foo and it would compile foo.c to foo.o. Targets and prerequisites can be accessed using automatic variables.



Got any makefile Question?