1e1fe3dbaSRuslan Ermilov 2c389411cSGlen BarberPACKAGE= clibs 318b2ee82SBaptiste DaroussinSHLIBDIR?= /lib 4fcaa4668SRuslan Ermilov 5c6063d0dSWarner Losh.include <src.opts.mk> 6e1fe3dbaSRuslan Ermilov 78876613dSMarcel MoolenaarLIBC_SRCTOP?= ${.CURDIR} 88269e767SBrooks DavisLIBSYS_SRCTOP?= ${.CURDIR:H}/libsys 98876613dSMarcel Moolenaar 10b19d8afeSWarner Losh# Pick the current architecture directory for libc. In general, this is named 11b19d8afeSWarner Losh# MACHINE_CPUARCH, but some ABIs are different enough to require their own libc, 12b19d8afeSWarner Losh# so allow a directory named MACHINE_ARCH to override this (though treat 13b19d8afeSWarner Losh# powerpc64le and powerpc64 the same). 14da8238d6SBrooks Davis# Note: This is copied to msun/Makefile 15b19d8afeSWarner LoshM=${MACHINE_ARCH:S/powerpc64le/powerpc64/} 16b19d8afeSWarner Losh.if exists(${LIBC_SRCTOP}/${M}) 17b19d8afeSWarner LoshLIBC_ARCH=${M} 182c0959aeSWarner Losh.else 19bff351d7SWarner LoshLIBC_ARCH=${MACHINE_CPUARCH} 202c0959aeSWarner Losh.endif 212c0959aeSWarner Losh 22ecaaecd7SDavid E. O'Brien# All library objects contain FreeBSD revision strings by default; they may be 2358f0484fSRodney W. Grimes# excluded as a space-saving measure. To produce a library that does 2454a5fb6cSDavid E. O'Brien# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS 25e481bf77SBruce Evans# below. Note: there are no IDs for syscall stubs whose sources are generated. 2641b9df16SJohn Baldwin# To include legacy CSRG SCCS ID strings, remove -DNO__SCCSID from CFLAGS. 2741b9df16SJohn Baldwin# To include RCS ID strings from other BSD projects, remove -DNO__RCSID from CFLAGS. 2841b9df16SJohn BaldwinCFLAGS+=-DNO__SCCSID -DNO__RCSID 2941b9df16SJohn Baldwin 3058f0484fSRodney W. GrimesLIB=c 31794063c0SHajimu UMEMOTOSHLIB_MAJOR= 7 320f611708SEd Maste.if ${MK_SSP} != "no" && \ 33884ba431SPiotr Kubaj (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "") 3454f82841SJeremie Le HenSHLIB_LDSCRIPT=libc.ldscript 3532797df5SRuslan Bukin.else 3632797df5SRuslan BukinSHLIB_LDSCRIPT=libc_nossp.ldscript 3732797df5SRuslan Bukin.endif 38f051a5b3SColin PercivalSHLIB_LDSCRIPT_LINKS=libxnet.so 398e1b0bc6SJacques VidrineWARNS?= 2 40d0fd0203SEnji CooperCFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include 418876613dSMarcel MoolenaarCFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} 428269e767SBrooks DavisCFLAGS+=-I${LIBSYS_SRCTOP}/${LIBC_ARCH} 43c7e52324SGleb Kurtsou.if ${MK_NLS} != "no" 44fe73c506SGabor KovesdanCFLAGS+=-DNLS 45c7e52324SGleb Kurtsou.endif 4658f0484fSRodney W. GrimesCLEANFILES+=tags 47a35d8893SRuslan ErmilovINSTALL_PIC_ARCHIVE= 48db08bfceSKonstantin BelousovBUILD_NOSSP_PIC_ARCHIVE= 49a35d8893SRuslan ErmilovPRECIOUSLIB= 5058f0484fSRodney W. Grimes 51f4213b90SDavid Xu.ifndef NO_THREAD_STACK_UNWIND 52f4213b90SDavid XuCANCELPOINTS_CFLAGS=-fexceptions 53f4213b90SDavid XuCFLAGS+=${CANCELPOINTS_CFLAGS} 54f4213b90SDavid Xu.endif 55f4213b90SDavid Xu 569c97062bSMark Johnston# Use a more efficient TLS model for libc since we can reasonably assume that 579c97062bSMark Johnston# it will be loaded during program startup. 589c97062bSMark JohnstonCFLAGS+= -ftls-model=initial-exec 599c97062bSMark Johnston 60e20b1658SAlexander Kabaev# 6137656b87SEd Schouten# Link with static libcompiler_rt.a. 62e20b1658SAlexander Kabaev# 630212104bSAlexander KabaevLDFLAGS+= -nodefaultlibs 646b129086SBaptiste DaroussinLIBADD+= compiler_rt 65*0d4f7723SBrooks DavisLIBADD+= sys 66*0d4f7723SBrooks Davis 67*0d4f7723SBrooks DavisLDFLAGS+=-Wl,--auxiliary,libsys.so 6846ad3707SMarcel Moolenaar 690f611708SEd Maste.if ${MK_SSP} != "no" && \ 70884ba431SPiotr Kubaj (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "") 716b129086SBaptiste DaroussinLIBADD+= ssp_nonshared 7246ad3707SMarcel Moolenaar.endif 73e20b1658SAlexander Kabaev 74db2af393SPeter Wemm# Extras that live in either libc.a or libc_nonshared.a 75db2af393SPeter WemmLIBC_NONSHARED_SRCS= 76db2af393SPeter Wemm 777f7489ebSKonstantin BelousovRTLD_ELF_DIR=${SRCTOP}/libexec/rtld-elf 787f7489ebSKonstantin Belousov.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) 797f7489ebSKonstantin BelousovRTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/} 807f7489ebSKonstantin Belousov.else 817f7489ebSKonstantin BelousovRTLD_ARCH= ${MACHINE_CPUARCH} 827f7489ebSKonstantin Belousov.endif 837f7489ebSKonstantin BelousovRTLD_HDRS= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR} 847f7489ebSKonstantin Belousov 85c51d717fSRuslan Ermilov# Define (empty) variables so that make doesn't give substitution 86c51d717fSRuslan Ermilov# errors if the included makefiles don't change these: 87c51d717fSRuslan ErmilovMDSRCS= 88c51d717fSRuslan ErmilovMISRCS= 89c51d717fSRuslan ErmilovMDASM= 90c51d717fSRuslan ErmilovMIASM= 91c51d717fSRuslan ErmilovNOASM= 92c51d717fSRuslan Ermilov 938876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc" 9451015e6dSKonstantin Belousov.include "${LIBC_SRCTOP}/csu/Makefile.inc" 958876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/db/Makefile.inc" 968876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/compat-43/Makefile.inc" 978876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gdtoa/Makefile.inc" 988876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gen/Makefile.inc" 998876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gmon/Makefile.inc" 100ad30f8e7SGabor Kovesdan.if ${MK_ICONV} != "no" 1018876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/iconv/Makefile.inc" 102ad30f8e7SGabor Kovesdan.endif 1038876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/inet/Makefile.inc" 1048876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/isc/Makefile.inc" 1058876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/locale/Makefile.inc" 1066f79a95bSHajimu UMEMOTO.include "${LIBC_SRCTOP}/md/Makefile.inc" 1078876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/nameser/Makefile.inc" 1088876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/net/Makefile.inc" 1098876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/nls/Makefile.inc" 1108876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/posix1e/Makefile.inc" 111c3fb59edSBrooks Davis.if ${MACHINE_ABI:Mlong32} 1128876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/quad/Makefile.inc" 113c51d717fSRuslan Ermilov.endif 1148876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/regex/Makefile.inc" 1158876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/resolv/Makefile.inc" 1168876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdio/Makefile.inc" 1178876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdlib/Makefile.inc" 1188876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdtime/Makefile.inc" 1198876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/string/Makefile.inc" 1208f529310SBrooks Davis.include "${LIBSYS_SRCTOP}/Makefile.sys" 121fe0d386cSPedro F. Giffuni.include "${LIBC_SRCTOP}/secure/Makefile.inc" 1228876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/rpc/Makefile.inc" 1238876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/uuid/Makefile.inc" 1248876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/xdr/Makefile.inc" 12547e888f8SJohn Baldwin.if (${LIBC_ARCH} == "arm" && (defined(CPUTYPE) && ${CPUTYPE:M*soft*})) 1268876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/softfloat/Makefile.inc" 1272357939bSOlivier Houchard.endif 12816808549SKonstantin Belousov.if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64" 129071bca67SKonstantin Belousov.include "${LIBC_SRCTOP}/x86/gen/Makefile.inc" 13016808549SKonstantin Belousov.endif 131e1fe3dbaSRuslan Ermilov.if ${MK_NIS} != "no" 132c51d717fSRuslan ErmilovCFLAGS+= -DYP 1338876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/yp/Makefile.inc" 134c51d717fSRuslan Ermilov.endif 1358876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/capability/Makefile.inc" 136e1fe3dbaSRuslan Ermilov.if ${MK_HESIOD} != "no" 137c51d717fSRuslan ErmilovCFLAGS+= -DHESIOD 138c51d717fSRuslan Ermilov.endif 139e1fe3dbaSRuslan Ermilov.if ${MK_FP_LIBC} == "no" 140757edc65SDavid SchultzCFLAGS+= -DNO_FLOATING_POINT 141757edc65SDavid Schultz.endif 14206a99fe3SHajimu UMEMOTO.if ${MK_NS_CACHING} != "no" 14306a99fe3SHajimu UMEMOTOCFLAGS+= -DNS_CACHING 14406a99fe3SHajimu UMEMOTO.endif 1453dd425f7SSimon L. B. Nielsen.if defined(_FREEFALL_CONFIG) 1463dd425f7SSimon L. B. NielsenCFLAGS+=-D_FREEFALL_CONFIG 1473dd425f7SSimon L. B. Nielsen.endif 148c51d717fSRuslan Ermilov 149db2af393SPeter WemmSTATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/} 150db2af393SPeter Wemm 1518876613dSMarcel MoolenaarVERSION_DEF=${LIBC_SRCTOP}/Versions.def 15296e022f7SDaniel EischenSYMBOL_MAPS=${SYM_MAPS} 15396e022f7SDaniel Eischen 154c51d717fSRuslan Ermilov# If there are no machine dependent sources, append all the 155c51d717fSRuslan Ermilov# machine-independent sources: 15620adba8bSGleb Popov.if empty(MDSRCS) || ${MK_MACHDEP_OPTIMIZATIONS} == no 157c51d717fSRuslan ErmilovSRCS+= ${MISRCS} 158c51d717fSRuslan Ermilov.else 159c51d717fSRuslan Ermilov# Append machine-dependent sources, then append machine-independent sources 160c51d717fSRuslan Ermilov# for which there is no machine-dependent variant. 161c51d717fSRuslan ErmilovSRCS+= ${MDSRCS} 162c51d717fSRuslan Ermilov.for _src in ${MISRCS} 163c51d717fSRuslan Ermilov.if ${MDSRCS:R:M${_src:R}} == "" 164c51d717fSRuslan ErmilovSRCS+= ${_src} 165c51d717fSRuslan Ermilov.endif 166c51d717fSRuslan Ermilov.endfor 167c51d717fSRuslan Ermilov.endif 16858f0484fSRodney W. Grimes 16958f0484fSRodney W. GrimesKQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ 17058f0484fSRodney W. Grimes lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ 17158f0484fSRodney W. Grimes subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c 17246632c18SEd SchoutenKSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ 17346632c18SEd Schouten strcmp.c strcpy.c strlen.c strncpy.c strrchr.c 17458f0484fSRodney W. Grimes 1752c0959aeSWarner Loshlibkern: libkern.gen libkern.${LIBC_ARCH} 17658f0484fSRodney W. Grimes 17758f0484fSRodney W. Grimeslibkern.gen: ${KQSRCS} ${KSRCS} 1787a37b5fcSWill Andrews ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern 17958f0484fSRodney W. Grimes 1802c0959aeSWarner Loshlibkern.${LIBC_ARCH}:: ${KMSRCS} 18158f0484fSRodney W. Grimes.if defined(KMSRCS) && !empty(KMSRCS) 1827a37b5fcSWill Andrews ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} 18358f0484fSRodney W. Grimes.endif 18458f0484fSRodney W. Grimes 185d511b20aSEnji CooperHAS_TESTS= 1864b330699SEnji CooperSUBDIR.${MK_TESTS}+= tests 1872f121787SEnji Cooper 18858f0484fSRodney W. Grimes.include <bsd.lib.mk> 189042a0b7eSRuslan Ermilov 1902417a95eSEd Maste.if (${LIBC_ARCH} == amd64 || ${LIBC_ARCH} == i386) && \ 1912417a95eSEd Maste ${.TARGETS:Mall} == all && \ 1922417a95eSEd Maste defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" 193f2be828fSSimon J. Gerraty.error ${LIBC_ARCH} libc requires linker ifunc support 1942417a95eSEd Maste.endif 1952417a95eSEd Maste 1967750ad47SMarcel Moolenaar.if !defined(_SKIP_BUILD) 1977750ad47SMarcel Moolenaar# We need libutil.h, get it directly to avoid 1987750ad47SMarcel Moolenaar# recording a build dependency 199dfdb6cf4SBryan DreweryCFLAGS+= -I${SRCTOP}/lib/libutil 2007750ad47SMarcel Moolenaar# Same issue with libm 201dfdb6cf4SBryan DreweryMSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR 2027750ad47SMarcel Moolenaar# unfortunately msun/src contains both private and public headers 203dfdb6cf4SBryan DreweryCFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR} 204aab5fee0SSimon J. Gerraty.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 205dfdb6cf4SBryan DreweryCFLAGS+= -I${SRCTOP}/lib/msun/x86 206aab5fee0SSimon J. Gerraty.endif 207dfdb6cf4SBryan DreweryCFLAGS+= -I${SRCTOP}/lib/msun/src 208aab5fee0SSimon J. Gerraty# and we do not want to record a dependency on msun 209aab5fee0SSimon J. Gerraty.if ${.MAKE.LEVEL} > 0 210aab5fee0SSimon J. GerratyGENDIRDEPS_FILTER+= N${RELDIR:H}/msun 211aab5fee0SSimon J. Gerraty.endif 2127750ad47SMarcel Moolenaar.endif 2137750ad47SMarcel Moolenaar 214042a0b7eSRuslan Ermilov# Disable warnings in contributed sources. 215271e7c59SRui PauloCWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} 216042df2e2SRuslan Ermilov# Disable stack protection for SSP symbols. 217042df2e2SRuslan ErmilovSSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/} 218f4213b90SDavid Xu# Generate stack unwinding tables for cancellation points 219f4213b90SDavid XuCANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//} 220