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