11.175Sriastrad#	$NetBSD: Makefile,v 1.175 2025/03/30 16:17:04 riastradh Exp $
21.36Scgd#	@(#)Makefile	8.2 (Berkeley) 2/3/94
31.1Scgd#
41.1Scgd# All library objects contain sccsid strings by default; they may be
51.1Scgd# excluded as a space-saving measure.  To produce a library that does
61.1Scgd# not contain these strings, delete -DLIBC_SCCS and -DSYSLIBC_SCCS
71.71Slukem# from CPPFLAGS below.  To remove these strings from just the system call
81.71Slukem# stubs, remove just -DSYSLIBC_SCCS from CPPFLAGS.
91.28Sjtc#
101.28Sjtc# The NLS (message catalog) functions are always in libc.  To choose that
111.28Sjtc# strerror(), perror(), strsignal(), psignal(), etc. actually call the NLS
121.71Slukem# functions, put -DNLS on the CPPFLAGS line below.
131.4Sderaadt#
141.6Sderaadt# The YP functions are always in libc. To choose that getpwent() and friends
151.71Slukem# actually call the YP functions, put -DYP on the CPPFLAGS line below.
161.79Slukem#
171.79Slukem# The Hesiod functions are always in libc. To choose that getpwent() and friends
181.79Slukem# actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below.
191.4Sderaadt
201.172Skamil
211.172Skamil# generated code depends on RTTI
221.172SkamilLIBCSANITIZERFLAGS+=	${${ACTIVE_CC} == "clang":? -fno-sanitize=function :}
231.171Skamil
241.127Schristos.include "Makefile.inc"
251.107Slukem
261.82StvLIB=		c
271.117SchristosCPPFLAGS+=	-I${.CURDIR}/include -I${.CURDIR}
281.104Sthorpej
291.136SmrgLIBCDIR=	${.CURDIR}
301.136Smrg
311.82Stv.if exists (${ARCHDIR}/Makefile.inc)
321.82Stv.PATH:	${ARCHDIR}
331.82Stv.include "${ARCHDIR}/Makefile.inc"
341.9Sderaadt.endif
351.127Schristos
361.114Smatt.if exists (${ARCHDIR}/genassym.cf)
371.114SmattDPSRCS+=	assym.h
381.114SmattCLEANFILES+=	assym.h assym.h.tmp
391.114Smatt
401.122Sthorpejassym.h: ${ARCHDIR}/genassym.cf
411.114Smatt	${_MKTARGET_CREATE}
421.165Sjoerg	${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} \
431.121Smatt		${CPPFLAGS} ${CPPFLAGS.assym.h} ${PROF} \
441.165Sjoerg		${GENASSYM_CPPFLAGS} < ${ARCHDIR}/genassym.cf > assym.h.tmp && \
451.114Smatt	mv -f assym.h.tmp assym.h
461.114Smatt.endif
471.1Scgd
481.127Schristos# The following controls how to build compatibility code for old NetBSD
491.150Sjoerg# binaries. If BUILD_LEGACY is yes, then we build a separate library; otherwise
501.127Schristos# we include the code in libc.
511.150SjoergBUILD_LEGACY?= no
521.150Sjoerg.if "${BUILD_LEGACY}" == "yes"
531.127SchristosSUBDIR=compat
541.127Schristos.include <bsd.subdir.mk>
551.127Schristos.else
561.127SchristosCOMPATDIR=${.CURDIR}/compat
571.127Schristos.include "${.CURDIR}/compat/Makefile.inc"
581.150Sjoerg# Marker for compat code that can't be easily isolated
591.150SjoergCPPFLAGS+=	-D__BUILD_LEGACY
601.127Schristos.endif
611.127Schristos
621.125Schristos.include "${.CURDIR}/../../common/lib/libc/Makefile.inc"
631.135Sad.include "${.CURDIR}/atomic/Makefile.inc"
641.141Sjoerg.include "${.CURDIR}/cdb/Makefile.inc"
651.7Scgd.include "${.CURDIR}/db/Makefile.inc"
661.111Stshiozak.include "${.CURDIR}/citrus/Makefile.inc"
671.1Scgd.include "${.CURDIR}/compat-43/Makefile.inc"
681.159Sjoerg.include "${.CURDIR}/compiler_rt/Makefile.inc"
691.88Sminoura.include "${.CURDIR}/dlfcn/Makefile.inc"
701.126Skleink.include "${.CURDIR}/gdtoa/Makefile.inc"
711.1Scgd.include "${.CURDIR}/gen/Makefile.inc"
721.24Scgd.include "${.CURDIR}/gmon/Makefile.inc"
731.81Sexplorer.include "${.CURDIR}/hash/Makefile.inc"
741.111Stshiozak.include "${.CURDIR}/iconv/Makefile.inc"
751.117Schristos.include "${.CURDIR}/inet/Makefile.inc"
761.117Schristos.include "${.CURDIR}/isc/Makefile.inc"
771.1Scgd.include "${.CURDIR}/locale/Makefile.inc"
781.52Sthorpej.include "${.CURDIR}/md/Makefile.inc"
791.132Sad.include "${.CURDIR}/misc/Makefile.inc"
801.1Scgd.include "${.CURDIR}/net/Makefile.inc"
811.117Schristos.include "${.CURDIR}/nameser/Makefile.inc"
821.25Sjtc.include "${.CURDIR}/nls/Makefile.inc"
831.173Schristos.include "${.CURDIR}/posix1e/Makefile.inc"
841.24Scgd.include "${.CURDIR}/regex/Makefile.inc"
851.117Schristos.include "${.CURDIR}/resolv/Makefile.inc"
861.24Scgd.include "${.CURDIR}/rpc/Makefile.inc"
871.131Stls.include "${.CURDIR}/ssp/Makefile.inc"
881.1Scgd.include "${.CURDIR}/stdio/Makefile.inc"
891.1Scgd.include "${.CURDIR}/stdlib/Makefile.inc"
901.1Scgd.include "${.CURDIR}/string/Makefile.inc"
911.40Sjtc.include "${.CURDIR}/termios/Makefile.inc"
921.108Sthorpej.include "${.CURDIR}/thread-stub/Makefile.inc"
931.38Sjtc.include "${.CURDIR}/time/Makefile.inc"
941.167Spooka.if ${RUMPRUN} != "yes"
951.144Sjoerg.include "${.CURDIR}/tls/Makefile.inc"
961.167Spooka.endif
971.1Scgd.include "${.CURDIR}/sys/Makefile.inc"
981.162Sjoerg.if ${HAVE_LIBGCC_EH} == "no"
991.159Sjoerg.include "${NETBSDSRCDIR}/sys/lib/libunwind/Makefile.inc"
1001.159Sjoerg.endif
1011.119Sthorpej.include "${.CURDIR}/uuid/Makefile.inc"
1021.104Sthorpej.if (${MKYP} != "no")
1031.4Sderaadt.include "${.CURDIR}/yp/Makefile.inc"
1041.104Sthorpej.endif
1051.41Sjtc
1061.138Sdsl# Remove from SRCS the .c files for any .S files added by the MD makefiles,
1071.138Sdsl# also remove from SRCS the .c files for the .S and .c files in NO_SRCS.
1081.138Sdsl# Add the .c file for .S files (in both variables) to LSRCS so that the
1091.138Sdsl# 'normal' .c file for assembly files is used for the lint librray.
1101.138Sdsl#
1111.138Sdsl# Usage:
1121.174Slukem# Add .S files to NO_SRCS when another .S file provides the entry points.
1131.174Slukem# Add .c files to NO_SRCS when another .c file provides the entry points.
1141.138Sdsl# (lint is run on all .c files in SRCS)
1151.138Sdsl
1161.138Sdsl.for check_file in ${SRCS:M*.S} ${NO_SRCS}
1171.138Sdslunwanted_file := ${SRCS:M${check_file:.S=.c}}
1181.137Sdsl.if "${unwanted_file}" != ""
1191.137SdslSRCS := ${SRCS:N${unwanted_file}}
1201.138Sdsl.if "${unwanted_file}" != "${check_file}"
1211.138SdslLSRCS := ${LSRCS} ${unwanted_file}
1221.138Sdsl.endif
1231.137Sdsl.endif
1241.137Sdsl.endfor
1251.137Sdsl
1261.109SjmmvNLS=	C.msg Pig.msg ca.msg cs.msg de.msg es.msg fi.msg fr.msg nl.msg \
1271.110Ssalo	no.msg pl.msg sk.msg sv.msg
1281.1Scgd
1291.163Sapb.if ${MKREPRO:Uno} == "yes"
1301.163SapbREGEX_SPECIALS=[][)(^$$.?*\\;]
1311.163SapbMKREPRO_SED=   -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}/\\\\&/g};/usr/src;'
1321.163Sapb.endif
1331.163Sapb
1341.169Schristos.if !defined(MLIBDIR) && ${RUMPRUN} != "yes"
1351.140Suebayasirealall: tags
1361.145Sdrochnertags: ${SRCS}
1371.118Slukem	${_MKTARGET_CREATE}
1381.163Sapb	-${TOOL_CTAGS} -f ${.TARGET}.tmp -w ${.ALLSRC:M*.c}
1391.115Sross	-egrep "^ENTRY(.*)|^FUNC(.*)|^SYSCALL(.*)" /dev/null ${.ALLSRC:M*.S} | \
1401.36Scgd	    sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
1411.163Sapb           >> ${.TARGET}.tmp
1421.163Sapb.if ${MKREPRO:Uno} == "yes"
1431.163Sapb	sed ${MKREPRO_SED} <${.TARGET}.tmp | sort -o ${.TARGET}
1441.163Sapb.else
1451.163Sapb	sort -o ${.TARGET} ${.TARGET}.tmp
1461.163Sapb.endif
1471.163Sapb	rm -f ${.TARGET}.tmp
1481.65Schristos
1491.145SdrochnerFILES=		tags
1501.82StvFILESNAME=	libc.tags
1511.82StvFILESDIR=	/var/db
1521.167Spooka.endif
1531.32Scgd
1541.97Sitojun
1551.103Stshiozak# workaround for I18N stuffs: build singlebyte setlocale() for libc.a,
1561.97Sitojun# multibyte for libc.so.  the quirk should be removed when we support
1571.97Sitojun# dlopen() from within statically linked binaries.
1581.130StnozakiCSHLIBFLAGS+=	-D_I18N_DYNAMIC
1591.105Syamt
1601.175Sriastrad# Tell ctype(3) that this is a dynamic libc, so if appropriate it
1611.175Sriastrad# should allocate a guard page.
1621.175SriastradCSHLIBFLAGS+=	-D_CTYPE_DYNAMIC
1631.175Sriastrad
1641.105Syamt.include <bsd.lib.mk>
1651.133Sad
1661.133Sad# force the dynamic linker to initialize libc first
1671.134SheSHLIB_SHFLAGS+=	-Wl,-z,initfirst
1681.160Sjoerg.if ${HAVE_LIBGCC} == "no"
1691.159SjoergSHLIB_SHFLAGS+= -Wl,-z,defs
1701.159Sjoerg.endif
171