150476Speter# $FreeBSD$
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
1238451SmsmithLIB=		stand
13139106SruNO_PROFILE=
14139106SruNO_PIC=
1596462SruINCS=		stand.h
1674870SruMAN=		libstand.3
1738451Smsmith
18223156SimpWARNS?=		0
19201381Sed
20100394SpeterCFLAGS+= -ffreestanding -Wformat
21100394SpeterCFLAGS+= -I${.CURDIR}
2294310Sobrien
23211725Simp.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
24217033SdimCFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
2564549Speter.endif
26271135Semaste.if ${MACHINE_CPUARCH} == "i386"
27271135SemasteCFLAGS.gcc+=	-mpreferred-stack-boundary=2
28271135Semaste.endif
29271135Semaste.if ${MACHINE_CPUARCH} == "amd64"
30271135SemasteCFLAGS+=	-fPIC
31271135Semaste.endif
32172664Snyan.if ${MACHINE} == "pc98"
33172664SnyanCFLAGS+=	-Os
34172664Snyan.endif
35211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
36209882SnwhitehornCFLAGS+=	-msoft-float -D_STANDALONE -DNETIF_DEBUG
3766929Sobrien.endif
38211725Simp.if ${MACHINE_CPUARCH} == "arm"
39193145SmarcelCFLAGS+=	-msoft-float -D_STANDALONE
40183876Sraj.endif
41249554Srwatson.if ${MACHINE_CPUARCH} == "mips"
42249554SrwatsonCFLAGS+=	-G0 -fno-pic -mno-abicalls
43249554Srwatson.endif
4438451Smsmith
4538451Smsmith# standalone components and stuff we have modified locally
46237410SdelphijSRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
47246931Skientzle	globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
4840805Smsmith	sbrk.c twiddle.c zalloc.c zalloc_malloc.c
4938451Smsmith
5040005Smsmith# private (pruned) versions of libc string functions
5140005SmsmithSRCS+=	strcasecmp.c
5239665Smsmith
53164053Scognet.PATH: ${.CURDIR}/../libc/net
5491394Stmm
55164053ScognetSRCS+= ntoh.c
56164053Scognet
5738451Smsmith# string functions from libc
58146324Sobrien.PATH: ${.CURDIR}/../libc/string
59250023Srwatson.if ${MACHINE_CPUARCH} != "ia64"
60229368SedSRCS+=	bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
61229368Sed	memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
62229368Sed	strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
63229368Sed	strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
6438451Smsmith.endif
65211725Simp.if ${MACHINE_CPUARCH} == "arm"
66183876Sraj.PATH: ${.CURDIR}/../libc/arm/gen
67246369Sandrew
68246369Sandrew.if ${MK_ARM_EABI} == "no"
69183876SrajSRCS+= divsi3.S
70246369Sandrew.else
71246369Sandrew# Compiler support functions
72246369Sandrew.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/
73247912Sandrew# __clzsi2 and ctzsi2 for various builtin functions
74247912SandrewSRCS+=	clzsi2.c ctzsi2.c
75247912Sandrew# Divide and modulus functions called by the compiler
76246369SandrewSRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
77246369SandrewSRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
78246369Sandrew
79246369Sandrew.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/arm/
80246369SandrewSRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
81246369SandrewSRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
82183876Sraj.endif
83246369Sandrew
84246369Sandrew.endif
85211725Simp.if ${MACHINE_CPUARCH} == "ia64"
8673887Sdfr.PATH: ${.CURDIR}/../libc/ia64/string
87229368SedSRCS+=	bcmp.c bcopy.S bzero.S ffs.S memccpy.c memchr.c memcmp.c memcpy.S \
88229368Sed	memmove.S memset.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c \
89229368Sed	strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
9073887Sdfr	strspn.c strstr.c strtok.c swab.c
9138451Smsmith
9273887Sdfr.PATH: ${.CURDIR}/../libc/ia64/gen
9373887SdfrSRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
9473887SdfrSRCS+= __udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S
9573887Sdfr.endif
96211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
97123382Sgrehan.PATH: ${.CURDIR}/../libc/quad
98123382SgrehanSRCS+=	ashldi3.c ashrdi3.c
99123382Sgrehan.PATH: ${.CURDIR}/../libc/powerpc/gen
100123382SgrehanSRCS+=	syncicache.c
101123382Sgrehan.endif
10273887Sdfr
103172940Sjhb# uuid functions from libc
104172940Sjhb.PATH: ${.CURDIR}/../libc/uuid
105172940SjhbSRCS+= uuid_equal.c uuid_is_nil.c
106172940Sjhb
10740891Smsmith# _setjmp/_longjmp
108271135Semaste.if ${MACHINE_ARCH} == "powerpc64"
109209882Snwhitehorn.PATH: ${.CURDIR}/powerpc
110116861Speter.else
111211725Simp.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
112116861Speter.endif
11340891SmsmithSRCS+=	_setjmp.S
11484995Srobert
115146788Ssobomax# decompression functionality from libbz2
116146788Ssobomax# NOTE: to actually test this functionality after libbz2 upgrade compile
117146788Ssobomax# loader(8) with LOADER_BZIP2_SUPPORT defined
118146324Sobrien.PATH: ${.CURDIR}/../../contrib/bzip2
119146839SobrienCFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
120146788SsobomaxSRCS+=	libstand_bzlib_private.h
121146324Sobrien
122146788Ssobomax.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
123146788SsobomaxSRCS+=	_${file}
124146788SsobomaxCLEANFILES+=	_${file}
125146788Ssobomax
126146788Ssobomax_${file}: ${file}
127146788Ssobomax	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" ${.ALLSRC} > ${.TARGET}
128146788Ssobomax.endfor
129146788Ssobomax
130146788SsobomaxCLEANFILES+= libstand_bzlib_private.h
131146788Ssobomaxlibstand_bzlib_private.h: bzlib_private.h
132146788Ssobomax	sed -e 's|<stdlib.h>|"stand.h"|' \
133146788Ssobomax		${.ALLSRC} > ${.TARGET}
134146788Ssobomax
135146324Sobrien# decompression functionality from libz
136146324Sobrien.PATH: ${.CURDIR}/../libz
137100394SpeterCFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../libz
138237410SdelphijSRCS+=	adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
13938451Smsmith
140131383Stjr.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
141146327SobrienSRCS+=	_${file}
142105430SmarcelCLEANFILES+=	_${file}
143105430Smarcel
144100394Speter_${file}: ${file}
145237410Sdelphij	sed -e "s|zutil\.h|libstand_zutil.h|" \
146237410Sdelphij	    -e "s|gzguts\.h|libstand_gzguts.h|" \
147237410Sdelphij	    ${.ALLSRC} > ${.TARGET}
148100394Speter.endfor
149100394Speter
150146327Sobrien# depend on stand.h being able to be included multiple times
151237410Sdelphij.for file in zutil.h gzguts.h
152237410SdelphijCLEANFILES+= libstand_${file}
153237410Sdelphijlibstand_${file}: ${file}
154237410Sdelphij	sed -e 's|<fcntl.h>|"stand.h"|' \
155237410Sdelphij	    -e 's|<stddef.h>|"stand.h"|' \
156146327Sobrien	    -e 's|<string.h>|"stand.h"|' \
157237410Sdelphij	    -e 's|<stdio.h>|"stand.h"|' \
158146327Sobrien	    -e 's|<stdlib.h>|"stand.h"|' \
159146327Sobrien	    ${.ALLSRC} > ${.TARGET}
160237410Sdelphij.endfor
161146327Sobrien
16238451Smsmith# io routines
16338451SmsmithSRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
16459766Sjlemon	fstat.c close.c lseek.c open.c read.c write.c readdir.c
16538451Smsmith
16638451Smsmith# network routines
16768362SpsSRCS+=	arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
16838451Smsmith
16938451Smsmith# network info services:
17038451SmsmithSRCS+=	bootp.c rarp.c bootparam.c
17138451Smsmith
17238451Smsmith# boot filesystems
173146324SobrienSRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
17459766SjlemonSRCS+=	dosfs.c ext2fs.c
17592494SsobomaxSRCS+=	splitfs.c
176235537Sgber.if ${MK_NAND} != "no"
177235537SgberSRCS+=	nandfs.c
178235537Sgber.endif
17938451Smsmith
18038451Smsmith.include <bsd.lib.mk>
181116861Speter
182