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