158f0484fSRodney W. Grimes# @(#)Makefile 8.2 (Berkeley) 2/3/94 27f3dea24SPeter Wemm# $FreeBSD$ 3e1fe3dbaSRuslan Ermilov 418b2ee82SBaptiste DaroussinSHLIBDIR?= /lib 5fcaa4668SRuslan Ermilov 6c6063d0dSWarner Losh.include <src.opts.mk> 7e1fe3dbaSRuslan Ermilov 88876613dSMarcel MoolenaarLIBC_SRCTOP?= ${.CURDIR} 98876613dSMarcel Moolenaar 10f61ce568SNathan Whitehorn# Pick the current architecture directory for libc. In general, this is 11f61ce568SNathan Whitehorn# named MACHINE_CPUARCH, but some ABIs are different enough to require 12f61ce568SNathan Whitehorn# their own libc, so allow a directory named MACHINE_ARCH to override this. 13f61ce568SNathan Whitehorn 148876613dSMarcel Moolenaar.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH}) 152c0959aeSWarner LoshLIBC_ARCH=${MACHINE_ARCH} 162c0959aeSWarner Losh.else 17bff351d7SWarner LoshLIBC_ARCH=${MACHINE_CPUARCH} 182c0959aeSWarner Losh.endif 192c0959aeSWarner Losh 20ecaaecd7SDavid E. O'Brien# All library objects contain FreeBSD revision strings by default; they may be 2158f0484fSRodney W. Grimes# excluded as a space-saving measure. To produce a library that does 2254a5fb6cSDavid E. O'Brien# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS 23e481bf77SBruce Evans# below. Note: there are no IDs for syscall stubs whose sources are generated. 24e481bf77SBruce Evans# To include legacy CSRG sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS 25e481bf77SBruce Evans# to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs. 2658f0484fSRodney W. GrimesLIB=c 27794063c0SHajimu UMEMOTOSHLIB_MAJOR= 7 2854f82841SJeremie Le HenSHLIB_LDSCRIPT=libc.ldscript 29*f051a5b3SColin PercivalSHLIB_LDSCRIPT_LINKS=libxnet.so 308e1b0bc6SJacques VidrineWARNS?= 2 318876613dSMarcel MoolenaarCFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include 328876613dSMarcel MoolenaarCFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} 33c7e52324SGleb Kurtsou.if ${MK_NLS} != "no" 34fe73c506SGabor KovesdanCFLAGS+=-DNLS 35c7e52324SGleb Kurtsou.endif 3658f0484fSRodney W. GrimesCLEANFILES+=tags 37a35d8893SRuslan ErmilovINSTALL_PIC_ARCHIVE= 38a35d8893SRuslan ErmilovPRECIOUSLIB= 3958f0484fSRodney W. Grimes 40f4213b90SDavid Xu.ifndef NO_THREAD_STACK_UNWIND 41f4213b90SDavid XuCANCELPOINTS_CFLAGS=-fexceptions 42f4213b90SDavid XuCFLAGS+=${CANCELPOINTS_CFLAGS} 43f4213b90SDavid Xu.endif 44f4213b90SDavid Xu 45e20b1658SAlexander Kabaev# 4637656b87SEd Schouten# Link with static libcompiler_rt.a. 47e20b1658SAlexander Kabaev# 480212104bSAlexander KabaevLDFLAGS+= -nodefaultlibs 496b129086SBaptiste DaroussinLIBADD+= compiler_rt 5046ad3707SMarcel Moolenaar 5146ad3707SMarcel Moolenaar.if ${MK_SSP} != "no" 526b129086SBaptiste DaroussinLIBADD+= ssp_nonshared 5346ad3707SMarcel Moolenaar.endif 54e20b1658SAlexander Kabaev 55db2af393SPeter Wemm# Extras that live in either libc.a or libc_nonshared.a 56db2af393SPeter WemmLIBC_NONSHARED_SRCS= 57db2af393SPeter Wemm 58c51d717fSRuslan Ermilov# Define (empty) variables so that make doesn't give substitution 59c51d717fSRuslan Ermilov# errors if the included makefiles don't change these: 60c51d717fSRuslan ErmilovMDSRCS= 61c51d717fSRuslan ErmilovMISRCS= 62c51d717fSRuslan ErmilovMDASM= 63c51d717fSRuslan ErmilovMIASM= 64c51d717fSRuslan ErmilovNOASM= 65c51d717fSRuslan Ermilov 668876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc" 678876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/db/Makefile.inc" 688876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/compat-43/Makefile.inc" 698876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gdtoa/Makefile.inc" 708876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gen/Makefile.inc" 718876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gmon/Makefile.inc" 72ad30f8e7SGabor Kovesdan.if ${MK_ICONV} != "no" 738876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/iconv/Makefile.inc" 74ad30f8e7SGabor Kovesdan.endif 758876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/inet/Makefile.inc" 768876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/isc/Makefile.inc" 778876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/locale/Makefile.inc" 786f79a95bSHajimu UMEMOTO.include "${LIBC_SRCTOP}/md/Makefile.inc" 798876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/nameser/Makefile.inc" 808876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/net/Makefile.inc" 818876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/nls/Makefile.inc" 828876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/posix1e/Makefile.inc" 83d422e6f9SAndrew Turner.if ${LIBC_ARCH} != "aarch64" && \ 84d422e6f9SAndrew Turner ${LIBC_ARCH} != "amd64" && \ 852c0959aeSWarner Losh ${LIBC_ARCH} != "powerpc64" && \ 862c0959aeSWarner Losh ${LIBC_ARCH} != "sparc64" && \ 877b87c35eSJayachandran C. ${MACHINE_ARCH:Mmipsn32*} == "" && \ 88cd2ae253SWarner Losh ${MACHINE_ARCH:Mmips64*} == "" 898876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/quad/Makefile.inc" 90c51d717fSRuslan Ermilov.endif 918876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/regex/Makefile.inc" 928876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/resolv/Makefile.inc" 938876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdio/Makefile.inc" 948876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdlib/Makefile.inc" 958876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc" 968876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdtime/Makefile.inc" 978876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/string/Makefile.inc" 988876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/sys/Makefile.inc" 99fe0d386cSPedro F. Giffuni.include "${LIBC_SRCTOP}/secure/Makefile.inc" 1008876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/rpc/Makefile.inc" 1018876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/uuid/Makefile.inc" 1028876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/xdr/Makefile.inc" 10373279d41SAndrew Turner.if (${LIBC_ARCH} == "arm" && ${MACHINE_ARCH} != "armv6hf") ||\ 10473279d41SAndrew Turner ${LIBC_ARCH} == "mips" 1058876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/softfloat/Makefile.inc" 1062357939bSOlivier Houchard.endif 107e1fe3dbaSRuslan Ermilov.if ${MK_NIS} != "no" 108c51d717fSRuslan ErmilovCFLAGS+= -DYP 1098876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/yp/Makefile.inc" 110c51d717fSRuslan Ermilov.endif 1118876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/capability/Makefile.inc" 112e1fe3dbaSRuslan Ermilov.if ${MK_HESIOD} != "no" 113c51d717fSRuslan ErmilovCFLAGS+= -DHESIOD 114c51d717fSRuslan Ermilov.endif 115e1fe3dbaSRuslan Ermilov.if ${MK_FP_LIBC} == "no" 116757edc65SDavid SchultzCFLAGS+= -DNO_FLOATING_POINT 117757edc65SDavid Schultz.endif 11806a99fe3SHajimu UMEMOTO.if ${MK_NS_CACHING} != "no" 11906a99fe3SHajimu UMEMOTOCFLAGS+= -DNS_CACHING 12006a99fe3SHajimu UMEMOTO.endif 1213dd425f7SSimon L. B. Nielsen.if defined(_FREEFALL_CONFIG) 1223dd425f7SSimon L. B. NielsenCFLAGS+=-D_FREEFALL_CONFIG 1233dd425f7SSimon L. B. Nielsen.endif 124c51d717fSRuslan Ermilov 125db2af393SPeter WemmSTATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/} 126db2af393SPeter Wemm 1278876613dSMarcel MoolenaarVERSION_DEF=${LIBC_SRCTOP}/Versions.def 12896e022f7SDaniel EischenSYMBOL_MAPS=${SYM_MAPS} 12996e022f7SDaniel EischenCFLAGS+= -DSYMBOL_VERSIONING 13096e022f7SDaniel Eischen 131c51d717fSRuslan Ermilov# If there are no machine dependent sources, append all the 132c51d717fSRuslan Ermilov# machine-independent sources: 133c51d717fSRuslan Ermilov.if empty(MDSRCS) 134c51d717fSRuslan ErmilovSRCS+= ${MISRCS} 135c51d717fSRuslan Ermilov.else 136c51d717fSRuslan Ermilov# Append machine-dependent sources, then append machine-independent sources 137c51d717fSRuslan Ermilov# for which there is no machine-dependent variant. 138c51d717fSRuslan ErmilovSRCS+= ${MDSRCS} 139c51d717fSRuslan Ermilov.for _src in ${MISRCS} 140c51d717fSRuslan Ermilov.if ${MDSRCS:R:M${_src:R}} == "" 141c51d717fSRuslan ErmilovSRCS+= ${_src} 142c51d717fSRuslan Ermilov.endif 143c51d717fSRuslan Ermilov.endfor 144c51d717fSRuslan Ermilov.endif 14558f0484fSRodney W. Grimes 14658f0484fSRodney W. GrimesKQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ 14758f0484fSRodney W. Grimes lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ 14858f0484fSRodney W. Grimes subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c 14946632c18SEd SchoutenKSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ 15046632c18SEd Schouten strcmp.c strcpy.c strlen.c strncpy.c strrchr.c 15158f0484fSRodney W. Grimes 1522c0959aeSWarner Loshlibkern: libkern.gen libkern.${LIBC_ARCH} 15358f0484fSRodney W. Grimes 15458f0484fSRodney W. Grimeslibkern.gen: ${KQSRCS} ${KSRCS} 1557a37b5fcSWill Andrews ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern 15658f0484fSRodney W. Grimes 1572c0959aeSWarner Loshlibkern.${LIBC_ARCH}:: ${KMSRCS} 15858f0484fSRodney W. Grimes.if defined(KMSRCS) && !empty(KMSRCS) 1597a37b5fcSWill Andrews ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} 16058f0484fSRodney W. Grimes.endif 16158f0484fSRodney W. Grimes 1621119ece4SEnji Cooper.if ${MK_TESTS} != "no" 1631119ece4SEnji CooperSUBDIR+= tests 1641119ece4SEnji Cooper.endif 1652f121787SEnji Cooper 16658f0484fSRodney W. Grimes.include <bsd.lib.mk> 167042a0b7eSRuslan Ermilov 1687750ad47SMarcel Moolenaar.if !defined(_SKIP_BUILD) 1697750ad47SMarcel Moolenaar# We need libutil.h, get it directly to avoid 1707750ad47SMarcel Moolenaar# recording a build dependency 1717750ad47SMarcel MoolenaarCFLAGS+= -I${.CURDIR:H}/libutil 1727750ad47SMarcel Moolenaar# Same issue with libm 1737750ad47SMarcel MoolenaarMSUN_ARCH_SUBDIR != ${MAKE} -B -C ${.CURDIR:H}/msun -V ARCH_SUBDIR 1747750ad47SMarcel Moolenaar# unfortunately msun/src contains both private and public headers 175aab5fee0SSimon J. GerratyCFLAGS+= -I${.CURDIR:H}/msun/${MSUN_ARCH_SUBDIR} 176aab5fee0SSimon J. Gerraty.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 177aab5fee0SSimon J. GerratyCFLAGS+= -I${.CURDIR:H}/msun/x86 178aab5fee0SSimon J. Gerraty.endif 179aab5fee0SSimon J. GerratyCFLAGS+= -I${.CURDIR:H}/msun/src 180aab5fee0SSimon J. Gerraty# and we do not want to record a dependency on msun 181aab5fee0SSimon J. Gerraty.if ${.MAKE.LEVEL} > 0 182aab5fee0SSimon J. GerratyGENDIRDEPS_FILTER+= N${RELDIR:H}/msun 183aab5fee0SSimon J. Gerraty.endif 1847750ad47SMarcel Moolenaar.endif 1857750ad47SMarcel Moolenaar 186042a0b7eSRuslan Ermilov# Disable warnings in contributed sources. 187271e7c59SRui PauloCWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} 188042df2e2SRuslan Ermilov# XXX For now, we don't allow libc to be compiled with 189042df2e2SRuslan Ermilov# -fstack-protector-all because it breaks rtld. We may want to make a librtld 190042df2e2SRuslan Ermilov# in the future to circumvent this. 191042df2e2SRuslan ErmilovSSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/} 192042df2e2SRuslan Ermilov# Disable stack protection for SSP symbols. 193042df2e2SRuslan ErmilovSSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/} 194f4213b90SDavid Xu# Generate stack unwinding tables for cancellation points 195f4213b90SDavid XuCANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//} 196