Makefile revision 1.171 1 # $NetBSD: Makefile,v 1.171 2018/08/03 02:29:35 kamil 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 LIBCSANITIZERFLAGS+= -fno-sanitize=function # generated code depends on RTTI
21
22 .include "Makefile.inc"
23
24 LIB= c
25 CPPFLAGS+= -I${.CURDIR}/include -I${.CURDIR}
26
27 LIBCDIR= ${.CURDIR}
28
29 .if exists (${ARCHDIR}/Makefile.inc)
30 .PATH: ${ARCHDIR}
31 .include "${ARCHDIR}/Makefile.inc"
32 .endif
33
34 .if exists (${ARCHDIR}/genassym.cf)
35 DPSRCS+= assym.h
36 CLEANFILES+= assym.h assym.h.tmp
37
38 assym.h: ${ARCHDIR}/genassym.cf
39 ${_MKTARGET_CREATE}
40 ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} \
41 ${CPPFLAGS} ${CPPFLAGS.assym.h} ${PROF} \
42 ${GENASSYM_CPPFLAGS} < ${ARCHDIR}/genassym.cf > assym.h.tmp && \
43 mv -f assym.h.tmp assym.h
44 .endif
45
46 # The following controls how to build compatibility code for old NetBSD
47 # binaries. If BUILD_LEGACY is yes, then we build a separate library; otherwise
48 # we include the code in libc.
49 BUILD_LEGACY?= no
50 .if "${BUILD_LEGACY}" == "yes"
51 SUBDIR=compat
52 .include <bsd.subdir.mk>
53 .else
54 COMPATDIR=${.CURDIR}/compat
55 .include "${.CURDIR}/compat/Makefile.inc"
56 # Marker for compat code that can't be easily isolated
57 CPPFLAGS+= -D__BUILD_LEGACY
58 .endif
59
60 .include "${.CURDIR}/../../common/lib/libc/Makefile.inc"
61 .include "${.CURDIR}/atomic/Makefile.inc"
62 .include "${.CURDIR}/cdb/Makefile.inc"
63 .include "${.CURDIR}/db/Makefile.inc"
64 .include "${.CURDIR}/citrus/Makefile.inc"
65 .include "${.CURDIR}/compat-43/Makefile.inc"
66 .include "${.CURDIR}/compiler_rt/Makefile.inc"
67 .include "${.CURDIR}/dlfcn/Makefile.inc"
68 .include "${.CURDIR}/gdtoa/Makefile.inc"
69 .include "${.CURDIR}/gen/Makefile.inc"
70 .include "${.CURDIR}/gmon/Makefile.inc"
71 .include "${.CURDIR}/hash/Makefile.inc"
72 .include "${.CURDIR}/iconv/Makefile.inc"
73 .include "${.CURDIR}/inet/Makefile.inc"
74 .include "${.CURDIR}/isc/Makefile.inc"
75 .include "${.CURDIR}/locale/Makefile.inc"
76 .include "${.CURDIR}/md/Makefile.inc"
77 .include "${.CURDIR}/misc/Makefile.inc"
78 .include "${.CURDIR}/net/Makefile.inc"
79 .include "${.CURDIR}/nameser/Makefile.inc"
80 .include "${.CURDIR}/nls/Makefile.inc"
81 .include "${.CURDIR}/regex/Makefile.inc"
82 .include "${.CURDIR}/resolv/Makefile.inc"
83 .include "${.CURDIR}/rpc/Makefile.inc"
84 .include "${.CURDIR}/ssp/Makefile.inc"
85 .include "${.CURDIR}/stdio/Makefile.inc"
86 .include "${.CURDIR}/stdlib/Makefile.inc"
87 .include "${.CURDIR}/string/Makefile.inc"
88 .include "${.CURDIR}/termios/Makefile.inc"
89 .include "${.CURDIR}/thread-stub/Makefile.inc"
90 .include "${.CURDIR}/time/Makefile.inc"
91 .if ${RUMPRUN} != "yes"
92 .include "${.CURDIR}/tls/Makefile.inc"
93 .endif
94 .include "${.CURDIR}/sys/Makefile.inc"
95 .if ${HAVE_LIBGCC_EH} == "no"
96 .include "${NETBSDSRCDIR}/sys/lib/libunwind/Makefile.inc"
97 .endif
98 .include "${.CURDIR}/uuid/Makefile.inc"
99 .if (${MKYP} != "no")
100 .include "${.CURDIR}/yp/Makefile.inc"
101 .endif
102
103 # Remove from SRCS the .c files for any .S files added by the MD makefiles,
104 # also remove from SRCS the .c files for the .S and .c files in NO_SRCS.
105 # Add the .c file for .S files (in both variables) to LSRCS so that the
106 # 'normal' .c file for assembly files is used for the lint librray.
107 #
108 # Usage:
109 # Add .S files to NO_SRSC when another .S file provides the entry points.
110 # Add .c files to NO_SRSC when another .c file provides the entry points.
111 # (lint is run on all .c files in SRCS)
112
113 .for check_file in ${SRCS:M*.S} ${NO_SRCS}
114 unwanted_file := ${SRCS:M${check_file:.S=.c}}
115 .if "${unwanted_file}" != ""
116 SRCS := ${SRCS:N${unwanted_file}}
117 .if "${unwanted_file}" != "${check_file}"
118 LSRCS := ${LSRCS} ${unwanted_file}
119 .endif
120 .endif
121 .endfor
122
123 NLS= C.msg Pig.msg ca.msg cs.msg de.msg es.msg fi.msg fr.msg nl.msg \
124 no.msg pl.msg sk.msg sv.msg
125
126 .if ${MKREPRO:Uno} == "yes"
127 REGEX_SPECIALS=[][)(^$$.?*\\;]
128 MKREPRO_SED= -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}/\\\\&/g};/usr/src;'
129 .endif
130
131 .if !defined(MLIBDIR) && ${RUMPRUN} != "yes"
132 realall: tags
133 tags: ${SRCS}
134 ${_MKTARGET_CREATE}
135 -${TOOL_CTAGS} -f ${.TARGET}.tmp -w ${.ALLSRC:M*.c}
136 -egrep "^ENTRY(.*)|^FUNC(.*)|^SYSCALL(.*)" /dev/null ${.ALLSRC:M*.S} | \
137 sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
138 >> ${.TARGET}.tmp
139 .if ${MKREPRO:Uno} == "yes"
140 sed ${MKREPRO_SED} <${.TARGET}.tmp | sort -o ${.TARGET}
141 .else
142 sort -o ${.TARGET} ${.TARGET}.tmp
143 .endif
144 rm -f ${.TARGET}.tmp
145
146 FILES= tags
147 FILESNAME= libc.tags
148 FILESDIR= /var/db
149 .endif
150
151
152 # workaround for I18N stuffs: build singlebyte setlocale() for libc.a,
153 # multibyte for libc.so. the quirk should be removed when we support
154 # dlopen() from within statically linked binaries.
155 CSHLIBFLAGS+= -D_I18N_DYNAMIC
156
157 .include <bsd.lib.mk>
158
159 # force the dynamic linker to initialize libc first
160 SHLIB_SHFLAGS+= -Wl,-z,initfirst
161 .if ${HAVE_LIBGCC} == "no"
162 SHLIB_SHFLAGS+= -Wl,-z,defs
163 .endif
164