]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/Makefile
Import device-tree files from Linux 6.0
[FreeBSD/FreeBSD.git] / lib / libc / Makefile
1 #       @(#)Makefile    8.2 (Berkeley) 2/3/94
2 # $FreeBSD$
3
4 PACKAGE=        clibs
5 SHLIBDIR?= /lib
6
7 .include <src.opts.mk>
8
9 # Force building of libc_pic.a
10 MK_TOOLCHAIN=   yes
11
12 LIBC_SRCTOP?= ${.CURDIR}
13
14 # Pick the current architecture directory for libc. In general, this is
15 # named MACHINE_CPUARCH, but some ABIs are different enough to require
16 # their own libc, so allow a directory named MACHINE_ARCH to override this.
17
18 .if exists(${LIBC_SRCTOP}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
19 LIBC_ARCH=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
20 .else
21 LIBC_ARCH=${MACHINE_CPUARCH}
22 .endif
23
24 # All library objects contain FreeBSD revision strings by default; they may be
25 # excluded as a space-saving measure.  To produce a library that does
26 # not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
27 # below.  Note: there are no IDs for syscall stubs whose sources are generated.
28 # To include legacy CSRG SCCS ID strings, remove -DNO__SCCSID from CFLAGS.
29 # To include RCS ID strings from other BSD projects, remove -DNO__RCSID from CFLAGS.
30 CFLAGS+=-DNO__SCCSID -DNO__RCSID
31
32 LIB=c
33 SHLIB_MAJOR= 7
34 .if ${MK_SSP} != "no" && \
35     (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
36 SHLIB_LDSCRIPT=libc.ldscript
37 .else
38 SHLIB_LDSCRIPT=libc_nossp.ldscript
39 .endif
40 SHLIB_LDSCRIPT_LINKS=libxnet.so
41 WARNS?= 2
42 CFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include
43 CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
44 .if ${MK_NLS} != "no"
45 CFLAGS+=-DNLS
46 .endif
47 CLEANFILES+=tags
48 INSTALL_PIC_ARCHIVE=
49 BUILD_NOSSP_PIC_ARCHIVE=
50 PRECIOUSLIB=
51
52 .ifndef NO_THREAD_STACK_UNWIND
53 CANCELPOINTS_CFLAGS=-fexceptions
54 CFLAGS+=${CANCELPOINTS_CFLAGS}
55 .endif
56
57 # Use a more efficient TLS model for libc since we can reasonably assume that
58 # it will be loaded during program startup.
59 .if ${LIBC_ARCH} == "aarch64" || ${LIBC_ARCH} == "amd64" || \
60     ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "riscv" || \
61     ${LIBC_ARCH:Mpowerpc*} != ""
62 CFLAGS+= -ftls-model=initial-exec
63 .endif
64
65 #
66 # Link with static libcompiler_rt.a.
67 #
68 LDFLAGS+= -nodefaultlibs
69 LIBADD+=        compiler_rt
70
71 .if ${MK_SSP} != "no" && \
72     (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
73 LIBADD+=        ssp_nonshared
74 .endif
75
76 # Extras that live in either libc.a or libc_nonshared.a
77 LIBC_NONSHARED_SRCS=
78
79 RTLD_ELF_DIR=${SRCTOP}/libexec/rtld-elf
80 .if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
81 RTLD_ARCH=      ${MACHINE_ARCH:S/powerpc64le/powerpc64/}
82 .else
83 RTLD_ARCH=      ${MACHINE_CPUARCH}
84 .endif
85 RTLD_HDRS= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR}
86
87 # Define (empty) variables so that make doesn't give substitution
88 # errors if the included makefiles don't change these:
89 MDSRCS=
90 MISRCS=
91 MDASM=
92 MIASM=
93 NOASM=
94
95 .include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc"
96 .include "${LIBC_SRCTOP}/db/Makefile.inc"
97 .include "${LIBC_SRCTOP}/compat-43/Makefile.inc"
98 .include "${LIBC_SRCTOP}/gdtoa/Makefile.inc"
99 .include "${LIBC_SRCTOP}/gen/Makefile.inc"
100 .include "${LIBC_SRCTOP}/gmon/Makefile.inc"
101 .if ${MK_ICONV} != "no"
102 .include "${LIBC_SRCTOP}/iconv/Makefile.inc"
103 .endif
104 .include "${LIBC_SRCTOP}/inet/Makefile.inc"
105 .include "${LIBC_SRCTOP}/isc/Makefile.inc"
106 .include "${LIBC_SRCTOP}/locale/Makefile.inc"
107 .include "${LIBC_SRCTOP}/md/Makefile.inc"
108 .include "${LIBC_SRCTOP}/nameser/Makefile.inc"
109 .include "${LIBC_SRCTOP}/net/Makefile.inc"
110 .include "${LIBC_SRCTOP}/nls/Makefile.inc"
111 .include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
112 .if ${MACHINE_ABI:Mlong32}
113 .include "${LIBC_SRCTOP}/quad/Makefile.inc"
114 .endif
115 .include "${LIBC_SRCTOP}/regex/Makefile.inc"
116 .include "${LIBC_SRCTOP}/resolv/Makefile.inc"
117 .include "${LIBC_SRCTOP}/stdio/Makefile.inc"
118 .include "${LIBC_SRCTOP}/stdlib/Makefile.inc"
119 .include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc"
120 .include "${LIBC_SRCTOP}/stdtime/Makefile.inc"
121 .include "${LIBC_SRCTOP}/string/Makefile.inc"
122 .include "${LIBC_SRCTOP}/sys/Makefile.inc"
123 .include "${LIBC_SRCTOP}/secure/Makefile.inc"
124 .include "${LIBC_SRCTOP}/rpc/Makefile.inc"
125 .include "${LIBC_SRCTOP}/uuid/Makefile.inc"
126 .include "${LIBC_SRCTOP}/xdr/Makefile.inc"
127 .if (${LIBC_ARCH} == "arm" && \
128         (${MACHINE_ARCH:Marmv[67]*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \
129     (${LIBC_ARCH} == "riscv" && ${MACHINE_ARCH:Mriscv*sf} != "")
130 .include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
131 .endif
132 .if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64"
133 .include "${LIBC_SRCTOP}/x86/sys/Makefile.inc"
134 .include "${LIBC_SRCTOP}/x86/gen/Makefile.inc"
135 .endif
136 .if ${MK_NIS} != "no"
137 CFLAGS+= -DYP
138 .include "${LIBC_SRCTOP}/yp/Makefile.inc"
139 .endif
140 .include "${LIBC_SRCTOP}/capability/Makefile.inc"
141 .if ${MK_HESIOD} != "no"
142 CFLAGS+= -DHESIOD
143 .endif
144 .if ${MK_FP_LIBC} == "no"
145 CFLAGS+= -DNO_FLOATING_POINT
146 .endif
147 .if ${MK_NS_CACHING} != "no"
148 CFLAGS+= -DNS_CACHING
149 .endif
150 .if defined(_FREEFALL_CONFIG)
151 CFLAGS+=-D_FREEFALL_CONFIG
152 .endif
153
154 STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
155
156 VERSION_DEF=${LIBC_SRCTOP}/Versions.def
157 SYMBOL_MAPS=${SYM_MAPS}
158 CFLAGS+= -DSYMBOL_VERSIONING
159
160 # If there are no machine dependent sources, append all the
161 # machine-independent sources:
162 .if empty(MDSRCS) || ${MK_MACHDEP_OPTIMIZATIONS} == no
163 SRCS+=  ${MISRCS}
164 .else
165 # Append machine-dependent sources, then append machine-independent sources
166 # for which there is no machine-dependent variant.
167 SRCS+=  ${MDSRCS}
168 .for _src in ${MISRCS}
169 .if ${MDSRCS:R:M${_src:R}} == ""
170 SRCS+=  ${_src}
171 .endif
172 .endfor
173 .endif
174
175 KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
176         lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
177         subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
178 KSRCS=  bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
179         strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
180
181 libkern: libkern.gen libkern.${LIBC_ARCH}
182
183 libkern.gen: ${KQSRCS} ${KSRCS}
184         ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
185
186 libkern.${LIBC_ARCH}:: ${KMSRCS}
187 .if defined(KMSRCS) && !empty(KMSRCS)
188         ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
189 .endif
190
191 HAS_TESTS=
192 SUBDIR.${MK_TESTS}+= tests
193
194 .include <bsd.lib.mk>
195
196 .if (${LIBC_ARCH} == amd64 || ${LIBC_ARCH} == i386) && \
197     ${.TARGETS:Mall} == all && \
198     defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == ""
199 .error ${LIBC_ARCH} libc requires linker ifunc support
200 .endif
201
202 .if !defined(_SKIP_BUILD)
203 # We need libutil.h, get it directly to avoid
204 # recording a build dependency
205 CFLAGS+= -I${SRCTOP}/lib/libutil
206 # Same issue with libm
207 MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR
208 # unfortunately msun/src contains both private and public headers
209 CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR}
210 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
211 CFLAGS+= -I${SRCTOP}/lib/msun/x86
212 .endif
213 CFLAGS+= -I${SRCTOP}/lib/msun/src
214 # and we do not want to record a dependency on msun
215 .if ${.MAKE.LEVEL} > 0
216 GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
217 .endif
218 .endif
219
220 # Disable warnings in contributed sources.
221 CWARNFLAGS:=    ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
222 # Disable stack protection for SSP symbols.
223 SSP_CFLAGS:=    ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
224 # Generate stack unwinding tables for cancellation points
225 CANCELPOINTS_CFLAGS:=   ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}