From 6b7bcb90df526b1a28fc290f511c2ae830fa739f Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Sat, 20 Jun 2009 15:39:33 -0400 Subject: [PATCH] fixed makefile hack to get tests depending on libs tests can now depend on libs cleanly tests CANNOT depend on tests libs CANNOT depend on tests this fixes the BUILD=FINAL bug when building tests --- Makefile | 6 ++++-- lib/dir.mk | 2 -- lib/vars.mk | 14 +++++++++++++- targets.mk | 3 +++ tests/rules.mk | 4 ++-- tests/src/1/rules.mk | 4 ++-- tests/src/printTrace/rules.mk | 4 ++-- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2c44e89..138bb33 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,13 @@ G_LISTSMK := lists.mk G_TVARSMK := tvars.mk include ${G_LISTSMK} +include ${G_VARSMK} include packages.mk -include targets.mk -include ${G_VARSMK} +include lib/${G_VARSMK} + +include targets.mk # include all of the dir.mk include lib/${G_DIRMK} diff --git a/lib/dir.mk b/lib/dir.mk index 9f379fe..70d24f1 100644 --- a/lib/dir.mk +++ b/lib/dir.mk @@ -11,8 +11,6 @@ CURDIR := ${DIRNAME}/ T_DIRNAME := -include ${CURDIR}${G_VARSMK} - include ${CURDIR}${G_LISTSMK} include ${SRCSDIR_$P}${G_DIRMK} diff --git a/lib/vars.mk b/lib/vars.mk index 0969478..9c851a9 100644 --- a/lib/vars.mk +++ b/lib/vars.mk @@ -1,4 +1,17 @@ +T_DIRNAME := lib + +################################################################################ + +# top define +DIRNAME := ${T_DIRNAME} +D := ${DIRNAME} +P := ${P_LIB} +CURDIR := ${DIRNAME}/ + +T_DIRNAME := + + CXX_$P := ${G_CXX} CXXFLAGS_$P := ${G_CXXFLAGS} -fPIC LIBS_$P := ${G_LIBSDL} ${G_LIBGL} @@ -45,5 +58,4 @@ endif LNKFLAGS_$P := ${G_LNKFLAGS} -shared -Wl,-soname,${SONAME_$P} TARGETTMP_$P := ${OBJSDIR_$P}${REALNAME_$P} -TARGET_$P := ${WORKINGDIR_$P}${REALNAME_$P} diff --git a/targets.mk b/targets.mk index e7503a6..90e8b6c 100644 --- a/targets.mk +++ b/targets.mk @@ -8,6 +8,9 @@ G_OBJS_LIB := objs-${G_LIB} G_DEPS_LIB := deps-${G_LIB} .PHONY: ${G_DEPS_LIB} +TARGET_${G_LIB} := ${WORKINGDIR_${G_LIB}}${REALNAME_${G_LIB}} + + G_TESTS := ${P_TESTS} .PHONY: ${G_TESTS} diff --git a/tests/rules.mk b/tests/rules.mk index 67aaab6..303c0ca 100644 --- a/tests/rules.mk +++ b/tests/rules.mk @@ -2,8 +2,8 @@ ${G_OBJS_TESTS}: ${L_OBJS_$P} ${G_DEPS_TESTS}: ${L_DEPS_$P} -# HACK -tests/bind/libbear.so.0: lib/bind/libbear.so.0.0 | $${@D} +# how to copy a library to the tests bin directory +${WORKINGDIR_$P}${SONAME_${G_LIB}}: ${TARGET_${G_LIB}} | $${@D} ${cmd-cp} # rule to make an object file from a .cpp diff --git a/tests/src/1/rules.mk b/tests/src/1/rules.mk index 130bab4..f32fe5f 100644 --- a/tests/src/1/rules.mk +++ b/tests/src/1/rules.mk @@ -2,8 +2,8 @@ ${G_TESTS}: ${TARGET_$D} ${G_TESTS}-${DIRNAME}: ${TARGET_$D} -# HACK -${TARGETTMP_$D}: tests/bind/libbear.so.0 +# this test depends on the G_LIB library +${TARGETTMP_$D}: ${WORKINGDIR_$P}${SONAME_${G_LIB}} # how to link the main target ${TARGETTMP_$D}: ${L_OBJS_$D} | $${@D} diff --git a/tests/src/printTrace/rules.mk b/tests/src/printTrace/rules.mk index 130bab4..f32fe5f 100644 --- a/tests/src/printTrace/rules.mk +++ b/tests/src/printTrace/rules.mk @@ -2,8 +2,8 @@ ${G_TESTS}: ${TARGET_$D} ${G_TESTS}-${DIRNAME}: ${TARGET_$D} -# HACK -${TARGETTMP_$D}: tests/bind/libbear.so.0 +# this test depends on the G_LIB library +${TARGETTMP_$D}: ${WORKINGDIR_$P}${SONAME_${G_LIB}} # how to link the main target ${TARGETTMP_$D}: ${L_OBJS_$D} | $${@D} -- 2.10.2