Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makefile notdir command

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.

like image 504
user1051003 Avatar asked Sep 06 '25 06:09

user1051003


2 Answers

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)))
like image 196
Eldar Abusalimov Avatar answered Sep 09 '25 20:09

Eldar Abusalimov


$(addprefix $(OBJDIR),$(notdir $(SOURCECODE:.c=.o)))
like image 30
thiton Avatar answered Sep 09 '25 20:09

thiton