From: Patrik Gornicz Date: Sat, 13 Jun 2009 16:24:09 +0000 (-0400) Subject: added prefixes to tests X-Git-Tag: libbear-premerge~61 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=a98a33a67b1153a67052d9c972d6d4f3093f6805;p=libbear.git added prefixes to tests --- diff --git a/Makefile b/Makefile index cc28ce0..4ea0517 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ include ${G_LISTSMK} # include all of the dir.mk include lib/${G_DIRMK} -#include tests/${G_DIRMK} +include tests/${G_DIRMK} # Do not include deps files when doing a clean operation ifeq ($(filter ${L_CLEANCMDS},${MAKECMDGOALS}),) diff --git a/lib/vars.mk b/lib/vars.mk index 822185b..0eb6e85 100644 --- a/lib/vars.mk +++ b/lib/vars.mk @@ -38,7 +38,7 @@ else T_LIBGL_$P := -lGL -lGLU T_LIBSDL_$P := `sdl-config --libs` endif -LIBS_$P := ${LIBSDL_$P} ${LIBGL_$P} +LIBS_$P := ${T_LIBSDL_$P} ${T_LIBGL_$P} T_LIBGL_$P := T_LIBSDL_$P := diff --git a/targets.mk b/targets.mk index a9d785f..fefa6e3 100644 --- a/targets.mk +++ b/targets.mk @@ -13,6 +13,12 @@ G_LIB_DEPS := lib-deps G_TESTS := tests .PHONY: ${G_TESTS} +G_TESTS_OBJS := tests-objs +.PHONY: ${G_TESTS_OBJS} + +G_TESTS_DEPS := tests-deps +.PHONY: ${G_TESTS_DEPS} + L_CLEANCMDS += cleanbin .PHONY: cleanbin cleanbin: diff --git a/tests/dir.mk b/tests/dir.mk index aa9097d..a324c2b 100644 --- a/tests/dir.mk +++ b/tests/dir.mk @@ -3,29 +3,19 @@ P := tests CURDIR := tests/ -include ${CURDIR}${VARSMK} +include ${CURDIR}${G_VARSMK} + +include ${CURDIR}${G_LISTSMK} # steps on variables -include ${SRCSDIR_$P}${DIRMK} +include ${SRCSDIR_$P}${G_DIRMK} # Restore variables CURDIR := tests/ -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}${G_TVARSMK} -include ${CURDIR}${RULESMK} +include ${CURDIR}${G_RULESMK} -# Do not include deps files when doing a clean operation -ifeq ($(filter ${CLEANCMDS},${MAKECMDGOALS}),) - -include ${DEPS_$P} -endif +L_DEPS += ${L_DEPS_$P} -P := diff --git a/tests/lists.mk b/tests/lists.mk new file mode 100644 index 0000000..db8c309 --- /dev/null +++ b/tests/lists.mk @@ -0,0 +1,12 @@ + +# lists populated by dir.mk files in subdirectories +L_SRCS_$P := # := start +L_OBJS_$P := # := start +L_DEPS_$P := # := start + +L_BLDDIRS_$P := # := start + +L_BLDDIRS_$P += ${OBJSDIR_$P} +L_BLDDIRS_$P += ${DEPSDIR_$P} +L_BLDDIRS_$P += ${WORKINGDIR_$P} + diff --git a/tests/rules.mk b/tests/rules.mk index 5d4d5b1..9a41581 100644 --- a/tests/rules.mk +++ b/tests/rules.mk @@ -1,6 +1,9 @@ +${G_TESTS_OBJS}: ${L_OBJS_$P} +${G_TESTS_DEPS}: ${L_DEPS_$P} + # how to make a directory -${BLDDIRS_$P}: +${L_BLDDIRS_$P}: ${Q1}${PRNTFMT} "mkdir" "$@" ${Q2}mkdir -p $@ @@ -16,31 +19,36 @@ ${DEPSDIR_$P}%.d: ${SRCSDIR_$P}%.cpp | $${@D} ${Q1}${PRNTFMT} "DEP" "$@" ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | sed 's/\(^.*\):/$(subst /,\/,${@:${DEPSDIR}%.d=${OBJSDIR}%.o} $@):/' > $@ -CLEANCMDS += $P-cleanbin + +L_CLEANCMDS += $P-cleanbin +cleanbin: $P-cleanbin .PHONY: $P-cleanbin $P-cleanbin: ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}" ${Q2}rm -rf ${WORKINGDIR} -CLEANCMDS += $P-cleanobjs +L_CLEANCMDS += $P-cleanobjs +cleanobjs: $P-cleanobjs .PHONY: $P-cleanobjs $P-cleanobjs: ${Q1}${PRNTFMT} "rm" "${OBJSDIR}" ${Q2}rm -rf ${OBJSDIR} -CLEANCMDS += $P-cleandeps +L_CLEANCMDS += $P-cleandeps +cleandeps: $P-cleandeps .PHONY: $P-cleandeps $P-cleandeps: ${Q1}${PRNTFMT} "rm" "${DEPSDIR}" ${Q2}rm -rf ${DEPSDIR} -CLEANCMDS += $P-clean +L_CLEANCMDS += $P-clean +clean: $P-clean .PHONY: $P-clean $P-clean: $P-cleanobjs ${Q1}${PRNTFMT} "rm" "${TARGET}" ${Q2}rm -f ${TARGET} -CLEANCMDS += $P-cleanall +L_CLEANCMDS += $P-cleanall +cleanall: $P-cleanall .PHONY: $P-cleanall $P-cleanall: $P-cleanbin $P-cleanobjs $P-cleandeps - diff --git a/tests/src/1/dir.mk b/tests/src/1/dir.mk index 3e8b58d..3d71d3a 100644 --- a/tests/src/1/dir.mk +++ b/tests/src/1/dir.mk @@ -3,25 +3,23 @@ D := tests_src_1 CURDIR := tests/src/1/ SRCPATH := 1/ -include ${CURDIR}${VARSMK} +include ${CURDIR}${G_VARSMK} -SRCS_$D := -OBJS_$D := -DEPS_$D := +include ${CURDIR}${G_LISTSMK} -include ${CURDIR}${FILESMK} +include ${CURDIR}${G_FILESMK} -SRCS_$P += ${SRCS_$D} -OBJS_$P += ${OBJS_$D} -DEPS_$P += ${DEPS_$D} - -include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS})) +include $(addprefix ${SRCSDIR_$P},$(addsuffix ${G_DIRMK},${NEWDIRS})) # restore CURDIR := tests/src/1/ SRCPATH := 1/ +L_SRCS_$P += ${L_SRCS_$D} +L_OBJS_$P += ${L_OBJS_$D} +L_DEPS_$P += ${L_DEPS_$D} + +include ${CURDIR}${G_TVARSMK} -include ${CURDIR}${RULESMK} +include ${CURDIR}${G_RULESMK} -D := diff --git a/tests/src/1/files.mk b/tests/src/1/files.mk index fc724fe..40c479a 100644 --- a/tests/src/1/files.mk +++ b/tests/src/1/files.mk @@ -13,10 +13,10 @@ NEWDEPS := ${NEWSRCS:.cpp=.d} # Append to lists -SRCS_$D += ${NEWSRCS} -OBJS_$D += $(addprefix ${OBJSDIR_$P},${NEWOBJS}) -DEPS_$D += $(addprefix ${DEPSDIR_$P},${NEWDEPS}) +L_SRCS_$D += ${NEWSRCS} +L_OBJS_$D += $(addprefix ${OBJSDIR_$P},${NEWOBJS}) +L_DEPS_$D += $(addprefix ${DEPSDIR_$P},${NEWDEPS}) -BLDDIRS_$P += $(addprefix ${OBJSDIR_$P},${NEWDIRS}) -BLDDIRS_$P += $(addprefix ${DEPSDIR_$P},${NEWDIRS}) +L_BLDDIRS_$P += $(addprefix ${OBJSDIR_$P},${NEWDIRS}) +L_BLDDIRS_$P += $(addprefix ${DEPSDIR_$P},${NEWDIRS}) diff --git a/tests/src/1/lists.mk b/tests/src/1/lists.mk new file mode 100644 index 0000000..c6f716a --- /dev/null +++ b/tests/src/1/lists.mk @@ -0,0 +1,5 @@ + +L_SRCS_$D := +L_OBJS_$D := +L_DEPS_$D := + diff --git a/tests/src/1/rules.mk b/tests/src/1/rules.mk index 4078f22..09d497f 100644 --- a/tests/src/1/rules.mk +++ b/tests/src/1/rules.mk @@ -1,12 +1,11 @@ +${G_TESTS}: ${TARGET_$D} + # how to link the main target -${TARGETTMP_$D}: ${OBJS_$D} | $${@D} +${TARGETTMP_$D}: ${L_OBJS_$D} | $${@D} ${Q1}${PRNTFMT} "${CXX}" "$@" ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS} -# TARGET will be built by default -tests: ${TARGET_$D} - # rule to copy tmp target to working directory ${TARGET_$D}: ${TARGETTMP_$D} | $${@D} ${Q1}${PRNTFMT} "cp" "$@" diff --git a/tests/src/1/tvars.mk b/tests/src/1/tvars.mk new file mode 100644 index 0000000..cda0e6f --- /dev/null +++ b/tests/src/1/tvars.mk @@ -0,0 +1,7 @@ + +${TARGETTMP_$D}: CXX := ${CXX_$D} +${TARGETTMP_$D}: CXXFLAGS := ${CXXFLAGS_$D} +${TARGETTMP_$D}: LNKFLAGS := ${LNKFLAGS_$D} +${TARGETTMP_$D}: LIBS := ${LIBS_$D} + +$P-clean: TARGET := ${TARGET_$D} diff --git a/tests/src/1/vars.mk b/tests/src/1/vars.mk index b1ffe30..16e650b 100644 --- a/tests/src/1/vars.mk +++ b/tests/src/1/vars.mk @@ -1,17 +1,10 @@ -ifeq (${BUILD},WIN32) - LIBGL_$D := -lopengl32 -lglu32 - LIBSDL_$D := `/usr/mingw32/bin/sdl-config --libs` -else - LIBGL_$D := -lGL -lGLU - LIBSDL_$D := `sdl-config --libs` -endif -LIBS_$D := ${LIBSDL_$D} ${LIBGL_$D} +CXX_$D := ${CXX_$P} +CXXFLAGS_$D := ${CXXFLAGS_$P} +LNKFLAGS_$D := ${LNKFLAGS_$P} +LIBS_$D := ${LIBS_$P} TARGETNAME_$D := test-1 TARGETTMP_$D := ${OBJSDIR_$P}${TARGETNAME_$D} TARGET_$D := ${WORKINGDIR_$P}${TARGETNAME_$D} -${TARGETTMP_$D}: LNKFLAGS := -Wl,-rpath,${RPATH_$P} -rdynamic -${TARGETTMP_$D}: LIBS := ${LIBS_$P} - diff --git a/tests/src/dir.mk b/tests/src/dir.mk index e475657..39dd426 100644 --- a/tests/src/dir.mk +++ b/tests/src/dir.mk @@ -2,5 +2,5 @@ CURDIR := tests/src/ SRCPATH := -include ${CURDIR}${FILESMK} -include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS})) +include ${CURDIR}${G_FILESMK} +include $(addprefix ${SRCSDIR_$P},$(addsuffix ${G_DIRMK},${NEWDIRS})) diff --git a/tests/src/files.mk b/tests/src/files.mk index 7167774..92433f2 100644 --- a/tests/src/files.mk +++ b/tests/src/files.mk @@ -15,10 +15,10 @@ NEWDEPS := ${NEWSRCS:.cpp=.d} # Append to lists -SRCS_$P += ${NEWSRCS} -OBJS_$P += $(addprefix ${OBJSDIR_$P},${NEWOBJS}) -DEPS_$P += $(addprefix ${DEPSDIR_$P},${NEWDEPS}) +L_SRCS_$P += ${NEWSRCS} +L_OBJS_$P += $(addprefix ${OBJSDIR_$P},${NEWOBJS}) +L_DEPS_$P += $(addprefix ${DEPSDIR_$P},${NEWDEPS}) -BLDDIRS_$P += $(addprefix ${OBJSDIR_$P},${NEWDIRS}) -BLDDIRS_$P += $(addprefix ${DEPSDIR_$P},${NEWDIRS}) +L_BLDDIRS_$P += $(addprefix ${OBJSDIR_$P},${NEWDIRS}) +L_BLDDIRS_$P += $(addprefix ${DEPSDIR_$P},${NEWDIRS}) diff --git a/tests/tvars.mk b/tests/tvars.mk new file mode 100644 index 0000000..6afc32d --- /dev/null +++ b/tests/tvars.mk @@ -0,0 +1,11 @@ + +${L_OBJS_$P} ${L_DEPS_$P}: CXX := ${CXX_$P} +${L_OBJS_$P} ${L_DEPS_$P}: CXXFLAGS := ${CXXFLAGS_$P} +${L_OBJS_$P} ${L_DEPS_$P}: INCFLAGS := ${INCFLAGS_$P} + ${L_DEPS_$P}: DEPSDIR := ${DEPSDIR_$P} + ${L_DEPS_$P}: OBJSDIR := ${OBJSDIR_$P} + +$P-cleanbin: WORKINGDIR := ${WORKINGDIR_$P} +$P-cleanobjs: OBJSDIR := ${OBJSDIR_$P} +$P-cleandeps: DEPSDIR := ${DEPSDIR_$P} + diff --git a/tests/vars.mk b/tests/vars.mk index d0f837d..4d9e0cf 100644 --- a/tests/vars.mk +++ b/tests/vars.mk @@ -1,9 +1,27 @@ -CXXFLAGS_$P := ${CXXFLAGS} +CXX_$P := ${G_CXX} +CXXFLAGS_$P := ${G_CXXFLAGS} +LNKFLAGS_$P := ${G_LNKFLAGS} -Wl,-rpath,./ -rdynamic + +ifeq (${BUILD},WIN32) + T_LIBGL_$P := -lopengl32 -lglu32 + T_LIBSDL_$P := `/usr/mingw32/bin/sdl-config --libs` +else + T_LIBGL_$P := -lGL -lGLU + T_LIBSDL_$P := `sdl-config --libs` +endif +LIBS_$P := ${T_LIBSDL_$P} ${T_LIBGL_$P} + +T_LIBGL_$P := +T_LIBSDL_$P := + SRCSDIR_$P := ${CURDIR}src/ DEPSDIR_$P := ${CURDIR}deps/ -INCDIRS_$P := lib/inc/ + +T_INCDIRS_$P := lib/inc/ +INCFLAGS_$P := $(addprefix -I, ${T_INCDIRS_$P}) +T_INCDIRS_$P := ifeq (${BUILD},WIN32) OBJSDIR_$P := ${CURDIR}objs-mingw32/ @@ -32,18 +50,3 @@ LIBSCPY_$P := # := start LIBSCPY_$P += libbear.so.0 LIBSCPY_$P := $(addprefix ${DSTLIBSDIR_$P},${LIBSCPY_$P}) - -RPATH_$P := ./ - - -# lists populated by dir.mk files in subdirectories -SRCS_$P := # := start -OBJS_$P := # := start -DEPS_$P := # := start - -BLDDIRS_$P := # := start - -BLDDIRS_$P += ${OBJSDIR_$P} -BLDDIRS_$P += ${DEPSDIR_$P} -BLDDIRS_$P += ${WORKINGDIR_$P} - diff --git a/vars.mk b/vars.mk index 5eb8ec4..58fb8d4 100644 --- a/vars.mk +++ b/vars.mk @@ -1,7 +1,7 @@ T_OPTFLAGS := -O2 T_DBGFLAGS := -ggdb -T_PRFFLAGS := ${G_DBGFLAGS} -pg +T_PRFFLAGS := ${T_DBGFLAGS} -pg T_WARFLAGS := -Wall -Wextra -pedantic -ansi G_CXXFLAGS := ${T_WARFLAGS} @@ -20,6 +20,7 @@ T_DBGFLAGS := T_PRFFLAGS := T_WARFLAGS := +G_LNKFLAGS := ifeq (${BUILD},WIN32) G_CXX := mingw32-g++