patsubst in makefile

hi,
I have .cpp files in 2 subdirectories within my ../src directory,
so the file structure is:
../src/subdir1/file1.cpp
../src/subdir2/file2.cpp

I am trying to use patsubst as follows:
1
2
3
4
5
6
7
8
SRCDIR = $(shell echo ../src/*)
libname := $(notdir $(basename $(SRCDIR)))
OBJDIR = ../objs
OBJDIRS := $(addprefix $(OBJDIR)/,$(libname))
find_cppfiles = $(wildcard $(dir)/*.cpp)
cppsources :=$(foreach dir, $(SRCDIR),$(find_cppfiles)) 
cppobjects :=$(patsubst $(SRCDIR)/%.cpp,$(OBJDIRS)/%.o, $(cppsources))
echo $(cppsources) $(cppobjects) */

but it doesn't work....the echo command returns:
../src/subdir1/file1.cpp
../src/subdir2/file2.cpp
../src/subdir1/file1.cpp
../src/subdir2/file2.cpp

Can you please let me know how I can fix this so that echo $(cppobjects) returns:
../objs/subdir1/file1.o
../objs/subdir2/file2.o

thanks!
Last edited on
Topic archived. No new replies allowed.