created basic logging system, also added cmd-rm and cmd-rmrec commands
authorPatrik Gornicz <Gornicz.P@gmail.com>
Sun, 23 Aug 2009 18:20:14 +0000 (14:20 -0400)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Sun, 23 Aug 2009 18:20:14 +0000 (14:20 -0400)
.gitignore
Makefile.d/cleanrules.mk
rules.mk
vars.mk

index f31a207..a6e3e74 100644 (file)
@@ -12,3 +12,5 @@ bin-mingw32
 *.swp
 
 physics
+
+bld.log
index 5fa7307..7c838d2 100644 (file)
@@ -6,23 +6,23 @@
 L_CLEANCMDS +=  cleanbin-$T
 cleanbin:       cleanbin-$T
 .PHONY:         cleanbin-$T
+cleanbin-$T: CLEANTARGET := ${BINDIR}
 cleanbin-$T:
-       ${Q1}${PRNTFMT} "rm" "${BINDIR}"
-       ${Q2}rm -rf ${BINDIR}
+       ${cmd-rmrec}
 
 L_CLEANCMDS +=  cleanobjs-$T
 cleanobjs:      cleanobjs-$T
 .PHONY:         cleanobjs-$T
+cleanobjs-$T: CLEANTARGET := ${OBJSDIR}
 cleanobjs-$T:
-       ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
-       ${Q2}rm -rf ${OBJSDIR}
+       ${cmd-rmrec}
 
 L_CLEANCMDS +=  cleandeps-$T
 cleandeps:      cleandeps-$T
 .PHONY:         cleandeps-$T
+cleandeps-$T: CLEANTARGET := ${DEPSDIR}
 cleandeps-$T:
-       ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
-       ${Q2}rm -rf ${DEPSDIR}
+       ${cmd-rmrec}
 
 L_CLEANCMDS +=  clean-$T
 clean:          clean-$T
index 9dbcfb0..1765b74 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -1,26 +1,50 @@
 
 define cmd-link
-  ${Q1}${PRNTFMT} "${CXX}" "$@"
-  ${Q2}${CXX} $^ -o $@ ${CXXFLAGS} ${LNKFLAGS} ${LIBS}
+  ${Q1s}${PRNTFMT} "${CXX}" "$@" ${Q1e}
+  ${Q2s}${PRNTFMT} "${CXX}" "$@" ${Q2e}
+  ${Q3s}${CXX} $^ -o $@ ${CXXFLAGS} ${LNKFLAGS} ${LIBS} ${Q3e}
+  ${Q4s}${CXX} $^ -o $@ ${CXXFLAGS} ${LNKFLAGS} ${LIBS} ${Q4e}
 endef
 
 define cmd-cp
-  ${Q1}${PRNTFMT} "cp" "$@"
-  ${Q2}cp $< $@
+  ${Q1s}${PRNTFMT} "cp" "$@" ${Q1e}
+  ${Q2s}${PRNTFMT} "cp" "$@" ${Q2e}
+  ${Q3s}cp $< $@ ${Q3e}
+  ${Q4s}cp $< $@ ${Q4e}
+endef
+
+define cmd-rm
+       ${Q1s}${PRNTFMT} "rm" "${CLEANTARGET}" ${Q1e}
+       ${Q2s}${PRNTFMT} "rm" "${CLEANTARGET}" ${Q2e}
+       ${Q3s}rm -f ${CLEANTARGET} ${Q3e}
+       ${Q4s}rm -f ${CLEANTARGET} ${Q4e}
+endef
+
+define cmd-rmrec
+       ${Q1s}${PRNTFMT} "rm" "${CLEANTARGET}" ${Q1e}
+       ${Q2s}${PRNTFMT} "rm" "${CLEANTARGET}" ${Q2e}
+       ${Q3s}rm -rf ${CLEANTARGET} ${Q3e}
+       ${Q4s}rm -rf ${CLEANTARGET} ${Q4e}
 endef
 
 define cmd-cpptoobj
