1#	@(#)Makefile	8.2 (Berkeley) 2/3/94
2# $FreeBSD$
3
4SHLIBDIR?= /lib
5
6.include <bsd.own.mk>
7
8# Pick the current architecture directory for libc. In general, this is
9# named MACHINE_CPUARCH, but some ABIs are different enough to require
10# their own libc, so allow a directory named MACHINE_ARCH to override this.
11
12.if exists(${.CURDIR}/${MACHINE_ARCH})
13LIBC_ARCH=${MACHINE_ARCH}
14.else
15LIBC_ARCH=${MACHINE_CPUARCH}
16.endif
17
18# All library objects contain FreeBSD revision strings by default; they may be
19# excluded as a space-saving measure.  To produce a library that does
20# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
21# below.  Note: there are no IDs for syscall stubs whose sources are generated.
22# To include legacy CSRG sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS
23# to CFLAGS below.  -DSYSLIBC_SCCS affects just the system call stubs.
24LIB=c
25SHLIB_MAJOR= 7
26SHLIB_LDSCRIPT=libc.ldscript
27WARNS?=	2
28CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include
29CFLAGS+=-I${.CURDIR}/${LIBC_ARCH}
30.if ${MK_NLS} != "no"
31CFLAGS+=-DNLS
32.endif
33CLEANFILES+=tags
34INSTALL_PIC_ARCHIVE=
35PRECIOUSLIB=
36
37.ifndef NO_THREAD_STACK_UNWIND
38CANCELPOINTS_CFLAGS=-fexceptions
39CFLAGS+=${CANCELPOINTS_CFLAGS}
40.endif
41
42#
43# Only link with static libgcc.a (no libgcc_eh.a).
44#
45DPADD+=	${LIBGCC}
46LDFLAGS+= -nodefaultlibs
47LDADD+= -lgcc
48
49.if ${MK_SSP} != "no"
50DPADD+= ${LIBSSP_NONSHARED}
51LDADD+= -lssp_nonshared
52.endif
53
54# Extras that live in either libc.a or libc_nonshared.a
55LIBC_NONSHARED_SRCS=
56
57# Define (empty) variables so that make doesn't give substitution
58# errors if the included makefiles don't change these:
59MDSRCS=
60MISRCS=
61MDASM=
62MIASM=
63NOASM=
64
65.include "${.CURDIR}/${LIBC_ARCH}/Makefile.inc"
66.include "${.CURDIR}/db/Makefile.inc"
67.include "${.CURDIR}/compat-43/Makefile.inc"
68.include "${.CURDIR}/gdtoa/Makefile.inc"
69.include "${.CURDIR}/gen/Makefile.inc"
70.include "${.CURDIR}/gmon/Makefile.inc"
71.if ${MK_ICONV} != "no"
72.include "${.CURDIR}/iconv/Makefile.inc"
73.endif
74.include "${.CURDIR}/inet/Makefile.inc"
75.include "${.CURDIR}/isc/Makefile.inc"
76.include "${.CURDIR}/locale/Makefile.inc"
77.include "${.CURDIR}/md/Makefile.inc"
78.include "${.CURDIR}/nameser/Makefile.inc"
79.include "${.CURDIR}/net/Makefile.inc"
80.include "${.CURDIR}/nls/Makefile.inc"
81.include "${.CURDIR}/posix1e/Makefile.inc"
82.if ${LIBC_ARCH} != "amd64" && \
83    ${LIBC_ARCH} != "ia64" && \
84    ${LIBC_ARCH} != "powerpc64" && \
85    ${LIBC_ARCH} != "sparc64" && \
86    ${MACHINE_ARCH:Mmipsn32*} == "" && \
87    ${MACHINE_ARCH:Mmips64*} == ""
88.include "${.CURDIR}/quad/Makefile.inc"
89.endif
90.include "${.CURDIR}/regex/Makefile.inc"
91.include "${.CURDIR}/resolv/Makefile.inc"
92.include "${.CURDIR}/stdio/Makefile.inc"
93.include "${.CURDIR}/stdlib/Makefile.inc"
94.include "${.CURDIR}/stdlib/jemalloc/Makefile.inc"
95.include "${.CURDIR}/stdtime/Makefile.inc"
96.include "${.CURDIR}/string/Makefile.inc"
97.include "${.CURDIR}/sys/Makefile.inc"
98.include "${.CURDIR}/rpc/Makefile.inc"
99.include "${.CURDIR}/uuid/Makefile.inc"
100.include "${.CURDIR}/xdr/Makefile.inc"
101.if ${LIBC_ARCH} == "arm" || ${LIBC_ARCH} == "mips"
102.include "${.CURDIR}/softfloat/Makefile.inc"
103.endif
104.if ${MK_NIS} != "no"
105CFLAGS+= -DYP
106.include "${.CURDIR}/yp/Makefile.inc"
107.endif
108.include "${.CURDIR}/capability/Makefile.inc"
109.if ${MK_HESIOD} != "no"
110CFLAGS+= -DHESIOD
111.endif
112.if ${MK_FP_LIBC} == "no"
113CFLAGS+= -DNO_FLOATING_POINT
114.endif
115.if ${MK_NS_CACHING} != "no"
116CFLAGS+= -DNS_CACHING
117.endif
118.if defined(_FREEFALL_CONFIG)
119CFLAGS+=-D_FREEFALL_CONFIG
120.endif
121
122STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
123
124VERSION_DEF=${.CURDIR}/Versions.def
125SYMBOL_MAPS=${SYM_MAPS}
126CFLAGS+= -DSYMBOL_VERSIONING
127
128# If there are no machine dependent sources, append all the
129# machine-independent sources:
130.if empty(MDSRCS)
131SRCS+=	${MISRCS}
132.else
133# Append machine-dependent sources, then append machine-independent sources
134# for which there is no machine-dependent variant.
135SRCS+=	${MDSRCS}
136.for _src in ${MISRCS}
137.if ${MDSRCS:R:M${_src:R}} == ""
138SRCS+=	${_src}
139.endif
140.endfor
141.endif
142
143KQSRCS=	adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
144	lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
145	subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
146KSRCS=	bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
147	strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
148
149libkern: libkern.gen libkern.${LIBC_ARCH}
150
151libkern.gen: ${KQSRCS} ${KSRCS}
152	cp -p ${.CURDIR}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
153
154libkern.${LIBC_ARCH}:: ${KMSRCS}
155.if defined(KMSRCS) && !empty(KMSRCS)
156	cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
157.endif
158
159.include <bsd.lib.mk>
160
161# Disable warnings in contributed sources.
162CWARNFLAGS:=	${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
163# XXX For now, we don't allow libc to be compiled with
164# -fstack-protector-all because it breaks rtld.  We may want to make a librtld
165# in the future to circumvent this.
166SSP_CFLAGS:=	${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
167# Disable stack protection for SSP symbols.
168SSP_CFLAGS:=	${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
169# Generate stack unwinding tables for cancellation points
170CANCELPOINTS_CFLAGS:=	${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
171