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 .if ${COMPILER_VERSION} < 30800
53 CFLAGS.clang+= -mllvm -arm-use-movt=0
55 CFLAGS.clang+= -mno-movt
57 CFLAGS.clang+= -mfpu=none
59 # Compiler support functions
60 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
61 # __clzsi2 and ctzsi2 for various builtin functions
62 SRCS+= clzsi2.c ctzsi2.c
63 # Divide and modulus functions called by the compiler
64 SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c
65 SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
67 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
68 SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
69 SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
72 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
73 .PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
76 .if ${MACHINE_CPUARCH} == "powerpc"
77 .PATH: ${LIBC_SRC}/quad
78 SRCS+= ashldi3.c ashrdi3.c
82 # uuid functions from libc
83 .PATH: ${LIBC_SRC}/uuid
84 SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
87 .PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH}
90 # decompression functionality from libbz2
91 # NOTE: to actually test this functionality after libbz2 upgrade compile
92 # loader(8) with LOADER_BZIP2_SUPPORT defined
93 .PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
94 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
95 SRCS+= libstand_bzlib_private.h
97 .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
102 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
103 ${.ALLSRC} > ${.TARGET}
106 CLEANFILES+= libstand_bzlib_private.h
107 libstand_bzlib_private.h: bzlib_private.h
108 sed -e 's|<stdlib.h>|"stand.h"|' \
109 ${.ALLSRC} > ${.TARGET}
111 # decompression functionality from libz
112 .PATH: ${LIBSTAND_SRC}/../libz
113 CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz
114 SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
116 .for file in infback.c inffast.c inflate.c inftrees.c zutil.c
118 CLEANFILES+= _${file}
121 sed -e "s|zutil\.h|libstand_zutil.h|" \
122 -e "s|gzguts\.h|libstand_gzguts.h|" \
123 ${.ALLSRC} > ${.TARGET}
126 # depend on stand.h being able to be included multiple times
127 .for file in zutil.h gzguts.h
128 CLEANFILES+= libstand_${file}
129 libstand_${file}: ${file}
130 sed -e 's|<fcntl.h>|"stand.h"|' \
131 -e 's|<stddef.h>|"stand.h"|' \
132 -e 's|<string.h>|"stand.h"|' \
133 -e 's|<stdio.h>|"stand.h"|' \
134 -e 's|<stdlib.h>|"stand.h"|' \
135 ${.ALLSRC} > ${.TARGET}
139 SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
140 fstat.c close.c lseek.c open.c read.c write.c readdir.c
143 SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
145 # network info services:
146 SRCS+= bootp.c rarp.c bootparam.c
149 SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
150 SRCS+= dosfs.c ext2fs.c
153 .if ${MK_NAND} != "no"
157 .include <bsd.stand.mk>
158 .include <bsd.lib.mk>