NetBSD/distrib/common/Makefile.crunch

52 lines
1.4 KiB
Makefile

# $NetBSD: Makefile.crunch,v 1.5 2002/03/17 21:33:45 lukem Exp $
#
# Makefile snippet to build a crunchgen(1)ed binary from the provided lists
#
#
# Required variables:
# _SRC_TOP_ top level of src tree (set by <bsd.own.mk>)
# CRUNCHBIN name of crunchgen(1)ed binary
# LISTS list file(s) to use
#
# Optional variables:
# DESTDIR destination directory
# PARSELISTENV environment variables to set for parselist.awk
#
PARSELISTENV+= _SRC_TOP_=${_SRC_TOP_:Q} \
CRUNCHBIN=${CRUNCHBIN:Q} \
CURDIR=${.CURDIR:Q} \
DESTDIR=${DESTDIR:Q} \
MACHINE=${MACHINE:Q} \
MACHINE_ARCH=${MACHINE_ARCH:Q} \
OBJDIR=${.OBJDIR:Q}
_PARSELIST= ${_SRC_TOP_}/distrib/common/parselist.awk
${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c
env SMALLPROG=1 ${MAKE} -f ${CRUNCHBIN}.mk all
${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c: ${CRUNCHBIN}.conf
env SMALLPROG=1 \
${CRUNCHGEN} -f -D ${_SRC_TOP_} -L ${DESTDIR}/usr/lib ${.ALLSRC}
${CRUNCHBIN}.conf: ${LISTS} ${_PARSELIST}
-rm -f ${.TARGET} ${.TARGET}.tmp
${PARSELISTENV} awk -f ${_PARSELIST} -v mode=crunch \
${LISTS} > ${.TARGET}.tmp \
&& mv ${.TARGET}.tmp ${.TARGET}
CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
${CRUNCHBIN}.cache *.o *.cro *.c
clean cleandir distclean: cleancrunchgen
.PHONY: cleancrunchgen
cleancrunchgen:
if [ -f ${CRUNCHBIN}.mk ]; then \
${MAKE} -f ${CRUNCHBIN}.mk clean; \
fi
rm -f ${CRUNCHBIN}.mk