#---*- Makefile -*-------------------------------------------------------
#$Author: saulius $
#$Date: 2019-03-07 15:28:04 +0000 (Thu, 07 Mar 2019) $
#$Revision: 182 $
#$URL: svn+ssh://saulius-grazulis.lt/home/saulius/svn-repositories/makefiles/timestamps/Makelocal-timestamps $
#------------------------------------------------------------------------
#*
# Separating the timestamp processing logic into a separate makefile,
# to be included into other makefiles.
#**

TIMESTAMPS = .time-stamps.lst
TOUCH_FILE = .touch.make

all: ${TIMESTAMPS}

#------------------------------------------------------------------------------
# Time-stamp processing

include ${TOUCH_FILE}

${TOUCH_FILE}:
	perl -F'\t' -lane 'printf "%s\0%s\0", @F if -f $$F[1]' \
		${TIMESTAMPS} \
	| xargs -t -0 -n2 --no-run-if-empty touch --date;
	if [ -d .svn ]; then \
		svn st \
		| perl -lane 'print $$F[-1] if -f $$F[-1]' \
		| xargs -t --no-run-if-empty touch; \
	fi
	> $@

.PHONY: touch

${TIMESTAMPS}: ${LOGS}
	find \
		-name .svn -prune -o \
		-name .git -prune -o \
		-type f -print0 \
	| xargs -0 stat --printf '%y\t%n\n' \
	> $@

touch:
	rm -f ${TOUCH_FILE}
	${MAKE} --no-print ${TOUCH_FILE}

#------------------------------------------------------------------------------
# Facilitating updating of the woking copy -- 'makeup' :):

.PHONY: up update

up update:
	svn up
	${MAKE} touch
