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 162b0268cfSWarner LoshSRCS+= gzguts.h zutil.h __main.c abort.c assert.c bcd.c environment.c getopt.c gets.c \ 17afa643baSWarner Losh globals.c pager.c panic.c printf.c strdup.c strerror.c \ 18ca987d46SWarner Losh random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c 19ca987d46SWarner Losh 20ca987d46SWarner Losh# private (pruned) versions of libc string functions 21ca987d46SWarner LoshSRCS+= strcasecmp.c 22ca987d46SWarner Losh 2380335781SKyle Evans.PATH: ${LIBCSRC}/net 24ca987d46SWarner Losh 25ca987d46SWarner LoshSRCS+= ntoh.c 26ca987d46SWarner Losh 27ca987d46SWarner Losh# string functions from libc 2880335781SKyle Evans.PATH: ${LIBCSRC}/string 29ca987d46SWarner LoshSRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \ 30ca987d46SWarner Losh memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \ 31*80746f9fSKyle Evans strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \ 32ca987d46SWarner Losh strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \ 3337cb59c8SKyle Evans strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c 3424dfa658SWarner Losh 3524dfa658SWarner Losh# stdlib functions from libc 3680335781SKyle Evans.PATH: ${LIBCSRC}/stdlib 37afa643baSWarner LoshSRCS+= abs.c strtol.c strtoll.c strtoul.c strtoull.c 3824dfa658SWarner Losh 3952379d36SWarner Losh# common boot code 4052379d36SWarner Losh.PATH: ${SYSDIR}/kern 4152379d36SWarner LoshSRCS+= subr_boot.c 4252379d36SWarner Losh 43ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "arm" 4480335781SKyle Evans.PATH: ${LIBCSRC}/arm/gen 45ca987d46SWarner Losh 46ca987d46SWarner Losh# Do not generate movt/movw, because the relocation fixup for them does not 47ca987d46SWarner Losh# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). 48ca987d46SWarner Losh# Also, the fpu is not available in a standalone environment. 49ca987d46SWarner Losh.if ${COMPILER_VERSION} < 30800 50ca987d46SWarner LoshCFLAGS.clang+= -mllvm -arm-use-movt=0 51ca987d46SWarner Losh.else 52ca987d46SWarner LoshCFLAGS.clang+= -mno-movt 53ca987d46SWarner Losh.endif 54ca987d46SWarner LoshCFLAGS.clang+= -mfpu=none 55ca987d46SWarner Losh 56ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/ 57ca987d46SWarner LoshSRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S 58ca987d46SWarner LoshSRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S 59ca987d46SWarner Losh.endif 60ca987d46SWarner Losh 61ca987d46SWarner Losh.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" 6280335781SKyle Evans.PATH: ${LIBCSRC}/${MACHINE_CPUARCH}/gen 63ca987d46SWarner Losh.endif 64ca987d46SWarner Losh 65*80746f9fSKyle Evans# Compiler support functions 66*80746f9fSKyle Evans.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/ 67*80746f9fSKyle Evans# __clzsi2 and ctzsi2 for various builtin functions 68*80746f9fSKyle EvansSRCS+= clzsi2.c ctzsi2.c 69*80746f9fSKyle Evans# Divide and modulus functions called by the compiler 70*80746f9fSKyle EvansSRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c 71*80746f9fSKyle EvansSRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c 7263d8b6eaSKyle EvansSRCS+= ashldi3.c ashrdi3.c lshrdi3.c 73ca987d46SWarner Losh 74*80746f9fSKyle Evans.if ${MACHINE_CPUARCH} == "powerpc" 75*80746f9fSKyle EvansSRCS+= syncicache.c 76bd7c104aSWarner Losh.endif 77bd7c104aSWarner Losh 78ca987d46SWarner Losh# uuid functions from libc 7980335781SKyle Evans.PATH: ${LIBCSRC}/uuid 80ca987d46SWarner LoshSRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c 81ca987d46SWarner Losh 82ca987d46SWarner Losh# _setjmp/_longjmp 83ca987d46SWarner Losh.PATH: ${SASRC}/${LIBSA_CPUARCH} 84ca987d46SWarner LoshSRCS+= _setjmp.S 85ca987d46SWarner Losh 86ca987d46SWarner Losh# decompression functionality from libbz2 87ca987d46SWarner Losh# NOTE: to actually test this functionality after libbz2 upgrade compile 88ca987d46SWarner Losh# loader(8) with LOADER_BZIP2_SUPPORT defined 89ca987d46SWarner Losh.PATH: ${SRCTOP}/contrib/bzip2 90ca987d46SWarner LoshCFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS 91ca987d46SWarner Losh 9209d8a81aSWarner LoshSRCS+=bzlib.c crctable.c decompress.c huffman.c randtable.c 93ca987d46SWarner Losh 94ca987d46SWarner Losh# decompression functionality from zlib 95c9083b85SXin LI.PATH: ${SRCTOP}/sys/contrib/zlib 96c9083b85SXin LICFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib 9709d8a81aSWarner LoshSRCS+= adler32.c crc32.c 9809d8a81aSWarner LoshSRCS+= infback.c inffast.c inflate.c inftrees.c zutil.c 99ca987d46SWarner Losh 10005f37f4dSWarner Losh# Create a subset of includes that are safe, as well as adjusting those that aren't 10105f37f4dSWarner Losh# The lists may drive people nuts, but they are explicitly opt-in 102c5095910SWarner LoshFAKE_DIRS=xlocale arpa 103c5095910SWarner 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 104c5095910SWarner LoshSTAND_H_INC=ctype.h fcntl.h signal.h stdio.h stdlib.h 105c5095910SWarner LoshOTHER_INC=stdarg.h errno.h stdint.h 106c5095910SWarner Losh 10705f37f4dSWarner Loshbeforedepend: 108c5095910SWarner Losh mkdir -p ${FAKE_DIRS}; \ 109c5095910SWarner Losh for i in ${SAFE_INCS}; do \ 11005f37f4dSWarner Losh ln -sf ${SRCTOP}/include/$$i $$i; \ 11105f37f4dSWarner Losh done; \ 11205f37f4dSWarner Losh ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \ 11305f37f4dSWarner Losh ln -sf ${SYSDIR}/sys/errno.h errno.h; \ 11405f37f4dSWarner Losh ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \ 11505f37f4dSWarner Losh ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \ 11605f37f4dSWarner Losh ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \ 11705f37f4dSWarner Losh for i in _time.h _strings.h _string.h; do \ 11805f37f4dSWarner Losh [ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \ 11905f37f4dSWarner Losh done; \ 120c5095910SWarner Losh for i in ${STAND_H_INC}; do \ 12105f37f4dSWarner Losh ln -sf ${SASRC}/stand.h $$i; \ 12205f37f4dSWarner Losh done 123c5095910SWarner LoshCLEANDIRS+=${FAKE_DIRS} 124c5095910SWarner LoshCLEANFILES+= ${SAFE_INCS} ${STAND_H_INC} ${OTHER_INC} 12505f37f4dSWarner Losh 126ca987d46SWarner Losh# io routines 127ca987d46SWarner LoshSRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \ 128ca987d46SWarner Losh fstat.c close.c lseek.c open.c read.c write.c readdir.c 129ca987d46SWarner Losh 130ca987d46SWarner Losh# network routines 131ca987d46SWarner LoshSRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c 132ca987d46SWarner Losh 133ca987d46SWarner Losh# network info services: 134ca987d46SWarner LoshSRCS+= bootp.c rarp.c bootparam.c 135ca987d46SWarner Losh 136ca987d46SWarner Losh# boot filesystems 137ca987d46SWarner LoshSRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c 138ca987d46SWarner LoshSRCS+= dosfs.c ext2fs.c 139ca987d46SWarner LoshSRCS+= splitfs.c 140ca987d46SWarner LoshSRCS+= pkgfs.c 141ca987d46SWarner Losh 142dffce215SKirk McKusick# kernel ufs support 143dffce215SKirk McKusick.PATH: ${SRCTOP}/sys/ufs/ffs 144dffce215SKirk McKusickSRCS+=ffs_subr.c ffs_tables.c 145dffce215SKirk McKusick 14605f37f4dSWarner LoshCFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2 14705f37f4dSWarner Losh 148ad6f5f9aSKonstantin Belousov# explicit_bzero and calculate_crc32c 149ca987d46SWarner Losh.PATH: ${SYSDIR}/libkern 150ad6f5f9aSKonstantin BelousovSRCS+= explicit_bzero.c crc32_libkern.c 151ca987d46SWarner Losh 15262bd02ceSWarner Losh# Maybe GELI 15362bd02ceSWarner Losh.if ${MK_LOADER_GELI} == "yes" 15462bd02ceSWarner Losh.include "${SASRC}/geli/Makefile.inc" 15562bd02ceSWarner Losh.endif 15662bd02ceSWarner Losh 1578df8b2d3SSimon J. Gerraty.if ${MK_LOADER_VERIEXEC} == "yes" && ${MK_BEARSSL} == "yes" 1588df8b2d3SSimon J. Gerraty.include "${SRCTOP}/lib/libbearssl/Makefile.libsa.inc" 1598df8b2d3SSimon J. Gerraty.include "${SRCTOP}/lib/libsecureboot/Makefile.libsa.inc" 1608df8b2d3SSimon J. Gerraty.endif 1618df8b2d3SSimon J. Gerraty 162b8902de1SWarner Losh# Maybe ZFS 163fbeb31a2SMatt Macy.if ${MK_LOADER_ZFS} == "yes" 164b8902de1SWarner Losh.include "${SASRC}/zfs/Makefile.inc" 165b8902de1SWarner Losh.endif 166b8902de1SWarner Losh 167ca987d46SWarner Losh.include <bsd.lib.mk> 168