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
55 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
57 libstdc___la_LIBADD = \
59 $(top_builddir)/libsupc++/libsupc++convenience.la \
60 $(top_builddir)/src/c++98/libc++98convenience.la \
61 $(top_builddir)/src/c++11/libc++11convenience.la
63 libstdc___la_DEPENDENCIES = \
65 $(top_builddir)/libsupc++/libsupc++convenience.la \
66 $(top_builddir)/src/c++98/libc++98convenience.la \
67 $(top_builddir)/src/c++11/libc++11convenience.la
69 libstdc___la_LDFLAGS = \
70 -version-info $(libtool_VERSION) ${version_arg} -lm
72 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
75 # Use special rules for compatibility-ldbl.cc compilation, as we need to
76 # pass -mlong-double-64.
77 if GLIBCXX_LDBL_COMPAT
78 compatibility-ldbl.lo: compatibility-ldbl.cc
79 $(LTCXXCOMPILE) -mlong-double-64 -c $<
80 compatibility-ldbl.o: compatibility-ldbl.cc
81 $(CXXCOMPILE) -mlong-double-64 -c $<
84 # Use special rules for C++11 files/objects.
85 compatibility-c++0x.lo: compatibility-c++0x.cc
86 $(LTCXXCOMPILE) -std=gnu++11 -c $<
87 compatibility-c++0x.o: compatibility-c++0x.cc
88 $(CXXCOMPILE) -std=gnu++11 -c $<
90 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
91 $(LTCXXCOMPILE) -std=gnu++11 -c $<
92 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
93 $(CXXCOMPILE) -std=gnu++11 -c $<
95 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
96 $(LTCXXCOMPILE) -std=gnu++11 -c $<
97 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
98 $(CXXCOMPILE) -std=gnu++11 -c $<
100 # A note on compatibility and static libraries.
102 # static lib == linked against only this version, should not need compat
103 # shared lib == linked against potentially all compat versions
105 # Thus, the shared libs have more compat symbols, which can be found
106 # segregated in the sources with -D_GLIBCXX_SHARED.
108 # In the sub-directories of libsupc++, src/c++98, src/c++11, only
109 # -prefer-pic objects are generated for the convenience libraries.
111 # In the main src directory, make shared and static objects just for
112 # the compat libraries. Shared objects are compiled with -prefer-pic
113 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
114 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
115 # the main src directory.
117 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
118 # because -fPIC is not harmful to use for objects destined for static
119 # libraries. In addition, using -fPIC will allow the use of static
120 # libstdc++.a in the creation of other C++ shared libraries.
122 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
123 # modified in a per-library or per-sub-library way. Need to manually
124 # set this option because CONFIG_CXXFLAGS has to be after
125 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
126 # as the occasion calls for it.
128 $(glibcxx_compiler_pic_flag) \
130 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
134 # 1) In general, libtool expects an argument such as `--tag=CXX' when
135 # using the C++ compiler, because that will enable the settings
136 # detected when C++ support was being configured. However, when no
137 # such flag is given in the command line, libtool attempts to figure
138 # it out by matching the compiler name in each configuration section
139 # against a prefix of the command line. The problem is that, if the
140 # compiler name and its initial flags stored in the libtool
141 # configuration file don't match those in the command line, libtool
142 # can't decide which configuration to use, and it gives up. The
143 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
144 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
145 # attempt to infer which configuration to use.
147 # The second tag argument, `--tag disable-shared` means that libtool
148 # only compiles each source once, for static objects. In actuality,
149 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
150 # the libtool command that is used create the object, which is
151 # suitable for shared libraries. The `--tag disable-shared` must be
152 # placed after --tag CXX lest things CXX undo the affect of
155 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
156 # last. (That way, things like -O2 passed down from the toplevel can
157 # be overridden by --enable-debug and --enable-cxx-flags.)
159 $(LIBTOOL) --tag CXX \
160 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
161 --mode=compile $(CXX) $(INCLUDES) \
162 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
164 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
166 # 3) We'd have a problem when building the shared libstdc++ object if
167 # the rules automake generates would be used. We cannot allow g++ to
168 # be used since this would add -lstdc++ to the link line which of
169 # course is problematic at this point. So, we get the top-level
170 # directory to configure libstdc++-v3 to use gcc as the C++
171 # compilation driver.
173 $(LIBTOOL) --tag CXX \
174 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
176 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
179 # Symbol versioning for shared libraries.
181 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
182 $(port_specific_symbol_files)
183 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
185 if test "x$(port_specific_symbol_files)" != x; then \
186 if grep '^# Appended to version file.' \
187 $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
188 cat $(port_specific_symbol_files) >> $@.tmp; \
190 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
191 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
192 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
193 rm tmp.top tmp.bottom; \
196 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
197 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
200 CLEANFILES = libstdc++-symbols.ver
202 if ENABLE_SYMVERS_GNU
203 version_arg = -Wl,--version-script=libstdc++-symbols.ver
204 version_dep = libstdc++-symbols.ver
206 if ENABLE_SYMVERS_GNU_NAMESPACE
207 version_arg = -Wl,--version-script=libstdc++-symbols.ver
208 version_dep = libstdc++-symbols.ver
210 if ENABLE_SYMVERS_SUN
211 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
212 version_dep = libstdc++-symbols.ver-sun
213 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
214 $(toplevel_srcdir)/contrib/make_sunver.pl \
215 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
216 CXXFILT="$(CXXFILT)"; export CXXFILT; \
217 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
218 libstdc++-symbols.ver \
219 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
220 `echo $(libstdc___la_LIBADD) | \
221 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
222 > $@ || (rm -f $@ ; exit 1)
224 if ENABLE_SYMVERS_DARWIN
225 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
226 version_dep = libstdc++-symbols.explist
227 libstdc++-symbols.explist : libstdc++-symbols.ver \
228 ${glibcxx_srcdir}/scripts/make_exports.pl \
229 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
230 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
231 libstdc++-symbols.ver \
232 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
233 `echo $(libstdc___la_LIBADD) | \
234 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
235 > $@ || (rm -f $@ ; exit 1)
238 CLEANFILES += $(version_dep)
245 # Control additional build primary rules.
246 all-once: libstdc++convenience.la $(STAMP_DEBUG)
247 install-data-once: $(STAMP_INSTALL_DEBUG)
250 install-data-local: install-data-once
252 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
254 # Make a non-installed convenience library, so that --disable-static
256 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
257 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
258 if test ! -f .libs/libstdc++.a; then \
259 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
261 echo `date` > stamp-libstdc++convenience;
265 # 2 supra-convenience library
266 if GLIBCXX_BUILD_DEBUG
267 STAMP_DEBUG = build-debug
268 STAMP_INSTALL_DEBUG = install-debug
272 STAMP_INSTALL_DEBUG =
276 # Build a debug variant.
277 # Take care to fix all possibly-relative paths.
278 debugdir = ${glibcxx_builddir}/src/debug
280 if test ! -d ${debugdir}; then \
281 mkdir -p ${debugdir}; \
282 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
284 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
285 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
286 -e 's/srcdir = \.\./srcdir = ..\/../' \
287 -e 's/VPATH = \.\./VPATH = ..\/../' \
288 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
289 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
290 < ../Makefile > Makefile ; \
291 for d in . $(SUBDIRS); do \
292 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
293 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
294 -e 's/srcdir = \.\./srcdir = ..\/../' \
295 -e 's/VPATH = \.\./VPATH = ..\/../' \
296 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
297 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
298 < ../$$d/Makefile > $$d/Makefile ; \
301 echo `date` > stamp-debug;
303 build-debug: stamp-debug
305 mv Makefile Makefile.tmp; \
306 sed -e 's,all-local: all-once,all-local:,' \
307 -e 's,install-data-local: install-data-once,install-data-local:,' \
308 -e '/vpath/!s,src/c,src/debug/c,' \
309 < Makefile.tmp > Makefile ; \
310 rm -f Makefile.tmp ; \
311 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
312 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
314 # Install debug library.
315 install-debug: build-debug
316 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
317 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;