Makefile.am revision 1.1.1.14
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
23include $(top_srcdir)/fragment.am
24
25if ENABLE_FILESYSTEM_TS
26filesystem_dir = filesystem
27else
28filesystem_dir =
29endif
30
31if ENABLE_BACKTRACE
32backtrace_dir = libbacktrace
33backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h
34else
35backtrace_dir =
36backtrace_supported_h =
37endif
38
39## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
40SUBDIRS = c++98 c++11 c++17 c++20 $(filesystem_dir) $(backtrace_dir)
41
42# Cross compiler support.
43if VTV_CYGMIN
44toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
45else
46toolexeclib_LTLIBRARIES = libstdc++.la
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
67
68vpath % $(top_srcdir)/src/c++98
69vpath % $(top_srcdir)/src/c++11
70vpath % $(top_srcdir)/src/c++17
71vpath % $(top_srcdir)/src/c++20
72if ENABLE_FILESYSTEM_TS
73vpath % $(top_srcdir)/src/filesystem
74endif
75if ENABLE_BACKTRACE
76vpath % $(top_srcdir)/src/libbacktrace
77endif
78
79if GLIBCXX_LDBL_COMPAT
80ldbl_compat_sources = compatibility-ldbl.cc
81else
82ldbl_compat_sources =
83endif
84
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
99
100parallel_compat_sources = \
101	compatibility-parallel_list.cc  compatibility-parallel_list-2.cc
102
103
104cxx98_sources = \
105	compatibility.cc \
106	compatibility-debug_list.cc \
107	compatibility-debug_list-2.cc \
108	${ldbl_compat_sources}
109
110cxx11_sources = \
111	compatibility-c++0x.cc \
112	compatibility-atomic-c++0x.cc \
113	compatibility-thread-c++0x.cc \
114	compatibility-chrono.cc \
115	compatibility-condvar.cc \
116	${ldbl_alt128_compat_sources}
117
118libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
119
120libstdc___la_LIBADD = \
121	$(GLIBCXX_LIBS) \
122	$(top_builddir)/libsupc++/libsupc++convenience.la \
123	$(top_builddir)/src/c++98/libc++98convenience.la \
124	$(top_builddir)/src/c++11/libc++11convenience.la \
125	$(top_builddir)/src/c++17/libc++17convenience.la \
126	$(top_builddir)/src/c++20/libc++20convenience.la
127
128libstdc___la_DEPENDENCIES = \
129	${version_dep} \
130	$(top_builddir)/libsupc++/libsupc++convenience.la \
131	$(top_builddir)/src/c++98/libc++98convenience.la \
132	$(top_builddir)/src/c++11/libc++11convenience.la \
133	$(top_builddir)/src/c++17/libc++17convenience.la \
134	$(top_builddir)/src/c++20/libc++20convenience.la
135
136libstdc___la_LDFLAGS = \
137	-version-info $(libtool_VERSION) ${version_arg} -lm
138
139libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
140
141# Use special rules for compatibility-ldbl.cc compilation, as we need to
142# pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
143if GLIBCXX_LDBL_COMPAT
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
153compatibility-ldbl.lo: compatibility-ldbl.cc
154	$(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
155compatibility-ldbl.o: compatibility-ldbl.cc
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
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
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
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
200# A note on compatibility and static libraries.
201#
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#
208# In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
209# src/c++20, only -prefer-pic objects are generated for the convenience
210# libraries.
211#
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
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.
228AM_CXXFLAGS_PRE = \
229	-std=gnu++98 \
230	$(glibcxx_compiler_pic_flag) \
231	$(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
232	$(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
233
234AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
235
236# Libtool notes
237
238# 1) In general, libtool expects an argument such as `--tag=CXX' when
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
249# attempt to infer which configuration to use.
250#
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
259# 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
260# last. (That way, things like -O2 passed down from the toplevel can
261# be overridden by --enable-debug and --enable-cxx-flags.)
262LTCXXCOMPILE = \
263	$(LIBTOOL) --tag CXX \
264	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
265	--mode=compile $(CXX) $(INCLUDES) \
266	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
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.
276CXXLINK = \
277	$(LIBTOOL) --tag CXX \
278	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
279	--mode=link $(CXX) \
280	$(VTV_CXXLINKFLAGS) \
281	$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
282	$(LTLDFLAGS) $(LTLIBICONV) \
283	-o $@
284
285# Symbol versioning for shared libraries.
286if ENABLE_SYMVERS
287libstdc++-symbols.ver:  ${glibcxx_srcdir}/$(SYMVER_FILE) \
288		$(port_specific_symbol_files)
289	cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
290	chmod +w $@.tmp
291	if test "x$(port_specific_symbol_files)" != x; then \
292	  if grep '^# Appended to version file.' \
293	       $(port_specific_symbol_files) > /dev/null 2>&1; then \
294	    cat $(port_specific_symbol_files) >> $@.tmp; \
295	  else \
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; \
299	    rm tmp.top tmp.bottom; \
300	  fi; \
301	fi
302	$(EGREP) -v '^[ 	]*#(#| |$$)' $@.tmp | \
303	  $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
304	rm -f $@.tmp
305
306CLEANFILES = libstdc++-symbols.ver
307
308if ENABLE_SYMVERS_GNU
309version_arg = -Wl,--version-script=libstdc++-symbols.ver
310version_dep = libstdc++-symbols.ver
311endif
312if ENABLE_SYMVERS_GNU_NAMESPACE
313version_arg = -Wl,--version-script=libstdc++-symbols.ver
314version_dep = libstdc++-symbols.ver
315endif
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) \
326	 `echo ' $(libstdc___la_LIBADD) ' | \
327	    sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
328	 > $@ || (rm -f $@ ; exit 1)
329endif
330if ENABLE_SYMVERS_DARWIN
331version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
332version_dep = libstdc++-symbols.explist
333libstdc++-symbols.explist : libstdc++-symbols.ver \
334		${glibcxx_srcdir}/scripts/make_exports.pl \
335		$(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
336	perl ${glibcxx_srcdir}/scripts/make_exports.pl \
337	  libstdc++-symbols.ver \
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)
342endif
343
344CLEANFILES += $(version_dep)
345else
346version_arg =
347version_dep =
348endif
349
350
351# Control additional build primary rules.
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)
359
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 \
365	  cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
366	fi; \
367	echo `date` > stamp-libstdc++convenience;
368
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
381
382# Build a debug variant.
383# Take care to fix all possibly-relative paths.
384debugdir = ${glibcxx_builddir}/src/debug
385stamp-debug: Makefile $(foreach dir,$(SUBDIRS),$(dir)/Makefile)
386	if test ! -d ${debugdir} || test ! -f ${debugdir}/Makefile ; then \
387	  mkdir -p ${debugdir}; \
388	  for d in $(SUBDIRS); do mkdir -p  ${debugdir}/$$d; done; \
389	  (cd ${debugdir}; \
390	  sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
391	      -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
392	      -e 's/srcdir = \.\./srcdir = ..\/../' \
393	      -e 's/VPATH = \.\./VPATH = ..\/../' \
394	      -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
395	      -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
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) ; \
406	fi; \
407	echo `date` > stamp-debug;
408
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)
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:,' \
422	      -e '/vpath/!s,src/c,src/debug/c,' \
423	  < Makefile.tmp > Makefile ; \
424	  rm -f Makefile.tmp ; \
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) ;
432