1# $FreeBSD$
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.gcc+=	-mpreferred-stack-boundary=2
25CFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
26.endif
27.if ${MACHINE} == "pc98"
28CFLAGS+=	-Os
29.endif
30.if ${MACHINE_CPUARCH} == "powerpc"
31CFLAGS+=	-msoft-float -D_STANDALONE -DNETIF_DEBUG
32.endif
33.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64"
34CFLAGS+=	-m32 -I.
35.endif
36.if ${MACHINE_CPUARCH} == "arm"
37CFLAGS+=	-msoft-float -D_STANDALONE
38.endif
39
40# standalone components and stuff we have modified locally
41SRCS+=	gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
42	globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \
43	sbrk.c twiddle.c zalloc.c zalloc_malloc.c
44
45# private (pruned) versions of libc string functions
46SRCS+=	strcasecmp.c
47
48.PATH: ${.CURDIR}/../libc/net
49
50SRCS+= ntoh.c
51
52# string functions from libc
53.PATH: ${.CURDIR}/../libc/string
54.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "powerpc" || \
55	${MACHINE_CPUARCH} == "sparc64" || ${MACHINE_CPUARCH} == "amd64" || \
56	${MACHINE_CPUARCH} == "arm"
57SRCS+=	bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \
58        memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \
59        strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \
60	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
61.endif
62.if ${MACHINE_CPUARCH} == "arm"
63.PATH: ${.CURDIR}/../libc/arm/gen
64SRCS+= divsi3.S
65.endif
66.if ${MACHINE_CPUARCH} == "ia64"
67.PATH: ${.CURDIR}/../libc/ia64/string
68SRCS+=	bcmp.c bcopy.S bzero.S ffs.S index.c memccpy.c memchr.c memcmp.c \
69	memcpy.S memmove.S memset.c rindex.c strcat.c strchr.c \
70	strcmp.c strcpy.c strcspn.c strlen.c \
71	strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \
72	strspn.c strstr.c strtok.c swab.c
73
74.PATH: ${.CURDIR}/../libc/ia64/gen
75SRCS+= __divdi3.S __divsi3.S __moddi3.S __modsi3.S
76SRCS+= __udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S
77.endif
78.if ${MACHINE_CPUARCH} == "powerpc"
79.PATH: ${.CURDIR}/../libc/quad
80SRCS+=	ashldi3.c ashrdi3.c
81.PATH: ${.CURDIR}/../libc/powerpc/gen
82SRCS+=	syncicache.c
83.endif
84
85# uuid functions from libc
86.PATH: ${.CURDIR}/../libc/uuid
87SRCS+= uuid_equal.c uuid_is_nil.c
88
89# _setjmp/_longjmp
90.if ${MACHINE_CPUARCH} == "amd64"
91.PATH: ${.CURDIR}/i386
92.elif ${MACHINE_ARCH} == "powerpc64"
93.PATH: ${.CURDIR}/powerpc
94.else
95.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
96.endif
97SRCS+=	_setjmp.S
98
99# decompression functionality from libbz2
100# NOTE: to actually test this functionality after libbz2 upgrade compile
101# loader(8) with LOADER_BZIP2_SUPPORT defined
102.PATH: ${.CURDIR}/../../contrib/bzip2
103CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
104SRCS+=	libstand_bzlib_private.h
105
106.for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
107SRCS+=	_${file}
108CLEANFILES+=	_${file}
109
110_${file}: ${file}
111	sed "s|bzlib_private\.h|libstand_bzlib_private.h|" ${.ALLSRC} > ${.TARGET}
112.endfor
113
114CLEANFILES+= libstand_bzlib_private.h
115libstand_bzlib_private.h: bzlib_private.h
116	sed -e 's|<stdlib.h>|"stand.h"|' \
117		${.ALLSRC} > ${.TARGET}
118
119# decompression functionality from libz
120.PATH: ${.CURDIR}/../libz
121CFLAGS+=-DHAVE_MEMCPY -I${.CURDIR}/../libz
122SRCS+=	adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
123
124.for file in infback.c inffast.c inflate.c inftrees.c zutil.c
125SRCS+=	_${file}
126CLEANFILES+=	_${file}
127
128_${file}: ${file}
129	sed -e "s|zutil\.h|libstand_zutil.h|" \
130	    -e "s|gzguts\.h|libstand_gzguts.h|" \
131	    ${.ALLSRC} > ${.TARGET}
132.endfor
133
134# depend on stand.h being able to be included multiple times
135.for file in zutil.h gzguts.h
136CLEANFILES+= libstand_${file}
137libstand_${file}: ${file}
138	sed -e 's|<fcntl.h>|"stand.h"|' \
139	    -e 's|<stddef.h>|"stand.h"|' \
140	    -e 's|<string.h>|"stand.h"|' \
141	    -e 's|<stdio.h>|"stand.h"|' \
142	    -e 's|<stdlib.h>|"stand.h"|' \
143	    ${.ALLSRC} > ${.TARGET}
144.endfor
145
146# io routines
147SRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
148	fstat.c close.c lseek.c open.c read.c write.c readdir.c
149
150# network routines
151SRCS+=	arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
152
153# network info services:
154SRCS+=	bootp.c rarp.c bootparam.c
155
156# boot filesystems
157SRCS+=	ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
158SRCS+=	dosfs.c ext2fs.c
159SRCS+=	splitfs.c
160
161.include <bsd.lib.mk>
162
163.if ${MACHINE_CPUARCH} == "amd64"
164beforedepend ${OBJS}: machine
165cleandepend: cleanmachine
166cleanmachine:
167	rm -f machine
168
169machine:
170	ln -s ${.CURDIR}/../../sys/i386/include machine
171.endif
172