158f0484fSRodney W. Grimes# @(#)Makefile 8.2 (Berkeley) 2/3/94 27f3dea24SPeter Wemm# $FreeBSD$ 3e1fe3dbaSRuslan Ermilov 4fcaa4668SRuslan ErmilovSHLIBDIR?= /lib 5fcaa4668SRuslan Ermilov 6*c6063d0dSWarner 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# 4737656b87SEd SchoutenDPADD+= ${LIBCOMPILER_RT} 480212104bSAlexander KabaevLDFLAGS+= -nodefaultlibs 4937656b87SEd SchoutenLDADD+= -lcompiler_rt 5046ad3707SMarcel Moolenaar 5146ad3707SMarcel Moolenaar.if ${MK_SSP} != "no" 5246ad3707SMarcel MoolenaarLDADD+= -lssp_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" 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" 822c0959aeSWarner Losh.if ${LIBC_ARCH} != "amd64" && \ 832c0959aeSWarner Losh ${LIBC_ARCH} != "ia64" && \ 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} 1538876613dSMarcel Moolenaar cp -p ${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) 1572c0959aeSWarner Losh cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} 15858f0484fSRodney W. Grimes.endif 15958f0484fSRodney W. Grimes 16058f0484fSRodney W. Grimes.include <bsd.lib.mk> 161042a0b7eSRuslan Ermilov 162042a0b7eSRuslan Ermilov# Disable warnings in contributed sources. 163271e7c59SRui PauloCWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} 164042df2e2SRuslan Ermilov# XXX For now, we don't allow libc to be compiled with 165042df2e2SRuslan Ermilov# -fstack-protector-all because it breaks rtld. We may want to make a librtld 166042df2e2SRuslan Ermilov# in the future to circumvent this. 167042df2e2SRuslan ErmilovSSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/} 168042df2e2SRuslan Ermilov# Disable stack protection for SSP symbols. 169042df2e2SRuslan ErmilovSSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/} 170f4213b90SDavid Xu# Generate stack unwinding tables for cancellation points 171f4213b90SDavid XuCANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//} 172