1# $FreeBSD: stable/12/tools/build/Makefile 373330 2024-12-12 22:45:14Z jrtc27 $
2
3.PATH: ${.CURDIR}/../../include
4
5LIB=		egacy
6SRC=
7INCSGROUPS=	INCS SYSINCS UFSINCS FFSINCS MSDOSFSINCS DISKINCS
8INCS=
9
10SYSINCSDIR=	${INCLUDEDIR}/sys
11# Also add ufs/ffs/msdosfs/disk headers to allow building makefs as a bootstrap tool
12UFSINCSDIR=	${INCLUDEDIR}/ufs/ufs
13FFSINCSDIR=	${INCLUDEDIR}/ufs/ffs
14MSDOSFSINCSDIR=	${INCLUDEDIR}/fs/msdosfs
15DISKINCSDIR=	${INCLUDEDIR}/sys/disk
16
17BOOTSTRAPPING?=	0
18
19_WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true
20.if ${_WITH_PWCACHEDB} == 0
21.PATH: ${.CURDIR}/../../contrib/libc-pwcache
22CFLAGS+=	-I${.CURDIR}/../../contrib/libc-pwcache \
23		-I${.CURDIR}/../../lib/libc/include
24SRCS+=		pwcache.c
25.endif
26
27_WITH_STRSVIS!=	grep -c strsvis /usr/include/vis.h || true
28.if ${_WITH_STRSVIS} == 0
29.PATH: ${.CURDIR}/../../contrib/libc-vis
30SRCS+=		vis.c
31CFLAGS+=	-I${.CURDIR}/../../contrib/libc-vis \
32		-I${.CURDIR}/../../lib/libc/include
33.endif
34
35_WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true
36.if ${_WITH_REALLOCARRAY} == 0
37.PATH: ${.CURDIR}/../../lib/libc/stdlib
38INCS+=		stdlib.h
39SRCS+=		reallocarray.c
40CFLAGS+=	-I${.CURDIR}/../../lib/libc/include
41.endif
42
43_WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true
44.if ${_WITH_UTIMENS} == 0
45SYSINCS+=	stat.h
46SRCS+=		futimens.c utimensat.c
47.endif
48
49_WITH_EXPLICIT_BZERO!= grep -c explicit_bzero /usr/include/strings.h || true
50.if ${_WITH_EXPLICIT_BZERO} == 0
51.PATH: ${SRCTOP}/sys/libkern
52INCS+=		strings.h
53SRCS+=		explicit_bzero.c
54.endif
55
56.if empty(SRCS)
57SRCS=		dummy.c
58.endif
59
60.if defined(CROSS_BUILD_TESTING)
61SUBDIR=		cross-build
62.endif
63
64# To allow bootstrapping makefs on FreeBSD 11 or non-FreeBSD systems:
65UFSINCS+=	${SRCTOP}/sys/ufs/ufs/dinode.h
66UFSINCS+=	${SRCTOP}/sys/ufs/ufs/dir.h
67FFSINCS+=	${SRCTOP}/sys/ufs/ffs/fs.h
68
69MSDOSFSINCS+=	${SRCTOP}/sys/fs/msdosfs/bootsect.h
70MSDOSFSINCS+=	${SRCTOP}/sys/fs/msdosfs/bpb.h
71MSDOSFSINCS+=	${SRCTOP}/sys/fs/msdosfs/denode.h
72MSDOSFSINCS+=	${SRCTOP}/sys/fs/msdosfs/direntry.h
73MSDOSFSINCS+=	${SRCTOP}/sys/fs/msdosfs/fat.h
74MSDOSFSINCS+=	${SRCTOP}/sys/fs/msdosfs/msdosfsmount.h
75DISKINCS+=	${SRCTOP}/sys/sys/disk/bsd.h
76
77# Needed to build config (since it uses libnv)
78SYSINCS+=	${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h
79
80
81# Create all the directories that are needed during the legacy, bootstrap-tools
82# and cross-tools stages. We do this here using mkdir since mtree may not exist
83# yet (this happens if we are crossbuilding from Linux/Mac).
84installdirs:
85.for _dir in bin sbin usr/bin usr/sbin usr/lib usr/include lib/geom lib/casper
86	mkdir -p "${DESTDIR}/${_dir}"
87.endfor
88
89.for _group in ${INCSGROUPS:NINCS}
90	mkdir -p "${DESTDIR}/${${_group}DIR}"
91.endfor
92
93.include <bsd.lib.mk>
94