| 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}) |
| 19 |
LIBC_ARCH=${MACHINE_ARCH} |
| 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 sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS |
| 29 |
# to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs. |
| 30 |
LIB=c |
| 31 |
SHLIB_MAJOR= 7 |
| 32 |
.if ${MK_SSP} != "no" |
| 33 |
SHLIB_LDSCRIPT=libc.ldscript |
| 34 |
.else |
| 35 |
SHLIB_LDSCRIPT=libc_nossp.ldscript |
| 36 |
.endif |
| 37 |
SHLIB_LDSCRIPT_LINKS=libxnet.so |
| 38 |
WARNS?= 2 |
| 39 |
CFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include |
| 40 |
CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} |
| 41 |
.if ${MK_NLS} != "no" |
| 42 |
CFLAGS+=-DNLS |
| 43 |
.endif |
| 44 |
CLEANFILES+=tags |
| 45 |
INSTALL_PIC_ARCHIVE= |
| 46 |
PRECIOUSLIB= |
| 47 |
|
| 48 |
.ifndef NO_THREAD_STACK_UNWIND |
| 49 |
CANCELPOINTS_CFLAGS=-fexceptions |
| 50 |
CFLAGS+=${CANCELPOINTS_CFLAGS} |
| 51 |
.endif |
| 52 |
|
| 53 |
# |
| 54 |
# Link with static libcompiler_rt.a. |
| 55 |
# |
| 56 |
LDFLAGS+= -nodefaultlibs |
| 57 |
LIBADD+= compiler_rt |
| 58 |
|
| 59 |
.if ${MK_SSP} != "no" |
| 60 |
LIBADD+= ssp_nonshared |
| 61 |
.endif |
| 62 |
|
| 63 |
# Extras that live in either libc.a or libc_nonshared.a |
| 64 |
LIBC_NONSHARED_SRCS= |
| 65 |
|
| 66 |
# Define (empty) variables so that make doesn't give substitution |
| 67 |
# errors if the included makefiles don't change these: |
| 68 |
MDSRCS= |
| 69 |
MISRCS= |
| 70 |
MDASM= |
| 71 |
MIASM= |
| 72 |
NOASM= |
| 73 |
|
| 74 |
.include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc" |
| 75 |
.include "${LIBC_SRCTOP}/db/Makefile.inc" |
| 76 |
.include "${LIBC_SRCTOP}/compat-43/Makefile.inc" |
| 77 |
.include "${LIBC_SRCTOP}/gdtoa/Makefile.inc" |
| 78 |
.include "${LIBC_SRCTOP}/gen/Makefile.inc" |
| 79 |
.include "${LIBC_SRCTOP}/gmon/Makefile.inc" |
| 80 |
.if ${MK_ICONV} != "no" |
| 81 |
.include "${LIBC_SRCTOP}/iconv/Makefile.inc" |
| 82 |
.endif |
| 83 |
.include "${LIBC_SRCTOP}/inet/Makefile.inc" |
| 84 |
.include "${LIBC_SRCTOP}/isc/Makefile.inc" |
| 85 |
.include "${LIBC_SRCTOP}/locale/Makefile.inc" |
| 86 |
.include "${LIBC_SRCTOP}/md/Makefile.inc" |
| 87 |
.include "${LIBC_SRCTOP}/nameser/Makefile.inc" |
| 88 |
.include "${LIBC_SRCTOP}/net/Makefile.inc" |
| 89 |
.include "${LIBC_SRCTOP}/nls/Makefile.inc" |
| 90 |
.include "${LIBC_SRCTOP}/posix1e/Makefile.inc" |
| 91 |
.if ${LIBC_ARCH} != "aarch64" && \ |
| 92 |
${LIBC_ARCH} != "amd64" && \ |
| 93 |
${LIBC_ARCH} != "powerpc64" && \ |
| 94 |
${LIBC_ARCH} != "riscv" && \ |
| 95 |
${LIBC_ARCH} != "sparc64" && \ |
| 96 |
${MACHINE_ARCH:Mmipsn32*} == "" && \ |
| 97 |
${MACHINE_ARCH:Mmips64*} == "" |
| 98 |
.include "${LIBC_SRCTOP}/quad/Makefile.inc" |
| 99 |
.endif |
| 100 |
.include "${LIBC_SRCTOP}/regex/Makefile.inc" |
| 101 |
.include "${LIBC_SRCTOP}/resolv/Makefile.inc" |
| 102 |
.include "${LIBC_SRCTOP}/stdio/Makefile.inc" |
| 103 |
.include "${LIBC_SRCTOP}/stdlib/Makefile.inc" |
| 104 |
.include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc" |
| 105 |
.include "${LIBC_SRCTOP}/stdtime/Makefile.inc" |
| 106 |
.include "${LIBC_SRCTOP}/string/Makefile.inc" |
| 107 |
.include "${LIBC_SRCTOP}/sys/Makefile.inc" |
| 108 |
.include "${LIBC_SRCTOP}/secure/Makefile.inc" |
| 109 |
.include "${LIBC_SRCTOP}/rpc/Makefile.inc" |
| 110 |
.include "${LIBC_SRCTOP}/uuid/Makefile.inc" |
| 111 |
.include "${LIBC_SRCTOP}/xdr/Makefile.inc" |
| 112 |
.if (${LIBC_ARCH} == "arm" && \ |
| 113 |
(${MACHINE_ARCH:Marmv6*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \ |
| 114 |
${LIBC_ARCH} == "mips" |
| 115 |
.include "${LIBC_SRCTOP}/softfloat/Makefile.inc" |
| 116 |
.endif |
| 117 |
.if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64" |
| 118 |
.include "${LIBC_SRCTOP}/x86/sys/Makefile.inc" |
| 119 |
.endif |
| 120 |
.if ${MK_NIS} != "no" |
| 121 |
CFLAGS+= -DYP |
| 122 |
.include "${LIBC_SRCTOP}/yp/Makefile.inc" |
| 123 |
.endif |
| 124 |
.include "${LIBC_SRCTOP}/capability/Makefile.inc" |
| 125 |
.if ${MK_HESIOD} != "no" |
| 126 |
CFLAGS+= -DHESIOD |
| 127 |
.endif |
| 128 |
.if ${MK_FP_LIBC} == "no" |
| 129 |
CFLAGS+= -DNO_FLOATING_POINT |
| 130 |
.endif |
| 131 |
.if ${MK_NS_CACHING} != "no" |
| 132 |
CFLAGS+= -DNS_CACHING |
| 133 |
.endif |
| 134 |
.if defined(_FREEFALL_CONFIG) |
| 135 |
CFLAGS+=-D_FREEFALL_CONFIG |
| 136 |
.endif |
| 137 |
|
| 138 |
STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/} |
| 139 |
|
| 140 |
VERSION_DEF=${LIBC_SRCTOP}/Versions.def |
| 141 |
SYMBOL_MAPS=${SYM_MAPS} |
| 142 |
CFLAGS+= -DSYMBOL_VERSIONING |
| 143 |
|
| 144 |
# If there are no machine dependent sources, append all the |
| 145 |
# machine-independent sources: |
| 146 |
.if empty(MDSRCS) |
| 147 |
SRCS+= ${MISRCS} |
| 148 |
.else |
| 149 |
# Append machine-dependent sources, then append machine-independent sources |
| 150 |
# for which there is no machine-dependent variant. |
| 151 |
SRCS+= ${MDSRCS} |
| 152 |
.for _src in ${MISRCS} |
| 153 |
.if ${MDSRCS:R:M${_src:R}} == "" |
| 154 |
SRCS+= ${_src} |
| 155 |
.endif |
| 156 |
.endfor |
| 157 |
.endif |
| 158 |
|
| 159 |
KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ |
| 160 |
lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ |
| 161 |
subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c |
| 162 |
KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ |
| 163 |
strcmp.c strcpy.c strlen.c strncpy.c strrchr.c |
| 164 |
|
| 165 |
libkern: libkern.gen libkern.${LIBC_ARCH} |
| 166 |
|
| 167 |
libkern.gen: ${KQSRCS} ${KSRCS} |
| 168 |
${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern |
| 169 |
|
| 170 |
libkern.${LIBC_ARCH}:: ${KMSRCS} |
| 171 |
.if defined(KMSRCS) && !empty(KMSRCS) |
| 172 |
${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} |
| 173 |
.endif |
| 174 |
|
| 175 |
.if ${MK_TESTS} != "no" |
| 176 |
SUBDIR+= tests |
| 177 |
.endif |
| 178 |
|
| 179 |
.include <bsd.lib.mk> |
| 180 |
|
| 181 |
.if !defined(_SKIP_BUILD) |
| 182 |
# We need libutil.h, get it directly to avoid |
| 183 |
# recording a build dependency |
| 184 |
CFLAGS+= -I${SRCTOP}/lib/libutil |
| 185 |
# Same issue with libm |
| 186 |
MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR |
| 187 |
# unfortunately msun/src contains both private and public headers |
| 188 |
CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR} |
| 189 |
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" |
| 190 |
CFLAGS+= -I${SRCTOP}/lib/msun/x86 |
| 191 |
.endif |
| 192 |
CFLAGS+= -I${SRCTOP}/lib/msun/src |
| 193 |
# and we do not want to record a dependency on msun |
| 194 |
.if ${.MAKE.LEVEL} > 0 |
| 195 |
GENDIRDEPS_FILTER+= N${RELDIR:H}/msun |
| 196 |
.endif |
| 197 |
.endif |
| 198 |
|
| 199 |
# Disable warnings in contributed sources. |
| 200 |
CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} |
| 201 |
# XXX For now, we don't allow libc to be compiled with |
| 202 |
# -fstack-protector-all because it breaks rtld. We may want to make a librtld |
| 203 |
# in the future to circumvent this. |
| 204 |
SSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/} |
| 205 |
# Disable stack protection for SSP symbols. |
| 206 |
SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/} |
| 207 |
# Generate stack unwinding tables for cancellation points |
| 208 |
CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//} |