]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/src/Makefile.am
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / src / Makefile.am
1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
2 ##
3 ## Copyright (C) 1997-2022 Free Software Foundation, Inc.
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
11 ## Free Software Foundation; either version 3, or (at your option)
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
20 ## with this library; see the file COPYING3. If not see
21 ## <http://www.gnu.org/licenses/>.
22
23 include $(top_srcdir)/fragment.am
24
25 if ENABLE_FILESYSTEM_TS
26 filesystem_dir = filesystem
27 else
28 filesystem_dir =
29 endif
30
31 ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
32 SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir)
33
34 # Cross compiler support.
35 if VTV_CYGMIN
36 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
37 else
38 toolexeclib_LTLIBRARIES = libstdc++.la
39 endif
40
41 if VTV_CYGMIN
42 vtv_stubs.cc:
43 rm -f $@
44 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
45
46 libvtv_la_SOURCES = vtv_stubs.cc
47 libvtv_la_LDFLAGS = $(lt_host_flags)
48
49 libvtv_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
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 $@
58 endif
59
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
66 endif
67
68 if GLIBCXX_LDBL_COMPAT
69 ldbl_compat_sources = compatibility-ldbl.cc
70 else
71 ldbl_compat_sources =
72 endif
73
74 if GLIBCXX_LDBL_ALT128_COMPAT
75 if ENABLE_DUAL_ABI
76 ldbl_alt128_compat_cxx11_sources = \
77 compatibility-ldbl-alt128-cxx11.cc
78 else
79 ldbl_alt128_compat_cxx11_sources =
80 endif
81 ldbl_alt128_compat_sources = \
82 compatibility-ldbl-alt128.cc \
83 ${ldbl_alt128_compat_cxx11_sources}
84 else
85 ldbl_alt128_compat_sources =
86 endif
87
88
89 parallel_compat_sources = \
90 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
91
92
93 cxx98_sources = \
94 compatibility.cc \
95 compatibility-debug_list.cc \
96 compatibility-debug_list-2.cc \
97 ${ldbl_compat_sources}
98
99 cxx11_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}
106
107 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
108
109 libstdc___la_LIBADD = \
110 $(GLIBCXX_LIBS) \
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
116
117 libstdc___la_DEPENDENCIES = \
118 ${version_dep} \
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
124
125 libstdc___la_LDFLAGS = \
126 -version-info $(libtool_VERSION) ${version_arg} -lm
127
128 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
129
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
134 LTCXXCOMPILE64 = \
135 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
136 CXXCOMPILE64 = \
137 $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
138 else
139 LTCXXCOMPILE64 = $(LTCXXCOMPILE)
140 CXXCOMPILE64 = $(CXXCOMPILE)
141 endif
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 $<
146 endif
147
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 $<
155 if ENABLE_DUAL_ABI
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 $<
160 endif
161 endif
162
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 $<
168
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 $<
173
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 $<
178
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 $<
183
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 $<
188
189 # A note on compatibility and static libraries.
190 #
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 #
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
199 # libraries.
200 #
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
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.
217 AM_CXXFLAGS_PRE = \
218 -std=gnu++98 \
219 $(glibcxx_compiler_pic_flag) \
220 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
221 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
222
223 AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
224
225 # Libtool notes
226
227 # 1) In general, libtool expects an argument such as `--tag=CXX' when
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
238 # attempt to infer which configuration to use.
239 #
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
248 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
249 # last. (That way, things like -O2 passed down from the toplevel can
250 # be overridden by --enable-debug and --enable-cxx-flags.)
251 LTCXXCOMPILE = \
252 $(LIBTOOL) --tag CXX \
253 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
254 --mode=compile $(CXX) $(INCLUDES) \
255 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
256
257 LTLDFLAGS = $(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.
265 CXXLINK = \
266 $(LIBTOOL) --tag CXX \
267 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
268 --mode=link $(CXX) \
269 $(VTV_CXXLINKFLAGS) \
270 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
271
272 # Symbol versioning for shared libraries.
273 if ENABLE_SYMVERS
274 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
275 $(port_specific_symbol_files)
276 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
277 chmod +w $@.tmp
278 if test "x$(port_specific_symbol_files)" != x; then \
279 if grep '^# Appended to version file.' \
280 $(port_specific_symbol_files) > /dev/null 2>&1; then \
281 cat $(port_specific_symbol_files) >> $@.tmp; \
282 else \
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; \
286 rm tmp.top tmp.bottom; \
287 fi; \
288 fi
289 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
290 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
291 rm -f $@.tmp
292
293 CLEANFILES = libstdc++-symbols.ver
294
295 if ENABLE_SYMVERS_GNU
296 version_arg = -Wl,--version-script=libstdc++-symbols.ver
297 version_dep = libstdc++-symbols.ver
298 endif
299 if ENABLE_SYMVERS_GNU_NAMESPACE
300 version_arg = -Wl,--version-script=libstdc++-symbols.ver
301 version_dep = libstdc++-symbols.ver
302 endif
303 if ENABLE_SYMVERS_SUN
304 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
305 version_dep = libstdc++-symbols.ver-sun
306 libstdc++-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) \
313 `echo ' $(libstdc___la_LIBADD) ' | \
314 sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
315 > $@ || (rm -f $@ ; exit 1)
316 endif
317 if ENABLE_SYMVERS_DARWIN
318 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
319 version_dep = libstdc++-symbols.explist
320 libstdc++-symbols.explist : libstdc++-symbols.ver \
321 ${glibcxx_srcdir}/scripts/make_exports.pl \
322 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
323 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
324 libstdc++-symbols.ver \
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)
329 endif
330
331 CLEANFILES += $(version_dep)
332 else
333 version_arg =
334 version_dep =
335 endif
336
337
338 # Control additional build primary rules.
339 all-once: libstdc++convenience.la $(STAMP_DEBUG)
340 install-data-once: $(STAMP_INSTALL_DEBUG)
341
342 all-local: all-once
343 install-data-local: install-data-once
344 clean-local:
345 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
346
347 # Make a non-installed convenience library, so that --disable-static
348 # may work.
349 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
350 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
351 if test ! -f .libs/libstdc++.a; then \
352 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
353 fi; \
354 echo `date` > stamp-libstdc++convenience;
355
356 # Added rules.
357 # 1 debug library
358 # 2 supra-convenience library
359 if GLIBCXX_BUILD_DEBUG
360 STAMP_DEBUG = build-debug
361 STAMP_INSTALL_DEBUG = install-debug
362 CLEAN_DEBUG = debug
363 else
364 STAMP_DEBUG =
365 STAMP_INSTALL_DEBUG =
366 CLEAN_DEBUG =
367 endif
368
369 # Build a debug variant.
370 # Take care to fix all possibly-relative paths.
371 debugdir = ${glibcxx_builddir}/src/debug
372 stamp-debug: Makefile $(foreach dir,$(SUBDIRS),$(dir)/Makefile)
373 if test ! -d ${debugdir} || test ! -f ${debugdir}/Makefile ; then \
374 mkdir -p ${debugdir}; \
375 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
376 (cd ${debugdir}; \
377 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
378 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
379 -e 's/srcdir = \.\./srcdir = ..\/../' \
380 -e 's/VPATH = \.\./VPATH = ..\/../' \
381 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
382 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
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) ; \
393 fi; \
394 echo `date` > stamp-debug;
395
396 build-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:,' \
401 -e '/vpath/!s,src/c,src/debug/c,' \
402 < Makefile.tmp > Makefile ; \
403 rm -f Makefile.tmp ; \
404 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
405 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
406
407 # Install debug library.
408 install-debug: build-debug
409 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
410 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;