# how to link the main target
-${TARGETTMP_$P}: ${L_OBJS_$P} | $${@D}
+${TARGETTMP_$P}: ${L_OBJS_$P} | $${SS_DIR}
${cmd-link}
# rule to copy tmp target to working directory
-${TARGET_$P}: ${TARGETTMP_$P} | $${@D}
+${TARGET_$P}: ${TARGETTMP_$P} | $${SS_DIR}
${cmd-cp}
# rule to make an object file from a .cpp
-${OBJSDIR_$P}%.o: ${SRCSDIR_$P}%.cpp | $${@D} \
- $$(patsubst ${OBJSDIR_$P},${DEPSDIR_$P},$${@D})
+${OBJSDIR_$P}/%.o: ${SRCSDIR_$P}/%.cpp | $${SS_DIR} $${call SS_DEPSDIR,$P}
${cmd-cpp_to_obj_and_dep}
${Q4s}${CXX} -c $< -o $@ -MF ${@:${OBJSDIR}%.o=${DEPSDIR}%.d} ${CXXFLAGS} ${INCFLAGS} -MMD -MQ $@ ${Q4e}
endef
-# Deprecated, use cmd-cpptoobjdep to create obj and dep
-define cmd-cpptoobj
- ${Q1s}${PRNTLOG} "${CXX}" "$@" ${Q1e}
- ${Q2s}${PRNTFMT} "${CXX}" "$@" ${Q2e}
- ${Q3s}${CXX} $< -o $@ ${CXXFLAGS} ${INCFLAGS} -c ${Q3e}
- ${Q4s}${CXX} $< -o $@ ${CXXFLAGS} ${INCFLAGS} -c ${Q4e}
-endef
-
${L_BLDDIRS}:
${Q1s}${PRNTLOG} "mkdir" "$@" ${Q1e}
${G_DEPS_TESTS}: ${L_DEPS_$P}
# how to copy a library to the tests bin directory
-${BINDIR_$P}/${SONAME_${G_LIB}}: ${TARGET_${G_LIB}} | $${@D}
+${BINDIR_$P}/${SONAME_${G_LIB}}: ${TARGET_${G_LIB}} | $${SS_DIR}
${cmd-cp}
# rule to make an object file from a .cpp
-${OBJSDIR_$P}%.o: ${SRCSDIR_$P}%.cpp | $${@D}
- ${cmd-cpptoobj}
-
-# rule to make a depend file from a .cpp
-${DEPSDIR_$P}%.d: ${SRCSDIR_$P}%.cpp | $${@D}
- ${cmd-cpptodep}
+${OBJSDIR_$P}/%.o: ${SRCSDIR_$P}/%.cpp | $${SS_DIR} $${call SS_DEPSDIR,$P}
+ ${cmd-cpp_to_obj_and_dep}
T := $P
-# cause the fancy $${@D} directory rules to work out
+# cause the fancy SS_ directory rules to work out
.SECONDEXPANSION:
+# The SS rules need to be 'recursive' so they evaluate the @ variables at
+# secondary expansion time
+SS_DIR = ${@D}
+
+# Warning this secondary expansion rule is very very sensitive
+# tricks are needed to make things work because the stem % does not match
+# empty also, it is used by the call syntax as the package variable needs to be
+# invoked as usage time while the rest has to be delayed till secondary
+# expansion.
+SS_DEPSDIR = $(patsubst %/,%,$(patsubst ${OBJSDIR_$(1)}%,${DEPSDIR_$(1)}%,$(dir $@)))
+
+
B_DEBUG := DEBUG
B_FINAL := FINAL
B_WIN32 := WIN32