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})
19 LIBC_ARCH=${MACHINE_ARCH}
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 sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS
29 # to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs.
33 SHLIB_LDSCRIPT=libc.ldscript
35 SHLIB_LDSCRIPT=libc_nossp.ldscript
37 SHLIB_LDSCRIPT_LINKS=libxnet.so
39 CFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include
40 CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
46 BUILD_NOSSP_PIC_ARCHIVE=
49 .ifndef NO_THREAD_STACK_UNWIND
50 CANCELPOINTS_CFLAGS=-fexceptions
51 CFLAGS+=${CANCELPOINTS_CFLAGS}
55 # Link with static libcompiler_rt.a.
57 LDFLAGS+= -nodefaultlibs
61 LIBADD+= ssp_nonshared
64 # Extras that live in either libc.a or libc_nonshared.a
67 # Define (empty) variables so that make doesn't give substitution
68 # errors if the included makefiles don't change these:
75 .include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc"
76 .include "${LIBC_SRCTOP}/db/Makefile.inc"
77 .include "${LIBC_SRCTOP}/compat-43/Makefile.inc"
78 .include "${LIBC_SRCTOP}/gdtoa/Makefile.inc"
79 .include "${LIBC_SRCTOP}/gen/Makefile.inc"
80 .include "${LIBC_SRCTOP}/gmon/Makefile.inc"
81 .if ${MK_ICONV} != "no"
82 .include "${LIBC_SRCTOP}/iconv/Makefile.inc"
84 .include "${LIBC_SRCTOP}/inet/Makefile.inc"
85 .include "${LIBC_SRCTOP}/isc/Makefile.inc"
86 .include "${LIBC_SRCTOP}/locale/Makefile.inc"
87 .include "${LIBC_SRCTOP}/md/Makefile.inc"
88 .include "${LIBC_SRCTOP}/nameser/Makefile.inc"
89 .include "${LIBC_SRCTOP}/net/Makefile.inc"
90 .include "${LIBC_SRCTOP}/nls/Makefile.inc"
91 .include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
92 .if ${LIBC_ARCH} != "aarch64" && \
93 ${LIBC_ARCH} != "amd64" && \
94 ${LIBC_ARCH} != "powerpc64" && \
95 ${LIBC_ARCH} != "riscv" && \
96 ${LIBC_ARCH} != "sparc64" && \
97 ${MACHINE_ARCH:Mmipsn32*} == "" && \
98 ${MACHINE_ARCH:Mmips64*} == ""
99 .include "${LIBC_SRCTOP}/quad/Makefile.inc"
101 .include "${LIBC_SRCTOP}/regex/Makefile.inc"
102 .include "${LIBC_SRCTOP}/resolv/Makefile.inc"
103 .include "${LIBC_SRCTOP}/stdio/Makefile.inc"
104 .include "${LIBC_SRCTOP}/stdlib/Makefile.inc"
105 .include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc"
106 .include "${LIBC_SRCTOP}/stdtime/Makefile.inc"
107 .include "${LIBC_SRCTOP}/string/Makefile.inc"
108 .include "${LIBC_SRCTOP}/sys/Makefile.inc"
109 .include "${LIBC_SRCTOP}/secure/Makefile.inc"
110 .include "${LIBC_SRCTOP}/rpc/Makefile.inc"
111 .include "${LIBC_SRCTOP}/uuid/Makefile.inc"
112 .include "${LIBC_SRCTOP}/xdr/Makefile.inc"
113 .if (${LIBC_ARCH} == "arm" && \
114 (${MACHINE_ARCH:Marmv[67]*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \
115 (${LIBC_ARCH} == "mips" && ${MACHINE_ARCH:Mmips*hf} == "") || \
116 (${LIBC_ARCH} == "riscv" && ${MACHINE_ARCH:Mriscv*sf} != "")
117 .include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
119 .if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64"
120 .include "${LIBC_SRCTOP}/x86/sys/Makefile.inc"
122 .if ${MK_NIS} != "no"
124 .include "${LIBC_SRCTOP}/yp/Makefile.inc"
126 .include "${LIBC_SRCTOP}/capability/Makefile.inc"
127 .if ${MK_HESIOD} != "no"
130 .if ${MK_FP_LIBC} == "no"
131 CFLAGS+= -DNO_FLOATING_POINT
133 .if ${MK_NS_CACHING} != "no"
134 CFLAGS+= -DNS_CACHING
136 .if defined(_FREEFALL_CONFIG)
137 CFLAGS+=-D_FREEFALL_CONFIG
140 STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
142 VERSION_DEF=${LIBC_SRCTOP}/Versions.def
143 SYMBOL_MAPS=${SYM_MAPS}
144 CFLAGS+= -DSYMBOL_VERSIONING
146 # If there are no machine dependent sources, append all the
147 # machine-independent sources:
151 # Append machine-dependent sources, then append machine-independent sources
152 # for which there is no machine-dependent variant.
154 .for _src in ${MISRCS}
155 .if ${MDSRCS:R:M${_src:R}} == ""
161 KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
162 lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
163 subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
164 KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
165 strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
167 libkern: libkern.gen libkern.${LIBC_ARCH}
169 libkern.gen: ${KQSRCS} ${KSRCS}
170 ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
172 libkern.${LIBC_ARCH}:: ${KMSRCS}
173 .if defined(KMSRCS) && !empty(KMSRCS)
174 ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
178 SUBDIR.${MK_TESTS}+= tests
180 .include <bsd.lib.mk>
182 .if !defined(_SKIP_BUILD)
183 # We need libutil.h, get it directly to avoid
184 # recording a build dependency
185 CFLAGS+= -I${SRCTOP}/lib/libutil
186 # Same issue with libm
187 MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR
188 # unfortunately msun/src contains both private and public headers
189 CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR}
190 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
191 CFLAGS+= -I${SRCTOP}/lib/msun/x86
193 CFLAGS+= -I${SRCTOP}/lib/msun/src
194 # and we do not want to record a dependency on msun
195 .if ${.MAKE.LEVEL} > 0
196 GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
200 # Disable warnings in contributed sources.
201 CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
202 # Disable stack protection for SSP symbols.
203 SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
204 # Generate stack unwinding tables for cancellation points
205 CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}