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