In short: I want to compile sources from different directories and put the object files in the current directory.
For example, I have files:
test.c
../../lib1/boot.c
../../lib2/startup.c
../common/utils.c
(there are also few .s (assembly) and .cpp files, but I hope this is not important).
All their object files I want to be in the current directory:
test.o
boot.o
startup.o
utils.o
And I canβt understand how to write such a rule in my makefile.
For instance,
%o.: %.c
now it doesnβt work, because it makecannot find a rule for building boot.ofrom ../../lib1/boot.c, it can only find a rule for building ../../lib1/boot.ofrom ../../lib1/boot.c.
I tried using this:
%o.: %.c
(my compilation line, for example "gcc -c $^ -o $@")
%o.: ../../lib1/%.c
(my compilation line)
%o.: ../../lib2/%.c
(my compilation line)
%o.: ../common/%.c
(my compilation line)
. , , , , , , ../../some_other_lib/common_things.c, makefile . . . .
, : - , ( ) , ?
.