-  ${Q1}${PRNTFMT} "${CXX}" "$@"
-  ${Q2}${CXX} $< -o $@ ${CXXFLAGS} ${INCFLAGS} -c
+  ${Q1s}${PRNTFMT} "${CXX}" "$@" ${Q1e}
+  ${Q2s}${PRNTFMT} "${CXX}" "$@" ${Q2e}
+  ${Q3s}${CXX} $< -o $@ ${CXXFLAGS} ${INCFLAGS} -c ${Q3e}
+  ${Q4s}${CXX} $< -o $@ ${CXXFLAGS} ${INCFLAGS} -c ${Q4e}
 endef
 
 define cmd-cpptodep
-  ${Q1}${PRNTFMT} "DEP" "$@"
-  ${Q2}${CXX} $< -MF $@ ${CXXFLAGS} ${INCFLAGS} -MM -MQ ${@:${DEPSDIR}%.d=${OBJSDIR}%.o} -MQ $@
+  ${Q1s}${PRNTFMT} "DEP" "$@" ${Q1e}
+  ${Q2s}${PRNTFMT} "DEP" "$@" ${Q2e}
+  ${Q3s}${CXX} $< -MF $@ ${CXXFLAGS} ${INCFLAGS} -MM -MQ ${@:${DEPSDIR}%.d=${OBJSDIR}%.o} -MQ $@ ${Q3e}
+  ${Q4s}${CXX} $< -MF $@ ${CXXFLAGS} ${INCFLAGS} -MM -MQ ${@:${DEPSDIR}%.d=${OBJSDIR}%.o} -MQ $@ ${Q4e}
 endef
 
 
 ${L_BLDDIRS}:
-       ${Q1}${PRNTFMT} "mkdir" "$@"
-       ${Q2}mkdir $@
+       ${Q1s}${PRNTFMT} "mkdir" "$@" ${Q1e}
+       ${Q2s}${PRNTFMT} "mkdir" "$@" ${Q2e}
+       ${Q3s}mkdir $@ ${Q3e}
+       ${Q4s}mkdir $@ ${Q4e}
 
diff --git a/vars.mk b/vars.mk
index 24bf396..baeee79 100644 (file)
--- a/vars.mk
+++ b/vars.mk
@@ -82,6 +82,9 @@ endif
 endif
 endif
 
+LOGFILE := bld.log
+
+$(shell rm -f ${LOGFILE}) # remove the log file from last run
 
 ifeq (${G_BUILD},${B_WIN32})
     PRNTFMT := printf "%-12s: %s\n"
@@ -92,15 +95,31 @@ endif
 VERBOSE := 0
 
 ifeq (${VERBOSE},0)
+    # log the printf command
+    Q1s := @
+    Q1e := >> ${LOGFILE}
     # quiet the printf command
-    Q1 := @
-    # quiet the command that is `replaced' by an echo
-    Q2 := @
+    Q2s := @
+    Q2e :=
+               # log the command
+    Q3s := @echo # NOTE: the space between @echo and the # is VERY important!!
+    Q3e := >> ${LOGFILE}
+    # quiet the command
+    Q4s := @
+    Q4e :=
 else
-    # EAT the printf command as if it was not there
-    Q1 := @true # NOTE: the space between @true and the # is VERY important!!
-    # do not quiet the command output
-    Q2 :=
+    # EAT the logging printf command
+    Q1s := @true # NOTE: the space between @true and the # is VERY important!!
+    Q1e :=
+    # EAT the quiet printf command
+    Q2s := @true # NOTE: the space between @true and the # is VERY important!!
+    Q2e :=
+               # EAT the logging command
+    Q3s := @true # NOTE: the space between @true and the # is VERY important!!
+    Q3e :=
+    # do not quiet the command
+    Q4s :=
+    Q4e :=
 endif