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