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