my source files are not inside of one directory which I need to do ../ or ../../ stuff.
after that, I need to change source file name for example: ../ex/test.c to obj/test.o
with this: command:
$(OBJDIR) $(notdir $(SOURCECODE:.c=.o))
however only first filename in $(SOURCECODE)
(../ex/test.c
) is correctly renamed to obj/test.o, the rest all look like *.o
, without directory information.
That's because you prepend $(OBJDIR)
to the list as is: obj/
+ foo.c bar.c baz.c
gives obj/foo.c bar.c baz.c
, which is not what you want.
To add directory to each file in your list use addprefix
function:
$(addprefix $(OBJDIR),$(notdir $(SOURCECODE:.c=.o)))
$(addprefix $(OBJDIR),$(notdir $(SOURCECODE:.c=.o)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With