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 Losh.include <bsd.init.mk> 10ca987d46SWarner Losh 11ca987d46SWarner LoshLIBSA_CPUARCH?=${MACHINE_CPUARCH} 12ca987d46SWarner Losh 13ca987d46SWarner LoshLIB?= sa 14ca987d46SWarner Losh 15ca987d46SWarner Losh# standalone components and stuff we have modified locally 16ed19b7c5SSimon J. GerratySRCS+= gzguts.h zutil.h __main.c abort.c assert.c bcd.c environment.c \ 17ed19b7c5SSimon J. Gerraty getopt.c gets.c globals.c \ 18ed19b7c5SSimon J. Gerraty hexdump.c pager.c panic.c printf.c strdup.c strerror.c \ 19e193d3baSColin Percival random.c sbrk.c tslog.c twiddle.c zalloc.c zalloc_malloc.c 20ca987d46SWarner Losh 21ca987d46SWarner Losh# private (pruned) versions of libc string functions 22ca987d46SWarner LoshSRCS+= strcasecmp.c 23ca987d46SWarner Losh 2480335781SKyle Evans.PATH: ${LIBCSRC}/net 25ca987d46SWarner Losh 26ca987d46SWarner LoshSRCS+= ntoh.c 27ca987d46SWarner Losh 28ca987d46SWarner Losh# string functions from libc 2980335781SKyle Evans.PATH: ${LIBCSRC}/string 30ca987d46SWarner LoshSRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ 31ca987d46SWarner Losh memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \ 327f72497eSEd Maste strcat.c strchr.c strchrnul.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ 33ca987d46SWarner Losh strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ 3437cb59c8SKyle Evans strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c 3524dfa658SWarner Losh 3624dfa658SWarner Losh# stdlib functions from libc 3780335781SKyle Evans.PATH: ${LIBCSRC}/stdlib 38afa643baSWarner LoshSRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c 3924dfa658SWarner Losh 4052379d36SWarner Losh# common boot code 4152379d36SWarner Losh.PATH: ${SYSDIR}/kern 4252379d36SWarner LoshSRCS+= subr_boot.c 4352379d36SWarner Losh 44ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "arm" 4580335781SKyle Evans.PATH: ${LIBCSRC}/arm/gen 46ca987d46SWarner Losh 47ca987d46SWarner Losh# Do not generate movt/movw, because the relocation fixup for them does not 48ca987d46SWarner Losh# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). 49ca987d46SWarner Losh# Also, the fpu is not available in a standalone environment. 50ca987d46SWarner LoshCFLAGS.clang+= -mno-movt 51ca987d46SWarner LoshCFLAGS.clang+= -mfpu=none 52ca987d46SWarner Losh 530b57cec5SDimitry Andric.PATH: ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins/arm/ 54ca987d46SWarner LoshSRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S 55ca987d46SWarner LoshSRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S 56ca987d46SWarner Losh.endif 57ca987d46SWarner Losh 58ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" 5980335781SKyle Evans.PATH: ${LIBCSRC}/${MACHINE_CPUARCH}/gen 60ca987d46SWarner Losh.endif 61ca987d46SWarner Losh 6280746f9fSKyle Evans# Compiler support functions 630b57cec5SDimitry Andric.PATH: ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins/ 6480746f9fSKyle Evans# __clzsi2 and ctzsi2 for various builtin functions 6580746f9fSKyle EvansSRCS+= clzsi2.c ctzsi2.c 6680746f9fSKyle Evans# Divide and modulus functions called by the compiler 6780746f9fSKyle EvansSRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c 6880746f9fSKyle EvansSRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c 6963d8b6eaSKyle EvansSRCS+= ashldi3.c ashrdi3.c lshrdi3.c 70ca987d46SWarner Losh 71e9b148a3SSimon J. Gerraty.if ${MACHINE_CPUARCH:Namd64:Ni386} == "" 72e9b148a3SSimon J. Gerraty.PATH: ${SASRC}/x86 73e9b148a3SSimon J. GerratySRCS+= hypervisor.c 74e9b148a3SSimon J. Gerraty.endif 75e9b148a3SSimon J. Gerraty 7680746f9fSKyle Evans.if ${MACHINE_CPUARCH} == "powerpc" 7780746f9fSKyle EvansSRCS+= syncicache.c 78bd7c104aSWarner Losh.endif 79bd7c104aSWarner Losh 80ca987d46SWarner Losh# uuid functions from libc 8180335781SKyle Evans.PATH: ${LIBCSRC}/uuid 82ca987d46SWarner LoshSRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c 83ca987d46SWarner Losh 84ca987d46SWarner Losh# _setjmp/_longjmp 85ca987d46SWarner Losh.PATH: ${SASRC}/${LIBSA_CPUARCH} 86ca987d46SWarner LoshSRCS+= _setjmp.S 87ca987d46SWarner Losh 88ca987d46SWarner Losh# decompression functionality from libbz2 89ca987d46SWarner Losh# NOTE: to actually test this functionality after libbz2 upgrade compile 90ca987d46SWarner Losh# loader(8) with LOADER_BZIP2_SUPPORT defined 91ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/bzip2 9259a4cfe0SWarner Losh.for i in bzlib.c crctable.c decompress.c huffman.c randtable.c 9359a4cfe0SWarner LoshCFLAGS.${i}+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS 9459a4cfe0SWarner LoshSRCS+=${i} 9559a4cfe0SWarner Losh.endfor 96ca987d46SWarner Losh 97ca987d46SWarner Losh# decompression functionality from zlib 98c9083b85SXin LI.PATH: ${SRCTOP}/sys/contrib/zlib 99*983a1802SWarner LoshZLIB_CFLAGS=-DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib ${NO_WDEPRECATED_NON_PROTOTYPE} 10084bf2bbbSWarner Losh.for i in adler32.c crc32.c infback.c inffast.c inflate.c inftrees.c zutil.c 10184bf2bbbSWarner LoshCFLAGS.${i}+=${ZLIB_CFLAGS} 10284bf2bbbSWarner LoshSRCS+= ${i} 10384bf2bbbSWarner Losh.endfor 104ca987d46SWarner Losh 105e499793eSToomas Soome# lz4 decompression functionality 106e499793eSToomas Soome.PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 107e499793eSToomas SoomeSRCS+= lz4.c 108e499793eSToomas SoomeCFLAGS.lz4.c+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 109e499793eSToomas Soome 11005f37f4dSWarner Losh# Create a subset of includes that are safe, as well as adjusting those that aren't 11105f37f4dSWarner Losh# The lists may drive people nuts, but they are explicitly opt-in 112c5095910SWarner LoshFAKE_DIRS=xlocale arpa 113c5095910SWarner LoshSAFE_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 114c5095910SWarner LoshSTAND_H_INC=ctype.h fcntl.h signal.h stdio.h stdlib.h 115c5095910SWarner LoshOTHER_INC=stdarg.h errno.h stdint.h 116c5095910SWarner Losh 11705f37f4dSWarner Loshbeforedepend: 118c5095910SWarner Losh mkdir -p ${FAKE_DIRS}; \ 119c5095910SWarner Losh for i in ${SAFE_INCS}; do \ 12005f37f4dSWarner Losh ln -sf ${SRCTOP}/include/$$i $$i; \ 12105f37f4dSWarner Losh done; \ 12205f37f4dSWarner Losh ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \ 12305f37f4dSWarner Losh ln -sf ${SYSDIR}/sys/errno.h errno.h; \ 12405f37f4dSWarner Losh ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \ 12505f37f4dSWarner Losh ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \ 12605f37f4dSWarner Losh ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \ 12705f37f4dSWarner Losh for i in _time.h _strings.h _string.h; do \ 128a5ebda46SWarner Losh [ -f xlocale/$$i ] || :> xlocale/$$i; \ 12905f37f4dSWarner Losh done; \ 130c5095910SWarner Losh for i in ${STAND_H_INC}; do \ 13105f37f4dSWarner Losh ln -sf ${SASRC}/stand.h $$i; \ 13205f37f4dSWarner Losh done 133c5095910SWarner LoshCLEANDIRS+=${FAKE_DIRS} 134c5095910SWarner LoshCLEANFILES+= ${SAFE_INCS} ${STAND_H_INC} ${OTHER_INC} 13505f37f4dSWarner Losh 136ca987d46SWarner Losh# io routines 137b4cb3fe0SToomas SoomeSRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c mount.c \ 138c25d9affSEmmanuel Vadot fstat.c close.c lseek.c open.c read.c write.c readdir.c preload.c 139ca987d46SWarner Losh 140a64f0b83SWarner Losh# SMBios routines 141a64f0b83SWarner LoshSRCS+= smbios.c 142a64f0b83SWarner Losh.if !defined(BOOT_HIDE_SERIAL_NUMBERS) 143a64f0b83SWarner Losh# Export serial numbers, UUID, and asset tag from loader. 144a64f0b83SWarner LoshCFLAGS.smbios.c+= -DSMBIOS_SERIAL_NUMBERS 145a64f0b83SWarner Losh.if defined(BOOT_LITTLE_ENDIAN_UUID) 146a64f0b83SWarner Losh# Use little-endian UUID format as defined in SMBIOS 2.6. 147a64f0b83SWarner LoshCFLAGS.smbios.c+= -DSMBIOS_LITTLE_ENDIAN_UUID 148a64f0b83SWarner Losh.elif defined(BOOT_NETWORK_ENDIAN_UUID) 149a64f0b83SWarner Losh# Use network-endian UUID format for backward compatibility. 150a64f0b83SWarner LoshCFLAGS.smbios.c+= -DSMBIOS_NETWORK_ENDIAN_UUID 151a64f0b83SWarner Losh.endif 152a64f0b83SWarner Losh.endif 153a64f0b83SWarner Losh 154ca987d46SWarner Losh# network routines 155ca987d46SWarner LoshSRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c 156ca987d46SWarner Losh 157ca987d46SWarner Losh# network info services: 158ca987d46SWarner LoshSRCS+= bootp.c rarp.c bootparam.c 159ca987d46SWarner Losh 160ca987d46SWarner Losh# boot filesystems 161ca987d46SWarner LoshSRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c 162ca987d46SWarner LoshSRCS+= dosfs.c ext2fs.c 163ca987d46SWarner LoshSRCS+= splitfs.c 164ca987d46SWarner LoshSRCS+= pkgfs.c 165ca987d46SWarner Losh 1666ab1ffcbSWarner Losh# Time support 1676ab1ffcbSWarner LoshSRCS+= time.c 1686ab1ffcbSWarner Losh 169dffce215SKirk McKusick# kernel ufs support 170dffce215SKirk McKusick.PATH: ${SRCTOP}/sys/ufs/ffs 171dffce215SKirk McKusickSRCS+=ffs_subr.c ffs_tables.c 172dffce215SKirk McKusick 17314821130SWarner Losh# 17414821130SWarner Losh# i386 has a constrained space for its /boot/loader, so compile out the 17514821130SWarner Losh# extensive messages diagnosing bad superblocks. i386 doesn't support UEFI 17614821130SWarner Losh# booting, so doing it always makes sense natively there. When we compile 17714821130SWarner Losh# for 32-bit on amd64, LIBSA_CPUARCH is also i386 and we use libsa32 only 17814821130SWarner Losh# for the BIOS /boot/loader which has the same constraints. 17914821130SWarner Losh# 18014821130SWarner Losh.if ${LIBSA_CPUARCH} == "i386" 18114821130SWarner LoshCFLAGS.ffs_subr.c+= -DSTANDALONE_SMALL 18214821130SWarner Losh.endif 18314821130SWarner Losh 18484bf2bbbSWarner LoshCFLAGS.gzipfs.c+= ${ZLIB_CFLAGS} 18584bf2bbbSWarner LoshCFLAGS.pkgfs.c+= ${ZLIB_CFLAGS} 18659a4cfe0SWarner LoshCFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2 -DBZ_NO_STDIO -DBZ_NO_COMPRESS 18705f37f4dSWarner Losh 188ad6f5f9aSKonstantin Belousov# explicit_bzero and calculate_crc32c 189ca987d46SWarner Losh.PATH: ${SYSDIR}/libkern 190ad6f5f9aSKonstantin BelousovSRCS+= explicit_bzero.c crc32_libkern.c 191ca987d46SWarner Losh 19262bd02ceSWarner Losh# Maybe GELI 19362bd02ceSWarner Losh.if ${MK_LOADER_GELI} == "yes" 19462bd02ceSWarner Losh.include "${SASRC}/geli/Makefile.inc" 19562bd02ceSWarner Losh.endif 19662bd02ceSWarner Losh 1978df8b2d3SSimon J. Gerraty.if ${MK_LOADER_VERIEXEC} == "yes" && ${MK_BEARSSL} == "yes" 19837dabb06SWarner Losh# XXX Note that these pollutes CFLAGS in a way that's not easy to fix 1998df8b2d3SSimon J. Gerraty.include "${SRCTOP}/lib/libbearssl/Makefile.libsa.inc" 2008df8b2d3SSimon J. Gerraty.include "${SRCTOP}/lib/libsecureboot/Makefile.libsa.inc" 2018df8b2d3SSimon J. Gerraty.endif 2028df8b2d3SSimon J. Gerraty 203b8902de1SWarner Losh# Maybe ZFS 204fbeb31a2SMatt Macy.if ${MK_LOADER_ZFS} == "yes" 205b8902de1SWarner Losh.include "${SASRC}/zfs/Makefile.inc" 206b8902de1SWarner Losh.endif 207b8902de1SWarner Losh 20870b5c4ffSWarner Losh.if ${DO32:U0} == 0 20970b5c4ffSWarner LoshMAN=libsa.3 21070b5c4ffSWarner Losh.endif 21170b5c4ffSWarner Losh 212ca987d46SWarner Losh.include <bsd.lib.mk> 213