1#	$NetBSD: Makefile,v 1.12 2023/02/20 02:12:25 mrg Exp $
2
3.include <bsd.init.mk>
4
5.include "${.CURDIR}/../../arch/${GCC_MACHINE_ARCH}/defs.mk"
6
7.cc: # disable .cc->NULL transform
8
9GNUHOSTDIST=	${DIST}
10
11GTHRINCS=	gthr.h gthr-single.h gthr-posix.h
12
13BUILDINCS=	basic_file.h c++allocator.h c++io.h c++locale.h
14BUILDINCS+=	messages_members.h time_members.h opt_random.h
15BUILDINCS+=	${GTHRINCS}
16
17INCS=		${G_bits_headers} ${G_c_base_headers_extra} ${G_host_headers}
18INCS+=		${BUILDINCS}
19
20# These are handled with special rules
21#INCS+=		${G_bits_host_headers} ${G_host_headers_extra}
22
23# libsupc++
24# XXX use bits_sup_headers from libstdc++/include/Makefile.am
25INCS+=		atomic_lockfree_defines.h \
26		cxxabi_forced.h \
27		cxxabi_init_exception.h \
28		exception.h \
29		exception_defines.h \
30		exception_ptr.h \
31		hash_bytes.h \
32		nested_exception.h
33
34# Build the gthr*.h files
35gthr.h: ${DIST}/libgcc/gthr.h Makefile
36	${TOOL_SED} \
37	    -e '/^#pragma/b' \
38	    -e '/^#/s/\([A-Z_][A-Z_]*\)/_GLIBCXX_\1/g' \
39	    -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
40	    -e 's/_GLIBCXX___MINGW32_GLIBCXX___/__MINGW32__/g' \
41	    -e 's,^#include "\(.*\)",#include <bits/\1>,g' \
42	    < ${DIST}/libgcc/gthr.h > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
43
44gthr-single.h: ${DIST}/libgcc/gthr-single.h Makefile
45	${TOOL_SED} \
46	    -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
47	    -e 's/\(GCC[A-Z_]*_H\)/_GLIBCXX_\1/g' \
48	    < ${DIST}/libgcc/gthr-single.h > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
49
50gthr-posix.h: ${DIST}/libgcc/gthr-posix.h Makefile
51	${TOOL_SED} \
52	    -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \
53	    -e 's/\(GCC[A-Z_]*_H\)/_GLIBCXX_\1/g' \
54	    -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \
55	    -e 's/\([A-Z_]*USE_WEAK\)/_GLIBCXX_\1/g' \
56	    < ${DIST}/libgcc/gthr-posix.h > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
57
58.for _f in ${GTHRINCS}
59CLEANFILES+=	${.TARGET} ${.TARGET}.tmp
60.endfor
61
62.if ${MKCOMPAT} != no && !empty(MACHINE_ARCH:M*64*)
63SUBDIR+=	arch
64.else
65INCS+=		c++config.h
66.endif
67
68INCSDIR=	/usr/include/g++/bits
69
70INCSYMLINKS+=	gthr-posix.h ${INCSDIR}/gthr-default.h
71
72.include "${.CURDIR}/../Makefile.includes"
73
74CLEANFILES+=	${BUILDINCS}
75
76CXXDIST=			${DIST}/libstdc++-v3
77COPYHEADERS= \
78	opt_random.h		${CXXDIST}/${G_CPU_OPT_BITS_RANDOM} \
79	basic_file.h		${CXXDIST}/${G_BASIC_FILE_H} \
80	c++allocator.h		${CXXDIST}/${G_ALLOCATOR_H} \
81	c++locale.h		${CXXDIST}/${G_CLOCALE_H} \
82	c++io.h			${CXXDIST}/${G_CSTDIO_H} \
83	messages_members.h	${CXXDIST}/${G_CMESSAGES_H} \
84	time_members.h		${CXXDIST}/${G_CTIME_H}
85
86.for _h _s in ${COPYHEADERS}
87${_h}: ${_s}
88	cp -pf ${.ALLSRC} ${.TARGET}
89.endfor
90
91.PATH: ${.CURDIR}/../../arch/${GCC_MACHINE_ARCH} \
92	${DIST}/libstdc++-v3/include \
93	${DIST}/libstdc++-v3/config \
94	${DIST}/libstdc++-v3/ \
95	${DIST}/libstdc++-v3/libsupc++
96
97.include <bsd.subdir.mk>
98