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.
29 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
31 toolexeclib_LTLIBRARIES = libstdc++.la
37 $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
39 libvtv_la_SOURCES = vtv_stubs.cc
40 libvtv_la_LDFLAGS = $(lt_host_flags)
42 libvtv_la_AM_CXXFLAGS = \
43 $(glibcxx_compiler_pic_flag) \
45 -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
46 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
48 libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
49 $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
50 $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
53 vpath % $(top_srcdir)/src/c++98
54 vpath % $(top_srcdir)/src/c++11
56 if GLIBCXX_LDBL_COMPAT
57 ldbl_compat_sources = compatibility-ldbl.cc
63 parallel_compat_sources = \
64 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
69 compatibility-debug_list.cc \
70 compatibility-debug_list-2.cc \
71 ${ldbl_compat_sources}
74 compatibility-c++0x.cc \
75 compatibility-atomic-c++0x.cc \
76 compatibility-thread-c++0x.cc \
77 compatibility-chrono.cc \
78 compatibility-condvar.cc
80 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
82 libstdc___la_LIBADD = \
84 $(top_builddir)/libsupc++/libsupc++convenience.la \
85 $(top_builddir)/src/c++98/libc++98convenience.la \
86 $(top_builddir)/src/c++11/libc++11convenience.la
88 libstdc___la_DEPENDENCIES = \
90 $(top_builddir)/libsupc++/libsupc++convenience.la \
91 $(top_builddir)/src/c++98/libc++98convenience.la \
92 $(top_builddir)/src/c++11/libc++11convenience.la
94 libstdc___la_LDFLAGS = \
95 -version-info $(libtool_VERSION) ${version_arg} -lm
97 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
99 # Use special rules for compatibility-ldbl.cc compilation, as we need to
100 # pass -mlong-double-64.
101 if GLIBCXX_LDBL_COMPAT
102 compatibility-ldbl.lo: compatibility-ldbl.cc
103 $(LTCXXCOMPILE) -mlong-double-64 -c $<
104 compatibility-ldbl.o: compatibility-ldbl.cc
105 $(CXXCOMPILE) -mlong-double-64 -c $<
108 # Use special rules for C++11 files/objects.
109 compatibility-c++0x.lo: compatibility-c++0x.cc
110 $(LTCXXCOMPILE) -std=gnu++11 -c $<
111 compatibility-c++0x.o: compatibility-c++0x.cc
112 $(CXXCOMPILE) -std=gnu++11 -c $<
114 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
115 $(LTCXXCOMPILE) -std=gnu++11 -c $<
116 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
117 $(CXXCOMPILE) -std=gnu++11 -c $<
119 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
120 $(LTCXXCOMPILE) -std=gnu++11 -c $<
121 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
122 $(CXXCOMPILE) -std=gnu++11 -c $<
124 compatibility-chrono.lo: compatibility-chrono.cc
125 $(LTCXXCOMPILE) -std=gnu++11 -c $<
126 compatibility-chrono.o: compatibility-chrono.cc
127 $(CXXCOMPILE) -std=gnu++11 -c $<
129 compatibility-condvar.lo: compatibility-condvar.cc
130 $(LTCXXCOMPILE) -std=gnu++11 -c $<
131 compatibility-condvar.o: compatibility-condvar.cc
132 $(CXXCOMPILE) -std=gnu++11 -c $<
134 # A note on compatibility and static libraries.
136 # static lib == linked against only this version, should not need compat
137 # shared lib == linked against potentially all compat versions
139 # Thus, the shared libs have more compat symbols, which can be found
140 # segregated in the sources with -D_GLIBCXX_SHARED.
142 # In the sub-directories of libsupc++, src/c++98, src/c++11, only
143 # -prefer-pic objects are generated for the convenience libraries.
145 # In the main src directory, make shared and static objects just for
146 # the compat libraries. Shared objects are compiled with -prefer-pic
147 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
148 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
149 # the main src directory.
151 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
152 # because -fPIC is not harmful to use for objects destined for static
153 # libraries. In addition, using -fPIC will allow the use of static
154 # libstdc++.a in the creation of other C++ shared libraries.
156 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
157 # modified in a per-library or per-sub-library way. Need to manually
158 # set this option because CONFIG_CXXFLAGS has to be after
159 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
160 # as the occasion calls for it.
162 $(glibcxx_compiler_pic_flag) \
163 $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
164 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
168 # 1) In general, libtool expects an argument such as `--tag=CXX' when
169 # using the C++ compiler, because that will enable the settings
170 # detected when C++ support was being configured. However, when no
171 # such flag is given in the command line, libtool attempts to figure
172 # it out by matching the compiler name in each configuration section
173 # against a prefix of the command line. The problem is that, if the
174 # compiler name and its initial flags stored in the libtool
175 # configuration file don't match those in the command line, libtool
176 # can't decide which configuration to use, and it gives up. The
177 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
178 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
179 # attempt to infer which configuration to use.
181 # The second tag argument, `--tag disable-shared` means that libtool
182 # only compiles each source once, for static objects. In actuality,
183 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
184 # the libtool command that is used create the object, which is
185 # suitable for shared libraries. The `--tag disable-shared` must be
186 # placed after --tag CXX lest things CXX undo the affect of
189 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
190 # last. (That way, things like -O2 passed down from the toplevel can
191 # be overridden by --enable-debug and --enable-cxx-flags.)
193 $(LIBTOOL) --tag CXX \
194 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
195 --mode=compile $(CXX) $(INCLUDES) \
196 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
198 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
200 # 3) We'd have a problem when building the shared libstdc++ object if
201 # the rules automake generates would be used. We cannot allow g++ to
202 # be used since this would add -lstdc++ to the link line which of
203 # course is problematic at this point. So, we get the top-level
204 # directory to configure libstdc++-v3 to use gcc as the C++
205 # compilation driver.
207 $(LIBTOOL) --tag CXX \
208 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
210 $(VTV_CXXLINKFLAGS) \
211 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
213 # Symbol versioning for shared libraries.
215 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
216 $(port_specific_symbol_files)
217 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
219 if test "x$(port_specific_symbol_files)" != x; then \
220 if grep '^# Appended to version file.' \
221 $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
222 cat $(port_specific_symbol_files) >> $@.tmp; \
224 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
225 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
226 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
227 rm tmp.top tmp.bottom; \
230 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
231 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
234 CLEANFILES = libstdc++-symbols.ver
236 if ENABLE_SYMVERS_GNU
237 version_arg = -Wl,--version-script=libstdc++-symbols.ver
238 version_dep = libstdc++-symbols.ver
240 if ENABLE_SYMVERS_GNU_NAMESPACE
241 version_arg = -Wl,--version-script=libstdc++-symbols.ver
242 version_dep = libstdc++-symbols.ver
244 if ENABLE_SYMVERS_SUN
245 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
246 version_dep = libstdc++-symbols.ver-sun
247 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
248 $(toplevel_srcdir)/contrib/make_sunver.pl \
249 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
250 CXXFILT="$(CXXFILT)"; export CXXFILT; \
251 perl $(toplevel_srcdir)/contrib/make_sunver.pl \
252 libstdc++-symbols.ver \
253 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
254 `echo $(libstdc___la_LIBADD) | \
255 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
256 > $@ || (rm -f $@ ; exit 1)
258 if ENABLE_SYMVERS_DARWIN
259 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
260 version_dep = libstdc++-symbols.explist
261 libstdc++-symbols.explist : libstdc++-symbols.ver \
262 ${glibcxx_srcdir}/scripts/make_exports.pl \
263 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
264 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
265 libstdc++-symbols.ver \
266 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
267 `echo $(libstdc___la_LIBADD) | \
268 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
269 > $@ || (rm -f $@ ; exit 1)
272 CLEANFILES += $(version_dep)
279 # Control additional build primary rules.
280 all-once: libstdc++convenience.la $(STAMP_DEBUG)
281 install-data-once: $(STAMP_INSTALL_DEBUG)
284 install-data-local: install-data-once
286 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
288 # Make a non-installed convenience library, so that --disable-static
290 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
291 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
292 if test ! -f .libs/libstdc++.a; then \
293 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
295 echo `date` > stamp-libstdc++convenience;
299 # 2 supra-convenience library
300 if GLIBCXX_BUILD_DEBUG
301 STAMP_DEBUG = build-debug
302 STAMP_INSTALL_DEBUG = install-debug
306 STAMP_INSTALL_DEBUG =
310 # Build a debug variant.
311 # Take care to fix all possibly-relative paths.
312 debugdir = ${glibcxx_builddir}/src/debug
314 if test ! -d ${debugdir}; then \
315 mkdir -p ${debugdir}; \
316 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
318 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
319 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
320 -e 's/srcdir = \.\./srcdir = ..\/../' \
321 -e 's/VPATH = \.\./VPATH = ..\/../' \
322 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
323 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
324 < ../Makefile > Makefile ; \
325 for d in . $(SUBDIRS); do \
326 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
327 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
328 -e 's/srcdir = \.\./srcdir = ..\/../' \
329 -e 's/VPATH = \.\./VPATH = ..\/../' \
330 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
331 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
332 < ../$$d/Makefile > $$d/Makefile ; \
335 echo `date` > stamp-debug;
337 build-debug: stamp-debug
339 mv Makefile Makefile.tmp; \
340 sed -e 's,all-local: all-once,all-local:,' \
341 -e 's,install-data-local: install-data-once,install-data-local:,' \
342 -e '/vpath/!s,src/c,src/debug/c,' \
343 < Makefile.tmp > Makefile ; \
344 rm -f Makefile.tmp ; \
345 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
346 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
348 # Install debug library.
349 install-debug: build-debug
350 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
351 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;