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