Makefile revision 312375
1# $FreeBSD: stable/10/lib/libstand/Makefile 312375 2017-01-18 08:20:36Z delphij $
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
9.include <bsd.own.mk>
10MK_SSP=		no
11
12LIB=		stand
13NO_PROFILE=
14NO_PIC=
15INCS=		stand.h
16MAN=		libstand.3
17
18WARNS?=		0
19
20CFLAGS+= -ffreestanding -Wformat
21CFLAGS+= -I${.CURDIR}
22
23.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
24CFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
25.endif
26.if ${MACHINE_CPUARCH} == "i386"
27CFLAGS.gcc+=	-mpreferred-stack-boundary=2
28.endif
29.if ${MACHINE_CPUARCH} == "amd64"
30CFLAGS+=	-fPIC -mno-red-zone
31.endif
32.if ${MACHINE} == "pc98"
33CFLAGS+=	-Os
34.endif
35.if ${MACHINE_CPUARCH} == "powerpc"
36CFLAGS+=	-msoft-float -D_STANDALONE -DNETIF_DEBUG
37.endif
38.if ${MACHINE_CPUARCH} == "arm"
39CFLAGS+=	-msoft-float -D_STANDALONE
40.endif
41.if ${MACHINE_CPUARCH} == "mips"
42CFLAGS+=	-G0 -fno-pic -mno-abicalls
43.endif
44
45# standalone components and stuff we have modified locally
46SRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
47	globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
48	sbrk.c twiddle.c zalloc.c zalloc_malloc.c
49
50# private (pruned) versions of libc string functions
51SRCS+=	strcasecmp.c
52
53.PATH: ${.CURDIR}/../libc/net
54
55SRCS+= ntoh.c
56
57# string functions from libc
58.PATH: ${.CURDIR}/../libc/string
59.if ${MACHINE_CPUARCH} != "ia64"
60SRCS+=	bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \
61	memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
62	strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
63	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
64.endif
65.if ${MACHINE_CPUARCH} == "arm"
66.PATH: ${.CURDIR}/../libc/arm/gen
67
68.if ${MK_ARM_EABI} == "no"
69SRCS+= divsi3.S
70.else
71# Compiler support functions
72.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/
73# __clzsi2 and ctzsi2 for various builtin functions
74SRCS+=	clzsi2.c ctzsi2.c
75# Divide and modulus functions called by the compiler
76SRCS+=	 divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
77SRCS+=	udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
78
79.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/arm/
80SRCS+=	aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
81SRCS+=	aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
82.endif
83
84.endif
85.if ${MACHINE_CPUARCH} == "ia64"
86.PATH: ${.CURDIR}/../libc/ia64/string
87SRCS+=	bcmp.c bcopy.S bzero.S ffs.S memccpy.c memchr.c memcmp.c memcpy.S \
88	memmove.S memset.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c \
89	strlcat.c strlcpy.c \
90	strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
91	strspn.c strstr.c strtok.c swab.c
92
93.PATH: ${.CURDIR}/../libc/ia64/gen
94SRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
95SRCS+= __udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S
96.endif
97.if ${MACHINE_CPUARCH} == "powerpc"
98.PATH: ${.CURDIR}/../libc/quad
99SRCS+=	ashldi3.c ashrdi3.c
100.PATH: ${.CURDIR}/../libc/powerpc/gen
101SRCS+=	syncicache.c
102.endif
103
104# uuid functions from libc
105.PATH: ${.CURDIR}/../libc/uuid
106SRCS+= uuid_equal.c uuid_is_nil.c
107
108# _setjmp/_longjmp
109.if ${MACHINE_ARCH} == "powerpc64"
110.PATH: ${.CURDIR}/powerpc
111.else
112.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
113.endif
114SRCS+=	_setjmp.S
115
116# decompression functionality from libbz2
117# NOTE: to actually test this functionality after libbz2 upgrade compile
118# loader(8) with LOADER_BZIP2_SUPPORT defined
119.PATH: ${.CURDIR}/../../contrib/bzip2
120CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
121SRCS+=	libstand_bzlib_private.h
122
123.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
124SRCS+=	_${file}
125CLEANFILES+=	_${file}
126
127_${file}: ${file}
128	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" ${.ALLSRC} > ${.TARGET}
129.endfor
130
131CLEANFILES+= libstand_bzlib_private.h
132libstand_bzlib_private.h: bzlib_private.h
133	sed -e 's|<stdlib.h>|"stand.h"|' \
134		${.ALLSRC} > ${.TARGET}
135
136# decompression functionality from libz
137.PATH: ${.CURDIR}/../../contrib/zlib
138CFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../../contrib/zlib
139SRCS+=	adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
140
141.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
142SRCS+=	_${file}
143CLEANFILES+=	_${file}
144
145_${file}: ${file}
146	sed -e "s|zutil\.h|libstand_zutil.h|" \
147	    -e "s|gzguts\.h|libstand_gzguts.h|" \
148	    ${.ALLSRC} > ${.TARGET}
149.endfor
150
151# depend on stand.h being able to be included multiple times
152.for file in zutil.h gzguts.h
153CLEANFILES+= libstand_${file}
154libstand_${file}: ${file}
155	sed -e 's|<fcntl.h>|"stand.h"|' \
156	    -e 's|<stddef.h>|"stand.h"|' \
157	    -e 's|<string.h>|"stand.h"|' \
158	    -e 's|<stdio.h>|"stand.h"|' \
159	    -e 's|<stdlib.h>|"stand.h"|' \
160	    ${.ALLSRC} > ${.TARGET}
161.endfor
162
163# io routines
164SRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
165	fstat.c close.c lseek.c open.c read.c write.c readdir.c
166
167# network routines
168SRCS+=	arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
169
170# network info services:
171SRCS+=	bootp.c rarp.c bootparam.c
172
173# boot filesystems
174SRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
175SRCS+=	dosfs.c ext2fs.c
176SRCS+=	splitfs.c
177.if ${MK_NAND} != "no"
178SRCS+=	nandfs.c
179.endif
180
181.include <bsd.lib.mk>
182
183