2008-02-07 22:36:13 +01:00
|
|
|
# $NetBSD: bsd.pkg.error.mk,v 1.4 2008/02/07 21:36:13 rillig Exp $
|
2006-06-09 15:59:06 +02:00
|
|
|
|
2006-10-06 21:05:43 +02:00
|
|
|
ERROR_DIR= ${WRKDIR}/.error
|
|
|
|
WARNING_DIR= ${WRKDIR}/.warning
|
|
|
|
_ERROR_DONE_DIR= ${WRKDIR}/.error-done
|
|
|
|
_WARNING_DONE_DIR= ${WRKDIR}/.warning-done
|
2006-06-09 15:59:06 +02:00
|
|
|
|
2006-06-14 17:09:34 +02:00
|
|
|
# Macros for outputting delayed error and warning messages that are
|
|
|
|
# picked up by the error-check target and can be used in place of
|
|
|
|
# ${ECHO}. We output to files that are named without leading dots.
|
|
|
|
#
|
|
|
|
DELAYED_ERROR_MSG?= ${ECHO} >> ${ERROR_DIR}/${.TARGET:T:C/^[.]*//:Q}
|
|
|
|
DELAYED_WARNING_MSG?= ${ECHO} >> ${WARNING_DIR}/${.TARGET:T:C/^[.]*//:Q}
|
|
|
|
|
2006-10-06 21:05:43 +02:00
|
|
|
makedirs: ${ERROR_DIR} ${WARNING_DIR} ${_ERROR_DONE_DIR} ${_WARNING_DONE_DIR}
|
|
|
|
${ERROR_DIR} ${WARNING_DIR} ${_ERROR_DONE_DIR} ${_WARNING_DONE_DIR}:
|
2008-02-07 22:36:13 +01:00
|
|
|
${RUN}${MKDIR} ${.TARGET}
|
2006-06-09 15:59:06 +02:00
|
|
|
|
|
|
|
.PHONY: error-check
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### error-check (PRIVATE)
|
|
|
|
######################################################################
|
|
|
|
### error-check is a macro target that will peek in the warning and
|
|
|
|
### error directories to check for the presence of any files. If they
|
|
|
|
### exist and are non-empty, then they are assumed to be message files
|
|
|
|
### and will be outputted then removed. If they are from the error
|
|
|
|
### directory, then the target will fail.
|
|
|
|
###
|
|
|
|
error-check: .USE
|
2008-02-07 22:36:13 +01:00
|
|
|
${RUN} \
|
2006-06-09 15:59:06 +02:00
|
|
|
${RM} -f ${WARNING_DIR}/*.tmp; \
|
|
|
|
${TEST} -d ${WARNING_DIR} || exit 0; \
|
|
|
|
cd ${WARNING_DIR}; \
|
|
|
|
for file in ./*; do \
|
|
|
|
${TEST} "$$file" != "./*" || exit 0; \
|
|
|
|
break; \
|
|
|
|
done; \
|
|
|
|
${CAT} ./* | ${WARNING_CAT}; \
|
2006-10-06 21:05:43 +02:00
|
|
|
${MV} -f ./* ${_WARNING_DONE_DIR}
|
2006-06-09 15:59:06 +02:00
|
|
|
|
2008-02-07 22:36:13 +01:00
|
|
|
${RUN} \
|
2006-06-09 15:59:06 +02:00
|
|
|
${RM} -f ${ERROR_DIR}/*.tmp; \
|
|
|
|
${TEST} -d ${ERROR_DIR} || exit 0; \
|
|
|
|
cd ${ERROR_DIR}; \
|
|
|
|
for file in ./*; do \
|
|
|
|
${TEST} "$$file" != "./*" || exit 0; \
|
|
|
|
break; \
|
|
|
|
done; \
|
|
|
|
${CAT} * | ${ERROR_CAT}; \
|
|
|
|
if ${_NONZERO_FILESIZE_P} ./*; then \
|
2006-10-06 21:05:43 +02:00
|
|
|
${MV} -f ./* ${_ERROR_DONE_DIR}; \
|
2006-06-09 15:59:06 +02:00
|
|
|
exit 1; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### error-clean (PRIVATE)
|
|
|
|
######################################################################
|
|
|
|
### error-clean removes the error and warning directory and files.
|
|
|
|
###
|
|
|
|
error-clean:
|
2008-02-07 22:36:13 +01:00
|
|
|
${RUN}${RM} -fr ${ERROR_DIR} ${WARNING_DIR}
|