1 # @(#)Makefile 8.2 (Berkeley) 2/3/94
9 # Force building of libc_pic.a
12 LIBC_SRCTOP?= ${.CURDIR}
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.
18 .if exists(${LIBC_SRCTOP}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
19 LIBC_ARCH=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
21 LIBC_ARCH=${MACHINE_CPUARCH}
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
34 .if ${MK_SSP} != "no" && \
35 (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
36 SHLIB_LDSCRIPT=libc.ldscript
38 SHLIB_LDSCRIPT=libc_nossp.ldscript
40 SHLIB_LDSCRIPT_LINKS=libxnet.so
42 CFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include
43 CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
49 BUILD_NOSSP_PIC_ARCHIVE=
52 .ifndef NO_THREAD_STACK_UNWIND
53 CANCELPOINTS_CFLAGS=-fexceptions
54 CFLAGS+=${CANCELPOINTS_CFLAGS}
58 # Link with static libcompiler_rt.a.
60 LDFLAGS+= -nodefaultlibs
63 .if ${MK_SSP} != "no" && \
64 (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
65 LIBADD+= ssp_nonshared
68 # Extras that live in either libc.a or libc_nonshared.a
71 # Define (empty) variables so that make doesn't give substitution
72 # errors if the included makefiles don't change these:
79 .include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc"
80 .include "${LIBC_SRCTOP}/db/Makefile.inc"
81 .include "${LIBC_SRCTOP}/compat-43/Makefile.inc"
82 .include "${LIBC_SRCTOP}/gdtoa/Makefile.inc"
83 .include "${LIBC_SRCTOP}/gen/Makefile.inc"
84 .include "${LIBC_SRCTOP}/gmon/Makefile.inc"
85 .if ${MK_ICONV} != "no"
86 .include "${LIBC_SRCTOP}/iconv/Makefile.inc"
88 .include "${LIBC_SRCTOP}/inet/Makefile.inc"
89 .include "${LIBC_SRCTOP}/isc/Makefile.inc"
90 .include "${LIBC_SRCTOP}/locale/Makefile.inc"
91 .include "${LIBC_SRCTOP}/md/Makefile.inc"
92 .include "${LIBC_SRCTOP}/nameser/Makefile.inc"
93 .include "${LIBC_SRCTOP}/net/Makefile.inc"
94 .include "${LIBC_SRCTOP}/nls/Makefile.inc"
95 .include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
96 .if ${LIBC_ARCH} != "aarch64" && \
97 ${LIBC_ARCH} != "amd64" && \
98 ${LIBC_ARCH} != "powerpc64" && \
99 ${LIBC_ARCH} != "riscv" && \
100 ${MACHINE_ARCH:Mmipsn32*} == "" && \
101 ${MACHINE_ARCH:Mmips64*} == ""
102 .include "${LIBC_SRCTOP}/quad/Makefile.inc"
104 .include "${LIBC_SRCTOP}/regex/Makefile.inc"
105 .include "${LIBC_SRCTOP}/resolv/Makefile.inc"
106 .include "${LIBC_SRCTOP}/stdio/Makefile.inc"
107 .include "${LIBC_SRCTOP}/stdlib/Makefile.inc"
108 .include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc"
109 .include "${LIBC_SRCTOP}/stdtime/Makefile.inc"
110 .include "${LIBC_SRCTOP}/string/Makefile.inc"
111 .include "${LIBC_SRCTOP}/sys/Makefile.inc"
112 .include "${LIBC_SRCTOP}/secure/Makefile.inc"
113 .include "${LIBC_SRCTOP}/rpc/Makefile.inc"
114 .include "${LIBC_SRCTOP}/uuid/Makefile.inc"
115 .include "${LIBC_SRCTOP}/xdr/Makefile.inc"
116 .if (${LIBC_ARCH} == "arm" && \
117 (${MACHINE_ARCH:Marmv[67]*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \
118 (${LIBC_ARCH} == "mips" && ${MACHINE_ARCH:Mmips*hf} == "") || \
119 (${LIBC_ARCH} == "riscv" && ${MACHINE_ARCH:Mriscv*sf} != "")
120 .include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
122 .if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64"
123 .include "${LIBC_SRCTOP}/x86/sys/Makefile.inc"
124 .include "${LIBC_SRCTOP}/x86/gen/Makefile.inc"
126 .if ${MK_NIS} != "no"
128 .include "${LIBC_SRCTOP}/yp/Makefile.inc"
130 .include "${LIBC_SRCTOP}/capability/Makefile.inc"
131 .if ${MK_HESIOD} != "no"
134 .if ${MK_FP_LIBC} == "no"
135 CFLAGS+= -DNO_FLOATING_POINT
137 .if ${MK_NS_CACHING} != "no"
138 CFLAGS+= -DNS_CACHING
140 .if defined(_FREEFALL_CONFIG)
141 CFLAGS+=-D_FREEFALL_CONFIG
144 STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
146 VERSION_DEF=${LIBC_SRCTOP}/Versions.def
147 SYMBOL_MAPS=${SYM_MAPS}
148 CFLAGS+= -DSYMBOL_VERSIONING
150 # If there are no machine dependent sources, append all the
151 # machine-independent sources:
155 # Append machine-dependent sources, then append machine-independent sources
156 # for which there is no machine-dependent variant.
158 .for _src in ${MISRCS}
159 .if ${MDSRCS:R:M${_src:R}} == ""
165 KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
166 lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
167 subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
168 KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
169 strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
171 libkern: libkern.gen libkern.${LIBC_ARCH}
173 libkern.gen: ${KQSRCS} ${KSRCS}
174 ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
176 libkern.${LIBC_ARCH}:: ${KMSRCS}
177 .if defined(KMSRCS) && !empty(KMSRCS)
178 ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
182 SUBDIR.${MK_TESTS}+= tests
184 .include <bsd.lib.mk>
186 .if (${LIBC_ARCH} == amd64 || ${LIBC_ARCH} == i386) && \
187 ${.TARGETS:Mall} == all && \
188 defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == ""
189 .error ${LIBC_ARCH} libc requires linker ifunc support
192 .if !defined(_SKIP_BUILD)
193 # We need libutil.h, get it directly to avoid
194 # recording a build dependency
195 CFLAGS+= -I${SRCTOP}/lib/libutil
196 # Same issue with libm
197 MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR
198 # unfortunately msun/src contains both private and public headers
199 CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR}
200 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
201 CFLAGS+= -I${SRCTOP}/lib/msun/x86
203 CFLAGS+= -I${SRCTOP}/lib/msun/src
204 # and we do not want to record a dependency on msun
205 .if ${.MAKE.LEVEL} > 0
206 GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
210 # Disable warnings in contributed sources.
211 CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
212 # Disable stack protection for SSP symbols.
213 SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
214 # Generate stack unwinding tables for cancellation points
215 CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}