# include all of the dir.mk
include lib/${DIRMK}
-#include tests/${DIRMK}
+include tests/${DIRMK}
-INCFLAGS_$P := $(addprefix -I, ${INCDIRS_$P})
-
# add flags specific to the library target and all prerequisites
-${OBJS_$P} ${DEPS_$P}: CXXFLAGS += -fPIC
-${OBJS_$P} ${DEPS_$P}: INCFLAGS += ${INCFLAGS_$P}
+${OBJS_$P} ${DEPS_$P}: CXXFLAGS := ${CXXFLAGS_$P}
+${OBJS_$P} ${DEPS_$P}: INCFLAGS := ${INCFLAGS_$P}
+ ${DEPS_$P}: OBJSDIR := ${OBJSDIR_$P}
-${TARGETTMP_$P}: LNKFLAGS += -shared -Wl,-soname,${SONAME_$P}
-${TARGETTMP_$P}: LIBS += ${LIBS_$P}
+${TARGETTMP_$P}: LNKFLAGS := ${LNKFLAGS_$P}
+${TARGETTMP_$P}: LIBS := ${LIBS_$P}
+$P-cleanbin: WORKINGDIR := ${WORKINGDIR_$P}
+$P-cleanobjs: OBJSDIR := ${OBJSDIR_$P}
+$P-cleandeps: DEPSDIR := ${DEPSDIR_$P}
+$P-clean: TARGET := ${TARGET_$P}
cleanbin: $P-cleanbin
.PHONY: $P-cleanbin
$P-cleanbin:
- ${Q1}${PRNTFMT} "rm" "${WORKINGDIR_$P}"
- ${Q2}rm -rf ${WORKINGDIR_$P}
+ ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
+ ${Q2}rm -rf ${WORKINGDIR}
CLEANCMDS += $P-cleanobjs
cleanobjs: $P-cleanobjs
.PHONY: $P-cleanobjs
$P-cleanobjs:
- ${Q1}${PRNTFMT} "rm" "${OBJSDIR_$P}"
- ${Q2}rm -rf ${OBJSDIR_$P}
+ ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
+ ${Q2}rm -rf ${OBJSDIR}
CLEANCMDS += $P-cleandeps
cleandeps: $P-cleandeps
.PHONY: $P-cleandeps
$P-cleandeps:
- ${Q1}${PRNTFMT} "rm" "${DEPSDIR_$P}"
- ${Q2}rm -rf ${DEPSDIR_$P}
+ ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
+ ${Q2}rm -rf ${DEPSDIR}
CLEANCMDS += $P-clean
clean: $P-clean
.PHONY: $P-clean
$P-clean: $P-cleanobjs
- ${Q1}${PRNTFMT} "rm" "${TARGET_$P}"
- ${Q2}rm -f ${TARGET_$P}
+ ${Q1}${PRNTFMT} "rm" "${TARGET}"
+ ${Q2}rm -f ${TARGET}
CLEANCMDS += $P-cleanall
cleanall: $P-cleanall
+CXXFLAGS_$P := ${CXXFLAGS} -fPIC
+
SRCSDIR_$P := ${CURDIR}src/
DEPSDIR_$P := ${CURDIR}deps/
INCDIRS_$P := ${SRCSDIR_$P} ${CURDIR}inc/
+INCFLAGS_$P := $(addprefix -I, ${INCDIRS_$P})
+
+
ifeq (${BUILD},WIN32)
OBJSDIR_$P := ${CURDIR}objs-mingw32/
else
REALNAME_$P := libbear.so.0.0
endif
+LNKFLAGS_$P := -shared -Wl,-soname,${SONAME_$P}
+
TARGETTMP_$P := ${OBJSDIR_$P}${REALNAME_$P}
TARGET_$P := ${WORKINGDIR_$P}${REALNAME_$P}
+# Package name
+P := tests
CURDIR := tests/
-#SRCPATH := # Not used at this level
include ${CURDIR}${VARSMK}
# steps on variables
-include ${SRCSDIR}${DIRMK}
+include ${SRCSDIR_$P}${DIRMK}
# Restore variables
CURDIR := tests/
-#SRCPATH := # Not used at this level
+
+INCFLAGS_$P := $(addprefix -I, ${INCDIRS_$P})
+${OBJS_$P} ${DEPS_$P}: CXXFLAGS := ${CXXFLAGS_$P}
+${OBJS_$P} ${DEPS_$P}: INCFLAGS := ${INCFLAGS_$P}
+ ${DEPS_$P}: OBJSDIRS := ${OBJSDIRS_$P}
+
+$P-cleanbin: WORKINGDIR := ${WORKINGDIR_$P}
+$P-cleanobjs: OBJSDIR := ${OBJSDIR_$P}
+$P-cleandeps: DEPSDIR := ${DEPSDIR_$P}
+$P-clean: TARGET := ${TARGET_$P}
include ${CURDIR}${RULESMK}
# Do not include deps files when doing a clean operation
ifeq ($(filter ${CLEANCMDS},${MAKECMDGOALS}),)
- -include ${DEPS}
+ -include ${DEPS_$P}
endif
+
+P :=
# how to make a directory
-${BLDDIRS}:
+${BLDDIRS_$P}:
${Q1}${PRNTFMT} "mkdir" "$@"
${Q2}mkdir -p $@
# rule to make an object file from a .cpp
-${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $${@D}
+${OBJSDIR_$P}%.o: ${SRCSDIR_$P}%.cpp | $${@D}
${Q1}${PRNTFMT} "${CXX}" "$@"
${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
# rule to make a depend file from a .cpp
# be clever and escape the / chars in file paths
# DON'T simply use another sed delimiter or it can't appear in the file paths
-${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $${@D}
+${DEPSDIR_$P}%.d: ${SRCSDIR_$P}%.cpp | $${@D}
${Q1}${PRNTFMT} "DEP" "$@"
${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
+CLEANCMDS += $P-cleanbin
+.PHONY: $P-cleanbin
+$P-cleanbin:
+ ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
+ ${Q2}rm -rf ${WORKINGDIR}
+
+CLEANCMDS += $P-cleanobjs
+.PHONY: $P-cleanobjs
+$P-cleanobjs:
+ ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
+ ${Q2}rm -rf ${OBJSDIR}
+
+CLEANCMDS += $P-cleandeps
+.PHONY: $P-cleandeps
+$P-cleandeps:
+ ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
+ ${Q2}rm -rf ${DEPSDIR}
+
+CLEANCMDS += $P-clean
+.PHONY: $P-clean
+$P-clean: $P-cleanobjs
+ ${Q1}${PRNTFMT} "rm" "${TARGET}"
+ ${Q2}rm -f ${TARGET}
+
+CLEANCMDS += $P-cleanall
+.PHONY: $P-cleanall
+$P-cleanall: $P-cleanbin $P-cleanobjs $P-cleandeps
+
+D := tests_src_1
CURDIR := tests/src/1/
SRCPATH := 1/
include ${CURDIR}${VARSMK}
+
+SRCS_$D :=
+OBJS_$D :=
+DEPS_$D :=
+
include ${CURDIR}${FILESMK}
-include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS}))
+
+SRCS_$P += ${SRCS_$D}
+OBJS_$P += ${OBJS_$D}
+DEPS_$P += ${DEPS_$D}
+
+include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS}))
# restore
CURDIR := tests/src/1/
SRCPATH := 1/
+
include ${CURDIR}${RULESMK}
+
+D :=
# Append to lists
-SRCS += ${NEWSRCS}
-OBJS += $(addprefix ${OBJSDIR},${NEWOBJS})
-DEPS += $(addprefix ${DEPSDIR},${NEWDEPS})
+SRCS_$D += ${NEWSRCS}
+OBJS_$D += $(addprefix ${OBJSDIR_$P},${NEWOBJS})
+DEPS_$D += $(addprefix ${DEPSDIR_$P},${NEWDEPS})
-BLDDIRS += $(addprefix ${OBJSDIR},${NEWDIRS})
-BLDDIRS += $(addprefix ${DEPSDIR},${NEWDIRS})
+BLDDIRS_$P += $(addprefix ${OBJSDIR_$P},${NEWDIRS})
+BLDDIRS_$P += $(addprefix ${DEPSDIR_$P},${NEWDIRS})
# how to link the main target
-${TARGETTMP}: ${OBJS} | $${@D}
+${TARGETTMP_$D}: ${OBJS_$D} | $${@D}
${Q1}${PRNTFMT} "${CXX}" "$@"
${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
# TARGET will be built by default
-tests: ${TARGET}
+tests: ${TARGET_$D}
# rule to copy tmp target to working directory
-${TARGET}: ${TARGETTMP} | $${@D}
+${TARGET_$D}: ${TARGETTMP_$D} | $${@D}
${Q1}${PRNTFMT} "cp" "$@"
${Q2}cp $< $@
ifeq (${BUILD},WIN32)
- LIBGL := -lopengl32 -lglu32
- LIBSDL := `/usr/mingw32/bin/sdl-config --libs`
+ LIBGL_$D := -lopengl32 -lglu32
+ LIBSDL_$D := `/usr/mingw32/bin/sdl-config --libs`
else
- LIBGL := -lGL -lGLU
- LIBSDL := `sdl-config --libs`
+ LIBGL_$D := -lGL -lGLU
+ LIBSDL_$D := `sdl-config --libs`
endif
-LIBS := ${LIBSDL} ${LIBGL}
+LIBS_$D := ${LIBSDL_$D} ${LIBGL_$D}
-TARGETNAME := test-1
-TARGETTMP := ${OBJSDIR}${TARGETNAME}
-TARGET := ${WORKINGDIR}${TARGETNAME}
+TARGETNAME_$D := test-1
+TARGETTMP_$D := ${OBJSDIR_$P}${TARGETNAME_$D}
+TARGET_$D := ${WORKINGDIR_$P}${TARGETNAME_$D}
-# HACK needed for deps
-INCFLAGS += $(addprefix -I, ${INCDIRS})
-
-# add flags specific to the library target and all prerequisites
-${TARGET}: CXXFLAGS += -fPIC
-${TARGET}: INCFLAGS += $(addprefix -I, ${INCDIRS})
-${TARGET}: LNKFLAGS += -Wl,-rpath,${RPATH} -rdynamic
+${TARGETTMP_$D}: LNKFLAGS := -Wl,-rpath,${RPATH_$P} -rdynamic
+${TARGETTMP_$D}: LIBS := ${LIBS_$P}
SRCPATH :=
include ${CURDIR}${FILESMK}
-include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS}))
+include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS}))
# Append to lists
-SRCS += ${NEWSRCS}
-OBJS += $(addprefix ${OBJSDIR},${NEWOBJS})
-DEPS += $(addprefix ${DEPSDIR},${NEWDEPS})
+SRCS_$P += ${NEWSRCS}
+OBJS_$P += $(addprefix ${OBJSDIR_$P},${NEWOBJS})
+DEPS_$P += $(addprefix ${DEPSDIR_$P},${NEWDEPS})
-BLDDIRS += $(addprefix ${OBJSDIR},${NEWDIRS})
-BLDDIRS += $(addprefix ${DEPSDIR},${NEWDIRS})
+BLDDIRS_$P += $(addprefix ${OBJSDIR_$P},${NEWDIRS})
+BLDDIRS_$P += $(addprefix ${DEPSDIR_$P},${NEWDIRS})
-SRCSDIR := ${CURDIR}src/
-DEPSDIR := ${CURDIR}deps/
-INCDIRS := ${SRCSDIR} lib/inc/
+CXXFLAGS_$P := ${CXXFLAGS}
+
+SRCSDIR_$P := ${CURDIR}src/
+DEPSDIR_$P := ${CURDIR}deps/
+INCDIRS_$P := lib/inc/
ifeq (${BUILD},WIN32)
- OBJSDIR := ${CURDIR}objs-mingw32/
+ OBJSDIR_$P := ${CURDIR}objs-mingw32/
else
ifeq (${BUILD},FINAL)
- OBJSDIR := ${CURDIR}objs/
+ OBJSDIR_$P := ${CURDIR}objs/
else
- OBJSDIR := ${CURDIR}objsd/
+ OBJSDIR_$P := ${CURDIR}objsd/
endif
endif
ifeq (${BUILD},WIN32)
- WORKINGDIR := ${CURDIR}bin-mingw32/
+ WORKINGDIR_$P := ${CURDIR}bin-mingw32/
else
ifeq (${BUILD},FINAL)
- WORKINGDIR := ${CURDIR}bin/
+ WORKINGDIR_$P := ${CURDIR}bin/
else
- WORKINGDIR := ${CURDIR}bind/
+ WORKINGDIR_$P := ${CURDIR}bind/
endif
endif
-SRCLIBSDIR := ${CURDIR}libs/
-DSTLIBSDIR := ${WORKINGDIR}
+SRCLIBSDIR_$P := ${CURDIR}libs/
+DSTLIBSDIR_$P := ${WORKINGDIR_$P}
-LIBSCPY := # := start
-LIBSCPY += libbear.so.0
-LIBSCPY := $(addprefix ${DSTLIBSDIR},${LIBSCPY})
+LIBSCPY_$P := # := start
+LIBSCPY_$P += libbear.so.0
+LIBSCPY_$P := $(addprefix ${DSTLIBSDIR_$P},${LIBSCPY_$P})
-RPATH := ./
+RPATH_$P := ./
# lists populated by dir.mk files in subdirectories
-SRCS := # := start
-OBJS := # := start
-DEPS := # := start
+SRCS_$P := # := start
+OBJS_$P := # := start
+DEPS_$P := # := start
-BLDDIRS := # := start
+BLDDIRS_$P := # := start
-BLDDIRS += ${OBJSDIR}
-BLDDIRS += ${DEPSDIR}
-BLDDIRS += ${WORKINGDIR}
+BLDDIRS_$P += ${OBJSDIR_$P}
+BLDDIRS_$P += ${DEPSDIR_$P}
+BLDDIRS_$P += ${WORKINGDIR_$P}