xref: /freebsd/lib/libc/Makefile (revision fafb1ee7bdc5d8a7d07cd03b2fb0bbb76f7a9d7c)
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
29SHLIB_LDSCRIPT_LINKS=libxnet.so
30WARNS?=	2
31CFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include
32CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
33.if ${MK_NLS} != "no"
34CFLAGS+=-DNLS
35.endif
36CLEANFILES+=tags
37INSTALL_PIC_ARCHIVE=
38PRECIOUSLIB=
39
40.ifndef NO_THREAD_STACK_UNWIND
41CANCELPOINTS_CFLAGS=-fexceptions
42CFLAGS+=${CANCELPOINTS_CFLAGS}
43.endif
44
45#
46# Link with static libcompiler_rt.a.
47#
48LDFLAGS+= -nodefaultlibs
49LIBADD+=	compiler_rt
50
51.if ${MK_SSP} != "no"
52LIBADD+=	ssp_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}/md/Makefile.inc"
79.include "${LIBC_SRCTOP}/nameser/Makefile.inc"
80.include "${LIBC_SRCTOP}/net/Makefile.inc"
81.include "${LIBC_SRCTOP}/nls/Makefile.inc"
82.include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
83.if ${LIBC_ARCH} != "aarch64" && \
84    ${LIBC_ARCH} != "amd64" && \
85    ${LIBC_ARCH} != "powerpc64" && \
86    ${LIBC_ARCH} != "sparc64" && \
87    ${MACHINE_ARCH:Mmipsn32*} == "" && \
88    ${MACHINE_ARCH:Mmips64*} == ""
89.include "${LIBC_SRCTOP}/quad/Makefile.inc"
90.endif
91.include "${LIBC_SRCTOP}/regex/Makefile.inc"
92.include "${LIBC_SRCTOP}/resolv/Makefile.inc"
93.include "${LIBC_SRCTOP}/stdio/Makefile.inc"
94.include "${LIBC_SRCTOP}/stdlib/Makefile.inc"
95.include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc"
96.include "${LIBC_SRCTOP}/stdtime/Makefile.inc"
97.include "${LIBC_SRCTOP}/string/Makefile.inc"
98.include "${LIBC_SRCTOP}/sys/Makefile.inc"
99.include "${LIBC_SRCTOP}/secure/Makefile.inc"
100.include "${LIBC_SRCTOP}/rpc/Makefile.inc"
101.include "${LIBC_SRCTOP}/uuid/Makefile.inc"
102.include "${LIBC_SRCTOP}/xdr/Makefile.inc"
103.if (${LIBC_ARCH} == "arm" && ${MACHINE_ARCH} != "armv6hf") ||\
104     ${LIBC_ARCH} == "mips"
105.include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
106.endif
107.if ${MK_NIS} != "no"
108CFLAGS+= -DYP
109.include "${LIBC_SRCTOP}/yp/Makefile.inc"
110.endif
111.include "${LIBC_SRCTOP}/capability/Makefile.inc"
112.if ${MK_HESIOD} != "no"
113CFLAGS+= -DHESIOD
114.endif
115.if ${MK_FP_LIBC} == "no"
116CFLAGS+= -DNO_FLOATING_POINT
117.endif
118.if ${MK_NS_CACHING} != "no"
119CFLAGS+= -DNS_CACHING
120.endif
121.if defined(_FREEFALL_CONFIG)
122CFLAGS+=-D_FREEFALL_CONFIG
123.endif
124
125STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
126
127VERSION_DEF=${LIBC_SRCTOP}/Versions.def
128SYMBOL_MAPS=${SYM_MAPS}
129CFLAGS+= -DSYMBOL_VERSIONING
130
131# If there are no machine dependent sources, append all the
132# machine-independent sources:
133.if empty(MDSRCS)
134SRCS+=	${MISRCS}
135.else
136# Append machine-dependent sources, then append machine-independent sources
137# for which there is no machine-dependent variant.
138SRCS+=	${MDSRCS}
139.for _src in ${MISRCS}
140.if ${MDSRCS:R:M${_src:R}} == ""
141SRCS+=	${_src}
142.endif
143.endfor
144.endif
145
146KQSRCS=	adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
147	lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
148	subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
149KSRCS=	bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
150	strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
151
152libkern: libkern.gen libkern.${LIBC_ARCH}
153
154libkern.gen: ${KQSRCS} ${KSRCS}
155	${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
156
157libkern.${LIBC_ARCH}:: ${KMSRCS}
158.if defined(KMSRCS) && !empty(KMSRCS)
159	${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
160.endif
161
162.if ${MK_TESTS} != "no"
163SUBDIR+=	tests
164.endif
165
166.include <bsd.lib.mk>
167
168.if !defined(_SKIP_BUILD)
169# We need libutil.h, get it directly to avoid
170# recording a build dependency
171CFLAGS+= -I${.CURDIR:H}/libutil
172# Same issue with libm
173MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${.CURDIR:H}/msun -V ARCH_SUBDIR
174# unfortunately msun/src contains both private and public headers
175CFLAGS+= -I${.CURDIR:H}/msun/${MSUN_ARCH_SUBDIR}
176.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
177CFLAGS+= -I${.CURDIR:H}/msun/x86
178.endif
179CFLAGS+= -I${.CURDIR:H}/msun/src
180# and we do not want to record a dependency on msun
181.if ${.MAKE.LEVEL} > 0
182GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
183.endif
184.endif
185
186# Disable warnings in contributed sources.
187CWARNFLAGS:=	${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
188# XXX For now, we don't allow libc to be compiled with
189# -fstack-protector-all because it breaks rtld.  We may want to make a librtld
190# in the future to circumvent this.
191SSP_CFLAGS:=	${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
192# Disable stack protection for SSP symbols.
193SSP_CFLAGS:=	${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
194# Generate stack unwinding tables for cancellation points
195CANCELPOINTS_CFLAGS:=	${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
196