NetBSD/rescue/Makefile
christos 128e5f5e67 1. Remove all the special handling of variables (-d -p -P -s -S) that
were dealing with DBG (-d) LDSTATIC/NOPIE (-p), and the rest with
   disabling/enabling sanitizers.
2. Use emalloc/estrdup for all the allocators instead of only some cases.
3. Add -V varspec which passes variables on the command line (as DBG
   and LDSTATIC used to be passed before) instead of appending them
   to the on-the-fly Makefile using -v varspec.
4. Change the distrib and rescue Makefiles to use -V instead of the removed
   flags.

The motivation of this is to make variable handling consistent, less magical,
and remove the need for changing crunchgen each time we want to add disabling
an option by default.

(as proposed in tech-toolchain)
2019-12-29 18:26:16 +00:00

89 lines
2.0 KiB
Makefile

# $NetBSD: Makefile,v 1.39 2019/12/29 18:26:16 christos Exp $
NOLIBCSANITIZER= # defined
NOSANITIZER= # defined
.include <bsd.own.mk>
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
WARNS= 1
# XXX
.if ${MACHINE_ARCH} != "m68000"
DBG+= -Os
.endif
CRUNCHGEN_FLAGS+=-V DBG="${DBG}"
.if ${MKSTATICPIE:Uno} == "yes"
CFLAGS+=-fPIE
CRUNCHGEN_FLAGS+=-V LDSTATIC="-static -pie"
.else
CRUNCHGEN_FLAGS+=-V LDSTATIC="-static" -V NOPIE=
.endif
CRUNCHGEN_FLAGS+=-V NOLIBCSANITIZER= -V NOSANITIZER= -V NOMAN=
RESCUEDIR= /rescue
CRUNCHBIN= rescue
CRUNCHENV= RESCUEDIR=${RESCUEDIR}
SMALLPROG= 0
LISTS= ${.CURDIR}/list
TARGETDIR= ${DESTDIR}/rescue
PARSELISTENV+= TARGETDIR=${TARGETDIR:Q}
.for f in pdisk
PROG_${f}!= cd ${NETBSDSRCDIR}/external/bsd/${f}/bin && ${MAKE} -V PROG
.if (${PROG_${f}} != "")
LISTS+= ${.CURDIR}/list.${f}
.endif
.endfor
.if ${USE_INET6} != "no"
LISTS+= ${.CURDIR}/list.inet6
.endif
LISTS+= ${.CURDIR}/list.crypto
CRUNCHENV+= MKKERBEROS=no # for ssh
LISTS+= ${.CURDIR}/list.ldd
LDD_ELF32DIR!= cd ${NETBSDSRCDIR}/usr.bin/ldd/elf32 && ${PRINTOBJDIR}
LDD_ELF64DIR!= cd ${NETBSDSRCDIR}/usr.bin/ldd/elf64 && ${PRINTOBJDIR}
PARSELISTENV+= LDD_ELF32DIR=${LDD_ELF32DIR} LDD_ELF64DIR=${LDD_ELF64DIR}
SMB_LIBDIR!= cd ${NETBSDSRCDIR}/external/bsd/smbfs/lib/libsmb && ${PRINTOBJDIR}
PARSELISTENV+= SMB_LIBDIR=${SMB_LIBDIR}
# Specially built objects to override the behaviour of
# various library functions
#
OVERRIDEOBJS= rcmd.o
.PATH: ${NETBSDSRCDIR}/lib/libc/net
CPPFLAGS.rcmd.c+=-I${NETBSDSRCDIR}/lib/libc/include -DRESCUEDIR=\"${RESCUEDIR}\"
LIBOVERRIDE= liboverride.o
${LIBOVERRIDE}: ${OVERRIDEOBJS}
${_MKTARGET_LINK}
${LD} -r -o $@ ${OVERRIDEOBJS}
CLEANFILES+= ${OVERRIDEOBJS} ${LIBOVERRIDE}
${CRUNCHBIN}: ${LIBOVERRIDE}
# The primary target ...
#
CLEANFILES+= rescue.unstripped
.include "${DISTRIBDIR}/common/Makefile.crunch"
realall: ${CRUNCHBIN}
install: ${CRUNCHBIN}
# XXX this MKMSG doesn't line up
${_MKMSG} "populate ${TARGETDIR}"
${PARSELIST} -v mode=install ${LISTS} | ${MAKE} -f - install
.include <bsd.prog.mk>