On Sat, Aug 9, 2025 at 3:31 PM lijh.8 via Users list for the GNU
implementation of make <help-make@gnu.org> wrote:

> But how can the linking rule match multiple object files

Usually you list all your object files in your makefile.
For example

hello.tsk: hello.o main.o; $(CC) $(LDFLAGS) -o $@ $^
%.o: %.c; $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<

here we build hello.tsk from hello.o and main.o.
The pattern rule relieves us from writing an individual rule for
compilation of each object file.
There is one rule for hello.tsk regardless of the number of object
files. All the object files listed are prerequisites of our target in
this rule.

regards, Dmitry

Reply via email to