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