xref: /freebsd/stand/libsa/Makefile (revision 8a0a413e)
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=
20WARNS?=		0
21
22CFLAGS+= -I${SASRC}
23
24# standalone components and stuff we have modified locally
25SRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
26	globals.c pager.c panic.c printf.c strdup.c strerror.c strtol.c strtoul.c \
27	random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c
28
29# private (pruned) versions of libc string functions
30SRCS+=	strcasecmp.c
31
32.PATH: ${LIBC_SRC}/net
33
34SRCS+= ntoh.c
35
36# string functions from libc
37.PATH: ${LIBC_SRC}/string
38SRCS+=	bcmp.c bcopy.c bzero.c ffs.c fls.c \
39	memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
40	qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \
41	strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
42	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
43.if ${MACHINE_CPUARCH} == "arm"
44.PATH: ${LIBC_SRC}/arm/gen
45
46# Do not generate movt/movw, because the relocation fixup for them does not
47# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
48# Also, the fpu is not available in a standalone environment.
49.if ${COMPILER_VERSION} < 30800
50CFLAGS.clang+=	-mllvm -arm-use-movt=0
51.else
52CFLAGS.clang+=	-mno-movt
53.endif
54CFLAGS.clang+=	-mfpu=none
55
56# Compiler support functions
57.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/
58# __clzsi2 and ctzsi2 for various builtin functions
59SRCS+=	clzsi2.c ctzsi2.c
60# Divide and modulus functions called by the compiler
61SRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
62SRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
63
64.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/
65SRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
66SRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
67.endif
68
69.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
70.PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
71.endif
72
73.if ${MACHINE_CPUARCH} == "powerpc"
74.PATH: ${LIBC_SRC}/quad
75SRCS+=	ashldi3.c ashrdi3.c
76SRCS+=	syncicache.c
77.endif
78
79# uuid functions from libc
80.PATH: ${LIBC_SRC}/uuid
81SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
82
83# _setjmp/_longjmp
84.PATH: ${SASRC}/${LIBSA_CPUARCH}
85SRCS+=	_setjmp.S
86
87# decompression functionality from libbz2
88# NOTE: to actually test this functionality after libbz2 upgrade compile
89# loader(8) with LOADER_BZIP2_SUPPORT defined
90.PATH: ${SRCTOP}/contrib/bzip2
91CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
92SRCS+=	libsa_bzlib_private.h
93
94.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
95SRCS+=	_${file}
96CLEANFILES+=	_${file}
97
98_${file}: ${file}
99	sed "s|bzlib_private\.h|libsa_bzlib_private.h|" \
100	    ${.ALLSRC} > ${.TARGET}
101.endfor
102
103CLEANFILES+= libsa_bzlib_private.h
104libsa_bzlib_private.h: bzlib_private.h
105	sed -e 's|<stdlib.h>|"stand.h"|' \
106		${.ALLSRC} > ${.TARGET}
107
108# decompression functionality from zlib
109.PATH: ${SRCTOP}/contrib/zlib
110CFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/contrib/zlib
111SRCS+=	adler32.c crc32.c libsa_zutil.h libsa_gzguts.h
112
113.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
114SRCS+=	_${file}
115CLEANFILES+=	_${file}
116
117_${file}: ${file}
118	sed -e "s|zutil\.h|libsa_zutil.h|" \
119	    -e "s|gzguts\.h|libsa_gzguts.h|" \
120	    ${.ALLSRC} > ${.TARGET}
121.endfor
122
123# depend on stand.h being able to be included multiple times
124.for file in zutil.h gzguts.h
125CLEANFILES+= libsa_${file}
126libsa_${file}: ${file}
127	sed -e 's|<fcntl.h>|"stand.h"|' \
128	    -e 's|<stddef.h>|"stand.h"|' \
129	    -e 's|<string.h>|"stand.h"|' \
130	    -e 's|<stdio.h>|"stand.h"|' \
131	    -e 's|<stdlib.h>|"stand.h"|' \
132	    ${.ALLSRC} > ${.TARGET}
133.endfor
134
135# io routines
136SRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
137	fstat.c close.c lseek.c open.c read.c write.c readdir.c
138
139# network routines
140SRCS+=	arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
141
142# network info services:
143SRCS+=	bootp.c rarp.c bootparam.c
144
145# boot filesystems
146SRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
147SRCS+=	dosfs.c ext2fs.c
148SRCS+=	splitfs.c
149SRCS+=	pkgfs.c
150.if ${MK_NAND} != "no"
151SRCS+=	nandfs.c
152.endif
153
154# explicit_bzero
155.PATH: ${SYSDIR}/libkern
156SRCS+=  explicit_bzero.c
157
158.include <bsd.stand.mk>
159.include <bsd.lib.mk>
160