1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997-2021 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
31 ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
32 SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
34 # Cross compiler support.
36 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
38 toolexeclib_LTLIBRARIES = libstdc++.la
44 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
46 libvtv_la_SOURCES = vtv_stubs.cc
47 libvtv_la_LDFLAGS = $(lt_host_flags)
49 libvtv_la_AM_CXXFLAGS = \
50 $(glibcxx_compiler_pic_flag) \
52 -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
53 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
55 libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
56 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
57 $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
60 vpath % $(top_srcdir)/src/c++98
61 vpath % $(top_srcdir)/src/c++11
62 vpath % $(top_srcdir)/src/c++17
63 vpath % $(top_srcdir)/src/c++20
64 if ENABLE_FILESYSTEM_TS
65 vpath % $(top_srcdir)/src/filesystem
68 if GLIBCXX_LDBL_COMPAT
69 ldbl_compat_sources = compatibility-ldbl.cc
74 if GLIBCXX_LDBL_ALT128_COMPAT
76 ldbl_alt128_compat_cxx11_sources = \
77 compatibility-ldbl-alt128-cxx11.cc
79 ldbl_alt128_compat_cxx11_sources =
81 ldbl_alt128_compat_sources = \
82 compatibility-ldbl-alt128.cc \
83 ${ldbl_alt128_compat_cxx11_sources}
85 ldbl_alt128_compat_sources =
89 parallel_compat_sources = \
90 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
95 compatibility-debug_list.cc \
96 compatibility-debug_list-2.cc \
97 ${ldbl_compat_sources}
100 compatibility-c++0x.cc \
101 compatibility-atomic-c++0x.cc \
102 compatibility-thread-c++0x.cc \
103 compatibility-chrono.cc \
104 compatibility-condvar.cc \
105 ${ldbl_alt128_compat_sources}
107 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
109 libstdc___la_LIBADD = \
111 $(top_builddir)/libsupc++/libsupc++convenience.la \
112 $(top_builddir)/src/c++98/libc++98convenience.la \
113 $(top_builddir)/src/c++11/libc++11convenience.la \
114 $(top_builddir)/src/c++17/libc++17convenience.la \
115 $(top_builddir)/src/c++20/libc++20convenience.la
117 libstdc___la_DEPENDENCIES = \
119 $(top_builddir)/libsupc++/libsupc++convenience.la \
120 $(top_builddir)/src/c++98/libc++98convenience.la \
121 $(top_builddir)/src/c++11/libc++11convenience.la \
122 $(top_builddir)/src/c++17/libc++17convenience.la \
123 $(top_builddir)/src/c++20/libc++20convenience.la
125 libstdc___la_LDFLAGS = \
126 -version-info $(libtool_VERSION) ${version_arg} -lm
128 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
130 # Use special rules for compatibility-ldbl.cc compilation, as we need to
131 # pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
132 if GLIBCXX_LDBL_COMPAT
133 if GLIBCXX_LDBL_ALT128_COMPAT
135 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
137 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
139 LTCXXCOMPILE64 = $(LTCXXCOMPILE)
140 CXXCOMPILE64 = $(CXXCOMPILE)
142 compatibility-ldbl.lo: compatibility-ldbl.cc
143 $(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
144 compatibility-ldbl.o: compatibility-ldbl.cc
145 $(CXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
148 # Use special rules for compatibility-ldbl-alt128.cc compilation, as we need to
149 # ensure it is compiled with the correct flag.
150 if GLIBCXX_LDBL_ALT128_COMPAT
151 compatibility-ldbl-alt128.lo: compatibility-ldbl-alt128.cc
152 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
153 compatibility-ldbl-alt128.o: compatibility-ldbl-alt128.cc
154 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
156 compatibility-ldbl-alt128-cxx11.lo: compatibility-ldbl-alt128-cxx11.cc
157 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
158 compatibility-ldbl-alt128-cxx11.o: compatibility-ldbl-alt128-cxx11.cc
159 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
163 # Use special rules for C++11 files/objects.
164 compatibility-c++0x.lo: compatibility-c++0x.cc
165 $(LTCXXCOMPILE) -std=gnu++11 -c $<
166 compatibility-c++0x.o: compatibility-c++0x.cc
167 $(CXXCOMPILE) -std=gnu++11 -c $<
169 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
170 $(LTCXXCOMPILE) -std=gnu++11 -c $<
171 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
172 $(CXXCOMPILE) -std=gnu++11 -c $<
174 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
175 $(LTCXXCOMPILE) -std=gnu++11 -c $<
176 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
177 $(CXXCOMPILE) -std=gnu++11 -c $<
179 compatibility-chrono.lo: compatibility-chrono.cc
180 $(LTCXXCOMPILE) -std=gnu++11 -c $<
181 compatibility-chrono.o: compatibility-chrono.cc
182 $(CXXCOMPILE) -std=gnu++11 -c $<
184 compatibility-condvar.lo: compatibility-condvar.cc
185 $(LTCXXCOMPILE) -std=gnu++11 -c $<
186 compatibility-condvar.o: compatibility-condvar.cc
187 $(CXXCOMPILE) -std=gnu++11 -c $<
189 # A note on compatibility and static libraries.
191 # static lib == linked against only this version, should not need compat
192 # shared lib == linked against potentially all compat versions
194 # Thus, the shared libs have more compat symbols, which can be found
195 # segregated in the sources with -D_GLIBCXX_SHARED.
197 # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
198 # src/c++20, only -prefer-pic objects are generated for the convenience
201 # In the main src directory, make shared and static objects just for
202 # the compat libraries. Shared objects are compiled with -prefer-pic
203 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
204 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
205 # the main src directory.
207 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
208 # because -fPIC is not harmful to use for objects destined for static
209 # libraries. In addition, using -fPIC will allow the use of static
210 # libstdc++.a in the creation of other C++ shared libraries.
212 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
213 # modified in a per-library or per-sub-library way. Need to manually
214 # set this option because CONFIG_CXXFLAGS has to be after
215 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
216 # as the occasion calls for it.
219 $(glibcxx_compiler_pic_flag) \
220 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
221 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
225 # 1) In general, libtool expects an argument such as `--tag=CXX' when
226 # using the C++ compiler, because that will enable the settings
227 # detected when C++ support was being configured. However, when no
228 # such flag is given in the command line, libtool attempts to figure
229 # it out by matching the compiler name in each configuration section
230 # against a prefix of the command line. The problem is that, if the
231 # compiler name and its initial flags stored in the libtool
232 # configuration file don't match those in the command line, libtool
233 # can't decide which configuration to use, and it gives up. The
234 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
235 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
236 # attempt to infer which configuration to use.
238 # The second tag argument, `--tag disable-shared` means that libtool
239 # only compiles each source once, for static objects. In actuality,
240 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
241 # the libtool command that is used create the object, which is
242 # suitable for shared libraries. The `--tag disable-shared` must be
243 # placed after --tag CXX lest things CXX undo the affect of
246 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
247 # last. (That way, things like -O2 passed down from the toplevel can
248 # be overridden by --enable-debug and --enable-cxx-flags.)
250 $(LIBTOOL) --tag CXX \
251 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
252 --mode=compile $(CXX) $(INCLUDES) \
253 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
255 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
257 # 3) We'd have a problem when building the shared libstdc++ object if
258 # the rules automake generates would be used. We cannot allow g++ to
259 # be used since this would add -lstdc++ to the link line which of
260 # course is problematic at this point. So, we get the top-level
261 # directory to configure libstdc++-v3 to use gcc as the C++
262 # compilation driver.
264 $(LIBTOOL) --tag CXX \
265 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
267 $(VTV_CXXLINKFLAGS) \
268 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
270 # Symbol versioning for shared libraries.
272 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
273 $(port_specific_symbol_files)
274 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
276 if test "x$(port_specific_symbol_files)" != x; then \
277 if grep '^# Appended to version file.' \
278 $(port_specific_symbol_files) > /dev/null 2>&1; then \
279 cat $(port_specific_symbol_files) >> $@.tmp; \
281 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
282 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
283 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
284 rm tmp.top tmp.bottom; \
287 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
288 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
291 CLEANFILES = libstdc++-symbols.ver
293 if ENABLE_SYMVERS_GNU
294 version_arg = -Wl,--version-script=libstdc++-symbols.ver
295 version_dep = libstdc++-symbols.ver
297 if ENABLE_SYMVERS_GNU_NAMESPACE
298 version_arg = -Wl,--version-script=libstdc++-symbols.ver
299 version_dep = libstdc++-symbols.ver
301 if ENABLE_SYMVERS_SUN
302 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
303 version_dep = libstdc++-symbols.ver-sun
304 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
305 $(toplevel_srcdir)/contrib/make_sunver.pl \
306 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
307 CXXFILT="$(CXXFILT)"; export CXXFILT; \
308 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
309 libstdc++-symbols.ver \
310 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
311 `echo ' $(libstdc___la_LIBADD) ' | \
312 sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
313 > $@ || (rm -f $@ ; exit 1)
315 if ENABLE_SYMVERS_DARWIN
316 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
317 version_dep = libstdc++-symbols.explist
318 libstdc++-symbols.explist : libstdc++-symbols.ver \
319 ${glibcxx_srcdir}/scripts/make_exports.pl \
320 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
321 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
322 libstdc++-symbols.ver \
323 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
324 `echo $(libstdc___la_LIBADD) | \
325 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
326 > $@ || (rm -f $@ ; exit 1)
329 CLEANFILES += $(version_dep)
336 # Control additional build primary rules.
337 all-once: libstdc++convenience.la $(STAMP_DEBUG)
338 install-data-once: $(STAMP_INSTALL_DEBUG)
341 install-data-local: install-data-once
343 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
345 # Make a non-installed convenience library, so that --disable-static
347 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
348 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
349 if test ! -f .libs/libstdc++.a; then \
350 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
352 echo `date` > stamp-libstdc++convenience;
356 # 2 supra-convenience library
357 if GLIBCXX_BUILD_DEBUG
358 STAMP_DEBUG = build-debug
359 STAMP_INSTALL_DEBUG = install-debug
363 STAMP_INSTALL_DEBUG =
367 # Build a debug variant.
368 # Take care to fix all possibly-relative paths.
369 debugdir = ${glibcxx_builddir}/src/debug
371 if test ! -d ${debugdir} || test ! -f ${debugdir}/Makefile ; then \
372 mkdir -p ${debugdir}; \
373 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
375 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
376 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
377 -e 's/srcdir = \.\./srcdir = ..\/../' \
378 -e 's/VPATH = \.\./VPATH = ..\/../' \
379 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
380 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
381 < ../Makefile > Makefile ; \
382 for d in . $(SUBDIRS); do \
383 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
384 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
385 -e 's/srcdir = \.\./srcdir = ..\/../' \
386 -e 's/VPATH = \.\./VPATH = ..\/../' \
387 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
388 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
389 < ../$$d/Makefile > $$d/Makefile ; \
392 echo `date` > stamp-debug;
394 build-debug: stamp-debug
396 mv Makefile Makefile.tmp; \
397 sed -e 's,all-local: all-once,all-local:,' \
398 -e 's,install-data-local: install-data-once,install-data-local:,' \
399 -e '/vpath/!s,src/c,src/debug/c,' \
400 < Makefile.tmp > Makefile ; \
401 rm -f Makefile.tmp ; \
402 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
403 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
405 # Install debug library.
406 install-debug: build-debug
407 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
408 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;