TARGETTMP := ${OBJSDIR}${TARGETNAME}
TARGET := ${WORKINGDIR}${TARGETNAME}
-BLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) $(addprefix ${OBJSDIR},${DIRS}) ${WORKINGDIR}
+DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS})
+OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS})
+BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR}
VERBOSE := 0
all: ${TARGET}
# rule to copy tmp target to working directory
-${TARGET}: ${TARGETTMP}
+${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
${Q1}echo "cp: $@"
${Q2}cp $^ $@
${Q2}mkdir -p $@
# rule to make a depend file from a .cpp
-${DEPSDIR}%.d: %.cpp | ${BLDDIRS}
+${DEPSDIR}%.d: %.cpp | ${DEPSBLDDIRS}
${Q1}echo "DEP: $@"
${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@
# rule to make an object file from a .cpp
-${OBJSDIR}%.o: %.cpp | ${BLDDIRS}
+${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS}
${Q1}echo "${CXX}: $@"
${Q2}${CXX} ${CXXFLAGS} -c -o $@ $<