1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997-2013 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
56 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
58 libstdc___la_LIBADD = \
60 $(top_builddir)/libsupc++/libsupc++convenience.la \
61 $(top_builddir)/src/c++98/libc++98convenience.la \
62 $(top_builddir)/src/c++11/libc++11convenience.la
64 libstdc___la_DEPENDENCIES = \
66 $(top_builddir)/libsupc++/libsupc++convenience.la \
67 $(top_builddir)/src/c++98/libc++98convenience.la \
68 $(top_builddir)/src/c++11/libc++11convenience.la
70 libstdc___la_LDFLAGS = \
71 -version-info $(libtool_VERSION) ${version_arg} -lm
73 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 # A note on compatibility and static libraries.
108 # static lib == linked against only this version, should not need compat
109 # shared lib == linked against potentially all compat versions
111 # Thus, the shared libs have more compat symbols, which can be found
112 # segregated in the sources with -D_GLIBCXX_SHARED.
114 # In the sub-directories of libsupc++, src/c++98, src/c++11, only
115 # -prefer-pic objects are generated for the convenience libraries.
117 # In the main src directory, make shared and static objects just for
118 # the compat libraries. Shared objects are compiled with -prefer-pic
119 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
120 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
121 # the main src directory.
123 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
124 # because -fPIC is not harmful to use for objects destined for static
125 # libraries. In addition, using -fPIC will allow the use of static
126 # libstdc++.a in the creation of other C++ shared libraries.
128 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
129 # modified in a per-library or per-sub-library way. Need to manually
130 # set this option because CONFIG_CXXFLAGS has to be after
131 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
132 # as the occasion calls for it.
134 $(glibcxx_compiler_pic_flag) \
136 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
140 # 1) In general, libtool expects an argument such as `--tag=CXX' when
141 # using the C++ compiler, because that will enable the settings
142 # detected when C++ support was being configured. However, when no
143 # such flag is given in the command line, libtool attempts to figure
144 # it out by matching the compiler name in each configuration section
145 # against a prefix of the command line. The problem is that, if the
146 # compiler name and its initial flags stored in the libtool
147 # configuration file don't match those in the command line, libtool
148 # can't decide which configuration to use, and it gives up. The
149 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
150 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
151 # attempt to infer which configuration to use.
153 # The second tag argument, `--tag disable-shared` means that libtool
154 # only compiles each source once, for static objects. In actuality,
155 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
156 # the libtool command that is used create the object, which is
157 # suitable for shared libraries. The `--tag disable-shared` must be
158 # placed after --tag CXX lest things CXX undo the affect of
161 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
162 # last. (That way, things like -O2 passed down from the toplevel can
163 # be overridden by --enable-debug and --enable-cxx-flags.)
165 $(LIBTOOL) --tag CXX \
166 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
167 --mode=compile $(CXX) $(INCLUDES) \
168 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
170 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
172 # 3) We'd have a problem when building the shared libstdc++ object if
173 # the rules automake generates would be used. We cannot allow g++ to
174 # be used since this would add -lstdc++ to the link line which of
175 # course is problematic at this point. So, we get the top-level
176 # directory to configure libstdc++-v3 to use gcc as the C++
177 # compilation driver.
179 $(LIBTOOL) --tag CXX \
180 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
182 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
185 # Symbol versioning for shared libraries.
187 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
188 $(port_specific_symbol_files)
189 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
191 if test "x$(port_specific_symbol_files)" != x; then \
192 if grep '^# Appended to version file.' \
193 $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
194 cat $(port_specific_symbol_files) >> $@.tmp; \
196 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
197 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
198 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
199 rm tmp.top tmp.bottom; \
202 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
203 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
206 CLEANFILES = libstdc++-symbols.ver
208 if ENABLE_SYMVERS_GNU
209 version_arg = -Wl,--version-script=libstdc++-symbols.ver
210 version_dep = libstdc++-symbols.ver
212 if ENABLE_SYMVERS_GNU_NAMESPACE
213 version_arg = -Wl,--version-script=libstdc++-symbols.ver
214 version_dep = libstdc++-symbols.ver
216 if ENABLE_SYMVERS_SUN
217 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
218 version_dep = libstdc++-symbols.ver-sun
219 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
220 $(toplevel_srcdir)/contrib/make_sunver.pl \
221 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
222 CXXFILT="$(CXXFILT)"; export CXXFILT; \
223 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
224 libstdc++-symbols.ver \
225 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
226 `echo $(libstdc___la_LIBADD) | \
227 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
228 > $@ || (rm -f $@ ; exit 1)
230 if ENABLE_SYMVERS_DARWIN
231 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
232 version_dep = libstdc++-symbols.explist
233 libstdc++-symbols.explist : libstdc++-symbols.ver \
234 ${glibcxx_srcdir}/scripts/make_exports.pl \
235 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
236 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
237 libstdc++-symbols.ver \
238 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
239 `echo $(libstdc___la_LIBADD) | \
240 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
241 > $@ || (rm -f $@ ; exit 1)
244 CLEANFILES += $(version_dep)
251 # Control additional build primary rules.
252 all-once: libstdc++convenience.la $(STAMP_DEBUG)
253 install-data-once: $(STAMP_INSTALL_DEBUG)
256 install-data-local: install-data-once
258 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
260 # Make a non-installed convenience library, so that --disable-static
262 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
263 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
264 if test ! -f .libs/libstdc++.a; then \
265 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
267 echo `date` > stamp-libstdc++convenience;
271 # 2 supra-convenience library
272 if GLIBCXX_BUILD_DEBUG
273 STAMP_DEBUG = build-debug
274 STAMP_INSTALL_DEBUG = install-debug
278 STAMP_INSTALL_DEBUG =
282 # Build a debug variant.
283 # Take care to fix all possibly-relative paths.
284 debugdir = ${glibcxx_builddir}/src/debug
286 if test ! -d ${debugdir}; then \
287 mkdir -p ${debugdir}; \
288 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
290 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
291 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
292 -e 's/srcdir = \.\./srcdir = ..\/../' \
293 -e 's/VPATH = \.\./VPATH = ..\/../' \
294 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
295 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
296 < ../Makefile > Makefile ; \
297 for d in . $(SUBDIRS); do \
298 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
299 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
300 -e 's/srcdir = \.\./srcdir = ..\/../' \
301 -e 's/VPATH = \.\./VPATH = ..\/../' \
302 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
303 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
304 < ../$$d/Makefile > $$d/Makefile ; \
307 echo `date` > stamp-debug;
309 build-debug: stamp-debug
311 mv Makefile Makefile.tmp; \
312 sed -e 's,all-local: all-once,all-local:,' \
313 -e 's,install-data-local: install-data-once,install-data-local:,' \
314 -e '/vpath/!s,src/c,src/debug/c,' \
315 < Makefile.tmp > Makefile ; \
316 rm -f Makefile.tmp ; \
317 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
318 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
320 # Install debug library.
321 install-debug: build-debug
322 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
323 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;