Makefile revision 235720
1#	@(#)Makefile	8.2 (Berkeley) 2/3/94
2# $FreeBSD: head/lib/libc/Makefile 235720 2012-05-21 08:10:42Z gleb $
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
26WARNS?=	2
27CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include
28CFLAGS+=-I${.CURDIR}/${LIBC_ARCH}
29.if ${MK_NLS} != "no"
30CFLAGS+=-DNLS
31.endif
32CLEANFILES+=tags
33INSTALL_PIC_ARCHIVE=
34PRECIOUSLIB=
35
36.ifndef NO_THREAD_STACK_UNWIND
37CANCELPOINTS_CFLAGS=-fexceptions
38CFLAGS+=${CANCELPOINTS_CFLAGS}
39.endif
40
41#
42# Only link with static libgcc.a (no libgcc_eh.a).
43#
44DPADD+=	${LIBGCC}
45LDFLAGS+= -nodefaultlibs
46LDADD+= -lgcc
47
48.if ${MK_SSP} != "no"
49LDADD+= -lssp_nonshared
50.endif
51
52# Define (empty) variables so that make doesn't give substitution
53# errors if the included makefiles don't change these:
54MDSRCS=
55MISRCS=
56MDASM=
57MIASM=
58NOASM=
59
60.include "${.CURDIR}/${LIBC_ARCH}/Makefile.inc"
61.include "${.CURDIR}/db/Makefile.inc"
62.include "${.CURDIR}/compat-43/Makefile.inc"
63.include "${.CURDIR}/gdtoa/Makefile.inc"
64.include "${.CURDIR}/gen/Makefile.inc"
65.include "${.CURDIR}/gmon/Makefile.inc"
66.if ${MK_ICONV} != "no"
67.include "${.CURDIR}/iconv/Makefile.inc"
68.endif
69.include "${.CURDIR}/inet/Makefile.inc"
70.include "${.CURDIR}/isc/Makefile.inc"
71.include "${.CURDIR}/locale/Makefile.inc"
72.include "${.CURDIR}/nameser/Makefile.inc"
73.include "${.CURDIR}/net/Makefile.inc"
74.include "${.CURDIR}/nls/Makefile.inc"
75.include "${.CURDIR}/posix1e/Makefile.inc"
76.if ${LIBC_ARCH} != "amd64" && \
77    ${LIBC_ARCH} != "ia64" && \
78    ${LIBC_ARCH} != "powerpc64" && \
79    ${LIBC_ARCH} != "sparc64" && \
80    ${MACHINE_ARCH:Mmipsn32*} == "" && \
81    ${MACHINE_ARCH:Mmips64*} == ""
82.include "${.CURDIR}/quad/Makefile.inc"
83.endif
84.include "${.CURDIR}/regex/Makefile.inc"
85.include "${.CURDIR}/resolv/Makefile.inc"
86.include "${.CURDIR}/stdio/Makefile.inc"
87.include "${.CURDIR}/stdlib/Makefile.inc"
88.include "${.CURDIR}/stdlib/jemalloc/Makefile.inc"
89.include "${.CURDIR}/stdtime/Makefile.inc"
90.include "${.CURDIR}/string/Makefile.inc"
91.include "${.CURDIR}/sys/Makefile.inc"
92.include "${.CURDIR}/rpc/Makefile.inc"
93.include "${.CURDIR}/uuid/Makefile.inc"
94.include "${.CURDIR}/xdr/Makefile.inc"
95.if ${LIBC_ARCH} == "arm" || ${LIBC_ARCH} == "mips"
96.include "${.CURDIR}/softfloat/Makefile.inc"
97.endif
98.if ${MK_NIS} != "no"
99CFLAGS+= -DYP
100.include "${.CURDIR}/yp/Makefile.inc"
101.endif
102.if ${MK_HESIOD} != "no"
103CFLAGS+= -DHESIOD
104.endif
105.if ${MK_FP_LIBC} == "no"
106CFLAGS+= -DNO_FLOATING_POINT
107.endif
108.if ${MK_NS_CACHING} != "no"
109CFLAGS+= -DNS_CACHING
110.endif
111.if defined(_FREEFALL_CONFIG)
112CFLAGS+=-D_FREEFALL_CONFIG
113.endif
114
115VERSION_DEF=${.CURDIR}/Versions.def
116SYMBOL_MAPS=${SYM_MAPS}
117CFLAGS+= -DSYMBOL_VERSIONING
118
119# If there are no machine dependent sources, append all the
120# machine-independent sources:
121.if empty(MDSRCS)
122SRCS+=	${MISRCS}
123.else
124# Append machine-dependent sources, then append machine-independent sources
125# for which there is no machine-dependent variant.
126SRCS+=	${MDSRCS}
127.for _src in ${MISRCS}
128.if ${MDSRCS:R:M${_src:R}} == ""
129SRCS+=	${_src}
130.endif
131.endfor
132.endif
133
134KQSRCS=	adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
135	lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
136	subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
137KSRCS=	bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
138	strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
139
140libkern: libkern.gen libkern.${LIBC_ARCH}
141
142libkern.gen: ${KQSRCS} ${KSRCS}
143	cp -p ${.CURDIR}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
144
145libkern.${LIBC_ARCH}:: ${KMSRCS}
146.if defined(KMSRCS) && !empty(KMSRCS)
147	cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
148.endif
149
150.include <bsd.lib.mk>
151
152# Disable warnings in contributed sources.
153CWARNFLAGS:=	${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
154# XXX For now, we don't allow libc to be compiled with
155# -fstack-protector-all because it breaks rtld.  We may want to make a librtld
156# in the future to circumvent this.
157SSP_CFLAGS:=	${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
158# Disable stack protection for SSP symbols.
159SSP_CFLAGS:=	${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
160# Generate stack unwinding tables for cancellation points
161CANCELPOINTS_CFLAGS:=	${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
162