1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997-2024 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
26 if ENABLE_FILESYSTEM_TS
27 filesystem_dir = filesystem
33 backtrace_dir = libbacktrace
38 experimental_dir = experimental
45 ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
46 SUBDIRS = c++98 c++11 c++17 c++20 c++23 c++26 \
47 $(filesystem_dir) $(backtrace_dir) $(experimental_dir)
49 # Cross compiler support.
51 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
53 toolexeclib_LTLIBRARIES = libstdc++.la
59 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
61 libvtv_la_SOURCES = vtv_stubs.cc
62 libvtv_la_LDFLAGS = $(lt_host_flags)
64 libvtv_la_AM_CXXFLAGS = \
65 $(glibcxx_compiler_pic_flag) \
67 -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
68 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
70 libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
71 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
72 $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
75 vpath % $(top_srcdir)/src/c++98
76 vpath % $(top_srcdir)/src/c++11
77 vpath % $(top_srcdir)/src/c++17
78 vpath % $(top_srcdir)/src/c++20
79 vpath % $(top_srcdir)/src/c++23
80 vpath % $(top_srcdir)/src/c++26
81 if ENABLE_FILESYSTEM_TS
82 vpath % $(top_srcdir)/src/filesystem
85 vpath % $(top_srcdir)/src/libbacktrace
87 vpath % $(top_srcdir)/src/experimental
89 if GLIBCXX_LDBL_COMPAT
90 ldbl_compat_sources = compatibility-ldbl.cc
95 if GLIBCXX_LDBL_ALT128_COMPAT
97 ldbl_alt128_compat_cxx11_sources = \
98 compatibility-ldbl-alt128-cxx11.cc
100 ldbl_alt128_compat_cxx11_sources =
102 ldbl_alt128_compat_sources = \
103 compatibility-ldbl-alt128.cc \
104 ${ldbl_alt128_compat_cxx11_sources}
106 ldbl_alt128_compat_sources =
109 if ENABLE_SYMVERS_GNU_NAMESPACE
110 cxx0x_compat_sources =
112 cxx0x_compat_sources = \
113 compatibility-atomic-c++0x.cc \
114 compatibility-c++0x.cc \
115 compatibility-chrono.cc \
116 compatibility-condvar.cc \
117 compatibility-thread-c++0x.cc
120 parallel_compat_sources = \
121 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
126 compatibility-debug_list.cc \
127 compatibility-debug_list-2.cc \
128 ${ldbl_compat_sources}
131 ${cxx0x_compat_sources} \
132 ${ldbl_alt128_compat_sources}
135 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
137 # When freestanding, there's currently no compatibility to preserve. Should
138 # that change, any compatibility sources can be added here.
139 libstdc___la_SOURCES =
142 libstdc___la_LIBADD = \
144 $(top_builddir)/libsupc++/libsupc++convenience.la \
145 $(top_builddir)/src/c++98/libc++98convenience.la \
146 $(top_builddir)/src/c++11/libc++11convenience.la \
147 $(top_builddir)/src/c++17/libc++17convenience.la \
148 $(top_builddir)/src/c++20/libc++20convenience.la
150 libstdc___la_DEPENDENCIES = \
152 $(top_builddir)/libsupc++/libsupc++convenience.la \
153 $(top_builddir)/src/c++98/libc++98convenience.la \
154 $(top_builddir)/src/c++11/libc++11convenience.la \
155 $(top_builddir)/src/c++17/libc++17convenience.la \
156 $(top_builddir)/src/c++20/libc++20convenience.la
158 if ENABLE_DARWIN_AT_RPATH
159 libstdc___darwin_rpath = -Wc,-nodefaultrpaths
160 libstdc___darwin_rpath += -Wl,-rpath,@loader_path
163 libstdc___la_LDFLAGS = \
164 -version-info $(libtool_VERSION) ${version_arg} -lm $(libstdc___darwin_rpath)
166 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
168 # Use special rules for compatibility-ldbl.cc compilation, as we need to
169 # pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
170 if GLIBCXX_LDBL_COMPAT
171 if GLIBCXX_LDBL_ALT128_COMPAT
173 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
175 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
177 LTCXXCOMPILE64 = $(LTCXXCOMPILE)
178 CXXCOMPILE64 = $(CXXCOMPILE)
180 compatibility-ldbl.lo: compatibility-ldbl.cc
181 $(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
182 compatibility-ldbl.o: compatibility-ldbl.cc
183 $(CXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
186 # Use special rules for compatibility-ldbl-alt128.cc compilation, as we need to
187 # ensure it is compiled with the correct flag.
188 if GLIBCXX_LDBL_ALT128_COMPAT
189 compatibility-ldbl-alt128.lo: compatibility-ldbl-alt128.cc
190 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
191 compatibility-ldbl-alt128.o: compatibility-ldbl-alt128.cc
192 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
194 compatibility-ldbl-alt128-cxx11.lo: compatibility-ldbl-alt128-cxx11.cc
195 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
196 compatibility-ldbl-alt128-cxx11.o: compatibility-ldbl-alt128-cxx11.cc
197 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
201 # Use special rules for C++11 files/objects.
202 compatibility-c++0x.lo: compatibility-c++0x.cc
203 $(LTCXXCOMPILE) -std=gnu++11 -c $<
204 compatibility-c++0x.o: compatibility-c++0x.cc
205 $(CXXCOMPILE) -std=gnu++11 -c $<
207 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
208 $(LTCXXCOMPILE) -std=gnu++11 -c $<
209 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
210 $(CXXCOMPILE) -std=gnu++11 -c $<
212 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
213 $(LTCXXCOMPILE) -std=gnu++11 -c $<
214 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
215 $(CXXCOMPILE) -std=gnu++11 -c $<
217 compatibility-chrono.lo: compatibility-chrono.cc
218 $(LTCXXCOMPILE) -std=gnu++11 -c $<
219 compatibility-chrono.o: compatibility-chrono.cc
220 $(CXXCOMPILE) -std=gnu++11 -c $<
222 compatibility-condvar.lo: compatibility-condvar.cc
223 $(LTCXXCOMPILE) -std=gnu++11 -c $<
224 compatibility-condvar.o: compatibility-condvar.cc
225 $(CXXCOMPILE) -std=gnu++11 -c $<
227 # A note on compatibility and static libraries.
229 # static lib == linked against only this version, should not need compat
230 # shared lib == linked against potentially all compat versions
232 # Thus, the shared libs have more compat symbols, which can be found
233 # segregated in the sources with -D_GLIBCXX_SHARED.
235 # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
236 # src/c++20, only -prefer-pic objects are generated for the convenience
239 # In the main src directory, make shared and static objects just for
240 # the compat libraries. Shared objects are compiled with -prefer-pic
241 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
242 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
243 # the main src directory.
245 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
246 # because -fPIC is not harmful to use for objects destined for static
247 # libraries. In addition, using -fPIC will allow the use of static
248 # libstdc++.a in the creation of other C++ shared libraries.
250 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
251 # modified in a per-library or per-sub-library way. Need to manually
252 # set this option because CONFIG_CXXFLAGS has to be after
253 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
254 # as the occasion calls for it.
257 $(glibcxx_compiler_pic_flag) \
258 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
259 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
261 AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
265 # 1) In general, libtool expects an argument such as `--tag=CXX' when
266 # using the C++ compiler, because that will enable the settings
267 # detected when C++ support was being configured. However, when no
268 # such flag is given in the command line, libtool attempts to figure
269 # it out by matching the compiler name in each configuration section
270 # against a prefix of the command line. The problem is that, if the
271 # compiler name and its initial flags stored in the libtool
272 # configuration file don't match those in the command line, libtool
273 # can't decide which configuration to use, and it gives up. The
274 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
275 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
276 # attempt to infer which configuration to use.
278 # The second tag argument, `--tag disable-shared` means that libtool
279 # only compiles each source once, for static objects. In actuality,
280 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
281 # the libtool command that is used create the object, which is
282 # suitable for shared libraries. The `--tag disable-shared` must be
283 # placed after --tag CXX lest things CXX undo the affect of
286 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
287 # last. (That way, things like -O2 passed down from the toplevel can
288 # be overridden by --enable-debug and --enable-cxx-flags.)
290 $(LIBTOOL) --tag CXX \
291 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
292 --mode=compile $(CXX) $(INCLUDES) \
293 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
295 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
297 # 3) We'd have a problem when building the shared libstdc++ object if
298 # the rules automake generates would be used. We cannot allow g++ to
299 # be used since this would add -lstdc++ to the link line which of
300 # course is problematic at this point. So, we get the top-level
301 # directory to configure libstdc++-v3 to use gcc as the C++
302 # compilation driver.
304 $(LIBTOOL) --tag CXX \
305 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
307 $(VTV_CXXLINKFLAGS) \
308 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
309 $(LTLDFLAGS) $(LTLIBICONV) \
312 # Symbol versioning for shared libraries.
313 # See configure.host and configure.ac for port_specific_symbol_files.
315 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
316 $(port_specific_symbol_files)
317 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
319 if test "x$(port_specific_symbol_files)" != x; then \
320 if grep '^# Appended to version file.' \
321 $(port_specific_symbol_files) > /dev/null 2>&1; then \
322 cat $(port_specific_symbol_files) >> $@.tmp; \
324 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
325 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
326 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
327 rm tmp.top tmp.bottom; \
330 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
331 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
334 CLEANFILES = libstdc++-symbols.ver
336 if ENABLE_SYMVERS_GNU
337 version_arg = -Wl,--version-script=libstdc++-symbols.ver
338 version_dep = libstdc++-symbols.ver
340 if ENABLE_SYMVERS_GNU_NAMESPACE
341 version_arg = -Wl,--version-script=libstdc++-symbols.ver
342 version_dep = libstdc++-symbols.ver
344 if ENABLE_SYMVERS_SUN
345 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
346 version_dep = libstdc++-symbols.ver-sun
347 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
348 $(toplevel_srcdir)/contrib/make_sunver.pl \
349 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
350 CXXFILT="$(CXXFILT)"; export CXXFILT; \
351 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
352 libstdc++-symbols.ver \
353 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD) \
354 > $@ || (rm -f $@ ; exit 1)
356 if ENABLE_SYMVERS_DARWIN
357 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
358 version_dep = libstdc++-symbols.explist
359 libstdc++-symbols.explist : libstdc++-symbols.ver \
360 ${glibcxx_srcdir}/scripts/make_exports.pl \
361 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
362 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
363 libstdc++-symbols.ver \
364 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
365 `echo $(libstdc___la_LIBADD) | \
366 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
367 > $@ || (rm -f $@ ; exit 1)
370 CLEANFILES += $(version_dep)
377 # Control additional build primary rules.
378 all-once: libstdc++convenience.la $(STAMP_DEBUG)
379 install-data-once: $(STAMP_INSTALL_DEBUG)
382 install-data-local: install-data-once
384 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
386 # Make a non-installed convenience library, so that --disable-static
388 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
389 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
390 if test ! -f .libs/libstdc++.a; then \
391 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
393 date > stamp-libstdc++convenience;
397 # 2 supra-convenience library
398 if GLIBCXX_BUILD_DEBUG
399 STAMP_DEBUG = build-debug
400 STAMP_INSTALL_DEBUG = install-debug
404 STAMP_INSTALL_DEBUG =
408 # Build a debug variant.
410 # Take care to fix all possibly-relative paths.
411 debug/%/Makefile: %/Makefile
413 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
414 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
415 -e 's/srcdir = \.\./srcdir = ..\/../' \
416 -e 's/VPATH = \.\./VPATH = ..\/../' \
417 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
418 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
421 stamp-debug: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
422 mv debug/Makefile debug/Makefile.tmp
423 sed -e 's,all-local: all-once,all-local:,' \
424 -e 's,install-data-local: install-data-once,install-data-local:,' \
425 -e '/vpath/!s,src/c,src/debug/c,' \
426 < debug/Makefile.tmp > debug/Makefile
427 rm -f debug/Makefile.tmp
430 .SECONDARY: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
433 backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h
434 debug_backtrace_supported_h = debug/$(backtrace_supported_h)
435 $(debug_backtrace_supported_h): $(backtrace_supported_h) stamp-debug
438 debug_backtrace_supported_h =
441 build-debug: stamp-debug $(debug_backtrace_supported_h)
442 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
443 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all
445 # Install debug library.
446 install-debug: build-debug
447 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
448 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install