158f0484fSRodney W. Grimes# @(#)Makefile 8.2 (Berkeley) 2/3/94 27f3dea24SPeter Wemm# $FreeBSD$ 3e1fe3dbaSRuslan Ermilov 4*18b2ee82SBaptiste 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 298e1b0bc6SJacques VidrineWARNS?= 2 308876613dSMarcel MoolenaarCFLAGS+=-I${LIBC_SRCTOP}/include -I${LIBC_SRCTOP}/../../include 318876613dSMarcel MoolenaarCFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} 32c7e52324SGleb Kurtsou.if ${MK_NLS} != "no" 33fe73c506SGabor KovesdanCFLAGS+=-DNLS 34c7e52324SGleb Kurtsou.endif 3558f0484fSRodney W. GrimesCLEANFILES+=tags 36a35d8893SRuslan ErmilovINSTALL_PIC_ARCHIVE= 37a35d8893SRuslan ErmilovPRECIOUSLIB= 3858f0484fSRodney W. Grimes 39f4213b90SDavid Xu.ifndef NO_THREAD_STACK_UNWIND 40f4213b90SDavid XuCANCELPOINTS_CFLAGS=-fexceptions 41f4213b90SDavid XuCFLAGS+=${CANCELPOINTS_CFLAGS} 42f4213b90SDavid Xu.endif 43f4213b90SDavid Xu 44e20b1658SAlexander Kabaev# 4537656b87SEd Schouten# Link with static libcompiler_rt.a. 46e20b1658SAlexander Kabaev# 470212104bSAlexander KabaevLDFLAGS+= -nodefaultlibs 486b129086SBaptiste DaroussinLIBADD+= compiler_rt 4946ad3707SMarcel Moolenaar 5046ad3707SMarcel Moolenaar.if ${MK_SSP} != "no" 516b129086SBaptiste DaroussinLIBADD+= ssp_nonshared 5246ad3707SMarcel Moolenaar.endif 53e20b1658SAlexander Kabaev 54db2af393SPeter Wemm# Extras that live in either libc.a or libc_nonshared.a 55db2af393SPeter WemmLIBC_NONSHARED_SRCS= 56db2af393SPeter Wemm 57c51d717fSRuslan Ermilov# Define (empty) variables so that make doesn't give substitution 58c51d717fSRuslan Ermilov# errors if the included makefiles don't change these: 59c51d717fSRuslan ErmilovMDSRCS= 60c51d717fSRuslan ErmilovMISRCS= 61c51d717fSRuslan ErmilovMDASM= 62c51d717fSRuslan ErmilovMIASM= 63c51d717fSRuslan ErmilovNOASM= 64c51d717fSRuslan Ermilov 658876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc" 668876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/db/Makefile.inc" 678876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/compat-43/Makefile.inc" 688876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gdtoa/Makefile.inc" 698876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gen/Makefile.inc" 708876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/gmon/Makefile.inc" 71ad30f8e7SGabor Kovesdan.if ${MK_ICONV} != "no" 728876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/iconv/Makefile.inc" 73ad30f8e7SGabor Kovesdan.endif 748876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/inet/Makefile.inc" 758876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/isc/Makefile.inc" 768876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/locale/Makefile.inc" 776f79a95bSHajimu UMEMOTO.include "${LIBC_SRCTOP}/md/Makefile.inc" 788876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/nameser/Makefile.inc" 798876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/net/Makefile.inc" 808876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/nls/Makefile.inc" 818876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/posix1e/Makefile.inc" 82d422e6f9SAndrew Turner.if ${LIBC_ARCH} != "aarch64" && \ 83d422e6f9SAndrew Turner ${LIBC_ARCH} != "amd64" && \ 842c0959aeSWarner Losh ${LIBC_ARCH} != "powerpc64" && \ 852c0959aeSWarner Losh ${LIBC_ARCH} != "sparc64" && \ 867b87c35eSJayachandran C. ${MACHINE_ARCH:Mmipsn32*} == "" && \ 87cd2ae253SWarner Losh ${MACHINE_ARCH:Mmips64*} == "" 888876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/quad/Makefile.inc" 89c51d717fSRuslan Ermilov.endif 908876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/regex/Makefile.inc" 918876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/resolv/Makefile.inc" 928876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdio/Makefile.inc" 938876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdlib/Makefile.inc" 948876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc" 958876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/stdtime/Makefile.inc" 968876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/string/Makefile.inc" 978876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/sys/Makefile.inc" 988876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/rpc/Makefile.inc" 998876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/uuid/Makefile.inc" 1008876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/xdr/Makefile.inc" 10173279d41SAndrew Turner.if (${LIBC_ARCH} == "arm" && ${MACHINE_ARCH} != "armv6hf") ||\ 10273279d41SAndrew Turner ${LIBC_ARCH} == "mips" 1038876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/softfloat/Makefile.inc" 1042357939bSOlivier Houchard.endif 105e1fe3dbaSRuslan Ermilov.if ${MK_NIS} != "no" 106c51d717fSRuslan ErmilovCFLAGS+= -DYP 1078876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/yp/Makefile.inc" 108c51d717fSRuslan Ermilov.endif 1098876613dSMarcel Moolenaar.include "${LIBC_SRCTOP}/capability/Makefile.inc" 110e1fe3dbaSRuslan Ermilov.if ${MK_HESIOD} != "no" 111c51d717fSRuslan ErmilovCFLAGS+= -DHESIOD 112c51d717fSRuslan Ermilov.endif 113e1fe3dbaSRuslan Ermilov.if ${MK_FP_LIBC} == "no" 114757edc65SDavid SchultzCFLAGS+= -DNO_FLOATING_POINT 115757edc65SDavid Schultz.endif 11606a99fe3SHajimu UMEMOTO.if ${MK_NS_CACHING} != "no" 11706a99fe3SHajimu UMEMOTOCFLAGS+= -DNS_CACHING 11806a99fe3SHajimu UMEMOTO.endif 1193dd425f7SSimon L. B. Nielsen.if defined(_FREEFALL_CONFIG) 1203dd425f7SSimon L. B. NielsenCFLAGS+=-D_FREEFALL_CONFIG 1213dd425f7SSimon L. B. Nielsen.endif 122c51d717fSRuslan Ermilov 123db2af393SPeter WemmSTATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/} 124db2af393SPeter Wemm 1258876613dSMarcel MoolenaarVERSION_DEF=${LIBC_SRCTOP}/Versions.def 12696e022f7SDaniel EischenSYMBOL_MAPS=${SYM_MAPS} 12796e022f7SDaniel EischenCFLAGS+= -DSYMBOL_VERSIONING 12896e022f7SDaniel Eischen 129c51d717fSRuslan Ermilov# If there are no machine dependent sources, append all the 130c51d717fSRuslan Ermilov# machine-independent sources: 131c51d717fSRuslan Ermilov.if empty(MDSRCS) 132c51d717fSRuslan ErmilovSRCS+= ${MISRCS} 133c51d717fSRuslan Ermilov.else 134c51d717fSRuslan Ermilov# Append machine-dependent sources, then append machine-independent sources 135c51d717fSRuslan Ermilov# for which there is no machine-dependent variant. 136c51d717fSRuslan ErmilovSRCS+= ${MDSRCS} 137c51d717fSRuslan Ermilov.for _src in ${MISRCS} 138c51d717fSRuslan Ermilov.if ${MDSRCS:R:M${_src:R}} == "" 139c51d717fSRuslan ErmilovSRCS+= ${_src} 140c51d717fSRuslan Ermilov.endif 141c51d717fSRuslan Ermilov.endfor 142c51d717fSRuslan Ermilov.endif 14358f0484fSRodney W. Grimes 14458f0484fSRodney W. GrimesKQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ 14558f0484fSRodney W. Grimes lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ 14658f0484fSRodney W. Grimes subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c 14746632c18SEd SchoutenKSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ 14846632c18SEd Schouten strcmp.c strcpy.c strlen.c strncpy.c strrchr.c 14958f0484fSRodney W. Grimes 1502c0959aeSWarner Loshlibkern: libkern.gen libkern.${LIBC_ARCH} 15158f0484fSRodney W. Grimes 15258f0484fSRodney W. Grimeslibkern.gen: ${KQSRCS} ${KSRCS} 1537a37b5fcSWill Andrews ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern 15458f0484fSRodney W. Grimes 1552c0959aeSWarner Loshlibkern.${LIBC_ARCH}:: ${KMSRCS} 15658f0484fSRodney W. Grimes.if defined(KMSRCS) && !empty(KMSRCS) 1577a37b5fcSWill Andrews ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} 15858f0484fSRodney W. Grimes.endif 15958f0484fSRodney W. Grimes 1601119ece4SEnji Cooper.if ${MK_TESTS} != "no" 1611119ece4SEnji CooperSUBDIR+= tests 1621119ece4SEnji Cooper.endif 1632f121787SEnji Cooper 16458f0484fSRodney W. Grimes.include <bsd.lib.mk> 165042a0b7eSRuslan Ermilov 1667750ad47SMarcel Moolenaar.if !defined(_SKIP_BUILD) 1677750ad47SMarcel Moolenaar# We need libutil.h, get it directly to avoid 1687750ad47SMarcel Moolenaar# recording a build dependency 1697750ad47SMarcel MoolenaarCFLAGS+= -I${.CURDIR:H}/libutil 1707750ad47SMarcel Moolenaar# Same issue with libm 1717750ad47SMarcel MoolenaarMSUN_ARCH_SUBDIR != ${MAKE} -B -C ${.CURDIR:H}/msun -V ARCH_SUBDIR 1727750ad47SMarcel Moolenaar# unfortunately msun/src contains both private and public headers 173aab5fee0SSimon J. GerratyCFLAGS+= -I${.CURDIR:H}/msun/${MSUN_ARCH_SUBDIR} 174aab5fee0SSimon J. Gerraty.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 175aab5fee0SSimon J. GerratyCFLAGS+= -I${.CURDIR:H}/msun/x86 176aab5fee0SSimon J. Gerraty.endif 177aab5fee0SSimon J. GerratyCFLAGS+= -I${.CURDIR:H}/msun/src 178aab5fee0SSimon J. Gerraty# and we do not want to record a dependency on msun 179aab5fee0SSimon J. Gerraty.if ${.MAKE.LEVEL} > 0 180aab5fee0SSimon J. GerratyGENDIRDEPS_FILTER+= N${RELDIR:H}/msun 181aab5fee0SSimon J. Gerraty.endif 1827750ad47SMarcel Moolenaar.endif 1837750ad47SMarcel Moolenaar 184042a0b7eSRuslan Ermilov# Disable warnings in contributed sources. 185271e7c59SRui PauloCWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} 186042df2e2SRuslan Ermilov# XXX For now, we don't allow libc to be compiled with 187042df2e2SRuslan Ermilov# -fstack-protector-all because it breaks rtld. We may want to make a librtld 188042df2e2SRuslan Ermilov# in the future to circumvent this. 189042df2e2SRuslan ErmilovSSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/} 190042df2e2SRuslan Ermilov# Disable stack protection for SSP symbols. 191042df2e2SRuslan ErmilovSSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/} 192f4213b90SDavid Xu# Generate stack unwinding tables for cancellation points 193f4213b90SDavid XuCANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//} 194