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
13 .include <src.opts.mk>
15 LIBSTAND_SRC?= ${.CURDIR}
16 LIBSTAND_CPUARCH?=${MACHINE_CPUARCH}
17 LIBC_SRC= ${LIBSTAND_SRC}/../libc
26 CFLAGS+= -I${LIBSTAND_SRC}
28 # standalone components and stuff we have modified locally
29 SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
30 globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
31 sbrk.c twiddle.c zalloc.c zalloc_malloc.c
33 # private (pruned) versions of libc string functions
36 .PATH: ${LIBC_SRC}/net
40 # string functions from libc
41 .PATH: ${LIBC_SRC}/string
42 SRCS+= bcmp.c bcopy.c bzero.c ffs.c fls.c \
43 memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
44 qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
45 strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
46 strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
47 .if ${MACHINE_CPUARCH} == "arm"
48 .PATH: ${LIBC_SRC}/arm/gen
50 # Do not generate movt/movw, because the relocation fixup for them does not
51 # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
52 # Also, the fpu is not available in a standalone environment.
53 .if ${COMPILER_VERSION} < 30800
54 CFLAGS.clang+= -mllvm -arm-use-movt=0
56 CFLAGS.clang+= -mno-movt
58 CFLAGS.clang+= -mfpu=none
60 # Compiler support functions
61 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
62 # __clzsi2 and ctzsi2 for various builtin functions
63 SRCS+= clzsi2.c ctzsi2.c
64 # Divide and modulus functions called by the compiler
65 SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c
66 SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
68 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
69 SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
70 SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
73 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
74 .PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
77 .if ${MACHINE_CPUARCH} == "powerpc"
78 .PATH: ${LIBC_SRC}/quad
79 SRCS+= ashldi3.c ashrdi3.c
83 # uuid functions from libc
84 .PATH: ${LIBC_SRC}/uuid
85 SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
88 .PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH}
91 # decompression functionality from libbz2
92 # NOTE: to actually test this functionality after libbz2 upgrade compile
93 # loader(8) with LOADER_BZIP2_SUPPORT defined
94 .PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
95 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
96 SRCS+= libstand_bzlib_private.h
98 .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
100 CLEANFILES+= _${file}
103 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
104 ${.ALLSRC} > ${.TARGET}
107 CLEANFILES+= libstand_bzlib_private.h
108 libstand_bzlib_private.h: bzlib_private.h
109 sed -e 's|<stdlib.h>|"stand.h"|' \
110 ${.ALLSRC} > ${.TARGET}
112 # decompression functionality from libz
113 .PATH: ${LIBSTAND_SRC}/../libz
114 CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz
115 SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
117 .for file in infback.c inffast.c inflate.c inftrees.c zutil.c
119 CLEANFILES+= _${file}
122 sed -e "s|zutil\.h|libstand_zutil.h|" \
123 -e "s|gzguts\.h|libstand_gzguts.h|" \
124 ${.ALLSRC} > ${.TARGET}
127 # depend on stand.h being able to be included multiple times
128 .for file in zutil.h gzguts.h
129 CLEANFILES+= libstand_${file}
130 libstand_${file}: ${file}
131 sed -e 's|<fcntl.h>|"stand.h"|' \
132 -e 's|<stddef.h>|"stand.h"|' \
133 -e 's|<string.h>|"stand.h"|' \
134 -e 's|<stdio.h>|"stand.h"|' \
135 -e 's|<stdlib.h>|"stand.h"|' \
136 ${.ALLSRC} > ${.TARGET}
140 SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
141 fstat.c close.c lseek.c open.c read.c write.c readdir.c
144 SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
146 # network info services:
147 SRCS+= bootp.c rarp.c bootparam.c
150 SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
151 SRCS+= dosfs.c ext2fs.c
154 .if ${MK_NAND} != "no"
158 .include <bsd.stand.mk>
159 .include <bsd.lib.mk>