1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997-2023 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 $(filesystem_dir) $(backtrace_dir) $(experimental_dir)
48 # Cross compiler support.
50 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
52 toolexeclib_LTLIBRARIES = libstdc++.la
58 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
60 libvtv_la_SOURCES = vtv_stubs.cc
61 libvtv_la_LDFLAGS = $(lt_host_flags)
63 libvtv_la_AM_CXXFLAGS = \
64 $(glibcxx_compiler_pic_flag) \
66 -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
67 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
69 libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
70 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
71 $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
74 vpath % $(top_srcdir)/src/c++98
75 vpath % $(top_srcdir)/src/c++11
76 vpath % $(top_srcdir)/src/c++17
77 vpath % $(top_srcdir)/src/c++20
78 if ENABLE_FILESYSTEM_TS
79 vpath % $(top_srcdir)/src/filesystem
82 vpath % $(top_srcdir)/src/libbacktrace
84 vpath % $(top_srcdir)/src/experimental
86 if GLIBCXX_LDBL_COMPAT
87 ldbl_compat_sources = compatibility-ldbl.cc
92 if GLIBCXX_LDBL_ALT128_COMPAT
94 ldbl_alt128_compat_cxx11_sources = \
95 compatibility-ldbl-alt128-cxx11.cc
97 ldbl_alt128_compat_cxx11_sources =
99 ldbl_alt128_compat_sources = \
100 compatibility-ldbl-alt128.cc \
101 ${ldbl_alt128_compat_cxx11_sources}
103 ldbl_alt128_compat_sources =
106 if ENABLE_SYMVERS_GNU_NAMESPACE
107 cxx0x_compat_sources =
109 cxx0x_compat_sources = \
110 compatibility-atomic-c++0x.cc \
111 compatibility-c++0x.cc \
112 compatibility-chrono.cc \
113 compatibility-condvar.cc \
114 compatibility-thread-c++0x.cc
117 parallel_compat_sources = \
118 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
123 compatibility-debug_list.cc \
124 compatibility-debug_list-2.cc \
125 ${ldbl_compat_sources}
128 ${cxx0x_compat_sources} \
129 ${ldbl_alt128_compat_sources}
132 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
134 # When freestanding, there's currently no compatibility to preserve. Should
135 # that change, any compatibility sources can be added here.
136 libstdc___la_SOURCES =
139 libstdc___la_LIBADD = \
141 $(top_builddir)/libsupc++/libsupc++convenience.la \
142 $(top_builddir)/src/c++98/libc++98convenience.la \
143 $(top_builddir)/src/c++11/libc++11convenience.la \
144 $(top_builddir)/src/c++17/libc++17convenience.la \
145 $(top_builddir)/src/c++20/libc++20convenience.la
147 libstdc___la_DEPENDENCIES = \
149 $(top_builddir)/libsupc++/libsupc++convenience.la \
150 $(top_builddir)/src/c++98/libc++98convenience.la \
151 $(top_builddir)/src/c++11/libc++11convenience.la \
152 $(top_builddir)/src/c++17/libc++17convenience.la \
153 $(top_builddir)/src/c++20/libc++20convenience.la
155 libstdc___la_LDFLAGS = \
156 -version-info $(libtool_VERSION) ${version_arg} -lm
158 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
160 # Use special rules for compatibility-ldbl.cc compilation, as we need to
161 # pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
162 if GLIBCXX_LDBL_COMPAT
163 if GLIBCXX_LDBL_ALT128_COMPAT
165 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
167 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
169 LTCXXCOMPILE64 = $(LTCXXCOMPILE)
170 CXXCOMPILE64 = $(CXXCOMPILE)
172 compatibility-ldbl.lo: compatibility-ldbl.cc
173 $(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
174 compatibility-ldbl.o: compatibility-ldbl.cc
175 $(CXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
178 # Use special rules for compatibility-ldbl-alt128.cc compilation, as we need to
179 # ensure it is compiled with the correct flag.
180 if GLIBCXX_LDBL_ALT128_COMPAT
181 compatibility-ldbl-alt128.lo: compatibility-ldbl-alt128.cc
182 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
183 compatibility-ldbl-alt128.o: compatibility-ldbl-alt128.cc
184 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
186 compatibility-ldbl-alt128-cxx11.lo: compatibility-ldbl-alt128-cxx11.cc
187 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
188 compatibility-ldbl-alt128-cxx11.o: compatibility-ldbl-alt128-cxx11.cc
189 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
193 # Use special rules for C++11 files/objects.
194 compatibility-c++0x.lo: compatibility-c++0x.cc
195 $(LTCXXCOMPILE) -std=gnu++11 -c $<
196 compatibility-c++0x.o: compatibility-c++0x.cc
197 $(CXXCOMPILE) -std=gnu++11 -c $<
199 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
200 $(LTCXXCOMPILE) -std=gnu++11 -c $<
201 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
202 $(CXXCOMPILE) -std=gnu++11 -c $<
204 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
205 $(LTCXXCOMPILE) -std=gnu++11 -c $<
206 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
207 $(CXXCOMPILE) -std=gnu++11 -c $<
209 compatibility-chrono.lo: compatibility-chrono.cc
210 $(LTCXXCOMPILE) -std=gnu++11 -c $<
211 compatibility-chrono.o: compatibility-chrono.cc
212 $(CXXCOMPILE) -std=gnu++11 -c $<
214 compatibility-condvar.lo: compatibility-condvar.cc
215 $(LTCXXCOMPILE) -std=gnu++11 -c $<
216 compatibility-condvar.o: compatibility-condvar.cc
217 $(CXXCOMPILE) -std=gnu++11 -c $<
219 # A note on compatibility and static libraries.
221 # static lib == linked against only this version, should not need compat
222 # shared lib == linked against potentially all compat versions
224 # Thus, the shared libs have more compat symbols, which can be found
225 # segregated in the sources with -D_GLIBCXX_SHARED.
227 # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
228 # src/c++20, only -prefer-pic objects are generated for the convenience
231 # In the main src directory, make shared and static objects just for
232 # the compat libraries. Shared objects are compiled with -prefer-pic
233 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
234 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
235 # the main src directory.
237 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
238 # because -fPIC is not harmful to use for objects destined for static
239 # libraries. In addition, using -fPIC will allow the use of static
240 # libstdc++.a in the creation of other C++ shared libraries.
242 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
243 # modified in a per-library or per-sub-library way. Need to manually
244 # set this option because CONFIG_CXXFLAGS has to be after
245 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
246 # as the occasion calls for it.
249 $(glibcxx_compiler_pic_flag) \
250 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
251 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
253 AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
257 # 1) In general, libtool expects an argument such as `--tag=CXX' when
258 # using the C++ compiler, because that will enable the settings
259 # detected when C++ support was being configured. However, when no
260 # such flag is given in the command line, libtool attempts to figure
261 # it out by matching the compiler name in each configuration section
262 # against a prefix of the command line. The problem is that, if the
263 # compiler name and its initial flags stored in the libtool
264 # configuration file don't match those in the command line, libtool
265 # can't decide which configuration to use, and it gives up. The
266 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
267 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
268 # attempt to infer which configuration to use.
270 # The second tag argument, `--tag disable-shared` means that libtool
271 # only compiles each source once, for static objects. In actuality,
272 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
273 # the libtool command that is used create the object, which is
274 # suitable for shared libraries. The `--tag disable-shared` must be
275 # placed after --tag CXX lest things CXX undo the affect of
278 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
279 # last. (That way, things like -O2 passed down from the toplevel can
280 # be overridden by --enable-debug and --enable-cxx-flags.)
282 $(LIBTOOL) --tag CXX \
283 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
284 --mode=compile $(CXX) $(INCLUDES) \
285 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
287 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
289 # 3) We'd have a problem when building the shared libstdc++ object if
290 # the rules automake generates would be used. We cannot allow g++ to
291 # be used since this would add -lstdc++ to the link line which of
292 # course is problematic at this point. So, we get the top-level
293 # directory to configure libstdc++-v3 to use gcc as the C++
294 # compilation driver.
296 $(LIBTOOL) --tag CXX \
297 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
299 $(VTV_CXXLINKFLAGS) \
300 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
301 $(LTLDFLAGS) $(LTLIBICONV) \
304 # Symbol versioning for shared libraries.
305 # See configure.host and configure.ac for port_specific_symbol_files.
307 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
308 $(port_specific_symbol_files)
309 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
311 if test "x$(port_specific_symbol_files)" != x; then \
312 if grep '^# Appended to version file.' \
313 $(port_specific_symbol_files) > /dev/null 2>&1; then \
314 cat $(port_specific_symbol_files) >> $@.tmp; \
316 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
317 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
318 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
319 rm tmp.top tmp.bottom; \
322 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
323 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
326 CLEANFILES = libstdc++-symbols.ver
328 if ENABLE_SYMVERS_GNU
329 version_arg = -Wl,--version-script=libstdc++-symbols.ver
330 version_dep = libstdc++-symbols.ver
332 if ENABLE_SYMVERS_GNU_NAMESPACE
333 version_arg = -Wl,--version-script=libstdc++-symbols.ver
334 version_dep = libstdc++-symbols.ver
336 if ENABLE_SYMVERS_SUN
337 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
338 version_dep = libstdc++-symbols.ver-sun
339 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
340 $(toplevel_srcdir)/contrib/make_sunver.pl \
341 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
342 CXXFILT="$(CXXFILT)"; export CXXFILT; \
343 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
344 libstdc++-symbols.ver \
345 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
346 `echo ' $(libstdc___la_LIBADD) ' | \
347 sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
348 > $@ || (rm -f $@ ; exit 1)
350 if ENABLE_SYMVERS_DARWIN
351 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
352 version_dep = libstdc++-symbols.explist
353 libstdc++-symbols.explist : libstdc++-symbols.ver \
354 ${glibcxx_srcdir}/scripts/make_exports.pl \
355 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
356 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
357 libstdc++-symbols.ver \
358 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
359 `echo $(libstdc___la_LIBADD) | \
360 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
361 > $@ || (rm -f $@ ; exit 1)
364 CLEANFILES += $(version_dep)
371 # Control additional build primary rules.
372 all-once: libstdc++convenience.la $(STAMP_DEBUG)
373 install-data-once: $(STAMP_INSTALL_DEBUG)
376 install-data-local: install-data-once
378 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
380 # Make a non-installed convenience library, so that --disable-static
382 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
383 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
384 if test ! -f .libs/libstdc++.a; then \
385 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
387 date > stamp-libstdc++convenience;
391 # 2 supra-convenience library
392 if GLIBCXX_BUILD_DEBUG
393 STAMP_DEBUG = build-debug
394 STAMP_INSTALL_DEBUG = install-debug
398 STAMP_INSTALL_DEBUG =
402 # Build a debug variant.
404 # Take care to fix all possibly-relative paths.
405 debug/%/Makefile: %/Makefile
407 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
408 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
409 -e 's/srcdir = \.\./srcdir = ..\/../' \
410 -e 's/VPATH = \.\./VPATH = ..\/../' \
411 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
412 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
415 stamp-debug: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
416 mv debug/Makefile debug/Makefile.tmp
417 sed -e 's,all-local: all-once,all-local:,' \
418 -e 's,install-data-local: install-data-once,install-data-local:,' \
419 -e '/vpath/!s,src/c,src/debug/c,' \
420 < debug/Makefile.tmp > debug/Makefile
421 rm -f debug/Makefile.tmp
424 .SECONDARY: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
427 backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h
428 debug_backtrace_supported_h = debug/$(backtrace_supported_h)
429 $(debug_backtrace_supported_h): $(backtrace_supported_h) stamp-debug
432 debug_backtrace_supported_h =
435 build-debug: stamp-debug $(debug_backtrace_supported_h)
436 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
437 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all
439 # Install debug library.
440 install-debug: build-debug
441 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
442 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install