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