Makefile revision 1.63 1 # $NetBSD: Makefile,v 1.63 2025/10/29 06:08:35 mrg Exp $
2
3 REQUIRETOOLS= yes
4 NOLINT= # defined
5 UNSUPPORTED_COMPILER.clang= # defined
6
7 .include <bsd.init.mk>
8
9 .include "Makefile.inc"
10
11 LIB= stdc++
12
13 LIBDPLIBS+= m ${.CURDIR}/../../../../../lib/libm
14
15 #COPTS+= -pthread
16 #LDFLAGS+= -pthread
17 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
18 COPTS.random.cc+= ${${ACTIVE_CC} == "clang":? -mrdrnd :}
19 .endif
20
21 DIST= ${GCCDIST}
22 GNUVER= ${DIST}/libstdc++-v3/config/abi/pre/gnu.ver
23 SYMBOLS= libstdc++-symbols.ver
24 .if ${MKPIC} != "no"
25 ${SYMBOLS}: Makefile ${GNUVER}
26 cat ${GNUVER} ${G_port_specific_symbol_files} | \
27 ${TOOL_GREP} -E -v '^[ ]*#(#| |$$)' | \
28 ${CXX} -I${DESTDIR}/usr/include/g++ -E -P -include ${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/symver-config.h - > \
29 ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} && rm -f ${.TARGET}.tmp
30
31 CLEANFILES+= ${SYMBOLS} ${SYMBOLS}.tmp
32
33 DPADD+= ${SYMBOLS}
34
35 .if ${MKPICLIB} != "no"
36 libstdc++_pic.a:: ${SYMBOLS}
37 .else
38 libstdc++.a:: ${SYMBOLS}
39 .endif
40
41 LDFLAGS+= -Wl,-O1 \
42 -Wl,--gc-sections \
43 -Wl,--version-script=${SYMBOLS}
44 .endif
45
46 CXXFLAGS.clang+= -stdlib=libstdc++ -std=c++11 -D_GLIBCXX_ABI_TAG_CXX11=
47 CXXFLAGS+= ${CXXFLAGS.${ACTIVE_CC}}
48 CWARNFLAGS.clang+= -Wno-logical-op-parentheses \
49 -Wno-deprecated-writable-strings -Wno-parentheses
50
51 .include "${.CURDIR}/../libsupc++/Makefile.common"
52
53 .if exists(${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk) && ${MKGCC} != "no"
54 .include "${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk"
55
56 SHLIB_MAJOR= 9
57 SHLIB_MINOR= 2
58
59 SUBDIR= include
60
61 SRCS= ${LIBSUPCXXSRCS} ${LIBSTDCXXSRCS}
62
63 GCC_MACHINE_SUBDIR=${MACHINE_CPU:C/powerpc.*/rs6000/:C/x86_64/i386/}
64
65 # Only the shared library is build with -D_GLIBCXX_SHARED, and the
66 # static library shouldn't need to provide old symbols.
67 CSHLIBFLAGS+= -D_GLIBCXX_SHARED
68
69 CXXFLAGS+= -fno-implicit-templates
70 CPPFLAGS+= -I${DIST}/libstdc++-v3/include
71 CPPFLAGS+= -I${DIST}/gcc/config/${GCC_MACHINE_SUBDIR}
72 CPPFLAGS+= -I${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}
73 CPPFLAGS+= -DGTHREAD_USE_WEAK -DSUPPORTS_WEAK
74 .if ${G_CLOCALE_CC:M*dragonfly*} != ""
75 CPPFLAGS+= -I${CONF}/locale/dragonfly
76 LOCALETYPE= dragonfly
77 .else
78 LOCALETYPE= generic
79 .endif
80
81 # affects profiling; can't switch it off just for profiling easily.
82 #CXXFLAGS+= ${G_SECTION_FLAGS}
83 #CXXFLAGS+= -ffunction-sections -fdata-sections
84 COPTS.bitmap_allocator.cc+= -ffunction-sections -fdata-sections
85 COPTS.pool_allocator.cc+= -ffunction-sections -fdata-sections
86
87 CONF= ${DIST}/libstdc++-v3/config
88
89 GLIBCPP_INCLUDE_DIR= ${DESTDIR}/usr/include/g++
90
91 # Template instantiation bug workaround for -O<2/s
92 COPTS.cp-demangle.cc += -Wno-stack-protector
93 COPTS.fstream-inst.cc += -Wno-stack-protector
94 COPTS.locale-inst.cc += -Wno-stack-protector
95 COPTS.misc-inst.cc += -Wno-stack-protector
96 COPTS.ostream-inst.cc += -Wno-stack-protector
97 COPTS.functexcept.cc += -Wno-stack-protector
98 COPTS.valarray-inst.cc += -Wno-stack-protector
99 COPTS.wlocale-inst.cc += -Wno-stack-protector
100 COPTS.snprintf_lite.cc += -Wno-stack-protector
101 # From system headers.
102 COPTS.cxx11-wlocale-inst.cc +=-Wno-stack-protector
103 COPTS.cxx11-locale-inst.cc +=-Wno-stack-protector
104 COPTS.cxx11-wlocale-inst.cc +=-Wno-stack-protector
105 COPTS.codecvt_members.cc +=-Wno-stack-protector
106 COPTS.compatibility-thread-c++0x.cc += -Wno-deprecated-declarations
107 COPTS.concept-inst.cc += -fimplicit-templates
108 COPTS.collate_members_cow.cc += -fimplicit-templates
109 COPTS.messages_members_cow.cc += -fimplicit-templates
110 COPTS.monetary_members_cow.cc += -fimplicit-templates
111 COPTS.numeric_members_cow.cc += -fimplicit-templates
112 COPTS.hashtable_c++0x.cc += -fimplicit-templates
113 COPTS.c++locale.cc += -fimplicit-templates
114 COPTS.functexcept.cc += -Wno-deprecated-declarations
115 COPTS.future.cc += -Wno-deprecated-declarations
116 COPTS.shared_ptr.cc += -Wno-deprecated-declarations
117 COPTS.thread.cc += -Wno-deprecated-declarations
118 CPPFLAGS.strstream.cc += -I$(GLIBCPP_INCLUDE_DIR)/backward -Wno-deprecated
119
120 CPPFLAGS.cp-demangle.cc += -DIN_GLIBCPP_V3
121 CPPFLAGS.concept-inst.cc += -D_GLIBCXX_CONCEPT_CHECKS
122 CPPFLAGS.parallel_list.cc += -D_GLIBCXX_PARALLEL
123 CPPFLAGS.parallel_settings.cc += -D_GLIBCXX_PARALLEL
124 CPPFLAGS.compatibility-parallel_list.cc += -D_GLIBCXX_PARALLEL
125 CPPFLAGS.compatibility.cc+= -I${DIST}/libstdc++-v3/config
126 CPPFLAGS.c11-cow-string-inst.cc+= -I${DIST}/libstdc++-v3/src/c++11
127 CPPFLAGS.c17-cow-string-inst.cc+= -I${DIST}/libstdc++-v3/src/c++17
128
129 cp-demangle.d cp-demangle.o: cp-demangle.h
130
131 .if ${MACHINE_ARCH} == "i386"
132 COPTS.random.cc += -Wno-error=psabi
133 COPTS.cow-string-inst.cc += -Wno-error=psabi
134 .endif
135
136 # XXX
137 MKDEPFLAGS+= -I$(GLIBCPP_INCLUDE_DIR)/backward
138
139 GLIBCXX_SRCDIR= ${DIST}/libstdc++-v3
140
141 BUILDSYMLINKS+= \
142 ${GLIBCXX_SRCDIR}/${G_CCODECVT_CC} codecvt_members.cc \
143 ${GLIBCXX_SRCDIR}/${G_CCOLLATE_CC} collate_members.cc \
144 ${GLIBCXX_SRCDIR}/${G_CCTYPE_CC} ctype_members.cc \
145 ${GLIBCXX_SRCDIR}/${G_CMESSAGES_CC} messages_members.cc \
146 ${GLIBCXX_SRCDIR}/${G_CMONEY_CC} monetary_members.cc \
147 ${GLIBCXX_SRCDIR}/${G_CNUMERIC_CC} numeric_members.cc \
148 ${GLIBCXX_SRCDIR}/${G_CTIME_CC} time_members.cc \
149 ${GLIBCXX_SRCDIR}/${G_ATOMICITY_SRCDIR}/atomicity.h atomicity.cc \
150 ${GLIBCXX_SRCDIR}/${G_CLOCALE_CC} c++locale.cc \
151 ${GLIBCXX_SRCDIR}/${G_BASIC_FILE_CC} basic_file.cc \
152 ${DIST}/libiberty/cp-demangle.c cp-demangle.c \
153 ${DIST}/libiberty/cp-demangle.h cp-demangle.h \
154 ${GLIBCXX_SRCDIR}/${G_CCOLLATE_CC} collate_members_cow.cc \
155 ${GLIBCXX_SRCDIR}/${G_CMESSAGES_CC} messages_members_cow.cc \
156 ${GLIBCXX_SRCDIR}/${G_CMONEY_CC} monetary_members_cow.cc \
157 ${GLIBCXX_SRCDIR}/${G_CNUMERIC_CC} numeric_members_cow.cc
158
159 # both c++98 and c++11 have codecvt.cc files.
160 # both c++11 and c++17 have cow-string-inst.cc, ostream-inst.cc,
161 # and string-inst.cc.
162 .for _N _V1 _V2 in \
163 codecvt 98 11 \
164 cow-string-inst 11 17 \
165 ostream-inst 11 17 \
166 string-inst 11 17 \
167 sstream-inst 11 20
168
169 BUILDSYMLINKS+= \
170 ${GLIBCXX_SRCDIR}/src/c++${_V1}/${_N}.cc c${_V1}-${_N}.cc
171 BUILDSYMLINKS+= \
172 ${GLIBCXX_SRCDIR}/src/c++${_V2}/${_N}.cc c${_V2}-${_N}.cc
173
174 .endfor
175
176 .include "../Makefile.gthr"
177
178 # XXX Special rules in c++98/Makefile; may move into c++11 in future GCC.
179 CXX11_ALWAYS= localename.cc \
180 locale_init.cc
181
182 FCHAR8_SRCS+= localename.cc \
183 locale_init.cc \
184 c11-codecvt.cc \
185 limits.cc
186
187 .for _s in ${G_cxx11_sources} ${CXX11_ALWAYS}
188 COPTS.${_s}+= -std=gnu++11
189 .endfor
190
191 .for _s in ${G_cxx98_sources}
192 COPTS.${_s}+= -std=gnu++98
193 .endfor
194
195 .for _s in ${FCHAR8_SRCS}
196 COPTS.${_s}+= -fchar8_t
197 .endfor
198
199 COPTS.cp-demangle.c += -Wno-unused-function
200
201 COPTS.ext-inst.cc+= -Wno-error
202
203 .for f in collate_members_cow \
204 messages_members_cow \
205 monetary_members_cow \
206 numeric_members_cow \
207 c++locale
208 COPTS.${f}.cc+= -fimplicit-templates ${G_GLIBCXX_ABI_FLAGS}
209 .endfor
210
211 # XXXGCC12
212 # hits on sparc, sparc64, armv7 at least
213 COPTS.floating_to_chars.cc+= -Wno-error=unused-function
214 COPTS.cp-demangle.c+= -Wno-error=stack-protector
215 COPTS.floating_to_chars.cc+= -Wno-error=stack-protector
216
217 # GCC 14 special cases
218 tzdata.zi.h: ${DIST}/libstdc++-v3/src/c++20/tzdata.zi
219 echo 'static const char tzdata_chars[] = R"__libstdcxx__(' > ${.TARGET}.tmp && \
220 cat $^ >> ${.TARGET}.tmp && \
221 echo ')__libstdcxx__";' >> ${.TARGET}.tmp && mv ${.TARGET}.tmp $@
222
223 # libbacktrace
224 # XXX This is not new, but GCC 14 is the first to start demanding it properly.
225 .for f in ${G_LIBBACKTRACE_SOURCES} ${G_LIBBACKTRACE_DEPS}
226 . if ${f} == "cp-demangle.c"
227 BUILDSYMLINKS+= \
228 ${DIST}/libiberty/${f} std_stacktrace-${f}
229 CPPFLAGS.std_stacktrace-${f}+= \
230 -I${.CURDIR}/../libiberty/arch/${LIBSTDCXX_MACHINE_ARCH}
231 . else
232 BUILDSYMLINKS+= \
233 ${DIST}/libbacktrace/${f} std_stacktrace-${f}
234 CPPFLAGS.std_stacktrace-${f}+= \
235 -I${.CURDIR}/../libbacktrace/arch/${LIBSTDCXX_MACHINE_ARCH} \
236 -I${DIST}/libbacktrace
237 . endif
238 SRCS+= std_stacktrace-${f}
239 .endfor
240
241 tzdb.cc: tzdata.zi.h
242
243 .include <bsd.lib.mk>
244 .include <bsd.subdir.mk>
245 .include <bsd.info.mk>
246
247 .PATH: ${DIST}/libstdc++-v3/src \
248 ${DIST}/libstdc++-v3/src/c++98 \
249 ${DIST}/libstdc++-v3/src/c++11 \
250 ${DIST}/libstdc++-v3/src/c++17 \
251 ${DIST}/libstdc++-v3/src/c++20 \
252 ${DIST}/libstdc++-v3/src/c++23 \
253 ${DIST}/libstdc++-v3/src/c++26 \
254 ${DIST}/libstdc++-v3/src/filesystem \
255 ${DIST}/libstdc++-v3/libsupc++ \
256 ${DIST}/libstdc++-v3/config/os/bsd/netbsd \
257 ${CONF}/locale/${LOCALETYPE} \
258 ${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}
259
260 ${OBJS}: ${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk
261
262 .else
263 .include <bsd.prog.mk> # do nothing
264 .endif
265