Home | History | Annotate | Line # | Download | only in libc
      1 #	$NetBSD: Makefile,v 1.175 2025/03/30 16:17:04 riastradh Exp $
      2 #	@(#)Makefile	8.2 (Berkeley) 2/3/94
      3 #
      4 # All library objects contain sccsid strings by default; they may be
      5 # excluded as a space-saving measure.  To produce a library that does
      6 # not contain these strings, delete -DLIBC_SCCS and -DSYSLIBC_SCCS
      7 # from CPPFLAGS below.  To remove these strings from just the system call
      8 # stubs, remove just -DSYSLIBC_SCCS from CPPFLAGS.
      9 #
     10 # The NLS (message catalog) functions are always in libc.  To choose that
     11 # strerror(), perror(), strsignal(), psignal(), etc. actually call the NLS
     12 # functions, put -DNLS on the CPPFLAGS line below.
     13 #
     14 # The YP functions are always in libc. To choose that getpwent() and friends
     15 # actually call the YP functions, put -DYP on the CPPFLAGS line below.
     16 #
     17 # The Hesiod functions are always in libc. To choose that getpwent() and friends
     18 # actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below.
     19 
     20 
     21 # generated code depends on RTTI
     22 LIBCSANITIZERFLAGS+=	${${ACTIVE_CC} == "clang":? -fno-sanitize=function :}
     23 
     24 .include "Makefile.inc"
     25 
     26 LIB=		c
     27 CPPFLAGS+=	-I${.CURDIR}/include -I${.CURDIR}
     28 
     29 LIBCDIR=	${.CURDIR}
     30 
     31 .if exists (${ARCHDIR}/Makefile.inc)
     32 .PATH:	${ARCHDIR}
     33 .include "${ARCHDIR}/Makefile.inc"
     34 .endif
     35 
     36 .if exists (${ARCHDIR}/genassym.cf)
     37 DPSRCS+=	assym.h
     38 CLEANFILES+=	assym.h assym.h.tmp
     39 
     40 assym.h: ${ARCHDIR}/genassym.cf
     41 	${_MKTARGET_CREATE}
     42 	${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} \
     43 		${CPPFLAGS} ${CPPFLAGS.assym.h} ${PROF} \
     44 		${GENASSYM_CPPFLAGS} < ${ARCHDIR}/genassym.cf > assym.h.tmp && \
     45 	mv -f assym.h.tmp assym.h
     46 .endif
     47 
     48 # The following controls how to build compatibility code for old NetBSD
     49 # binaries. If BUILD_LEGACY is yes, then we build a separate library; otherwise
     50 # we include the code in libc.
     51 BUILD_LEGACY?= no
     52 .if "${BUILD_LEGACY}" == "yes"
     53 SUBDIR=compat
     54 .include <bsd.subdir.mk>
     55 .else
     56 COMPATDIR=${.CURDIR}/compat
     57 .include "${.CURDIR}/compat/Makefile.inc"
     58 # Marker for compat code that can't be easily isolated
     59 CPPFLAGS+=	-D__BUILD_LEGACY
     60 .endif
     61 
     62 .include "${.CURDIR}/../../common/lib/libc/Makefile.inc"
     63 .include "${.CURDIR}/atomic/Makefile.inc"
     64 .include "${.CURDIR}/cdb/Makefile.inc"
     65 .include "${.CURDIR}/db/Makefile.inc"
     66 .include "${.CURDIR}/citrus/Makefile.inc"
     67 .include "${.CURDIR}/compat-43/Makefile.inc"
     68 .include "${.CURDIR}/compiler_rt/Makefile.inc"
     69 .include "${.CURDIR}/dlfcn/Makefile.inc"
     70 .include "${.CURDIR}/gdtoa/Makefile.inc"
     71 .include "${.CURDIR}/gen/Makefile.inc"
     72 .include "${.CURDIR}/gmon/Makefile.inc"
     73 .include "${.CURDIR}/hash/Makefile.inc"
     74 .include "${.CURDIR}/iconv/Makefile.inc"
     75 .include "${.CURDIR}/inet/Makefile.inc"
     76 .include "${.CURDIR}/isc/Makefile.inc"
     77 .include "${.CURDIR}/locale/Makefile.inc"
     78 .include "${.CURDIR}/md/Makefile.inc"
     79 .include "${.CURDIR}/misc/Makefile.inc"
     80 .include "${.CURDIR}/net/Makefile.inc"
     81 .include "${.CURDIR}/nameser/Makefile.inc"
     82 .include "${.CURDIR}/nls/Makefile.inc"
     83 .include "${.CURDIR}/posix1e/Makefile.inc"
     84 .include "${.CURDIR}/regex/Makefile.inc"
     85 .include "${.CURDIR}/resolv/Makefile.inc"
     86 .include "${.CURDIR}/rpc/Makefile.inc"
     87 .include "${.CURDIR}/ssp/Makefile.inc"
     88 .include "${.CURDIR}/stdio/Makefile.inc"
     89 .include "${.CURDIR}/stdlib/Makefile.inc"
     90 .include "${.CURDIR}/string/Makefile.inc"
     91 .include "${.CURDIR}/termios/Makefile.inc"
     92 .include "${.CURDIR}/thread-stub/Makefile.inc"
     93 .include "${.CURDIR}/time/Makefile.inc"
     94 .if ${RUMPRUN} != "yes"
     95 .include "${.CURDIR}/tls/Makefile.inc"
     96 .endif
     97 .include "${.CURDIR}/sys/Makefile.inc"
     98 .if ${HAVE_LIBGCC_EH} == "no"
     99 .include "${NETBSDSRCDIR}/sys/lib/libunwind/Makefile.inc"
    100 .endif
    101 .include "${.CURDIR}/uuid/Makefile.inc"
    102 .if (${MKYP} != "no")
    103 .include "${.CURDIR}/yp/Makefile.inc"
    104 .endif
    105 
    106 # Remove from SRCS the .c files for any .S files added by the MD makefiles,
    107 # also remove from SRCS the .c files for the .S and .c files in NO_SRCS.
    108 # Add the .c file for .S files (in both variables) to LSRCS so that the
    109 # 'normal' .c file for assembly files is used for the lint librray.
    110 #
    111 # Usage:
    112 # Add .S files to NO_SRCS when another .S file provides the entry points.
    113 # Add .c files to NO_SRCS when another .c file provides the entry points.
    114 # (lint is run on all .c files in SRCS)
    115 
    116 .for check_file in ${SRCS:M*.S} ${NO_SRCS}
    117 unwanted_file := ${SRCS:M${check_file:.S=.c}}
    118 .if "${unwanted_file}" != ""
    119 SRCS := ${SRCS:N${unwanted_file}}
    120 .if "${unwanted_file}" != "${check_file}"
    121 LSRCS := ${LSRCS} ${unwanted_file}
    122 .endif
    123 .endif
    124 .endfor
    125 
    126 NLS=	C.msg Pig.msg ca.msg cs.msg de.msg es.msg fi.msg fr.msg nl.msg \
    127 	no.msg pl.msg sk.msg sv.msg
    128 
    129 .if ${MKREPRO:Uno} == "yes"
    130 REGEX_SPECIALS=[][)(^$$.?*\\;]
    131 MKREPRO_SED=   -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}/\\\\&/g};/usr/src;'
    132 .endif
    133 
    134 .if !defined(MLIBDIR) && ${RUMPRUN} != "yes"
    135 realall: tags
    136 tags: ${SRCS}
    137 	${_MKTARGET_CREATE}
    138 	-${TOOL_CTAGS} -f ${.TARGET}.tmp -w ${.ALLSRC:M*.c}
    139 	-egrep "^ENTRY(.*)|^FUNC(.*)|^SYSCALL(.*)" /dev/null ${.ALLSRC:M*.S} | \
    140 	    sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
    141            >> ${.TARGET}.tmp
    142 .if ${MKREPRO:Uno} == "yes"
    143 	sed ${MKREPRO_SED} <${.TARGET}.tmp | sort -o ${.TARGET}
    144 .else
    145 	sort -o ${.TARGET} ${.TARGET}.tmp
    146 .endif
    147 	rm -f ${.TARGET}.tmp
    148 
    149 FILES=		tags
    150 FILESNAME=	libc.tags
    151 FILESDIR=	/var/db
    152 .endif
    153 
    154 
    155 # workaround for I18N stuffs: build singlebyte setlocale() for libc.a,
    156 # multibyte for libc.so.  the quirk should be removed when we support
    157 # dlopen() from within statically linked binaries.
    158 CSHLIBFLAGS+=	-D_I18N_DYNAMIC
    159 
    160 # Tell ctype(3) that this is a dynamic libc, so if appropriate it
    161 # should allocate a guard page.
    162 CSHLIBFLAGS+=	-D_CTYPE_DYNAMIC
    163 
    164 .include <bsd.lib.mk>
    165 
    166 # force the dynamic linker to initialize libc first
    167 SHLIB_SHFLAGS+=	-Wl,-z,initfirst
    168 .if ${HAVE_LIBGCC} == "no"
    169 SHLIB_SHFLAGS+= -Wl,-z,defs
    170 .endif
    171