xref: /freebsd/stand/libsa/Makefile (revision 05f37f4d86721a17fd1657a48b1de148f8075dd4)
1ca987d46SWarner Losh# $FreeBSD$
2ca987d46SWarner Losh# Originally from	$NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
3ca987d46SWarner Losh#
4ca987d46SWarner Losh# Notes:
5ca987d46SWarner Losh# - We don't use the libc strerror/sys_errlist because the string table is
6ca987d46SWarner Losh#   quite large.
7ca987d46SWarner Losh#
8ca987d46SWarner Losh
9ca987d46SWarner LoshMK_PROFILE=	no
10ca987d46SWarner LoshMK_SSP=		no
11ca987d46SWarner Losh
12ca987d46SWarner Losh.include <bsd.init.mk>
13ca987d46SWarner Losh
14ca987d46SWarner LoshINTERNALLIB=
15ca987d46SWarner LoshLIBSA_CPUARCH?=${MACHINE_CPUARCH}
16ca987d46SWarner LoshLIBC_SRC=	${SRCTOP}/lib/libc
17ca987d46SWarner Losh
18ca987d46SWarner LoshLIB?=		sa
19ca987d46SWarner LoshNO_PIC=
20ca987d46SWarner Losh
21ca987d46SWarner Losh# standalone components and stuff we have modified locally
22ca987d46SWarner LoshSRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
23ca987d46SWarner Losh	globals.c pager.c panic.c printf.c strdup.c strerror.c strtol.c strtoul.c \
24ca987d46SWarner Losh	random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c
25ca987d46SWarner Losh
26ca987d46SWarner Losh# private (pruned) versions of libc string functions
27ca987d46SWarner LoshSRCS+=	strcasecmp.c
28ca987d46SWarner Losh
29ca987d46SWarner Losh.PATH: ${LIBC_SRC}/net
30ca987d46SWarner Losh
31ca987d46SWarner LoshSRCS+= ntoh.c
32ca987d46SWarner Losh
33ca987d46SWarner Losh# string functions from libc
34ca987d46SWarner Losh.PATH: ${LIBC_SRC}/string
35ca987d46SWarner LoshSRCS+=	bcmp.c bcopy.c bzero.c ffs.c fls.c \
36ca987d46SWarner Losh	memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
37ca987d46SWarner Losh	qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \
38ca987d46SWarner Losh	strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
39ca987d46SWarner Losh	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
40ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "arm"
41ca987d46SWarner Losh.PATH: ${LIBC_SRC}/arm/gen
42ca987d46SWarner Losh
43ca987d46SWarner Losh# Do not generate movt/movw, because the relocation fixup for them does not
44ca987d46SWarner Losh# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
45ca987d46SWarner Losh# Also, the fpu is not available in a standalone environment.
46ca987d46SWarner Losh.if ${COMPILER_VERSION} < 30800
47ca987d46SWarner LoshCFLAGS.clang+=	-mllvm -arm-use-movt=0
48ca987d46SWarner Losh.else
49ca987d46SWarner LoshCFLAGS.clang+=	-mno-movt
50ca987d46SWarner Losh.endif
51ca987d46SWarner LoshCFLAGS.clang+=	-mfpu=none
52ca987d46SWarner Losh
53ca987d46SWarner Losh# Compiler support functions
54ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/
55ca987d46SWarner Losh# __clzsi2 and ctzsi2 for various builtin functions
56ca987d46SWarner LoshSRCS+=	clzsi2.c ctzsi2.c
57ca987d46SWarner Losh# Divide and modulus functions called by the compiler
58ca987d46SWarner LoshSRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
59ca987d46SWarner LoshSRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
60ca987d46SWarner Losh
61ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/
62ca987d46SWarner LoshSRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
63ca987d46SWarner LoshSRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
64ca987d46SWarner Losh.endif
65ca987d46SWarner Losh
66ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
67ca987d46SWarner Losh.PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
68ca987d46SWarner Losh.endif
69ca987d46SWarner Losh
70ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "powerpc"
71ca987d46SWarner Losh.PATH: ${LIBC_SRC}/quad
72ca987d46SWarner LoshSRCS+=	ashldi3.c ashrdi3.c
73ca987d46SWarner LoshSRCS+=	syncicache.c
74ca987d46SWarner Losh.endif
75ca987d46SWarner Losh
76ca987d46SWarner Losh# uuid functions from libc
77ca987d46SWarner Losh.PATH: ${LIBC_SRC}/uuid
78ca987d46SWarner LoshSRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
79ca987d46SWarner Losh
80ca987d46SWarner Losh# _setjmp/_longjmp
81ca987d46SWarner Losh.PATH: ${SASRC}/${LIBSA_CPUARCH}
82ca987d46SWarner LoshSRCS+=	_setjmp.S
83ca987d46SWarner Losh
84ca987d46SWarner Losh# decompression functionality from libbz2
85ca987d46SWarner Losh# NOTE: to actually test this functionality after libbz2 upgrade compile
86ca987d46SWarner Losh# loader(8) with LOADER_BZIP2_SUPPORT defined
87ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/bzip2
88ca987d46SWarner LoshCFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
89ca987d46SWarner LoshSRCS+=	libsa_bzlib_private.h
90ca987d46SWarner Losh
91ca987d46SWarner Losh.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
92ca987d46SWarner LoshSRCS+=	_${file}
93ca987d46SWarner LoshCLEANFILES+=	_${file}
94*05f37f4dSWarner LoshCFLAGS._${file}+=-I${SRCTOP}/contrib/bzip2
95ca987d46SWarner Losh
96ca987d46SWarner Losh_${file}: ${file}
97ca987d46SWarner Losh	sed "s|bzlib_private\.h|libsa_bzlib_private.h|" \
98ca987d46SWarner Losh	    ${.ALLSRC} > ${.TARGET}
99ca987d46SWarner Losh.endfor
100ca987d46SWarner Losh
101ca987d46SWarner LoshCLEANFILES+= libsa_bzlib_private.h
102ca987d46SWarner Loshlibsa_bzlib_private.h: bzlib_private.h
103ca987d46SWarner Losh	sed -e 's|<stdlib.h>|"stand.h"|' \
104ca987d46SWarner Losh		${.ALLSRC} > ${.TARGET}
105ca987d46SWarner Losh
106ca987d46SWarner Losh# decompression functionality from zlib
107ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/zlib
108ca987d46SWarner LoshCFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/contrib/zlib
109ca987d46SWarner LoshSRCS+=	adler32.c crc32.c libsa_zutil.h libsa_gzguts.h
110ca987d46SWarner Losh
111ca987d46SWarner Losh.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
112ca987d46SWarner LoshSRCS+=	_${file}
113ca987d46SWarner LoshCLEANFILES+=	_${file}
114ca987d46SWarner Losh
115ca987d46SWarner Losh_${file}: ${file}
116ca987d46SWarner Losh	sed -e "s|zutil\.h|libsa_zutil.h|" \
117ca987d46SWarner Losh	    -e "s|gzguts\.h|libsa_gzguts.h|" \
118ca987d46SWarner Losh	    ${.ALLSRC} > ${.TARGET}
119ca987d46SWarner Losh.endfor
120ca987d46SWarner Losh
121ca987d46SWarner Losh# depend on stand.h being able to be included multiple times
122ca987d46SWarner Losh.for file in zutil.h gzguts.h
123ca987d46SWarner LoshCLEANFILES+= libsa_${file}
124ca987d46SWarner Loshlibsa_${file}: ${file}
125ca987d46SWarner Losh	sed -e 's|<fcntl.h>|"stand.h"|' \
126ca987d46SWarner Losh	    -e 's|<stddef.h>|"stand.h"|' \
127ca987d46SWarner Losh	    -e 's|<string.h>|"stand.h"|' \
128ca987d46SWarner Losh	    -e 's|<stdio.h>|"stand.h"|' \
129ca987d46SWarner Losh	    -e 's|<stdlib.h>|"stand.h"|' \
130ca987d46SWarner Losh	    ${.ALLSRC} > ${.TARGET}
131ca987d46SWarner Losh.endfor
132ca987d46SWarner Losh
133*05f37f4dSWarner Losh# Create a subset of includes that are safe, as well as adjusting those that aren't
134*05f37f4dSWarner Losh# The lists may drive people nuts, but they are explicitly opt-in
135*05f37f4dSWarner Loshbeforedepend:
136*05f37f4dSWarner Losh	echo beforedepend; \
137*05f37f4dSWarner Losh	mkdir -p xlocale arpa; \
138*05f37f4dSWarner Losh	for i in 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; do \
139*05f37f4dSWarner Losh		ln -sf ${SRCTOP}/include/$$i $$i; \
140*05f37f4dSWarner Losh	done; \
141*05f37f4dSWarner Losh	ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \
142*05f37f4dSWarner Losh	ln -sf ${SYSDIR}/sys/errno.h errno.h; \
143*05f37f4dSWarner Losh	ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \
144*05f37f4dSWarner Losh	ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
145*05f37f4dSWarner Losh	ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
146*05f37f4dSWarner Losh	for i in _time.h _strings.h _string.h; do \
147*05f37f4dSWarner Losh		[ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
148*05f37f4dSWarner Losh	done; \
149*05f37f4dSWarner Losh	for i in ctype.h stdio.h stdlib.h; do \
150*05f37f4dSWarner Losh		ln -sf ${SASRC}/stand.h $$i; \
151*05f37f4dSWarner Losh	done
152*05f37f4dSWarner Losh
153ca987d46SWarner Losh# io routines
154ca987d46SWarner LoshSRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
155ca987d46SWarner Losh	fstat.c close.c lseek.c open.c read.c write.c readdir.c
156ca987d46SWarner Losh
157ca987d46SWarner Losh# network routines
158ca987d46SWarner LoshSRCS+=	arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
159ca987d46SWarner Losh
160ca987d46SWarner Losh# network info services:
161ca987d46SWarner LoshSRCS+=	bootp.c rarp.c bootparam.c
162ca987d46SWarner Losh
163ca987d46SWarner Losh# boot filesystems
164ca987d46SWarner LoshSRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
165ca987d46SWarner LoshSRCS+=	dosfs.c ext2fs.c
166ca987d46SWarner LoshSRCS+=	splitfs.c
167ca987d46SWarner LoshSRCS+=	pkgfs.c
168ca987d46SWarner Losh.if ${MK_NAND} != "no"
169ca987d46SWarner LoshSRCS+=	nandfs.c
170ca987d46SWarner Losh.endif
171ca987d46SWarner Losh
172*05f37f4dSWarner LoshCFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2
173*05f37f4dSWarner Losh
174ca987d46SWarner Losh# explicit_bzero
175ca987d46SWarner Losh.PATH: ${SYSDIR}/libkern
176ca987d46SWarner LoshSRCS+=  explicit_bzero.c
177ca987d46SWarner Losh
178ca987d46SWarner Losh.include <bsd.stand.mk>
179ca987d46SWarner Losh.include <bsd.lib.mk>
180