Makefile revision 246931
150476Speter# $FreeBSD: head/lib/libstand/Makefile 246931 2013-02-18 01:55:53Z kientzle $
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"
2464549SpeterCFLAGS+=	-mpreferred-stack-boundary=2
25217033SdimCFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
2664549Speter.endif
27172664Snyan.if ${MACHINE} == "pc98"
28172664SnyanCFLAGS+=	-Os
29172664Snyan.endif
30211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
31209882SnwhitehornCFLAGS+=	-msoft-float -D_STANDALONE -DNETIF_DEBUG
3266929Sobrien.endif
33209882Snwhitehorn.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64"
34146425SpeterCFLAGS+=	-m32 -I.
35116861Speter.endif
36211725Simp.if ${MACHINE_CPUARCH} == "arm"
37193145SmarcelCFLAGS+=	-msoft-float -D_STANDALONE
38183876Sraj.endif
3938451Smsmith
4038451Smsmith# standalone components and stuff we have modified locally
41237410SdelphijSRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
42246931Skientzle	globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
4340805Smsmith	sbrk.c twiddle.c zalloc.c zalloc_malloc.c
4438451Smsmith
4540005Smsmith# private (pruned) versions of libc string functions
4640005SmsmithSRCS+=	strcasecmp.c
4739665Smsmith
48164053Scognet.PATH: ${.CURDIR}/../libc/net
4991394Stmm
50164053ScognetSRCS+= ntoh.c
51164053Scognet
5238451Smsmith# string functions from libc
53146324Sobrien.PATH: ${.CURDIR}/../libc/string
54211725Simp.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "powerpc" || \
55211725Simp	${MACHINE_CPUARCH} == "sparc64" || ${MACHINE_CPUARCH} == "amd64" || \
56211725Simp	${MACHINE_CPUARCH} == "arm"
57229368SedSRCS+=	bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
58229368Sed	memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
59229368Sed	strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \
60229368Sed	strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
6138451Smsmith.endif
62211725Simp.if ${MACHINE_CPUARCH} == "arm"
63183876Sraj.PATH: ${.CURDIR}/../libc/arm/gen
64246369Sandrew
65246369Sandrew.if ${MK_ARM_EABI} == "no"
66183876SrajSRCS+= divsi3.S
67246369Sandrew.else
68246369Sandrew# Compiler support functions
69246369Sandrew.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/
70246369SandrewSRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
71246369SandrewSRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
72246369Sandrew
73246369Sandrew.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/arm/
74246369SandrewSRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
75246369SandrewSRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
76183876Sraj.endif
77246369Sandrew
78246369Sandrew.endif
79211725Simp.if ${MACHINE_CPUARCH} == "ia64"
8073887Sdfr.PATH: ${.CURDIR}/../libc/ia64/string
81229368SedSRCS+=	bcmp.c bcopy.S bzero.S ffs.S memccpy.c memchr.c memcmp.c memcpy.S \
82229368Sed	memmove.S memset.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c \
83229368Sed	strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
8473887Sdfr	strspn.c strstr.c strtok.c swab.c
8538451Smsmith
8673887Sdfr.PATH: ${.CURDIR}/../libc/ia64/gen
8773887SdfrSRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
8873887SdfrSRCS+= __udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S
8973887Sdfr.endif
90211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
91123382Sgrehan.PATH: ${.CURDIR}/../libc/quad
92123382SgrehanSRCS+=	ashldi3.c ashrdi3.c
93123382Sgrehan.PATH: ${.CURDIR}/../libc/powerpc/gen
94123382SgrehanSRCS+=	syncicache.c
95123382Sgrehan.endif
9673887Sdfr
97172940Sjhb# uuid functions from libc
98172940Sjhb.PATH: ${.CURDIR}/../libc/uuid
99172940SjhbSRCS+= uuid_equal.c uuid_is_nil.c
100172940Sjhb
10140891Smsmith# _setjmp/_longjmp
102211725Simp.if ${MACHINE_CPUARCH} == "amd64"
103146324Sobrien.PATH: ${.CURDIR}/i386
104209882Snwhitehorn.elif ${MACHINE_ARCH} == "powerpc64"
105209882Snwhitehorn.PATH: ${.CURDIR}/powerpc
106116861Speter.else
107211725Simp.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
108116861Speter.endif
10940891SmsmithSRCS+=	_setjmp.S
11084995Srobert
111146788Ssobomax# decompression functionality from libbz2
112146788Ssobomax# NOTE: to actually test this functionality after libbz2 upgrade compile
113146788Ssobomax# loader(8) with LOADER_BZIP2_SUPPORT defined
114146324Sobrien.PATH: ${.CURDIR}/../../contrib/bzip2
115146839SobrienCFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
116146788SsobomaxSRCS+=	libstand_bzlib_private.h
117146324Sobrien
118146788Ssobomax.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
119146788SsobomaxSRCS+=	_${file}
120146788SsobomaxCLEANFILES+=	_${file}
121146788Ssobomax
122146788Ssobomax_${file}: ${file}
123146788Ssobomax	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" ${.ALLSRC} > ${.TARGET}
124146788Ssobomax.endfor
125146788Ssobomax
126146788SsobomaxCLEANFILES+= libstand_bzlib_private.h
127146788Ssobomaxlibstand_bzlib_private.h: bzlib_private.h
128146788Ssobomax	sed -e 's|<stdlib.h>|"stand.h"|' \
129146788Ssobomax		${.ALLSRC} > ${.TARGET}
130146788Ssobomax
131146324Sobrien# decompression functionality from libz
132146324Sobrien.PATH: ${.CURDIR}/../libz
133100394SpeterCFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../libz
134237410SdelphijSRCS+=	adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
13538451Smsmith
136131383Stjr.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
137146327SobrienSRCS+=	_${file}
138105430SmarcelCLEANFILES+=	_${file}
139105430Smarcel
140100394Speter_${file}: ${file}
141237410Sdelphij	sed -e "s|zutil\.h|libstand_zutil.h|" \
142237410Sdelphij	    -e "s|gzguts\.h|libstand_gzguts.h|" \
143237410Sdelphij	    ${.ALLSRC} > ${.TARGET}
144100394Speter.endfor
145100394Speter
146146327Sobrien# depend on stand.h being able to be included multiple times
147237410Sdelphij.for file in zutil.h gzguts.h
148237410SdelphijCLEANFILES+= libstand_${file}
149237410Sdelphijlibstand_${file}: ${file}
150237410Sdelphij	sed -e 's|<fcntl.h>|"stand.h"|' \
151237410Sdelphij	    -e 's|<stddef.h>|"stand.h"|' \
152146327Sobrien	    -e 's|<string.h>|"stand.h"|' \
153237410Sdelphij	    -e 's|<stdio.h>|"stand.h"|' \
154146327Sobrien	    -e 's|<stdlib.h>|"stand.h"|' \
155146327Sobrien	    ${.ALLSRC} > ${.TARGET}
156237410Sdelphij.endfor
157146327Sobrien
15838451Smsmith# io routines
15938451SmsmithSRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
16059766Sjlemon	fstat.c close.c lseek.c open.c read.c write.c readdir.c
16138451Smsmith
16238451Smsmith# network routines
16368362SpsSRCS+=	arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
16438451Smsmith
16538451Smsmith# network info services:
16638451SmsmithSRCS+=	bootp.c rarp.c bootparam.c
16738451Smsmith
16838451Smsmith# boot filesystems
169146324SobrienSRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
17059766SjlemonSRCS+=	dosfs.c ext2fs.c
17192494SsobomaxSRCS+=	splitfs.c
172235537Sgber.if ${MK_NAND} != "no"
173235537SgberSRCS+=	nandfs.c
174235537Sgber.endif
17538451Smsmith
17638451Smsmith.include <bsd.lib.mk>
177116861Speter
178211725Simp.if ${MACHINE_CPUARCH} == "amd64"
179178664Srubeforedepend ${OBJS}: machine
180178663Srucleandepend: cleanmachine
181178663Srucleanmachine:
182178663Sru	rm -f machine
183116861Speter
184116861Spetermachine:
185116861Speter	ln -s ${.CURDIR}/../../sys/i386/include machine
186116861Speter.endif
187