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