1#	$NetBSD: Makefile,v 1.47 2025/12/28 19:07:42 thorpej Exp $
2
3NOLIBCSANITIZER=	# defined
4NOSANITIZER=		# defined
5
6.include <bsd.own.mk>
7.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
8
9WARNS=		1
10# XXX
11.if ${MACHINE_ARCH} != "m68000"
12DBG+=		-Os
13.endif
14
15CRUNCHGEN_FLAGS+=-V DBG="${DBG}"
16
17.if ${MKSTATICPIE:Uno} == "yes"
18CFLAGS+=-fPIE
19CRUNCHGEN_FLAGS+=-V LDSTATIC="-static -pie"
20.else
21CRUNCHGEN_FLAGS+=-V LDSTATIC="-static" -V NOPIE=
22.endif
23
24CRUNCHGEN_FLAGS+=-V NOLIBCSANITIZER= -V NOSANITIZER= -V NOMAN=
25
26.if (${MKSSH} != "no")
27# libssh is private, so libssh.a is not installed in DESTDIR, so we
28# have to get it out of the objdir.
29#
30# XXX Should do this differently, and uniformly for all libraries.
31.if !defined(LIBDO.ssh)
32LIBDO.ssh!=	cd ${NETBSDSRCDIR}/crypto/external/bsd/openssh/lib && \
33		${PRINTOBJDIR}
34.MAKEOVERRIDES+=LIBDO.ssh
35.endif
36CRUNCHGEN_FLAGS+=-L ${LIBDO.ssh}
37.endif		# MKSSH != "no"
38
39RESCUEDIR=	/rescue
40CRUNCHBIN=	rescue
41CRUNCHENV=	RESCUEDIR=${RESCUEDIR}
42SMALLPROG=	0
43LISTS=		${.CURDIR}/list
44TARGETDIR=	${DESTDIR}/rescue
45PARSELISTENV+=  TARGETDIR=${TARGETDIR:Q}
46
47.for f in pdisk
48PROG_${f}!=	cd ${NETBSDSRCDIR}/external/bsd/${f}/bin && ${MAKE} -V PROG
49.if (${PROG_${f}} != "")
50LISTS+=		${.CURDIR}/list.${f}
51.endif
52.endfor
53
54RESCUEFSLIST=	adosfs cd9660fs efs ext2fs fdescfs filecorefs kernfs lfs \
55		msdosfs nfs ntfs nullfs overlayfs procfs tmpfs umapfs unionfs
56
57.for f in ${RESCUEFSLIST}
58.if (${MK${f:tu}} != "no")
59LISTS+=		${.CURDIR}/list.${f}
60.endif
61.endfor
62
63.if ${USE_INET6} != "no"
64LISTS+=		${.CURDIR}/list.inet6
65.endif
66
67.if ${MKIPSEC} != "no"
68LISTS+=		${.CURDIR}/list.ipsec
69.endif
70
71.if ${MKSSH} != "no"
72LISTS+=		${.CURDIR}/list.ssh
73CRUNCHENV+=	MKKERBEROS=no		# for ssh
74.endif
75
76.if ${MKUSB} != "no"
77LISTS+=		${.CURDIR}/list.usb
78.endif
79
80LISTS+=		${.CURDIR}/list.crypto
81
82LISTS+=		${.CURDIR}/list.ldd
83LDD_ELF32DIR!=	cd ${NETBSDSRCDIR}/usr.bin/ldd/elf32 && ${PRINTOBJDIR}
84LDD_ELF64DIR!=	cd ${NETBSDSRCDIR}/usr.bin/ldd/elf64 && ${PRINTOBJDIR}
85PARSELISTENV+=	LDD_ELF32DIR=${LDD_ELF32DIR} LDD_ELF64DIR=${LDD_ELF64DIR}
86
87#	Specially built objects to override the behaviour of
88#	various library functions
89#
90
91OVERRIDEOBJS=	rcmd.o
92.PATH:	${NETBSDSRCDIR}/lib/libc/net
93CPPFLAGS.rcmd.c+=-I${NETBSDSRCDIR}/lib/libc/include -DRESCUEDIR=\"${RESCUEDIR}\"
94
95LIBOVERRIDE=	liboverride.o
96${LIBOVERRIDE}: ${OVERRIDEOBJS}
97	${_MKTARGET_LINK}
98	${LD} -r -o $@ ${OVERRIDEOBJS}
99
100CLEANFILES+=	${OVERRIDEOBJS} ${LIBOVERRIDE}
101
102${CRUNCHBIN}:	${LIBOVERRIDE}
103
104
105#	The primary target ...
106#
107
108CLEANFILES+=	rescue.unstripped
109
110.include "${DISTRIBDIR}/common/Makefile.crunch"
111
112realall: ${CRUNCHBIN}
113
114install: ${CRUNCHBIN}
115# XXX this MKMSG doesn't line up
116	${_MKMSG} "populate ${TARGETDIR}"
117	${PARSELIST} -v mode=install ${LISTS} | ${MAKE} -f - install
118
119.include <bsd.prog.mk>
120