bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implicit rule for linking multiple object files


From: ljh
Subject: Implicit rule for linking multiple object files
Date: Thu, 11 Aug 2022 01:58:29 +0800

Hello list,

GNU Make Manual / 10.2 / Linking a single object file, mentions this:
    x: y.o z.o 

I have three c source files: x.c, y.c, z.c and I name x as the target on left. Can I put x.o in the prerequisites on the right too? Are they the same, with or without x.o in the prerequisites on the right?    
    x: y.o z.o x.o  # with x.o

Is it correct for me to use patsubst function to include all object files?
    x: $(patsubst %.c,%.o,$(wildcard *.c))

In my test the rule with patsubst works on most cases. But if my code uses C++20 modules, I need to omit x.o if I want to omit the recipe:
    x: y.o z.o  # without x.o and recipe

if I include x.o, I can't omit the recipe:
    ` x: y.o z.o x.o ` # with x.o 
    `    $ (CXX) $ (LDFLAGS) $^ $(LDLIBS) -o $@ ` # with recipe

Thanks

reply via email to

[Prev in Thread] Current Thread [Next in Thread]