From: Patrik Gornicz Date: Sat, 13 Jun 2009 04:00:29 +0000 (-0400) Subject: added varible prefixes to lib X-Git-Tag: libbear-premerge~64 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=7bbc50a4afd37542c898e2f004a37464934db175;p=libbear.git added varible prefixes to lib --- diff --git a/Makefile b/Makefile index 67d1542..cc28ce0 100644 --- a/Makefile +++ b/Makefile @@ -13,17 +13,26 @@ all: # Include the variables that describe targets include targets.mk -all: ${LIB} +all: ${G_LIB} -DIRMK := dir.mk -VARSMK := vars.mk -FILESMK := files.mk -RULESMK := rules.mk +G_DIRMK := dir.mk +G_VARSMK := vars.mk +G_FILESMK := files.mk +G_RULESMK := rules.mk +G_LISTSMK := lists.mk +G_TVARSMK := tvars.mk -include ${VARSMK} + +include ${G_VARSMK} +include ${G_LISTSMK} # include all of the dir.mk -include lib/${DIRMK} -include tests/${DIRMK} +include lib/${G_DIRMK} +#include tests/${G_DIRMK} + +# Do not include deps files when doing a clean operation +ifeq ($(filter ${L_CLEANCMDS},${MAKECMDGOALS}),) + -include ${L_DEPS} +endif diff --git a/lib/dir.mk b/lib/dir.mk index 95234e7..71eb385 100644 --- a/lib/dir.mk +++ b/lib/dir.mk @@ -3,19 +3,17 @@ P := lib CURDIR := lib/ -include ${CURDIR}${VARSMK} +include ${CURDIR}${G_VARSMK} -include ${CURDIR}pre-${DIRMK} +include ${CURDIR}${G_LISTSMK} # steps on variables - include ${SRCSDIR_$P}${DIRMK} + include ${SRCSDIR_$P}${G_DIRMK} # Restore variables CURDIR := lib/ -include ${CURDIR}post-${DIRMK} +include ${CURDIR}${G_TVARSMK} -include ${CURDIR}${RULESMK} +include ${CURDIR}${G_RULESMK} + +L_DEPS += ${L_DEPS_$P} -# Do not include deps files when doing a clean operation -ifeq ($(filter ${CLEANCMDS},${MAKECMDGOALS}),) - -include ${DEPS_$P} -endif diff --git a/lib/lists.mk b/lib/lists.mk new file mode 100644 index 0000000..db8c309 --- /dev/null +++ b/lib/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/lib/post-dir.mk b/lib/post-dir.mk deleted file mode 100644 index c858276..0000000 --- a/lib/post-dir.mk +++ /dev/null @@ -1,13 +0,0 @@ - -# add flags specific to the library target and all prerequisites -${OBJS_$P} ${DEPS_$P}: CXXFLAGS := ${CXXFLAGS_$P} -${OBJS_$P} ${DEPS_$P}: INCFLAGS := ${INCFLAGS_$P} - ${DEPS_$P}: OBJSDIR := ${OBJSDIR_$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} diff --git a/lib/pre-dir.mk b/lib/pre-dir.mk deleted file mode 100644 index d262969..0000000 --- a/lib/pre-dir.mk +++ /dev/null @@ -1,12 +0,0 @@ - -# 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/lib/rules.mk b/lib/rules.mk index 95d17c6..6a8fd30 100644 --- a/lib/rules.mk +++ b/lib/rules.mk @@ -15,13 +15,13 @@ uninstall: rm /usr/lib/${SONAME} -${LIB}: ${TARGET_$P} -${LIB_OBJS}: ${OBJS_$P} -${LIB_DEPS}: ${DEPS_$P} +${G_LIB}: ${TARGET_$P} +${G_LIB_OBJS}: ${L_OBJS_$P} +${G_LIB_DEPS}: ${L_DEPS_$P} # how to link the main target -${TARGETTMP_$P}: ${OBJS_$P} | $${@D} +${TARGETTMP_$P}: ${L_OBJS_$P} | $${@D} ${Q1}${PRNTFMT} "${CXX}" "$@" ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS} @@ -31,7 +31,7 @@ ${TARGET_$P}: ${TARGETTMP_$P} | $${@D} ${Q2}cp $< $@ # how to make a directory -${BLDDIRS_$P}: +${L_BLDDIRS_$P}: ${Q1}${PRNTFMT} "mkdir" "$@" ${Q2}mkdir -p $@ @@ -49,35 +49,35 @@ ${DEPSDIR_$P}%.d: ${SRCSDIR_$P}%.cpp | $${@D} sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@ -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/lib/src/dir.mk b/lib/src/dir.mk index 75283ae..51f68a5 100644 --- a/lib/src/dir.mk +++ b/lib/src/dir.mk @@ -2,5 +2,5 @@ CURDIR := lib/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/lib/src/files.mk b/lib/src/files.mk index 5999663..96bd6b9 100644 --- a/lib/src/files.mk +++ b/lib/src/files.mk @@ -18,10 +18,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/lib/src/locks/dir.mk b/lib/src/locks/dir.mk index ec92cc6..ee53887 100644 --- a/lib/src/locks/dir.mk +++ b/lib/src/locks/dir.mk @@ -2,5 +2,5 @@ CURDIR := lib/src/locks/ SRCPATH := locks/ -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/lib/src/locks/files.mk b/lib/src/locks/files.mk index bbd35e2..c77058f 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_$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/lib/tvars.mk b/lib/tvars.mk new file mode 100644 index 0000000..7148e05 --- /dev/null +++ b/lib/tvars.mk @@ -0,0 +1,18 @@ + +# add flags specific to the library target and all prerequisites +${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} + +${TARGETTMP_$P}: CXX := ${CXX_$P} +${TARGETTMP_$P}: CXXFLAGS := ${CXXFLAGS_$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} + diff --git a/lib/vars.mk b/lib/vars.mk index a3b40b3..822185b 100644 --- a/lib/vars.mk +++ b/lib/vars.mk @@ -1,11 +1,13 @@ -CXXFLAGS_$P := ${CXXFLAGS} -fPIC +CXX_$P := ${G_CXX} +CXXFLAGS_$P := ${G_CXXFLAGS} -fPIC SRCSDIR_$P := ${CURDIR}src/ DEPSDIR_$P := ${CURDIR}deps/ -INCDIRS_$P := ${SRCSDIR_$P} ${CURDIR}inc/ -INCFLAGS_$P := $(addprefix -I, ${INCDIRS_$P}) +T_INCDIRS_$P := ${SRCSDIR_$P} ${CURDIR}inc/ +INCFLAGS_$P := $(addprefix -I, ${T_INCDIRS_$P}) +T_INCDIRS_$P := ifeq (${BUILD},WIN32) @@ -30,14 +32,17 @@ endif ifeq (${BUILD},WIN32) - LIBGL_$P := -lopengl32 -lglu32 - LIBSDL_$P := `/usr/mingw32/bin/sdl-config --libs` + T_LIBGL_$P := -lopengl32 -lglu32 + T_LIBSDL_$P := `/usr/mingw32/bin/sdl-config --libs` else - LIBGL_$P := -lGL -lGLU - LIBSDL_$P := `sdl-config --libs` + T_LIBGL_$P := -lGL -lGLU + T_LIBSDL_$P := `sdl-config --libs` endif LIBS_$P := ${LIBSDL_$P} ${LIBGL_$P} +T_LIBGL_$P := +T_LIBSDL_$P := + ifeq (${BUILD},WIN32) LINKERNAME_$P := bear.dll diff --git a/lists.mk b/lists.mk new file mode 100644 index 0000000..019794a --- /dev/null +++ b/lists.mk @@ -0,0 +1,4 @@ + +L_CLEANCMDS := # empty +L_DEPS := # empty + diff --git a/targets.mk b/targets.mk index 0aae6ce..a9d785f 100644 --- a/targets.mk +++ b/targets.mk @@ -1,34 +1,34 @@ # LIB: the target of the lib directory -LIB := lib -.PHONY: ${LIB} +G_LIB := lib +.PHONY: ${G_LIB} -LIB_OBJS := lib-objs -.PHONY: ${LIB_OBJS} +G_LIB_OBJS := lib-objs +.PHONY: ${G_LIB_OBJS} -LIB_DEPS := lib-deps -.PHONY: ${LIB_DEPS} +G_LIB_DEPS := lib-deps +.PHONY: ${G_LIB_DEPS} # TESTS: build all of the tests -TESTS := tests -.PHONY: ${TESTS} +G_TESTS := tests +.PHONY: ${G_TESTS} -CLEANCMDS += cleanbin +L_CLEANCMDS += cleanbin .PHONY: cleanbin cleanbin: -CLEANCMDS += cleanobjs +L_CLEANCMDS += cleanobjs .PHONY: cleanobjs cleanobjs: -CLEANCMDS += cleandeps +L_CLEANCMDS += cleandeps .PHONY: cleandeps cleandeps: -CLEANCMDS += clean +L_CLEANCMDS += clean .PHONY: clean clean: cleanobjs -CLEANCMDS += cleanall +L_CLEANCMDS += cleanall .PHONY: cleanall cleanall: cleanbin cleanobjs cleandeps diff --git a/vars.mk b/vars.mk index 1df38df..5eb8ec4 100644 --- a/vars.mk +++ b/vars.mk @@ -1,24 +1,30 @@ -OPTFLAGS := -O2 -DBGFLAGS := -ggdb -PRFFLAGS := ${DBGFLAGS} -pg -WARFLAGS := -Wall -Wextra -pedantic -ansi +T_OPTFLAGS := -O2 +T_DBGFLAGS := -ggdb +T_PRFFLAGS := ${G_DBGFLAGS} -pg +T_WARFLAGS := -Wall -Wextra -pedantic -ansi -CXXFLAGS := ${WARFLAGS} +G_CXXFLAGS := ${T_WARFLAGS} ifeq (${BUILD},WIN32) - CXXFLAGS += ${OPTFLAGS} + G_CXXFLAGS += ${T_OPTFLAGS} else ifeq (${BUILD},FINAL) - CXXFLAGS += ${OPTFLAGS} + G_CXXFLAGS += ${T_OPTFLAGS} else - CXXFLAGS += ${DBGFLAGS} + G_CXXFLAGS += ${T_DBGFLAGS} endif endif +T_OPTFLAGS := +T_DBGFLAGS := +T_PRFFLAGS := +T_WARFLAGS := + + ifeq (${BUILD},WIN32) - CXX := mingw32-g++ + G_CXX := mingw32-g++ else - CXX := g++ + G_CXX := g++ endif ifeq (${BUILD},WIN32)