DEPS := ${SRCS:.cpp=.d}
DEPS := $(addprefix ${DEPSDIR},${DEPS})
+BLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) $(addprefix ${OBJSDIR},${DIRS})
+BLDDIRS := $(addsuffix /,${BLDDIRS})
+
VERBOSE := 0
.PHONY: all
all: ${TARGET}
+# how to link the main target
${TARGET}: ${OBJS}
${Q1}echo "${CXX}: $@"
${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS}
+# how to make a directory
+${BLDDIRS}:
+ ${Q2}mkdir -p $@
+
# rule to make a depend file from a .cpp
-${DEPSDIR}%.d: %.cpp
+${DEPSDIR}%.d: %.cpp | ${BLDDIRS}
${Q1}echo "DEP: $@"
${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@
# rule to make an object file from a .cpp
-${OBJSDIR}%.o: %.cpp
+${OBJSDIR}%.o: %.cpp | ${BLDDIRS}
${Q1}echo "${CXX}: $@"
${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<