1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997-2022 Free Software Foundation, Inc.
5 ## This file is part of the libstdc++ version 3 distribution.
6 ## Process this file with automake to produce Makefile.in.
8 ## This file is part of the GNU ISO C++ Library. This library is free
9 ## software; you can redistribute it and/or modify it under the
10 ## terms of the GNU General Public License as published by the
11 ## Free Software Foundation; either version 3, or (at your option)
14 ## This library is distributed in the hope that it will be useful,
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ## GNU General Public License for more details.
19 ## You should have received a copy of the GNU General Public License along
20 ## with this library; see the file COPYING3. If not see
21 ## <http://www.gnu.org/licenses/>.
23 include $(top_srcdir)/fragment.am
25 if ENABLE_FILESYSTEM_TS
26 filesystem_dir = filesystem
32 backtrace_dir = libbacktrace
37 ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
38 SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) $(backtrace_dir) experimental
40 # Cross compiler support.
42 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
44 toolexeclib_LTLIBRARIES = libstdc++.la
50 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
52 libvtv_la_SOURCES = vtv_stubs.cc
53 libvtv_la_LDFLAGS = $(lt_host_flags)
55 libvtv_la_AM_CXXFLAGS = \
56 $(glibcxx_compiler_pic_flag) \
58 -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
59 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
61 libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
62 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
63 $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
66 vpath % $(top_srcdir)/src/c++98
67 vpath % $(top_srcdir)/src/c++11
68 vpath % $(top_srcdir)/src/c++17
69 vpath % $(top_srcdir)/src/c++20
70 if ENABLE_FILESYSTEM_TS
71 vpath % $(top_srcdir)/src/filesystem
74 vpath % $(top_srcdir)/src/libbacktrace
76 vpath % $(top_srcdir)/src/experimental
78 if GLIBCXX_LDBL_COMPAT
79 ldbl_compat_sources = compatibility-ldbl.cc
84 if GLIBCXX_LDBL_ALT128_COMPAT
86 ldbl_alt128_compat_cxx11_sources = \
87 compatibility-ldbl-alt128-cxx11.cc
89 ldbl_alt128_compat_cxx11_sources =
91 ldbl_alt128_compat_sources = \
92 compatibility-ldbl-alt128.cc \
93 ${ldbl_alt128_compat_cxx11_sources}
95 ldbl_alt128_compat_sources =
98 if ENABLE_SYMVERS_GNU_NAMESPACE
99 cxx0x_compat_sources =
101 cxx0x_compat_sources = \
102 compatibility-atomic-c++0x.cc \
103 compatibility-c++0x.cc \
104 compatibility-chrono.cc \
105 compatibility-condvar.cc \
106 compatibility-thread-c++0x.cc
109 parallel_compat_sources = \
110 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
115 compatibility-debug_list.cc \
116 compatibility-debug_list-2.cc \
117 ${ldbl_compat_sources}
120 ${cxx0x_compat_sources} \
121 ${ldbl_alt128_compat_sources}
123 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
125 libstdc___la_LIBADD = \
127 $(top_builddir)/libsupc++/libsupc++convenience.la \
128 $(top_builddir)/src/c++98/libc++98convenience.la \
129 $(top_builddir)/src/c++11/libc++11convenience.la \
130 $(top_builddir)/src/c++17/libc++17convenience.la \
131 $(top_builddir)/src/c++20/libc++20convenience.la
133 libstdc___la_DEPENDENCIES = \
135 $(top_builddir)/libsupc++/libsupc++convenience.la \
136 $(top_builddir)/src/c++98/libc++98convenience.la \
137 $(top_builddir)/src/c++11/libc++11convenience.la \
138 $(top_builddir)/src/c++17/libc++17convenience.la \
139 $(top_builddir)/src/c++20/libc++20convenience.la
141 libstdc___la_LDFLAGS = \
142 -version-info $(libtool_VERSION) ${version_arg} -lm
144 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
146 # Use special rules for compatibility-ldbl.cc compilation, as we need to
147 # pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
148 if GLIBCXX_LDBL_COMPAT
149 if GLIBCXX_LDBL_ALT128_COMPAT
151 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
153 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
155 LTCXXCOMPILE64 = $(LTCXXCOMPILE)
156 CXXCOMPILE64 = $(CXXCOMPILE)
158 compatibility-ldbl.lo: compatibility-ldbl.cc
159 $(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
160 compatibility-ldbl.o: compatibility-ldbl.cc
161 $(CXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
164 # Use special rules for compatibility-ldbl-alt128.cc compilation, as we need to
165 # ensure it is compiled with the correct flag.
166 if GLIBCXX_LDBL_ALT128_COMPAT
167 compatibility-ldbl-alt128.lo: compatibility-ldbl-alt128.cc
168 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
169 compatibility-ldbl-alt128.o: compatibility-ldbl-alt128.cc
170 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
172 compatibility-ldbl-alt128-cxx11.lo: compatibility-ldbl-alt128-cxx11.cc
173 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
174 compatibility-ldbl-alt128-cxx11.o: compatibility-ldbl-alt128-cxx11.cc
175 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
179 # Use special rules for C++11 files/objects.
180 compatibility-c++0x.lo: compatibility-c++0x.cc
181 $(LTCXXCOMPILE) -std=gnu++11 -c $<
182 compatibility-c++0x.o: compatibility-c++0x.cc
183 $(CXXCOMPILE) -std=gnu++11 -c $<
185 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
186 $(LTCXXCOMPILE) -std=gnu++11 -c $<
187 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
188 $(CXXCOMPILE) -std=gnu++11 -c $<
190 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
191 $(LTCXXCOMPILE) -std=gnu++11 -c $<
192 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
193 $(CXXCOMPILE) -std=gnu++11 -c $<
195 compatibility-chrono.lo: compatibility-chrono.cc
196 $(LTCXXCOMPILE) -std=gnu++11 -c $<
197 compatibility-chrono.o: compatibility-chrono.cc
198 $(CXXCOMPILE) -std=gnu++11 -c $<
200 compatibility-condvar.lo: compatibility-condvar.cc
201 $(LTCXXCOMPILE) -std=gnu++11 -c $<
202 compatibility-condvar.o: compatibility-condvar.cc
203 $(CXXCOMPILE) -std=gnu++11 -c $<
205 # A note on compatibility and static libraries.
207 # static lib == linked against only this version, should not need compat
208 # shared lib == linked against potentially all compat versions
210 # Thus, the shared libs have more compat symbols, which can be found
211 # segregated in the sources with -D_GLIBCXX_SHARED.
213 # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
214 # src/c++20, only -prefer-pic objects are generated for the convenience
217 # In the main src directory, make shared and static objects just for
218 # the compat libraries. Shared objects are compiled with -prefer-pic
219 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
220 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
221 # the main src directory.
223 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
224 # because -fPIC is not harmful to use for objects destined for static
225 # libraries. In addition, using -fPIC will allow the use of static
226 # libstdc++.a in the creation of other C++ shared libraries.
228 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
229 # modified in a per-library or per-sub-library way. Need to manually
230 # set this option because CONFIG_CXXFLAGS has to be after
231 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
232 # as the occasion calls for it.
235 $(glibcxx_compiler_pic_flag) \
236 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
237 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
239 AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
243 # 1) In general, libtool expects an argument such as `--tag=CXX' when
244 # using the C++ compiler, because that will enable the settings
245 # detected when C++ support was being configured. However, when no
246 # such flag is given in the command line, libtool attempts to figure
247 # it out by matching the compiler name in each configuration section
248 # against a prefix of the command line. The problem is that, if the
249 # compiler name and its initial flags stored in the libtool
250 # configuration file don't match those in the command line, libtool
251 # can't decide which configuration to use, and it gives up. The
252 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
253 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
254 # attempt to infer which configuration to use.
256 # The second tag argument, `--tag disable-shared` means that libtool
257 # only compiles each source once, for static objects. In actuality,
258 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
259 # the libtool command that is used create the object, which is
260 # suitable for shared libraries. The `--tag disable-shared` must be
261 # placed after --tag CXX lest things CXX undo the affect of
264 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
265 # last. (That way, things like -O2 passed down from the toplevel can
266 # be overridden by --enable-debug and --enable-cxx-flags.)
268 $(LIBTOOL) --tag CXX \
269 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
270 --mode=compile $(CXX) $(INCLUDES) \
271 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
273 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
275 # 3) We'd have a problem when building the shared libstdc++ object if
276 # the rules automake generates would be used. We cannot allow g++ to
277 # be used since this would add -lstdc++ to the link line which of
278 # course is problematic at this point. So, we get the top-level
279 # directory to configure libstdc++-v3 to use gcc as the C++
280 # compilation driver.
282 $(LIBTOOL) --tag CXX \
283 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
285 $(VTV_CXXLINKFLAGS) \
286 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
287 $(LTLDFLAGS) $(LTLIBICONV) \
290 # Symbol versioning for shared libraries.
292 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
293 $(port_specific_symbol_files)
294 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
296 if test "x$(port_specific_symbol_files)" != x; then \
297 if grep '^# Appended to version file.' \
298 $(port_specific_symbol_files) > /dev/null 2>&1; then \
299 cat $(port_specific_symbol_files) >> $@.tmp; \
301 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
302 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
303 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
304 rm tmp.top tmp.bottom; \
307 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
308 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
311 CLEANFILES = libstdc++-symbols.ver
313 if ENABLE_SYMVERS_GNU
314 version_arg = -Wl,--version-script=libstdc++-symbols.ver
315 version_dep = libstdc++-symbols.ver
317 if ENABLE_SYMVERS_GNU_NAMESPACE
318 version_arg = -Wl,--version-script=libstdc++-symbols.ver
319 version_dep = libstdc++-symbols.ver
321 if ENABLE_SYMVERS_SUN
322 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
323 version_dep = libstdc++-symbols.ver-sun
324 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
325 $(toplevel_srcdir)/contrib/make_sunver.pl \
326 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
327 CXXFILT="$(CXXFILT)"; export CXXFILT; \
328 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
329 libstdc++-symbols.ver \
330 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
331 `echo ' $(libstdc___la_LIBADD) ' | \
332 sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
333 > $@ || (rm -f $@ ; exit 1)
335 if ENABLE_SYMVERS_DARWIN
336 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
337 version_dep = libstdc++-symbols.explist
338 libstdc++-symbols.explist : libstdc++-symbols.ver \
339 ${glibcxx_srcdir}/scripts/make_exports.pl \
340 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
341 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
342 libstdc++-symbols.ver \
343 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
344 `echo $(libstdc___la_LIBADD) | \
345 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
346 > $@ || (rm -f $@ ; exit 1)
349 CLEANFILES += $(version_dep)
356 # Control additional build primary rules.
357 all-once: libstdc++convenience.la $(STAMP_DEBUG)
358 install-data-once: $(STAMP_INSTALL_DEBUG)
361 install-data-local: install-data-once
363 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
365 # Make a non-installed convenience library, so that --disable-static
367 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
368 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
369 if test ! -f .libs/libstdc++.a; then \
370 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
372 date > stamp-libstdc++convenience;
376 # 2 supra-convenience library
377 if GLIBCXX_BUILD_DEBUG
378 STAMP_DEBUG = build-debug
379 STAMP_INSTALL_DEBUG = install-debug
383 STAMP_INSTALL_DEBUG =
387 # Build a debug variant.
389 # Take care to fix all possibly-relative paths.
390 debug/%/Makefile: %/Makefile
392 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
393 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
394 -e 's/srcdir = \.\./srcdir = ..\/../' \
395 -e 's/VPATH = \.\./VPATH = ..\/../' \
396 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
397 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
400 stamp-debug: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
401 mv debug/Makefile debug/Makefile.tmp
402 sed -e 's,all-local: all-once,all-local:,' \
403 -e 's,install-data-local: install-data-once,install-data-local:,' \
404 -e '/vpath/!s,src/c,src/debug/c,' \
405 < debug/Makefile.tmp > debug/Makefile
406 rm -f debug/Makefile.tmp
409 .SECONDARY: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
412 backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h
413 debug_backtrace_supported_h = debug/$(backtrace_supported_h)
414 $(debug_backtrace_supported_h): $(backtrace_supported_h) stamp-debug
417 debug_backtrace_supported_h =
420 build-debug: stamp-debug $(debug_backtrace_supported_h)
421 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
422 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all
424 # Install debug library.
425 install-debug: build-debug
426 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
427 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install