Makefile revision 329175
1# $FreeBSD: stable/11/stand/libsa/Makefile 329175 2018-02-12 17:44:35Z kevans $
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
9PACKAGE=lib${LIB}
10MK_PROFILE=	no
11MK_SSP=		no
12
13.include <bsd.init.mk>
14
15INTERNALLIB=
16LIBSA_CPUARCH?=${MACHINE_CPUARCH}
17LIBC_SRC=	${SRCTOP}/lib/libc
18
19LIB?=		sa
20NO_PIC=
21
22# standalone components and stuff we have modified locally
23SRCS+=	gzguts.h zutil.h __main.c abort.c assert.c bcd.c environment.c getopt.c gets.c \
24	globals.c pager.c panic.c printf.c strdup.c strerror.c \
25	random.c sbrk.c twiddle.c zalloc.c zalloc_malloc.c
26
27# private (pruned) versions of libc string functions
28SRCS+=	strcasecmp.c
29
30.PATH: ${LIBC_SRC}/net
31
32SRCS+= ntoh.c
33
34# string functions from libc
35.PATH: ${LIBC_SRC}/string
36SRCS+=	bcmp.c bcopy.c bzero.c ffs.c fls.c \
37	memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
38	qdivrem.c strcat.c strchr.c strcmp.c strcpy.c stpcpy.c stpncpy.c \
39	strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
40	strnlen.c strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
41
42# stdlib functions from libc
43.PATH: ${LIBC_SRC}/stdlib
44SRCS+=	abs.c strtol.c strtoll.c strtoul.c strtoull.c
45
46.if ${MACHINE_CPUARCH} == "arm"
47.PATH: ${LIBC_SRC}/arm/gen
48
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
53CFLAGS.clang+=	-mllvm -arm-use-movt=0
54.else
55CFLAGS.clang+=	-mno-movt
56.endif
57CFLAGS.clang+=	-mfpu=none
58
59# Compiler support functions
60.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/
61# __clzsi2 and ctzsi2 for various builtin functions
62SRCS+=	clzsi2.c ctzsi2.c
63# Divide and modulus functions called by the compiler
64SRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
65SRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
66
67.PATH: ${SRCTOP}/contrib/compiler-rt/lib/builtins/arm/
68SRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
69SRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
70.endif
71
72.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
73.PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
74.endif
75
76.if ${MACHINE_CPUARCH} == "powerpc"
77.PATH: ${LIBC_SRC}/quad
78SRCS+=	ashldi3.c ashrdi3.c
79SRCS+=	syncicache.c
80.endif
81
82# uuid functions from libc
83.PATH: ${LIBC_SRC}/uuid
84SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
85
86# _setjmp/_longjmp
87.PATH: ${SASRC}/${LIBSA_CPUARCH}
88SRCS+=	_setjmp.S
89
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: ${SRCTOP}/contrib/bzip2
94CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
95
96SRCS+=bzlib.c crctable.c decompress.c huffman.c randtable.c
97
98# decompression functionality from zlib
99.PATH: ${SRCTOP}/contrib/zlib
100CFLAGS+=-DHAVE_MEMCPY -I${SRCTOP}/contrib/zlib
101SRCS+=	adler32.c crc32.c
102SRCS+=	infback.c inffast.c inflate.c inftrees.c zutil.c
103
104# Create a subset of includes that are safe, as well as adjusting those that aren't
105# The lists may drive people nuts, but they are explicitly opt-in
106FAKE_DIRS=xlocale arpa
107SAFE_INCS=a.out.h assert.h elf.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h
108STAND_H_INC=ctype.h fcntl.h signal.h stdio.h stdlib.h
109OTHER_INC=stdarg.h errno.h stdint.h
110
111beforedepend:
112	echo beforedepend; \
113	mkdir -p ${FAKE_DIRS}; \
114	for i in ${SAFE_INCS}; do \
115		ln -sf ${SRCTOP}/include/$$i $$i; \
116	done; \
117	ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \
118	ln -sf ${SYSDIR}/sys/errno.h errno.h; \
119	ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \
120	ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
121	ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
122	for i in _time.h _strings.h _string.h; do \
123		[ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
124	done; \
125	for i in ${STAND_H_INC}; do \
126		ln -sf ${SASRC}/stand.h $$i; \
127	done
128CLEANDIRS+=${FAKE_DIRS}
129CLEANFILES+= ${SAFE_INCS} ${STAND_H_INC} ${OTHER_INC}
130
131# io routines
132SRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
133	fstat.c close.c lseek.c open.c read.c write.c readdir.c
134
135# network routines
136SRCS+=	arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
137
138# network info services:
139SRCS+=	bootp.c rarp.c bootparam.c
140
141# boot filesystems
142SRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
143SRCS+=	dosfs.c ext2fs.c
144SRCS+=	splitfs.c
145SRCS+=	pkgfs.c
146.if ${MK_NAND} != "no"
147SRCS+=	nandfs.c
148.endif
149
150CFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2
151
152# explicit_bzero
153.PATH: ${SYSDIR}/libkern
154SRCS+=  explicit_bzero.c
155
156.include <bsd.stand.mk>
157.include <bsd.lib.mk>
158