From caa7531c4c01e6c40dfeb60b5730cd64c528b4c9 Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Thu, 11 Jun 2009 22:45:22 -0400 Subject: [PATCH] suffixing varibles began (lib) --- lib/dir.mk | 8 +++--- lib/post-dir.mk | 11 ++++---- lib/pre-dir.mk | 14 +++++----- lib/rules.mk | 71 ++++++++++++++++++++++++++++---------------------- lib/src/dir.mk | 2 +- lib/src/files.mk | 10 +++---- lib/src/locks/dir.mk | 2 +- lib/src/locks/files.mk | 10 +++---- lib/vars.mk | 44 +++++++++++++++---------------- targets.mk | 19 ++++++++++++++ 10 files changed, 109 insertions(+), 82 deletions(-) diff --git a/lib/dir.mk b/lib/dir.mk index 60bf8c9..95234e7 100644 --- a/lib/dir.mk +++ b/lib/dir.mk @@ -1,21 +1,21 @@ +# Package name +P := lib CURDIR := lib/ -#SRCPATH := # Not used at this level include ${CURDIR}${VARSMK} include ${CURDIR}pre-${DIRMK} # steps on variables - include ${SRCSDIR}${DIRMK} + include ${SRCSDIR_$P}${DIRMK} # Restore variables CURDIR := lib/ - #SRCPATH := # Not used at this level include ${CURDIR}post-${DIRMK} include ${CURDIR}${RULESMK} # Do not include deps files when doing a clean operation ifeq ($(filter ${CLEANCMDS},${MAKECMDGOALS}),) - -include ${DEPS} + -include ${DEPS_$P} endif diff --git a/lib/post-dir.mk b/lib/post-dir.mk index 671ba1f..c888a88 100644 --- a/lib/post-dir.mk +++ b/lib/post-dir.mk @@ -1,11 +1,10 @@ -INCFLAGS := $(addprefix -I, ${INCDIRS}) +INCFLAGS_$P := $(addprefix -I, ${INCDIRS_$P}) # add flags specific to the library target and all prerequisites -${OBJS}: CXXFLAGS += -fPIC -${OBJS}: INCFLAGS := ${INCFLAGS} +${OBJS_$P} ${DEPS_$P}: CXXFLAGS += -fPIC +${OBJS_$P} ${DEPS_$P}: INCFLAGS += ${INCFLAGS_$P} -${TARGET}: LNKFLAGS += -shared -Wl,-soname,${SONAME} - -${DEPS}: INCFLAGS := ${INCFLAGS} +${TARGETTMP_$P}: LNKFLAGS += -shared -Wl,-soname,${SONAME_$P} +${TARGETTMP_$P}: LIBS += ${LIBS_$P} diff --git a/lib/pre-dir.mk b/lib/pre-dir.mk index df03279..d262969 100644 --- a/lib/pre-dir.mk +++ b/lib/pre-dir.mk @@ -1,12 +1,12 @@ # 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} diff --git a/lib/rules.mk b/lib/rules.mk index 5e1fed4..75573e6 100644 --- a/lib/rules.mk +++ b/lib/rules.mk @@ -15,60 +15,69 @@ uninstall: rm /usr/lib/${SONAME} -${LIB}: ${TARGET} -${LIB_OBJS}: ${OBJS} -${LIB_DEPS}: ${DEPS} +${LIB}: ${TARGET_$P} +${LIB_OBJS}: ${OBJS_$P} +${LIB_DEPS}: ${DEPS_$P} # how to link the main target -${TARGETTMP}: ${OBJS} | $${@D} +${TARGETTMP_$P}: ${OBJS_$P} | $${@D} ${Q1}${PRNTFMT} "${CXX}" "$@" ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS} # rule to copy tmp target to working directory -${TARGET}: ${TARGETTMP} | $${@D} +${TARGET_$P}: ${TARGETTMP_$P} | $${@D} ${Q1}${PRNTFMT} "cp" "$@" ${Q2}cp $< $@ # 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 := cleanbin cleanobjs cleandeps clean cleanall -.PHONY: cleanbin -cleanbin: - ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}" - ${Q2}rm -rf ${WORKINGDIR} - -.PHONY: cleanobjs -cleanobjs: - ${Q1}${PRNTFMT} "rm" "${OBJSDIR}" - ${Q2}rm -rf ${OBJSDIR} - -.PHONY: cleandeps -cleandeps: - ${Q1}${PRNTFMT} "rm" "${DEPSDIR}" - ${Q2}rm -rf ${DEPSDIR} - -.PHONY: clean -clean: cleanobjs - ${Q1}${PRNTFMT} "rm" "${TARGET}" - ${Q2}rm -f ${TARGET} - -.PHONY: cleanall -cleanall: cleanbin cleanobjs cleandeps +CLEANCMDS += $P-cleanbin +cleanbin: $P-cleanbin +.PHONY: $P-cleanbin +$P-cleanbin: + ${Q1}${PRNTFMT} "rm" "${WORKINGDIR_$P}" + ${Q2}rm -rf ${WORKINGDIR_$P} + +CLEANCMDS += $P-cleanobjs +cleanobjs: $P-cleanobjs +.PHONY: $P-cleanobjs +$P-cleanobjs: + ${Q1}${PRNTFMT} "rm" "${OBJSDIR_$P}" + ${Q2}rm -rf ${OBJSDIR_$P} + +CLEANCMDS += $P-cleandeps +cleandeps: $P-cleandeps +.PHONY: $P-cleandeps +$P-cleandeps: + ${Q1}${PRNTFMT} "rm" "${DEPSDIR_$P}" + ${Q2}rm -rf ${DEPSDIR_$P} + +CLEANCMDS += $P-clean +clean: $P-clean +.PHONY: $P-clean +$P-clean: $P-cleanobjs + ${Q1}${PRNTFMT} "rm" "${TARGET_$P}" + ${Q2}rm -f ${TARGET_$P} + +CLEANCMDS += $P-cleanall +cleanall: $P-cleanall +.PHONY: $P-cleanall +$P-cleanall: $P-cleanbin $P-cleanobjs $P-cleandeps diff --git a/lib/src/dir.mk b/lib/src/dir.mk index 0b75341..75283ae 100644 --- a/lib/src/dir.mk +++ b/lib/src/dir.mk @@ -3,4 +3,4 @@ CURDIR := lib/src/ SRCPATH := include ${CURDIR}${FILESMK} -include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS})) +include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS})) diff --git a/lib/src/files.mk b/lib/src/files.mk index 10c0f64..5999663 100644 --- a/lib/src/files.mk +++ b/lib/src/files.mk @@ -18,10 +18,10 @@ NEWDEPS := ${NEWSRCS:.cpp=.d} # 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}) diff --git a/lib/src/locks/dir.mk b/lib/src/locks/dir.mk index 96bf61d..ec92cc6 100644 --- a/lib/src/locks/dir.mk +++ b/lib/src/locks/dir.mk @@ -3,4 +3,4 @@ CURDIR := lib/src/locks/ SRCPATH := locks/ include ${CURDIR}${FILESMK} -include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS})) +include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS})) diff --git a/lib/src/locks/files.mk b/lib/src/locks/files.mk index 58c2cd8..bbd35e2 100644 --- a/lib/src/locks/files.mk +++ b/lib/src/locks/files.mk @@ -14,10 +14,10 @@ NEWDEPS := ${NEWSRCS:.cpp=.d} # 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}) diff --git a/lib/vars.mk b/lib/vars.mk index 2ba9c2e..db42bc1 100644 --- a/lib/vars.mk +++ b/lib/vars.mk @@ -1,51 +1,51 @@ -SRCSDIR := ${CURDIR}src/ -DEPSDIR := ${CURDIR}deps/ -INCDIRS := ${SRCSDIR} ${CURDIR}inc/ +SRCSDIR_$P := ${CURDIR}src/ +DEPSDIR_$P := ${CURDIR}deps/ +INCDIRS_$P := ${SRCSDIR_$P} ${CURDIR}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 ifeq (${BUILD},WIN32) - LIBGL := -lopengl32 -lglu32 - LIBSDL := `/usr/mingw32/bin/sdl-config --libs` + LIBGL_$P := -lopengl32 -lglu32 + LIBSDL_$P := `/usr/mingw32/bin/sdl-config --libs` else - LIBGL := -lGL -lGLU - LIBSDL := `sdl-config --libs` + LIBGL_$P := -lGL -lGLU + LIBSDL_$P := `sdl-config --libs` endif -LIBS := ${LIBSDL} ${LIBGL} +LIBS_$P := ${LIBSDL_$P} ${LIBGL_$P} ifeq (${BUILD},WIN32) - LINKERNAME := bear.dll - SONAME := bear.dll - REALNAME := bear.dll + LINKERNAME_$P := bear.dll + SONAME_$P := bear.dll + REALNAME_$P := bear.dll else - LINKERNAME := libbear.so - SONAME := libbear.so.0 - REALNAME := libbear.so.0.0 + LINKERNAME_$P := libbear.so + SONAME_$P := libbear.so.0 + REALNAME_$P := libbear.so.0.0 endif -TARGETTMP := ${OBJSDIR}${REALNAME} -TARGET := ${WORKINGDIR}${REALNAME} +TARGETTMP_$P := ${OBJSDIR_$P}${REALNAME_$P} +TARGET_$P := ${WORKINGDIR_$P}${REALNAME_$P} ifeq (${BUILD},WIN32) diff --git a/targets.mk b/targets.mk index 059a67a..0aae6ce 100644 --- a/targets.mk +++ b/targets.mk @@ -13,3 +13,22 @@ LIB_DEPS := lib-deps TESTS := tests .PHONY: ${TESTS} +CLEANCMDS += cleanbin +.PHONY: cleanbin +cleanbin: + +CLEANCMDS += cleanobjs +.PHONY: cleanobjs +cleanobjs: + +CLEANCMDS += cleandeps +.PHONY: cleandeps +cleandeps: + +CLEANCMDS += clean +.PHONY: clean +clean: cleanobjs + +CLEANCMDS += cleanall +.PHONY: cleanall +cleanall: cleanbin cleanobjs cleandeps -- 2.10.2