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 LIBC_SRC= ${LIBSTAND_SRC}/../libc
24 CFLAGS+= -ffreestanding -Wformat
25 CFLAGS+= -I${LIBSTAND_SRC}
27 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
28 CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
30 .if ${MACHINE_CPUARCH} == "i386"
31 CFLAGS.gcc+= -mpreferred-stack-boundary=2
33 .if ${MACHINE_CPUARCH} == "amd64"
34 CFLAGS+= -fPIC -mno-red-zone
36 .if ${MACHINE} == "pc98"
39 .if ${MACHINE_CPUARCH} == "powerpc"
40 CFLAGS+= -msoft-float -D_STANDALONE -DNETIF_DEBUG
42 .if ${MACHINE_CPUARCH} == "arm"
43 CFLAGS+= -msoft-float -D_STANDALONE
45 .if ${MACHINE_CPUARCH} == "aarch64"
46 CFLAGS+= -D_STANDALONE -mgeneral-regs-only
48 .if ${MACHINE_CPUARCH} == "mips"
49 CFLAGS+= -G0 -fno-pic -mno-abicalls
52 # standalone components and stuff we have modified locally
53 SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
54 globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
55 sbrk.c twiddle.c zalloc.c zalloc_malloc.c
57 # private (pruned) versions of libc string functions
60 .PATH: ${LIBC_SRC}/net
64 # string functions from libc
65 .PATH: ${LIBC_SRC}/string
66 SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
67 memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
68 strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
69 strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
70 .if ${MACHINE_CPUARCH} == "arm"
71 .PATH: ${LIBC_SRC}/arm/gen
73 # Compiler support functions
74 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
75 # __clzsi2 and ctzsi2 for various builtin functions
76 SRCS+= clzsi2.c ctzsi2.c
77 # Divide and modulus functions called by the compiler
78 SRCS+= divmoddi4.c divmodsi4.c divdi3.c divsi3.c moddi3.c modsi3.c
79 SRCS+= udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
81 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
82 SRCS+= aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
83 SRCS+= aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
86 .if ${MACHINE_CPUARCH} == "aarch64"
87 .PATH: ${LIBC_SRC}/aarch64/gen
90 .if ${MACHINE_CPUARCH} == "powerpc"
91 .PATH: ${LIBC_SRC}/quad
92 SRCS+= ashldi3.c ashrdi3.c
96 # uuid functions from libc
97 .PATH: ${LIBC_SRC}/uuid
98 SRCS+= uuid_equal.c uuid_is_nil.c
101 .PATH: ${LIBSTAND_SRC}/${MACHINE_CPUARCH}
104 # decompression functionality from libbz2
105 # NOTE: to actually test this functionality after libbz2 upgrade compile
106 # loader(8) with LOADER_BZIP2_SUPPORT defined
107 .PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
108 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
109 SRCS+= libstand_bzlib_private.h
111 .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
113 CLEANFILES+= _${file}
116 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
117 ${.ALLSRC} > ${.TARGET}
120 CLEANFILES+= libstand_bzlib_private.h
121 libstand_bzlib_private.h: bzlib_private.h
122 sed -e 's|<stdlib.h>|"stand.h"|' \
123 ${.ALLSRC} > ${.TARGET}
125 # decompression functionality from libz
126 .PATH: ${LIBSTAND_SRC}/../libz
127 CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz
128 SRCS+= adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
130 .for file in infback.c inffast.c inflate.c inftrees.c zutil.c
132 CLEANFILES+= _${file}
135 sed -e "s|zutil\.h|libstand_zutil.h|" \
136 -e "s|gzguts\.h|libstand_gzguts.h|" \
137 ${.ALLSRC} > ${.TARGET}
140 # depend on stand.h being able to be included multiple times
141 .for file in zutil.h gzguts.h
142 CLEANFILES+= libstand_${file}
143 libstand_${file}: ${file}
144 sed -e 's|<fcntl.h>|"stand.h"|' \
145 -e 's|<stddef.h>|"stand.h"|' \
146 -e 's|<string.h>|"stand.h"|' \
147 -e 's|<stdio.h>|"stand.h"|' \
148 -e 's|<stdlib.h>|"stand.h"|' \
149 ${.ALLSRC} > ${.TARGET}
153 SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
154 fstat.c close.c lseek.c open.c read.c write.c readdir.c
157 SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
159 # network info services:
160 SRCS+= bootp.c rarp.c bootparam.c
163 SRCS+= ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
164 SRCS+= dosfs.c ext2fs.c
167 .if ${MK_NAND} != "no"
171 .include <bsd.lib.mk>