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