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