2 # Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
5 # - We don't use the libc strerror/sys_errlist because the string table is
12 .include <src.opts.mk>
14 LIBSTAND_SRC?= ${.CURDIR}
15 LIBSTAND_CPUARCH?=${MACHINE_CPUARCH}
16 LIBC_SRC= ${LIBSTAND_SRC}/../libc
25 CFLAGS+= -I${LIBSTAND_SRC}
27 # standalone components and stuff we have modified locally
28 SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
29 globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
30 sbrk.c twiddle.c zalloc.c zalloc_malloc.c
32 # private (pruned) versions of libc string functions
35 .PATH: ${LIBC_SRC}/net
39 # string functions from libc
40 .PATH: ${LIBC_SRC}/string
41 SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \
42 memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
43 qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
44 strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
45 strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
46 .if ${MACHINE_CPUARCH} == "arm"
47 .PATH: ${LIBC_SRC}/arm/gen
49 # Do not generate movt/movw, because the relocation fixup for them does not
50 # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
51 # Also, the fpu is not available in a standalone environment.
52 CFLAGS.clang+= -mllvm -arm-use-movt=0
53 CFLAGS.clang+= -mfpu=none
55 # Compiler support functions
56 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
57 # __clzsi2 and ctzsi2 for various builtin functions
58 SRCS+= clzsi2.c ctzsi2.c
59 # Divide and modulus functions called by the compiler
60 SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c
61 SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
63 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
64 SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
65 SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
68 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
69 .PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
72 .if ${MACHINE_CPUARCH} == "powerpc"
73 .PATH: ${LIBC_SRC}/quad
74 SRCS+= ashldi3.c ashrdi3.c
78 # uuid functions from libc
79 .PATH: ${LIBC_SRC}/uuid
80 SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
83 .PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH}
86 # decompression functionality from libbz2
87 # NOTE: to actually test this functionality after libbz2 upgrade compile
88 # loader(8) with LOADER_BZIP2_SUPPORT defined
89 .PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
90 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
91 SRCS+= libstand_bzlib_private.h
93 .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
98 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
99 ${.ALLSRC} > ${.TARGET}
102 CLEANFILES+= libstand_bzlib_private.h
103 libstand_bzlib_private.h: bzlib_private.h
104 sed -e 's|<stdlib.h>|"stand.h"|' \
105 ${.ALLSRC} > ${.TARGET}
107 # decompression functionality from libz
108 .PATH: ${LIBSTAND_SRC}/../libz
109 CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz
110 SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
112 .for file in infback.c inffast.c inflate.c inftrees.c zutil.c
114 CLEANFILES+= _${file}
117 sed -e "s|zutil\.h|libstand_zutil.h|" \
118 -e "s|gzguts\.h|libstand_gzguts.h|" \
119 ${.ALLSRC} > ${.TARGET}
122 # depend on stand.h being able to be included multiple times
123 .for file in zutil.h gzguts.h
124 CLEANFILES+= libstand_${file}
125 libstand_${file}: ${file}
126 sed -e 's|<fcntl.h>|"stand.h"|' \
127 -e 's|<stddef.h>|"stand.h"|' \
128 -e 's|<string.h>|"stand.h"|' \
129 -e 's|<stdio.h>|"stand.h"|' \
130 -e 's|<stdlib.h>|"stand.h"|' \
131 ${.ALLSRC} > ${.TARGET}
135 SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
136 fstat.c close.c lseek.c open.c read.c write.c readdir.c
139 SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
141 # network info services:
142 SRCS+= bootp.c rarp.c bootparam.c
145 SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
146 SRCS+= dosfs.c ext2fs.c
149 .if ${MK_NAND} != "no"
153 .include <bsd.stand.mk>
154 .include <bsd.lib.mk>