suffixing varibles began (lib)
authorPatrik Gornicz <Gornicz.P@gmail.com>
Fri, 12 Jun 2009 02:45:22 +0000 (22:45 -0400)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Fri, 12 Jun 2009 02:45:22 +0000 (22:45 -0400)
lib/dir.mk
lib/post-dir.mk
lib/pre-dir.mk
lib/rules.mk
lib/src/dir.mk
lib/src/files.mk
lib/src/locks/dir.mk
lib/src/locks/files.mk
lib/vars.mk
targets.mk

index 60bf8c9..95234e7 100644 (file)
@@ -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
index 671ba1f..c888a88 100644 (file)
@@ -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}
 
index df03279..d262969 100644 (file)
@@ -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}
 
index 5e1fed4..75573e6 100644 (file)
@@ -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
index 0b75341..75283ae 100644 (file)
@@ -3,4 +3,4 @@ CURDIR  := lib/src/
 SRCPATH :=
 
 include ${CURDIR}${FILESMK}
-include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS}))
+include $(addprefix ${SRCSDIR_$P},$(addsuffix ${DIRMK},${NEWDIRS}))
index 10c0f64..5999663 100644 (file)
@@ -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})
 
index 96bf61d..ec92cc6 100644 (file)
@@ -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}))
index 58c2cd8..bbd35e2 100644 (file)
@@ -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})
 
index 2ba9c2e..db42bc1 100644 (file)
@@ -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)
index 059a67a..0aae6ce 100644 (file)
@@ -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