150476Speter# $FreeBSD: stable/10/lib/libstand/Makefile 312403 2017-01-19 07:29:52Z delphij $
238451Smsmith# Originally from	$NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
338451Smsmith#
438451Smsmith# Notes:
538451Smsmith# - We don't use the libc strerror/sys_errlist because the string table is
638451Smsmith#   quite large.
738451Smsmith#
838451Smsmith
9188895Sru.include <bsd.own.mk>
10188895SruMK_SSP=		no
11188895Sru
12312403SdelphijLIBSTAND_SRC?=	${.CURDIR}
13312403SdelphijLIBSTAND_CPUARCH?=${MACHINE_CPUARCH}
14312403SdelphijLIBC_SRC=	${LIBSTAND_SRC}/../libc
15312403Sdelphij
1638451SmsmithLIB=		stand
17139106SruNO_PROFILE=
18139106SruNO_PIC=
19312403SdelphijINCS?=		stand.h
20312403SdelphijMAN?=		libstand.3
2138451Smsmith
22223156SimpWARNS?=		0
23201381Sed
24100394SpeterCFLAGS+= -ffreestanding -Wformat
25312403SdelphijCFLAGS+= -I${LIBSTAND_SRC}
2694310Sobrien
27211725Simp.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
28217033SdimCFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
2964549Speter.endif
30271135Semaste.if ${MACHINE_CPUARCH} == "i386"
31271135SemasteCFLAGS.gcc+=	-mpreferred-stack-boundary=2
32271135Semaste.endif
33271135Semaste.if ${MACHINE_CPUARCH} == "amd64"
34281321SjhbCFLAGS+=	-fPIC -mno-red-zone
35271135Semaste.endif
36172664Snyan.if ${MACHINE} == "pc98"
37172664SnyanCFLAGS+=	-Os
38172664Snyan.endif
39211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
40209882SnwhitehornCFLAGS+=	-msoft-float -D_STANDALONE -DNETIF_DEBUG
4166929Sobrien.endif
42211725Simp.if ${MACHINE_CPUARCH} == "arm"
43193145SmarcelCFLAGS+=	-msoft-float -D_STANDALONE
44183876Sraj.endif
45249554Srwatson.if ${MACHINE_CPUARCH} == "mips"
46249554SrwatsonCFLAGS+=	-G0 -fno-pic -mno-abicalls
47249554Srwatson.endif
4838451Smsmith
4938451Smsmith# standalone components and stuff we have modified locally
50301056SianSRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
51246931Skientzle	globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
5240805Smsmith	sbrk.c twiddle.c zalloc.c zalloc_malloc.c
5338451Smsmith
5440005Smsmith# private (pruned) versions of libc string functions
5540005SmsmithSRCS+=	strcasecmp.c
5639665Smsmith
57312403Sdelphij.PATH: ${LIBC_SRC}/net
5891394Stmm
59164053ScognetSRCS+= ntoh.c
60164053Scognet
6138451Smsmith# string functions from libc
62312403Sdelphij.PATH: ${LIBC_SRC}/string
63250023Srwatson.if ${MACHINE_CPUARCH} != "ia64"
64229368SedSRCS+=	bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
65229368Sed	memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
66294342Sian	strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
67294342Sian	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
6838451Smsmith.endif
69211725Simp.if ${MACHINE_CPUARCH} == "arm"
70312403Sdelphij.PATH: ${LIBC_SRC}/arm/gen
71246369Sandrew
72246369Sandrew.if ${MK_ARM_EABI} == "no"
73183876SrajSRCS+= divsi3.S
74246369Sandrew.else
75246369Sandrew# Compiler support functions
76312403Sdelphij.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/
77247912Sandrew# __clzsi2 and ctzsi2 for various builtin functions
78247912SandrewSRCS+=	clzsi2.c ctzsi2.c
79247912Sandrew# Divide and modulus functions called by the compiler
80246369SandrewSRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
81246369SandrewSRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
82246369Sandrew
83312403Sdelphij.PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/arm/
84246369SandrewSRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
85246369SandrewSRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
86183876Sraj.endif
87246369Sandrew
88246369Sandrew.endif
89211725Simp.if ${MACHINE_CPUARCH} == "ia64"
90312403Sdelphij.PATH: ${LIBC_SRC}/ia64/string
91229368SedSRCS+=	bcmp.c bcopy.S bzero.S ffs.S memccpy.c memchr.c memcmp.c memcpy.S \
92229368Sed	memmove.S memset.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c \
93294462Sian	strlcat.c strlcpy.c \
94229368Sed	strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
9573887Sdfr	strspn.c strstr.c strtok.c swab.c
9638451Smsmith
97312403Sdelphij.PATH: ${LIBC_SRC}/ia64/gen
9873887SdfrSRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
9973887SdfrSRCS+= __udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S
10073887Sdfr.endif
101211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
102312403Sdelphij.PATH: ${LIBC_SRC}/quad
103123382SgrehanSRCS+=	ashldi3.c ashrdi3.c
104312403Sdelphij.PATH: ${LIBC_SRC}/powerpc/gen
105123382SgrehanSRCS+=	syncicache.c
106123382Sgrehan.endif
10773887Sdfr
108172940Sjhb# uuid functions from libc
109312403Sdelphij.PATH: ${LIBC_SRC}/uuid
110172940SjhbSRCS+= uuid_equal.c uuid_is_nil.c
111172940Sjhb
11240891Smsmith# _setjmp/_longjmp
113271135Semaste.if ${MACHINE_ARCH} == "powerpc64"
114312403Sdelphij.PATH: ${LIBSTAND_SRC}/powerpc
115116861Speter.else
116312403Sdelphij.PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH}
117116861Speter.endif
11840891SmsmithSRCS+=	_setjmp.S
11984995Srobert
120146788Ssobomax# decompression functionality from libbz2
121146788Ssobomax# NOTE: to actually test this functionality after libbz2 upgrade compile
122146788Ssobomax# loader(8) with LOADER_BZIP2_SUPPORT defined
123312403Sdelphij.PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
124146839SobrienCFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
125146788SsobomaxSRCS+=	libstand_bzlib_private.h
126146324Sobrien
127146788Ssobomax.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
128146788SsobomaxSRCS+=	_${file}
129146788SsobomaxCLEANFILES+=	_${file}
130146788Ssobomax
131146788Ssobomax_${file}: ${file}
132146788Ssobomax	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" ${.ALLSRC} > ${.TARGET}
133146788Ssobomax.endfor
134146788Ssobomax
135146788SsobomaxCLEANFILES+= libstand_bzlib_private.h
136146788Ssobomaxlibstand_bzlib_private.h: bzlib_private.h
137146788Ssobomax	sed -e 's|<stdlib.h>|"stand.h"|' \
138146788Ssobomax		${.ALLSRC} > ${.TARGET}
139146788Ssobomax
140146324Sobrien# decompression functionality from libz
141312403Sdelphij.PATH: ${LIBSTAND_SRC}/../../contrib/zlib
142312403SdelphijCFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../../contrib/zlib
143237410SdelphijSRCS+=	adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
14438451Smsmith
145131383Stjr.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
146146327SobrienSRCS+=	_${file}
147105430SmarcelCLEANFILES+=	_${file}
148105430Smarcel
149100394Speter_${file}: ${file}
150237410Sdelphij	sed -e "s|zutil\.h|libstand_zutil.h|" \
151237410Sdelphij	    -e "s|gzguts\.h|libstand_gzguts.h|" \
152237410Sdelphij	    ${.ALLSRC} > ${.TARGET}
153100394Speter.endfor
154100394Speter
155146327Sobrien# depend on stand.h being able to be included multiple times
156237410Sdelphij.for file in zutil.h gzguts.h
157237410SdelphijCLEANFILES+= libstand_${file}
158237410Sdelphijlibstand_${file}: ${file}
159237410Sdelphij	sed -e 's|<fcntl.h>|"stand.h"|' \
160237410Sdelphij	    -e 's|<stddef.h>|"stand.h"|' \
161146327Sobrien	    -e 's|<string.h>|"stand.h"|' \
162237410Sdelphij	    -e 's|<stdio.h>|"stand.h"|' \
163146327Sobrien	    -e 's|<stdlib.h>|"stand.h"|' \
164146327Sobrien	    ${.ALLSRC} > ${.TARGET}
165237410Sdelphij.endfor
166146327Sobrien
16738451Smsmith# io routines
16838451SmsmithSRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
16959766Sjlemon	fstat.c close.c lseek.c open.c read.c write.c readdir.c
17038451Smsmith
17138451Smsmith# network routines
17268362SpsSRCS+=	arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
17338451Smsmith
17438451Smsmith# network info services:
17538451SmsmithSRCS+=	bootp.c rarp.c bootparam.c
17638451Smsmith
17738451Smsmith# boot filesystems
178146324SobrienSRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
17959766SjlemonSRCS+=	dosfs.c ext2fs.c
18092494SsobomaxSRCS+=	splitfs.c
181235537Sgber.if ${MK_NAND} != "no"
182235537SgberSRCS+=	nandfs.c
183235537Sgber.endif
18438451Smsmith
18538451Smsmith.include <bsd.lib.mk>
186116861Speter
187