I have project folder with src, obj and inc dirs.
I declare var with obj - OBJS
SDIR = src
ODIR = obj
# I change /src/*.c to /obj/*.o
_OBJS = $(patsubst %.c, %.o, $(wildcard $(SDIR)/*.c))
# I need to change /src/*.o to /obj/*.o
OBJS = $(??? $ODIR ??? $_OBJS ???)
Now in _OBJS - ./src/*.o, How to change in OBJS /src/ to /obj/?
Thanks.
What about this (if I understand the question correctly):
SDIR = src
ODIR = obj
# I change /src/*.c to /obj/*.o
_OBJS = $(patsubst %.c, %.o, $(wildcard $(SDIR)/*.c))
# I need to change /src/*.o to /obj/*.o
_OBJS := $(subst $(SDIR), $(ODIR), $(_OBJS))
debug:
@echo $(_OBJS)
Output/Test:
$ mkdir ./src/
$ touch ./src/a.c
$ touch ./src/b.c
$ touch ./src/c.c
$ ls ./src/
a.c b.c c.c
$ make debug
obj/a.o obj/b.o obj/c.o
_OBJS = $(patsubst %.c, %.o, $(wildcard $(SDIR)/*.c))
_OBJS := $(notdir $(_OBJS))
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
But, I think, its bad way
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