1 # @(#)Makefile 8.2 (Berkeley) 2/3/94
8 LIBC_SRCTOP?= ${.CURDIR}
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.
14 .if exists(${LIBC_SRCTOP}/${MACHINE_ARCH})
15 LIBC_ARCH=${MACHINE_ARCH}
17 LIBC_ARCH=${MACHINE_CPUARCH}
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.
28 SHLIB_LDSCRIPT=libc.ldscript
30 CFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include
31 CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
39 .ifndef NO_THREAD_STACK_UNWIND
40 CANCELPOINTS_CFLAGS=-fexceptions
41 CFLAGS+=${CANCELPOINTS_CFLAGS}
45 # Link with static libcompiler_rt.a.
47 DPADD+= ${LIBCOMPILER_RT}
48 LDFLAGS+= -nodefaultlibs
52 DPADD+= ${LIBSSP_NONSHARED}
53 LDADD+= -lssp_nonshared
56 # Extras that live in either libc.a or libc_nonshared.a
59 # Define (empty) variables so that make doesn't give substitution
60 # errors if the included makefiles don't change these:
67 .include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc"
68 .include "${LIBC_SRCTOP}/db/Makefile.inc"
69 .include "${LIBC_SRCTOP}/compat-43/Makefile.inc"
70 .include "${LIBC_SRCTOP}/gdtoa/Makefile.inc"
71 .include "${LIBC_SRCTOP}/gen/Makefile.inc"
72 .include "${LIBC_SRCTOP}/gmon/Makefile.inc"
73 .if ${MK_ICONV} != "no"
74 .include "${LIBC_SRCTOP}/iconv/Makefile.inc"
76 .include "${LIBC_SRCTOP}/inet/Makefile.inc"
77 .include "${LIBC_SRCTOP}/isc/Makefile.inc"
78 .include "${LIBC_SRCTOP}/locale/Makefile.inc"
79 .include "${LIBC_SRCTOP}/md/Makefile.inc"
80 .include "${LIBC_SRCTOP}/nameser/Makefile.inc"
81 .include "${LIBC_SRCTOP}/net/Makefile.inc"
82 .include "${LIBC_SRCTOP}/nls/Makefile.inc"
83 .include "${LIBC_SRCTOP}/posix1e/Makefile.inc"
84 .if ${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"
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}/rpc/Makefile.inc"
100 .include "${LIBC_SRCTOP}/uuid/Makefile.inc"
101 .include "${LIBC_SRCTOP}/xdr/Makefile.inc"
102 .if (${LIBC_ARCH} == "arm" && ${MACHINE_ARCH} != "armv6hf") ||\
103 ${LIBC_ARCH} == "mips"
104 .include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
106 .if ${MK_NIS} != "no"
108 .include "${LIBC_SRCTOP}/yp/Makefile.inc"
110 .include "${LIBC_SRCTOP}/capability/Makefile.inc"
111 .if ${MK_HESIOD} != "no"
114 .if ${MK_FP_LIBC} == "no"
115 CFLAGS+= -DNO_FLOATING_POINT
117 .if ${MK_NS_CACHING} != "no"
118 CFLAGS+= -DNS_CACHING
120 .if defined(_FREEFALL_CONFIG)
121 CFLAGS+=-D_FREEFALL_CONFIG
124 STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
126 VERSION_DEF=${LIBC_SRCTOP}/Versions.def
127 SYMBOL_MAPS=${SYM_MAPS}
128 CFLAGS+= -DSYMBOL_VERSIONING
130 # If there are no machine dependent sources, append all the
131 # machine-independent sources:
135 # Append machine-dependent sources, then append machine-independent sources
136 # for which there is no machine-dependent variant.
138 .for _src in ${MISRCS}
139 .if ${MDSRCS:R:M${_src:R}} == ""
145 KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
146 lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
147 subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
148 KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
149 strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
151 libkern: libkern.gen libkern.${LIBC_ARCH}
153 libkern.gen: ${KQSRCS} ${KSRCS}
154 cp -fp ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
156 libkern.${LIBC_ARCH}:: ${KMSRCS}
157 .if defined(KMSRCS) && !empty(KMSRCS)
158 cp -fp ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
161 .include <bsd.lib.mk>
163 # Disable warnings in contributed sources.
164 CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
165 # XXX For now, we don't allow libc to be compiled with
166 # -fstack-protector-all because it breaks rtld. We may want to make a librtld
167 # in the future to circumvent this.
168 SSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
169 # Disable stack protection for SSP symbols.
170 SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
171 # Generate stack unwinding tables for cancellation points
172 CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}