1324453Simp# $FreeBSD: stable/11/stand/libsa/Makefile 360660 2020-05-05 17:10:49Z dim $
2329132Skevans# Originally from	$NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
3329132Skevans#
4329132Skevans# Notes:
5329132Skevans# - We don't use the libc strerror/sys_errlist because the string table is
6329132Skevans#   quite large.
7329132Skevans#
8324453Simp
9329140Skevans.include <bsd.init.mk>
10324453Simp
11329140SkevansLIBSA_CPUARCH?=${MACHINE_CPUARCH}
12324453Simp
13329134SkevansLIB?=		sa
14329132Skevans
15329132Skevans# standalone components and stuff we have modified locally
16329175SkevansSRCS+=	gzguts.h zutil.h __main.c abort.c assert.c bcd.c environment.c getopt.c gets.c \
17329175Skevans	globals.c pager.c panic.c printf.c strdup.c strerror.c \
18329135Skevans	random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c
19329132Skevans
20329132Skevans# private (pruned) versions of libc string functions
21329132SkevansSRCS+=	strcasecmp.c
22329132Skevans
23351515Skevans.PATH: ${LIBCSRC}/net
24329132Skevans
25329132SkevansSRCS+= ntoh.c
26329132Skevans
27329132Skevans# string functions from libc
28351515Skevans.PATH: ${LIBCSRC}/string
29329132SkevansSRCS+=	bcmp.c bcopy.c bzero.c ffs.c fls.c \
30329132Skevans	memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
31351515Skevans	strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \
32329132Skevans	strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
33329132Skevans	strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
34329175Skevans
35329175Skevans# stdlib functions from libc
36351515Skevans.PATH: ${LIBCSRC}/stdlib
37329175SkevansSRCS+=	abs.c strtol.c strtoll.c strtoul.c strtoull.c
38329175Skevans
39344378Skevans# common boot code
40344378Skevans.PATH:	${SYSDIR}/kern
41344378SkevansSRCS+=	subr_boot.c
42344378Skevans
43329132Skevans.if ${MACHINE_CPUARCH} == "arm"
44351515Skevans.PATH: ${LIBCSRC}/arm/gen
45329132Skevans
46329132Skevans# Do not generate movt/movw, because the relocation fixup for them does not
47329132Skevans# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
48329132Skevans# Also, the fpu is not available in a standalone environment.
49329132Skevans.if ${COMPILER_VERSION} < 30800
50329132SkevansCFLAGS.clang+=	-mllvm -arm-use-movt=0
51329132Skevans.else
52329132SkevansCFLAGS.clang+=	-mno-movt
53329132Skevans.endif
54329132SkevansCFLAGS.clang+=	-mfpu=none
55329132Skevans
56360660Sdim.PATH: ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins/arm/
57329132SkevansSRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
58329132SkevansSRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
59329132Skevans.endif
60329132Skevans
61329132Skevans.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
62351515Skevans.PATH: ${LIBCSRC}/${MACHINE_CPUARCH}/gen
63329132Skevans.endif
64329132Skevans
65351515Skevans# Compiler support functions
66360660Sdim.PATH: ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins/
67351515Skevans# __clzsi2 and ctzsi2 for various builtin functions
68351515SkevansSRCS+=	clzsi2.c ctzsi2.c
69351515Skevans# Divide and modulus functions called by the compiler
70351515SkevansSRCS+=	divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
71351515SkevansSRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
72351515SkevansSRCS+=	ashldi3.c ashrdi3.c lshrdi3.c
73351515Skevans
74329132Skevans.if ${MACHINE_CPUARCH} == "powerpc"
75329132SkevansSRCS+=	syncicache.c
76329132Skevans.endif
77329132Skevans
78329132Skevans# uuid functions from libc
79351515Skevans.PATH: ${LIBCSRC}/uuid
80329132SkevansSRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
81329132Skevans
82329132Skevans# _setjmp/_longjmp
83329140Skevans.PATH: ${SASRC}/${LIBSA_CPUARCH}
84329132SkevansSRCS+=	_setjmp.S
85329132Skevans
86329132Skevans# decompression functionality from libbz2
87329132Skevans# NOTE: to actually test this functionality after libbz2 upgrade compile
88329132Skevans# loader(8) with LOADER_BZIP2_SUPPORT defined
89329138Skevans.PATH: ${SRCTOP}/contrib/bzip2
90329132SkevansCFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
91329132Skevans
92329175SkevansSRCS+=bzlib.c crctable.c decompress.c huffman.c randtable.c
93329132Skevans
94329132Skevans# decompression functionality from zlib
95348261Sdelphij.PATH: ${SRCTOP}/sys/contrib/zlib
96348261SdelphijCFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
97329175SkevansSRCS+=	adler32.c crc32.c
98329175SkevansSRCS+=	infback.c inffast.c inflate.c inftrees.c zutil.c
99329132Skevans
100329175Skevans# Create a subset of includes that are safe, as well as adjusting those that aren't
101329175Skevans# The lists may drive people nuts, but they are explicitly opt-in
102329175SkevansFAKE_DIRS=xlocale arpa
103329175SkevansSAFE_INCS=a.out.h assert.h elf.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h
104329175SkevansSTAND_H_INC=ctype.h fcntl.h signal.h stdio.h stdlib.h
105329175SkevansOTHER_INC=stdarg.h errno.h stdint.h
106329132Skevans
107329175Skevansbeforedepend:
108329175Skevans	mkdir -p ${FAKE_DIRS}; \
109329175Skevans	for i in ${SAFE_INCS}; do \
110329175Skevans		ln -sf ${SRCTOP}/include/$$i $$i; \
111329175Skevans	done; \
112329175Skevans	ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \
113329175Skevans	ln -sf ${SYSDIR}/sys/errno.h errno.h; \
114329175Skevans	ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \
115329175Skevans	ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
116329175Skevans	ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
117329175Skevans	for i in _time.h _strings.h _string.h; do \
118329175Skevans		[ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
119329175Skevans	done; \
120329175Skevans	for i in ${STAND_H_INC}; do \
121329175Skevans		ln -sf ${SASRC}/stand.h $$i; \
122329175Skevans	done
123329175SkevansCLEANDIRS+=${FAKE_DIRS}
124329175SkevansCLEANFILES+= ${SAFE_INCS} ${STAND_H_INC} ${OTHER_INC}
125329132Skevans
126329132Skevans# io routines
127329132SkevansSRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
128329132Skevans	fstat.c close.c lseek.c open.c read.c write.c readdir.c
129329132Skevans
130329132Skevans# network routines
131329132SkevansSRCS+=	arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
132329132Skevans
133329132Skevans# network info services:
134329132SkevansSRCS+=	bootp.c rarp.c bootparam.c
135329132Skevans
136329132Skevans# boot filesystems
137329132SkevansSRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
138329132SkevansSRCS+=	dosfs.c ext2fs.c
139329132SkevansSRCS+=	splitfs.c
140329132SkevansSRCS+=	pkgfs.c
141329132Skevans.if ${MK_NAND} != "no"
142329132SkevansSRCS+=	nandfs.c
143329132Skevans.endif
144329132Skevans
145329175SkevansCFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2
146329175Skevans
147329132Skevans# explicit_bzero
148329140Skevans.PATH: ${SYSDIR}/libkern
149329132SkevansSRCS+=  explicit_bzero.c
150329132Skevans
151344373Skevans# Maybe GELI
152344373Skevans.if ${MK_LOADER_GELI} == "yes"
153344373Skevans.include "${SASRC}/geli/Makefile.inc"
154344373Skevans.endif
155344373Skevans
156344377Skevans# Maybe ZFS
157344399Skevans.if ${MK_LOADER_ZFS} == "yes"
158344377Skevans.include "${SASRC}/zfs/Makefile.inc"
159344377Skevans.endif
160344377Skevans
161329132Skevans.include <bsd.lib.mk>
162