Home | History | Annotate | Line # | Download | only in libstdc++-v3
      1 #	$NetBSD: Makefile,v 1.19 2026/03/09 22:58:34 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 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=	1
     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 COPTS.std_stacktrace-cp-demangle.c += -Wno-stack-protector
    102 # From system headers.
    103 COPTS.cxx11-wlocale-inst.cc +=-Wno-stack-protector
    104 COPTS.cxx11-locale-inst.cc +=-Wno-stack-protector
    105 COPTS.cxx11-wlocale-inst.cc +=-Wno-stack-protector
    106 COPTS.codecvt_members.cc +=-Wno-stack-protector
    107 COPTS.compatibility-thread-c++0x.cc += -Wno-deprecated-declarations
    108 COPTS.concept-inst.cc += -fimplicit-templates
    109 COPTS.collate_members_cow.cc += -fimplicit-templates
    110 COPTS.messages_members_cow.cc += -fimplicit-templates
    111 COPTS.monetary_members_cow.cc += -fimplicit-templates
    112 COPTS.numeric_members_cow.cc += -fimplicit-templates
    113 COPTS.hashtable_c++0x.cc += -fimplicit-templates
    114 COPTS.c++locale.cc += -fimplicit-templates
    115 COPTS.functexcept.cc += -Wno-deprecated-declarations
    116 COPTS.future.cc += -Wno-deprecated-declarations
    117 COPTS.shared_ptr.cc += -Wno-deprecated-declarations
    118 COPTS.thread.cc += -Wno-deprecated-declarations
    119 CPPFLAGS.strstream.cc += -I$(GLIBCPP_INCLUDE_DIR)/backward -Wno-deprecated
    120 
    121 CPPFLAGS.cp-demangle.cc += -DIN_GLIBCPP_V3
    122 CPPFLAGS.concept-inst.cc += -D_GLIBCXX_CONCEPT_CHECKS
    123 CPPFLAGS.parallel_list.cc += -D_GLIBCXX_PARALLEL
    124 CPPFLAGS.parallel_settings.cc += -D_GLIBCXX_PARALLEL
    125 CPPFLAGS.compatibility-parallel_list.cc += -D_GLIBCXX_PARALLEL
    126 CPPFLAGS.compatibility.cc+=	-I${DIST}/libstdc++-v3/config
    127 CPPFLAGS.c11-cow-string-inst.cc+=	-I${DIST}/libstdc++-v3/src/c++11
    128 CPPFLAGS.c17-cow-string-inst.cc+=	-I${DIST}/libstdc++-v3/src/c++17
    129 
    130 cp-demangle.d cp-demangle.o: cp-demangle.h
    131 
    132 .if ${MACHINE_ARCH} == "i386"
    133 COPTS.random.cc += -Wno-error=psabi
    134 COPTS.cow-string-inst.cc += -Wno-error=psabi
    135 .endif
    136 
    137 .if ${MACHINE} == "sun2"
    138 COPTS.std_stacktrace-cp-demangle.c += -Wno-stack-protector
    139 .endif
    140 
    141 # XXX
    142 MKDEPFLAGS+=	-I$(GLIBCPP_INCLUDE_DIR)/backward
    143 
    144 GLIBCXX_SRCDIR=	${DIST}/libstdc++-v3
    145 
    146 BUILDSYMLINKS+=	\
    147 	${GLIBCXX_SRCDIR}/${G_CCODECVT_CC} codecvt_members.cc \
    148 	${GLIBCXX_SRCDIR}/${G_CCOLLATE_CC} collate_members.cc \
    149 	${GLIBCXX_SRCDIR}/${G_CCTYPE_CC} ctype_members.cc \
    150 	${GLIBCXX_SRCDIR}/${G_CMESSAGES_CC} messages_members.cc \
    151 	${GLIBCXX_SRCDIR}/${G_CMONEY_CC} monetary_members.cc \
    152 	${GLIBCXX_SRCDIR}/${G_CNUMERIC_CC} numeric_members.cc \
    153 	${GLIBCXX_SRCDIR}/${G_CTIME_CC} time_members.cc \
    154 	${GLIBCXX_SRCDIR}/${G_ATOMICITY_SRCDIR}/atomicity.h atomicity.cc \
    155 	${GLIBCXX_SRCDIR}/${G_CLOCALE_CC} c++locale.cc \
    156 	${GLIBCXX_SRCDIR}/${G_BASIC_FILE_CC} basic_file.cc \
    157 	${DIST}/libiberty/cp-demangle.c cp-demangle.c \
    158 	${DIST}/libiberty/cp-demangle.h cp-demangle.h \
    159 	${GLIBCXX_SRCDIR}/${G_CCOLLATE_CC} collate_members_cow.cc \
    160 	${GLIBCXX_SRCDIR}/${G_CMESSAGES_CC} messages_members_cow.cc \
    161 	${GLIBCXX_SRCDIR}/${G_CMONEY_CC} monetary_members_cow.cc \
    162 	${GLIBCXX_SRCDIR}/${G_CNUMERIC_CC} numeric_members_cow.cc
    163 
    164 # both c++98 and c++11 have codecvt.cc files.
    165 # both c++11 and c++17 have cow-string-inst.cc, ostream-inst.cc,
    166 # and string-inst.cc.
    167 .for _N _V1 _V2 in \
    168 	codecvt 98 11 \
    169 	cow-string-inst 11 17 \
    170 	ostream-inst 11 17 \
    171 	string-inst 11 17 \
    172 	sstream-inst 11 20
    173 
    174 BUILDSYMLINKS+=	\
    175 	${GLIBCXX_SRCDIR}/src/c++${_V1}/${_N}.cc c${_V1}-${_N}.cc
    176 BUILDSYMLINKS+=	\
    177 	${GLIBCXX_SRCDIR}/src/c++${_V2}/${_N}.cc c${_V2}-${_N}.cc
    178 
    179 .endfor
    180 
    181 .include "../Makefile.gthr"
    182 
    183 # XXX Special rules in c++98/Makefile; may move into c++11 in future GCC.
    184 CXX11_ALWAYS=	localename.cc \
    185 		locale_init.cc
    186 
    187 FCHAR8_SRCS+=	localename.cc \
    188 		locale_init.cc \
    189 		c11-codecvt.cc \
    190 		limits.cc
    191 
    192 .for _s in ${G_cxx11_sources} ${CXX11_ALWAYS}
    193 COPTS.${_s}+= -std=gnu++11
    194 .endfor
    195 
    196 .for _s in ${G_cxx98_sources}
    197 COPTS.${_s}+= -std=gnu++98
    198 .endfor
    199 
    200 .for _s in ${FCHAR8_SRCS}
    201 COPTS.${_s}+= -fchar8_t
    202 .endfor
    203 
    204 COPTS.cp-demangle.c += -Wno-unused-function
    205 
    206 COPTS.ext-inst.cc+= -Wno-error
    207 
    208 .for f in collate_members_cow \
    209 	  messages_members_cow \
    210           monetary_members_cow \
    211 	  numeric_members_cow \
    212 	  c++locale
    213 COPTS.${f}.cc+= -fimplicit-templates ${G_GLIBCXX_ABI_FLAGS}
    214 .endfor
    215 
    216 # XXXGCC12
    217 # hits on sparc, sparc64, armv7 at least
    218 COPTS.floating_to_chars.cc+=	-Wno-error=unused-function
    219 COPTS.cp-demangle.c+=	-Wno-error=stack-protector
    220 COPTS.floating_to_chars.cc+=	-Wno-error=stack-protector
    221 
    222 # libbacktrace
    223 .for f in ${G_LIBBACKTRACE_SOURCES} ${G_LIBBACKTRACE_DEPS}
    224 . if ${f} == "cp-demangle.c"
    225 BUILDSYMLINKS+=	\
    226 	${DIST}/libiberty/${f} std_stacktrace-${f}
    227 CPPFLAGS.std_stacktrace-${f}+= \
    228 	-I${.CURDIR}/../libiberty/arch/${LIBSTDCXX_MACHINE_ARCH}
    229 . else
    230 BUILDSYMLINKS+=	\
    231 	${DIST}/libbacktrace/${f} std_stacktrace-${f}
    232 CPPFLAGS.std_stacktrace-${f}+= \
    233 	-I${.CURDIR}/../libbacktrace/arch/${LIBSTDCXX_MACHINE_ARCH} \
    234 	-I${DIST}/libbacktrace
    235 . endif
    236 SRCS+=	std_stacktrace-${f}
    237 CPPFLAGS.std_stacktrace-${f}+= \
    238 	-include ${GLIBCXX_SRCDIR}/src/libbacktrace/backtrace-rename.h
    239 .endfor
    240 
    241 .include <bsd.lib.mk>
    242 .include <bsd.subdir.mk>
    243 .include <bsd.info.mk>
    244 
    245 .PATH:	${DIST}/libstdc++-v3/src \
    246 	${DIST}/libstdc++-v3/src/c++98 \
    247 	${DIST}/libstdc++-v3/src/c++11 \
    248 	${DIST}/libstdc++-v3/src/c++17 \
    249 	${DIST}/libstdc++-v3/src/filesystem \
    250 	${DIST}/libstdc++-v3/libsupc++ \
    251 	${DIST}/libstdc++-v3/config/os/bsd/netbsd \
    252 	${CONF}/locale/${LOCALETYPE} \
    253 	${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}
    254 
    255 ${OBJS}: ${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk
    256 
    257 .else
    258 .include <bsd.prog.mk> # do nothing
    259 .endif
    260