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