]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/src/Makefile.am
libstdc++: Disable building additional archives for freestanding
[thirdparty/gcc.git] / libstdc++-v3 / src / Makefile.am
CommitLineData
8bae34da 1## Makefile for the C++11 sources of the GNU C++ Standard library.
b2dad0e3 2##
83ffe9cd 3## Copyright (C) 1997-2023 Free Software Foundation, Inc.
b2dad0e3
BK
4##
5## This file is part of the libstdc++ version 3 distribution.
6## Process this file with automake to produce Makefile.in.
7
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
748086b7 11## Free Software Foundation; either version 3, or (at your option)
b2dad0e3
BK
12## any later version.
13
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.
18
19## You should have received a copy of the GNU General Public License along
748086b7
JJ
20## with this library; see the file COPYING3. If not see
21## <http://www.gnu.org/licenses/>.
b2dad0e3 22
0df3f383 23include $(top_srcdir)/fragment.am
ae9dc931 24
fb8e29a5 25if GLIBCXX_HOSTED
0ca7ba9a
JW
26if ENABLE_FILESYSTEM_TS
27filesystem_dir = filesystem
28else
29filesystem_dir =
30endif
31
3acb929c
JW
32if ENABLE_BACKTRACE
33backtrace_dir = libbacktrace
34else
35backtrace_dir =
36endif
37
fb8e29a5
JW
38experimental_dir = experimental
39else
40filesystem_dir =
41backtrace_dir =
42experimental_dir =
43endif
44
a9d49e96 45## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
fb8e29a5 46SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) $(backtrace_dir) $(experimental_dir)
8bae34da 47
714e9334 48# Cross compiler support.
f7f049fa
CT
49if VTV_CYGMIN
50toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
51else
b2dad0e3 52toolexeclib_LTLIBRARIES = libstdc++.la
f7f049fa
CT
53endif
54
55if VTV_CYGMIN
56vtv_stubs.cc:
57 rm -f $@
58 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
59
60libvtv_la_SOURCES = vtv_stubs.cc
61libvtv_la_LDFLAGS = $(lt_host_flags)
62
63libvtv_la_AM_CXXFLAGS = \
64 $(glibcxx_compiler_pic_flag) \
65 $(XTEMPLATE_FLAGS) \
66 -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
67 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
68
69libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
70 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
71 $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
72endif
b2dad0e3 73
0b284728
BK
74vpath % $(top_srcdir)/src/c++98
75vpath % $(top_srcdir)/src/c++11
dfaa3c47 76vpath % $(top_srcdir)/src/c++17
a0e4d7b4 77vpath % $(top_srcdir)/src/c++20
0ca7ba9a
JW
78if ENABLE_FILESYSTEM_TS
79vpath % $(top_srcdir)/src/filesystem
80endif
3acb929c
JW
81if ENABLE_BACKTRACE
82vpath % $(top_srcdir)/src/libbacktrace
83endif
ea63396f 84vpath % $(top_srcdir)/src/experimental
8bae34da 85
0b284728
BK
86if GLIBCXX_LDBL_COMPAT
87ldbl_compat_sources = compatibility-ldbl.cc
88else
89ldbl_compat_sources =
90endif
91
7c1e7eed
JW
92if GLIBCXX_LDBL_ALT128_COMPAT
93if ENABLE_DUAL_ABI
94ldbl_alt128_compat_cxx11_sources = \
95 compatibility-ldbl-alt128-cxx11.cc
96else
97ldbl_alt128_compat_cxx11_sources =
98endif
99ldbl_alt128_compat_sources = \
100 compatibility-ldbl-alt128.cc \
101 ${ldbl_alt128_compat_cxx11_sources}
102else
103ldbl_alt128_compat_sources =
104endif
105
357d6fcd
JW
106if ENABLE_SYMVERS_GNU_NAMESPACE
107cxx0x_compat_sources =
108else
109cxx0x_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
115endif
495de4f4 116
0b284728
BK
117parallel_compat_sources = \
118 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
495de4f4 119
0b284728
BK
120
121cxx98_sources = \
122 compatibility.cc \
123 compatibility-debug_list.cc \
124 compatibility-debug_list-2.cc \
f92ab29f 125 ${ldbl_compat_sources}
0b284728
BK
126
127cxx11_sources = \
357d6fcd 128 ${cxx0x_compat_sources} \
7c1e7eed 129 ${ldbl_alt128_compat_sources}
0b284728
BK
130
131libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
8bae34da
BK
132
133libstdc___la_LIBADD = \
134 $(GLIBCXX_LIBS) \
135 $(top_builddir)/libsupc++/libsupc++convenience.la \
136 $(top_builddir)/src/c++98/libc++98convenience.la \
dfaa3c47 137 $(top_builddir)/src/c++11/libc++11convenience.la \
a0e4d7b4
TR
138 $(top_builddir)/src/c++17/libc++17convenience.la \
139 $(top_builddir)/src/c++20/libc++20convenience.la
8bae34da
BK
140
141libstdc___la_DEPENDENCIES = \
142 ${version_dep} \
143 $(top_builddir)/libsupc++/libsupc++convenience.la \
144 $(top_builddir)/src/c++98/libc++98convenience.la \
dfaa3c47 145 $(top_builddir)/src/c++11/libc++11convenience.la \
a0e4d7b4
TR
146 $(top_builddir)/src/c++17/libc++17convenience.la \
147 $(top_builddir)/src/c++20/libc++20convenience.la
8bae34da
BK
148
149libstdc___la_LDFLAGS = \
150 -version-info $(libtool_VERSION) ${version_arg} -lm
151
08fca4df 152libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
8bae34da 153
0b284728 154# Use special rules for compatibility-ldbl.cc compilation, as we need to
7c1e7eed 155# pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
0b284728 156if GLIBCXX_LDBL_COMPAT
7c1e7eed
JW
157if GLIBCXX_LDBL_ALT128_COMPAT
158LTCXXCOMPILE64 = \
159 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
160CXXCOMPILE64 = \
161 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
162else
163LTCXXCOMPILE64 = $(LTCXXCOMPILE)
164CXXCOMPILE64 = $(CXXCOMPILE)
165endif
0b284728 166compatibility-ldbl.lo: compatibility-ldbl.cc
7c1e7eed 167 $(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
0b284728 168compatibility-ldbl.o: compatibility-ldbl.cc
7c1e7eed
JW
169 $(CXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
170endif
171
172# Use special rules for compatibility-ldbl-alt128.cc compilation, as we need to
173# ensure it is compiled with the correct flag.
174if GLIBCXX_LDBL_ALT128_COMPAT
175compatibility-ldbl-alt128.lo: compatibility-ldbl-alt128.cc
176 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
177compatibility-ldbl-alt128.o: compatibility-ldbl-alt128.cc
178 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
179if ENABLE_DUAL_ABI
180compatibility-ldbl-alt128-cxx11.lo: compatibility-ldbl-alt128-cxx11.cc
181 $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
182compatibility-ldbl-alt128-cxx11.o: compatibility-ldbl-alt128-cxx11.cc
183 $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
184endif
0b284728
BK
185endif
186
187# Use special rules for C++11 files/objects.
188compatibility-c++0x.lo: compatibility-c++0x.cc
189 $(LTCXXCOMPILE) -std=gnu++11 -c $<
190compatibility-c++0x.o: compatibility-c++0x.cc
191 $(CXXCOMPILE) -std=gnu++11 -c $<
192
193compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
194 $(LTCXXCOMPILE) -std=gnu++11 -c $<
195compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
196 $(CXXCOMPILE) -std=gnu++11 -c $<
197
198compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
199 $(LTCXXCOMPILE) -std=gnu++11 -c $<
200compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
201 $(CXXCOMPILE) -std=gnu++11 -c $<
202
2e8a9734
JJ
203compatibility-chrono.lo: compatibility-chrono.cc
204 $(LTCXXCOMPILE) -std=gnu++11 -c $<
205compatibility-chrono.o: compatibility-chrono.cc
206 $(CXXCOMPILE) -std=gnu++11 -c $<
207
3429db0f
JW
208compatibility-condvar.lo: compatibility-condvar.cc
209 $(LTCXXCOMPILE) -std=gnu++11 -c $<
210compatibility-condvar.o: compatibility-condvar.cc
211 $(CXXCOMPILE) -std=gnu++11 -c $<
212
ac6d1200 213# A note on compatibility and static libraries.
f92ab29f 214#
ac6d1200
BK
215# static lib == linked against only this version, should not need compat
216# shared lib == linked against potentially all compat versions
217#
218# Thus, the shared libs have more compat symbols, which can be found
219# segregated in the sources with -D_GLIBCXX_SHARED.
220#
dfaa3c47 221# In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
a0e4d7b4
TR
222# src/c++20, only -prefer-pic objects are generated for the convenience
223# libraries.
f92ab29f 224#
ac6d1200
BK
225# In the main src directory, make shared and static objects just for
226# the compat libraries. Shared objects are compiled with -prefer-pic
227# -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
228# compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
229# the main src directory.
230#
231# Why are objects destined for libstdc++.a compiled with -fPIC? First,
232# because -fPIC is not harmful to use for objects destined for static
233# libraries. In addition, using -fPIC will allow the use of static
234# libstdc++.a in the creation of other C++ shared libraries.
235
236# AM_CXXFLAGS needs to be in each sub-directory so that it can be
8bae34da
BK
237# modified in a per-library or per-sub-library way. Need to manually
238# set this option because CONFIG_CXXFLAGS has to be after
239# OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
240# as the occasion calls for it.
c2be8205 241AM_CXXFLAGS_PRE = \
6cd9cb89 242 -std=gnu++98 \
ac6d1200 243 $(glibcxx_compiler_pic_flag) \
2077db1b 244 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
0b284728 245 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
8bae34da 246
c2be8205
CT
247AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
248
0b284728 249# Libtool notes
8bae34da 250
ac6d1200 251# 1) In general, libtool expects an argument such as `--tag=CXX' when
8bae34da
BK
252# using the C++ compiler, because that will enable the settings
253# detected when C++ support was being configured. However, when no
254# such flag is given in the command line, libtool attempts to figure
255# it out by matching the compiler name in each configuration section
256# against a prefix of the command line. The problem is that, if the
257# compiler name and its initial flags stored in the libtool
258# configuration file don't match those in the command line, libtool
259# can't decide which configuration to use, and it gives up. The
260# correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
261# CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
ac6d1200 262# attempt to infer which configuration to use.
f92ab29f 263#
ac6d1200
BK
264# The second tag argument, `--tag disable-shared` means that libtool
265# only compiles each source once, for static objects. In actuality,
266# glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
267# the libtool command that is used create the object, which is
268# suitable for shared libraries. The `--tag disable-shared` must be
269# placed after --tag CXX lest things CXX undo the affect of
270# disable-shared.
271
b1d6986c 272# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
ac6d1200 273# last. (That way, things like -O2 passed down from the toplevel can
b1d6986c 274# be overridden by --enable-debug and --enable-cxx-flags.)
0b284728
BK
275LTCXXCOMPILE = \
276 $(LIBTOOL) --tag CXX \
277 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
278 --mode=compile $(CXX) $(INCLUDES) \
b1d6986c 279 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
8bae34da
BK
280
281LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
282
283# 3) We'd have a problem when building the shared libstdc++ object if
284# the rules automake generates would be used. We cannot allow g++ to
285# be used since this would add -lstdc++ to the link line which of
286# course is problematic at this point. So, we get the top-level
287# directory to configure libstdc++-v3 to use gcc as the C++
288# compilation driver.
0b284728
BK
289CXXLINK = \
290 $(LIBTOOL) --tag CXX \
291 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
292 --mode=link $(CXX) \
2077db1b 293 $(VTV_CXXLINKFLAGS) \
c644b7df
JW
294 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
295 $(LTLDFLAGS) $(LTLIBICONV) \
296 -o $@
0b284728 297
6aa43d99 298# Symbol versioning for shared libraries.
fb5c309d
BK
299if ENABLE_SYMVERS
300libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
f9314d01 301 $(port_specific_symbol_files)
cc2de92d
RO
302 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
303 chmod +w $@.tmp
0df3f383 304 if test "x$(port_specific_symbol_files)" != x; then \
6defecc2 305 if grep '^# Appended to version file.' \
49a52ebc 306 $(port_specific_symbol_files) > /dev/null 2>&1; then \
cc2de92d 307 cat $(port_specific_symbol_files) >> $@.tmp; \
6defecc2 308 else \
cc2de92d
RO
309 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
310 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
311 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
6defecc2
JJ
312 rm tmp.top tmp.bottom; \
313 fi; \
e6b7a69a 314 fi
9396206b 315 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
d392c399 316 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
cc2de92d 317 rm -f $@.tmp
f9314d01 318
c18dc5cc
RO
319CLEANFILES = libstdc++-symbols.ver
320
f9314d01 321if ENABLE_SYMVERS_GNU
fb5c309d
BK
322version_arg = -Wl,--version-script=libstdc++-symbols.ver
323version_dep = libstdc++-symbols.ver
324endif
3cbc7af0
BK
325if ENABLE_SYMVERS_GNU_NAMESPACE
326version_arg = -Wl,--version-script=libstdc++-symbols.ver
327version_dep = libstdc++-symbols.ver
328endif
c18dc5cc
RO
329if ENABLE_SYMVERS_SUN
330version_arg = -Wl,-M,libstdc++-symbols.ver-sun
331version_dep = libstdc++-symbols.ver-sun
332libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
333 $(toplevel_srcdir)/contrib/make_sunver.pl \
334 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
335 CXXFILT="$(CXXFILT)"; export CXXFILT; \
336 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
337 libstdc++-symbols.ver \
338 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
b2099e9f
JW
339 `echo ' $(libstdc___la_LIBADD) ' | \
340 sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
c18dc5cc
RO
341 > $@ || (rm -f $@ ; exit 1)
342endif
fb5c309d
BK
343if ENABLE_SYMVERS_DARWIN
344version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
345version_dep = libstdc++-symbols.explist
346libstdc++-symbols.explist : libstdc++-symbols.ver \
a9fdd472
GK
347 ${glibcxx_srcdir}/scripts/make_exports.pl \
348 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
349 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
fb5c309d 350 libstdc++-symbols.ver \
a9fdd472
GK
351 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
352 `echo $(libstdc___la_LIBADD) | \
353 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
354 > $@ || (rm -f $@ ; exit 1)
fb5c309d 355endif
c18dc5cc
RO
356
357CLEANFILES += $(version_dep)
a9fdd472 358else
6aa43d99 359version_arg =
7b865c36 360version_dep =
6aa43d99
BK
361endif
362
56378d0e
BK
363
364# Control additional build primary rules.
56378d0e
BK
365all-once: libstdc++convenience.la $(STAMP_DEBUG)
366install-data-once: $(STAMP_INSTALL_DEBUG)
367
368all-local: all-once
369install-data-local: install-data-once
370clean-local:
371 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
6aa43d99 372
8bae34da
BK
373# Make a non-installed convenience library, so that --disable-static
374# may work.
375libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
376 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
377 if test ! -f .libs/libstdc++.a; then \
a7a790e9
BK
378 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
379 fi; \
ba755148 380 date > stamp-libstdc++convenience;
8bae34da 381
56378d0e
BK
382# Added rules.
383# 1 debug library
384# 2 supra-convenience library
385if GLIBCXX_BUILD_DEBUG
386STAMP_DEBUG = build-debug
387STAMP_INSTALL_DEBUG = install-debug
388CLEAN_DEBUG = debug
389else
390STAMP_DEBUG =
391STAMP_INSTALL_DEBUG =
392CLEAN_DEBUG =
393endif
6aa43d99 394
56378d0e 395# Build a debug variant.
ba755148 396
8d03ad01 397# Take care to fix all possibly-relative paths.
ba755148
JW
398debug/%/Makefile: %/Makefile
399 $(MKDIR_P) $(dir $@)
400 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
401 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
402 -e 's/srcdir = \.\./srcdir = ..\/../' \
403 -e 's/VPATH = \.\./VPATH = ..\/../' \
404 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
405 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
406 < $< > $@
407
408stamp-debug: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
409 mv debug/Makefile debug/Makefile.tmp
410 sed -e 's,all-local: all-once,all-local:,' \
411 -e 's,install-data-local: install-data-once,install-data-local:,' \
412 -e '/vpath/!s,src/c,src/debug/c,' \
413 < debug/Makefile.tmp > debug/Makefile
414 rm -f debug/Makefile.tmp
415 date > stamp-debug;
416
417.SECONDARY: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
6aa43d99 418
6a26ad67 419if ENABLE_BACKTRACE
ba755148
JW
420backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h
421debug_backtrace_supported_h = debug/$(backtrace_supported_h)
422$(debug_backtrace_supported_h): $(backtrace_supported_h) stamp-debug
6a26ad67 423 cp $< $@
6a26ad67
JW
424else
425debug_backtrace_supported_h =
426endif
427
428build-debug: stamp-debug $(debug_backtrace_supported_h)
ba755148
JW
429 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
430 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all
56378d0e
BK
431
432# Install debug library.
433install-debug: build-debug
3c672179
BRF
434 $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
435 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install