I have the following directory structure
(root) / / \ \ / | | \ src obj include bin
I would like to use an implicit rule to compile all .cc files in root\src files to .o in root\obj .
This is my makefile:
basedir = . incl = ${basedir}\include obj = ${basedir}\obj src = ${basedir}\src lib = ${basedir}\lib bin = ${basedir}\bin CXX = gcc LDLIBS = -lstdc++ -lmingw32 -lSDLmain -lSDL -lSDL_image -lchipmunk -lSDL_ttf \ -lSDL_mixer LDFLAGS = -L${lib} objects = $(addprefix ${obj}\, GameObject.o PhysicalObject.o \ Terrain.o Timer.o main.o ImageLoader.o Player.o ) sources = $(addprefix ${src}\, GameObject.cc PhysicalObject.cc \ Terrain.cc Timer.cc main.cc ImageLoader.cc Player.cc ) Cyborg : ${objects} ${CXX} ${objects} -o ${bin}\Cyborg.exe -L${lib} ${LDFLAGS} ${LDFLAGS} ${obj}\%.o : ${src}\%.c ${CXX} ${src}\$^ -c -o ${obj}\ $@ .PHONY: clean clean : rm ${bin}\Cyborg.exe ${objects}
The error I get is make: *** No rule to make target .\obj\GameObject.o, needed by Cyborg. Stop. make: *** No rule to make target .\obj\GameObject.o, needed by Cyborg. Stop.
Any idea what goes wrong? I am new to makefiles, so this can be very obvious.
source share