1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997-2015 Free Software Foundation, Inc.
5 ## This file is part of the libstdc++ version 3 distribution.
6 ## Process this file with automake to produce Makefile.in.
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)
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.
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/>.
23 include $(top_srcdir)/fragment.am
27 # Cross compiler support.
28 toolexeclib_LTLIBRARIES = libstdc++.la
30 vpath % $(top_srcdir)/src/c++98
31 vpath % $(top_srcdir)/src/c++11
33 if GLIBCXX_LDBL_COMPAT
34 ldbl_compat_sources = compatibility-ldbl.cc
40 parallel_compat_sources = \
41 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
46 compatibility-debug_list.cc \
47 compatibility-debug_list-2.cc \
48 ${ldbl_compat_sources}
51 compatibility-c++0x.cc \
52 compatibility-atomic-c++0x.cc \
53 compatibility-thread-c++0x.cc \
54 compatibility-chrono.cc \
55 compatibility-condvar.cc
57 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
59 libstdc___la_LIBADD = \
61 $(top_builddir)/libsupc++/libsupc++convenience.la \
62 $(top_builddir)/src/c++98/libc++98convenience.la \
63 $(top_builddir)/src/c++11/libc++11convenience.la
65 libstdc___la_DEPENDENCIES = \
67 $(top_builddir)/libsupc++/libsupc++convenience.la \
68 $(top_builddir)/src/c++98/libc++98convenience.la \
69 $(top_builddir)/src/c++11/libc++11convenience.la
71 libstdc___la_LDFLAGS = \
72 -version-info $(libtool_VERSION) ${version_arg} -lm
74 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
76 # Use special rules for compatibility-ldbl.cc compilation, as we need to
77 # pass -mlong-double-64.
78 if GLIBCXX_LDBL_COMPAT
79 compatibility-ldbl.lo: compatibility-ldbl.cc
80 $(LTCXXCOMPILE) -mlong-double-64 -c $<
81 compatibility-ldbl.o: compatibility-ldbl.cc
82 $(CXXCOMPILE) -mlong-double-64 -c $<
85 # Use special rules for C++11 files/objects.
86 compatibility-c++0x.lo: compatibility-c++0x.cc
87 $(LTCXXCOMPILE) -std=gnu++11 -c $<
88 compatibility-c++0x.o: compatibility-c++0x.cc
89 $(CXXCOMPILE) -std=gnu++11 -c $<
91 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
92 $(LTCXXCOMPILE) -std=gnu++11 -c $<
93 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
94 $(CXXCOMPILE) -std=gnu++11 -c $<
96 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
97 $(LTCXXCOMPILE) -std=gnu++11 -c $<
98 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
99 $(CXXCOMPILE) -std=gnu++11 -c $<
101 compatibility-chrono.lo: compatibility-chrono.cc
102 $(LTCXXCOMPILE) -std=gnu++11 -c $<
103 compatibility-chrono.o: compatibility-chrono.cc
104 $(CXXCOMPILE) -std=gnu++11 -c $<
106 compatibility-condvar.lo: compatibility-condvar.cc
107 $(LTCXXCOMPILE) -std=gnu++11 -c $<
108 compatibility-condvar.o: compatibility-condvar.cc
109 $(CXXCOMPILE) -std=gnu++11 -c $<
111 # A note on compatibility and static libraries.
113 # static lib == linked against only this version, should not need compat
114 # shared lib == linked against potentially all compat versions
116 # Thus, the shared libs have more compat symbols, which can be found
117 # segregated in the sources with -D_GLIBCXX_SHARED.
119 # In the sub-directories of libsupc++, src/c++98, src/c++11, only
120 # -prefer-pic objects are generated for the convenience libraries.
122 # In the main src directory, make shared and static objects just for
123 # the compat libraries. Shared objects are compiled with -prefer-pic
124 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
125 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
126 # the main src directory.
128 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
129 # because -fPIC is not harmful to use for objects destined for static
130 # libraries. In addition, using -fPIC will allow the use of static
131 # libstdc++.a in the creation of other C++ shared libraries.
133 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
134 # modified in a per-library or per-sub-library way. Need to manually
135 # set this option because CONFIG_CXXFLAGS has to be after
136 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
137 # as the occasion calls for it.
139 $(glibcxx_compiler_pic_flag) \
140 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
141 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
145 # 1) In general, libtool expects an argument such as `--tag=CXX' when
146 # using the C++ compiler, because that will enable the settings
147 # detected when C++ support was being configured. However, when no
148 # such flag is given in the command line, libtool attempts to figure
149 # it out by matching the compiler name in each configuration section
150 # against a prefix of the command line. The problem is that, if the
151 # compiler name and its initial flags stored in the libtool
152 # configuration file don't match those in the command line, libtool
153 # can't decide which configuration to use, and it gives up. The
154 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
155 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
156 # attempt to infer which configuration to use.
158 # The second tag argument, `--tag disable-shared` means that libtool
159 # only compiles each source once, for static objects. In actuality,
160 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
161 # the libtool command that is used create the object, which is
162 # suitable for shared libraries. The `--tag disable-shared` must be
163 # placed after --tag CXX lest things CXX undo the affect of
166 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
167 # last. (That way, things like -O2 passed down from the toplevel can
168 # be overridden by --enable-debug and --enable-cxx-flags.)
170 $(LIBTOOL) --tag CXX \
171 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
172 --mode=compile $(CXX) $(INCLUDES) \
173 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
175 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
177 # 3) We'd have a problem when building the shared libstdc++ object if
178 # the rules automake generates would be used. We cannot allow g++ to
179 # be used since this would add -lstdc++ to the link line which of
180 # course is problematic at this point. So, we get the top-level
181 # directory to configure libstdc++-v3 to use gcc as the C++
182 # compilation driver.
184 $(LIBTOOL) --tag CXX \
185 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
187 $(VTV_CXXLINKFLAGS) \
188 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
190 # Symbol versioning for shared libraries.
192 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
193 $(port_specific_symbol_files)
194 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
196 if test "x$(port_specific_symbol_files)" != x; then \
197 if grep '^# Appended to version file.' \
198 $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
199 cat $(port_specific_symbol_files) >> $@.tmp; \
201 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
202 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
203 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
204 rm tmp.top tmp.bottom; \
207 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
208 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
211 CLEANFILES = libstdc++-symbols.ver
213 if ENABLE_SYMVERS_GNU
214 version_arg = -Wl,--version-script=libstdc++-symbols.ver
215 version_dep = libstdc++-symbols.ver
217 if ENABLE_SYMVERS_GNU_NAMESPACE
218 version_arg = -Wl,--version-script=libstdc++-symbols.ver
219 version_dep = libstdc++-symbols.ver
221 if ENABLE_SYMVERS_SUN
222 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
223 version_dep = libstdc++-symbols.ver-sun
224 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
225 $(toplevel_srcdir)/contrib/make_sunver.pl \
226 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
227 CXXFILT="$(CXXFILT)"; export CXXFILT; \
228 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
229 libstdc++-symbols.ver \
230 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
231 `echo $(libstdc___la_LIBADD) | \
232 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
233 > $@ || (rm -f $@ ; exit 1)
235 if ENABLE_SYMVERS_DARWIN
236 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
237 version_dep = libstdc++-symbols.explist
238 libstdc++-symbols.explist : libstdc++-symbols.ver \
239 ${glibcxx_srcdir}/scripts/make_exports.pl \
240 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
241 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
242 libstdc++-symbols.ver \
243 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
244 `echo $(libstdc___la_LIBADD) | \
245 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
246 > $@ || (rm -f $@ ; exit 1)
249 CLEANFILES += $(version_dep)
256 # Control additional build primary rules.
257 all-once: libstdc++convenience.la $(STAMP_DEBUG)
258 install-data-once: $(STAMP_INSTALL_DEBUG)
261 install-data-local: install-data-once
263 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
265 # Make a non-installed convenience library, so that --disable-static
267 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
268 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
269 if test ! -f .libs/libstdc++.a; then \
270 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
272 echo `date` > stamp-libstdc++convenience;
276 # 2 supra-convenience library
277 if GLIBCXX_BUILD_DEBUG
278 STAMP_DEBUG = build-debug
279 STAMP_INSTALL_DEBUG = install-debug
283 STAMP_INSTALL_DEBUG =
287 # Build a debug variant.
288 # Take care to fix all possibly-relative paths.
289 debugdir = ${glibcxx_builddir}/src/debug
291 if test ! -d ${debugdir}; then \
292 mkdir -p ${debugdir}; \
293 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
295 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
296 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
297 -e 's/srcdir = \.\./srcdir = ..\/../' \
298 -e 's/VPATH = \.\./VPATH = ..\/../' \
299 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
300 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
301 < ../Makefile > Makefile ; \
302 for d in . $(SUBDIRS); do \
303 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
304 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
305 -e 's/srcdir = \.\./srcdir = ..\/../' \
306 -e 's/VPATH = \.\./VPATH = ..\/../' \
307 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
308 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
309 < ../$$d/Makefile > $$d/Makefile ; \
312 echo `date` > stamp-debug;
314 build-debug: stamp-debug
316 mv Makefile Makefile.tmp; \
317 sed -e 's,all-local: all-once,all-local:,' \
318 -e 's,install-data-local: install-data-once,install-data-local:,' \
319 -e '/vpath/!s,src/c,src/debug/c,' \
320 < Makefile.tmp > Makefile ; \
321 rm -f Makefile.tmp ; \
322 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
323 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
325 # Install debug library.
326 install-debug: build-debug
327 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
328 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;