NetBSD/distrib/common/Makefile.mdset
2002-05-10 02:31:45 +00:00

120 lines
3.1 KiB
Makefile

# $NetBSD: Makefile.mdset,v 1.16 2002/05/10 02:31:45 lukem Exp $
#
# Makefile snippet to ${MDSETIMAGE} file system images into kernels
#
#
# Required variables:
# NETBSDSRCDIR Top level of src tree (set by <bsd.own.mk>)
# MDSETTARGETS List of images to ${MDSETIMAGE} into kernels,
# containing one or more tuples of the form:
# KERNEL IMAGE FILENAME
#
# The kernel is ${MDSETIMAGE} with ${IMAGE},
# ${STRIP}ped (after the symbols are stored in
# ${FILENAME}.symbols.gz), and gzipped into
# ${FILENAME}.gz.
#
# If FILENAME is "-", use "netbsd.${KERNEL}" as
# the target name.
#
# Optional variables:
# MDSET_RELEASEDIR Where to install release kernels.
#
# MDSET_NOSTRIP.${FILENAME} If defined, don't strip ${FILENAME}
#
# MDSET_NOSYMBOLS.${FILENAME} If defined, don't generate
# ${FILENAME}.symbols.gz
#
# MDSET_POST.${FILENAME} For each kernel named ${FILENAME},
# execute this after ${NM} / ${STRIP}.
# Kernel is available as "${.TARGET}"
#
# MDSET_SUFFIXES.${FILENAME} List of extra install kernel suffixes
# and build commands to create from
# ${FILENAME} after its created by
# ${MDSET} ; ${NM} ; ${STRIP}:
# SUFFIX COMMANDVAR
# "${.TARGET}" is "${FILENAME}.${SUFFIX}"
# COMMANDVAR is the name of the variable
# containing the command to build
# ${.TARGET}.
#
# Variables modified by this:
# KERNELS List of kernel .gz files to build
# KERNELSYMS List of kernel .symbol.gz files to build
#
.include <bsd.kernobj.mk>
.for _K _I _F in ${MDSETTARGETS} # {
_FILENAME:=${_F} # work around obscure issue in make(1)
.if ${_FILENAME} == "-"
_KERNEL.${_K}:= netbsd.${_K}
.else
_KERNEL.${_K}:= ${_F}
.endif
KERNELS+= ${_KERNEL.${_K}}.gz
.for _S _C in ${MDSET_SUFFIXES.${_FILENAME}} # {
KERNELS+= ${_KERNEL.${_K}}.${_S}.gz
CLEANFILES+= ${_KERNEL.${_K}}.${_S}
${_KERNEL.${_K}}.${_S}: ${_KERNEL.${_K}}
.if defined(${_C})
${${_C}}
.else
@echo "No such variable \"${_C}\""
false
.endif
${_KERNEL.${_K}}.${_S}.gz: ${_KERNEL.${_K}}.${_S}
-rm -f ${.TARGET}
gzip -9c ${.ALLSRC} > ${.TARGET}
.endfor # }
.if !defined(MDSET_NOSYMBOLS.${_FILENAME})
KERNELSYMS+= ${_KERNEL.${_K}}.symbols.gz
.endif
.if defined(MDSET_POST.${_FILENAME})
_POST.${_KERNEL.${_K}}:= ${MDSET_POST.${_FILENAME}}
.endif
${_KERNEL.${_K}}: .NOTMAIN ${KERNOBJDIR}/${_K}/netbsd ${_I}
@echo "mdsetimage: ${KERNOBJDIR}/${_K}/netbsd"
@echo " with: ${_I}"
@echo " into: ${.TARGET}"
@rm -f ${.TARGET} ${.TARGET}.symbols.gz
@cp ${KERNOBJDIR}/${_K}/netbsd ${.TARGET}
${MDSETIMAGE} -v ${.TARGET} ${_I}
.if !defined(MDSET_NOSYMBOLS.${_FILENAME})
${NM} ${.TARGET} | gzip -9 > ${.TARGET}.symbols.gz
.endif
.if !defined(MDSET_NOSTRIP.${_FILENAME})
${STRIP} ${.TARGET}
.endif
.if defined(MDSET_POST.${_FILENAME})
${_POST.${.TARGET}}
.endif
${_KERNEL.${_K}}.gz: ${_KERNEL.${_K}}
-rm -f ${.TARGET}
gzip -9c ${.ALLSRC} > ${.TARGET}
CLEANFILES+= ${_KERNEL.${_K}}
.endfor # }
CLEANFILES+= ${KERNELS} ${KERNELSYMS}
realall: ${KERNELS}
.if defined(MDSET_RELEASEDIR)
release:: check_RELEASEDIR .WAIT ${KERNELS}
${RELEASE_INSTALL} ${KERNELS} ${KERNELSYMS} \
${RELEASEDIR}/${MDSET_RELEASEDIR}
.endif