1#	$NetBSD: Makefile,v 1.20 2015/01/29 21:12:10 joerg Exp $
2
3REQUIRETOOLS=	yes
4NOLINT=		# defined
5
6.include <bsd.init.mk>
7
8.include "Makefile.inc"
9
10LIB=		stdc++
11
12LIBDPLIBS+=	m ${.CURDIR}/../../../../../lib/libm
13
14#COPTS+=		-pthread
15#LDFLAGS+=	-pthread
16.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
17COPTS.random.cc+=	${${ACTIVE_CC} == "clang":? -mrdrnd :}
18.endif
19
20CXXFLAGS.clang+=	-stdlib=libstdc++ -std=c++11 -D_GLIBCXX_ABI_TAG_CXX11=
21CXXFLAGS+=	${CXXFLAGS.${ACTIVE_CC}}
22CWARNFLAGS.clang+=	-Wno-logical-op-parentheses \
23			-Wno-deprecated-writable-strings -Wno-parentheses
24
25.include "${.CURDIR}/../libsupc++/Makefile.common"
26
27.if exists(${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk) && ${MKGCC} != "no"
28.include "${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk"
29
30.if defined(__MINIX)
31# by itself, libstdc++ think it is version 6, so use the same number here
32# as this is the exact same code, and will allow us to provide this library
33# from the base system (here), or through the gcc48 package.
34SHLIB_MAJOR=	6
35.else
36SHLIB_MAJOR=	7
37.endif # defined(__MINIX)
38SHLIB_MINOR=	3
39
40SUBDIR=		include
41
42SRCS=		${LIBSUPCXXSRCS} ${LIBSTDCXXSRCS}
43# affects profiling; can't switch it off just for profiling easily.
44#CXXFLAGS+=	${G_SECTION_FLAGS}
45#CXXFLAGS+=	-ffunction-sections -fdata-sections
46CXXFLAGS+=	-fno-implicit-templates -fdiagnostics-show-location=once
47CPPFLAGS+=	-I${DIST}/libstdc++-v3/include
48CPPFLAGS+=	-I${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}
49# include backwards compatible code
50CPPFLAGS+=     -D_GLIBCXX_SHARED -DGTHREAD_USE_WEAK -DSUPPORTS_WEAK
51
52CONF=		${DIST}/libstdc++-v3/config
53
54GLIBCPP_INCLUDE_DIR=	${DESTDIR}/usr/include/g++
55
56# Template instantiation bug workaround for -O<2/s
57COPTS.cp-demangle.c = -Wno-stack-protector
58COPTS.cp-demangle.c = -Wno-stack-protector
59COPTS.fstream-inst.cc = -Wno-stack-protector
60COPTS.locale-inst.cc = -Wno-stack-protector
61COPTS.misc-inst.cc = -Wno-stack-protector
62COPTS.ostream-inst.cc = -Wno-stack-protector
63COPTS.valarray-inst.cc = -Wno-stack-protector
64COPTS.wlocale-inst.cc = -Wno-stack-protector
65COPTS.concept-inst.cc=	-fimplicit-templates
66COPTS.hashtable_c++0x.cc=  -fimplicit-templates
67COPTS.bitmap_allocator.cc = -fimplicit-templates
68CPPFLAGS.strstream.cc=	-I$(GLIBCPP_INCLUDE_DIR)/backward -Wno-deprecated
69
70# XXX also need this for some PCHs.
71CPPFLAGS.atomic.cc = -std=gnu++0x
72CPPFLAGS.compatibility-c++0x.cc = -std=gnu++0x
73CPPFLAGS.functexcept.cc = -std=gnu++0x
74CPPFLAGS.hash_c++0x.cc = -std=gnu++0x
75CPPFLAGS.hashtable_c++0x.cc = -std=gnu++0x
76CPPFLAGS.limits.cc = -std=gnu++0x
77CPPFLAGS.system_error.cc = -std=gnu++0x
78CPPFLAGS.fstream-inst.cc = -std=gnu++0x
79CPPFLAGS.string-inst.cc = -std=gnu++0x
80CPPFLAGS.wstring-inst.cc = -std=gnu++0x
81CPPFLAGS.mutex.cc = -std=gnu++0x
82CPPFLAGS.condition_variable.cc = -std=gnu++0x
83CPPFLAGS.chrono.cc = -std=gnu++0x
84CPPFLAGS.thread.cc = -std=gnu++0x
85CPPFLAGS.future.cc = -std=gnu++0x
86
87CPPFLAGS.cp-demangle.cc += -DIN_GLIBCPP_V3
88CPPFLAGS.concept-inst.cc += -D_GLIBCXX_CONCEPT_CHECKS
89CPPFLAGS.parallel_list.cc += -D_GLIBCXX_PARALLEL
90CPPFLAGS.parallel_settings.cc += -D_GLIBCXX_PARALLEL
91CPPFLAGS.compatibility-parallel_list.cc += -D_GLIBCXX_PARALLEL
92
93cp-demangle.d cp-demangle.o: cp-demangle.h
94
95# XXX
96MKDEPFLAGS+=	-I$(GLIBCPP_INCLUDE_DIR)/backward
97
98GLIBCXX_SRCDIR=	${DIST}/libstdc++-v3
99
100BUILDSYMLINKS+=	\
101	${GLIBCXX_SRCDIR}/${G_CCODECVT_CC} codecvt_members.cc \
102	${GLIBCXX_SRCDIR}/${G_CCOLLATE_CC} collate_members.cc \
103	${GLIBCXX_SRCDIR}/${G_CCTYPE_CC} ctype_members.cc \
104	${GLIBCXX_SRCDIR}/${G_CMESSAGES_CC} messages_members.cc \
105	${GLIBCXX_SRCDIR}/${G_CMONEY_CC} monetary_members.cc \
106	${GLIBCXX_SRCDIR}/${G_CNUMERIC_CC} numeric_members.cc \
107	${GLIBCXX_SRCDIR}/${G_CTIME_CC} time_members.cc \
108	${GLIBCXX_SRCDIR}/${G_ATOMICITY_SRCDIR}/atomicity.h atomicity.cc \
109	${GLIBCXX_SRCDIR}/${G_CLOCALE_CC} c++locale.cc \
110	${GLIBCXX_SRCDIR}/${G_BASIC_FILE_CC} basic_file.cc \
111	${DIST}/libiberty/cp-demangle.c cp-demangle.c \
112	${DIST}/libiberty/cp-demangle.h cp-demangle.h
113
114.if ${HAVE_LIBGCC_EH} == "no"
115G_CONFIGLINKS:= ${G_CONFIGLINKS:S,libgcc/config/arm/unwind-arm.h,libgcc/unwind-generic.h,}
116.endif
117
118.if ${MKGCC} != "no"
119.if defined(G_CONFIGLINKS) && !empty(G_CONFIGLINKS)
120BUILDSYMLINKS+=        ${G_CONFIGLINKS}
121.for _src _dst in ${G_CONFIGLINKS}
122DPSRCS+=       ${_dst}
123.endfor
124.endif
125.endif
126
127.for f in compatibility-c++0x compatibility-atomic-c++0x \
128          compatibility-thread-c++0x compatibility-chrono chrono \
129	  condition_variable debug functexcept functional future \
130	  hash_c++0x hashtable_c++0x limits mutex placeholders \
131	  random regex shared_ptr system_error thread
132COPTS.${f}.cc+= -std=gnu++11
133.endfor
134
135.include <bsd.lib.mk>
136.include <bsd.subdir.mk>
137.include <bsd.info.mk>
138
139.PATH:	${DIST}/libstdc++-v3/src \
140	${DIST}/libstdc++-v3/src/c++98 \
141	${DIST}/libstdc++-v3/src/c++11 \
142	${DIST}/libstdc++-v3/libsupc++ \
143	${DIST}/libstdc++-v3/config/os/bsd/netbsd \
144	${CONF}/locale/generic \
145	${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}
146
147${OBJS}: ${.CURDIR}/arch/${LIBSTDCXX_MACHINE_ARCH}/defs.mk
148.else
149.include <bsd.prog.mk> # do nothing
150.endif
151