I am trying to use Makefile to compile a bunch of .cpp
files located in src/code/*.cpp
, then compile each *.o
in build/
,
Your patsubst
function is wrong; you can't use shell wildcard characters like *
. You want:
OBJECTS = $(patsubst $(SOURCEDIR)/%.cpp,$(BUILDDIR)/%.o,$(SOURCES))
Also you should be using SOURCEDIR
and BUILDDIR
everywhere, not just in some places (otherwise you'll get inconsistencies). And finally, your SOURCEDIR value is wrong: it should not start with /
I expect:
SOURCEDIR = src/code
SOURCES = $(wildcard $(SOURCEDIR)/*.cpp)