1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
3 ## Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4 ## 2006, 2007, 2008, 2009, 2010, 2011, 2012
5 ## Free Software Foundation, Inc.
7 ## This file is part of the libstdc++ version 3 distribution.
8 ## Process this file with automake to produce Makefile.in.
10 ## This file is part of the GNU ISO C++ Library. This library is free
11 ## software; you can redistribute it and/or modify it under the
12 ## terms of the GNU General Public License as published by the
13 ## Free Software Foundation; either version 3, or (at your option)
16 ## This library is distributed in the hope that it will be useful,
17 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ## GNU General Public License for more details.
21 ## You should have received a copy of the GNU General Public License along
22 ## with this library; see the file COPYING3. If not see
23 ## <http://www.gnu.org/licenses/>.
25 include $(top_srcdir)/fragment.am
29 # Cross compiler support.
30 toolexeclib_LTLIBRARIES = libstdc++.la
32 vpath % $(top_srcdir)/src/c++98
33 vpath % $(top_srcdir)/src/c++11
35 if GLIBCXX_LDBL_COMPAT
36 ldbl_compat_sources = compatibility-ldbl.cc
42 parallel_compat_sources = \
43 compatibility-parallel_list.cc compatibility-parallel_list-2.cc
45 parallel_compat_sources =
50 compatibility-debug_list.cc \
51 compatibility-debug_list-2.cc \
52 compatibility-list.cc \
53 compatibility-list-2.cc \
54 ${ldbl_compat_sources} \
55 ${parallel_compat_sources}
58 compatibility-c++0x.cc \
59 compatibility-atomic-c++0x.cc \
60 compatibility-thread-c++0x.cc
62 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
64 libstdc___la_LIBADD = \
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_DEPENDENCIES = \
72 $(top_builddir)/libsupc++/libsupc++convenience.la \
73 $(top_builddir)/src/c++98/libc++98convenience.la \
74 $(top_builddir)/src/c++11/libc++11convenience.la
76 libstdc___la_LDFLAGS = \
77 -version-info $(libtool_VERSION) ${version_arg} -lm
79 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
82 # Use special rules for parallel mode compilation.
83 PARALLEL_FLAGS = -fopenmp -D_GLIBCXX_PARALLEL -I$(glibcxx_builddir)/../libgomp
84 compatibility-parallel_list.lo: compatibility-parallel_list.cc
86 compatibility-parallel_list.o: compatibility-parallel_list.cc
89 compatibility-parallel_list-2.lo: compatibility-parallel_list-2.cc
91 compatibility-parallel_list-2.o: compatibility-parallel_list-2.cc
94 # Use special rules for compatibility-ldbl.cc compilation, as we need to
95 # pass -mlong-double-64.
96 if GLIBCXX_LDBL_COMPAT
97 compatibility-ldbl.lo: compatibility-ldbl.cc
98 $(LTCXXCOMPILE) -mlong-double-64 -c $<
99 compatibility-ldbl.o: compatibility-ldbl.cc
100 $(CXXCOMPILE) -mlong-double-64 -c $<
103 # Use special rules for C++11 files/objects.
104 compatibility-c++0x.lo: compatibility-c++0x.cc
105 $(LTCXXCOMPILE) -std=gnu++11 -c $<
106 compatibility-c++0x.o: compatibility-c++0x.cc
107 $(CXXCOMPILE) -std=gnu++11 -c $<
109 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
110 $(LTCXXCOMPILE) -std=gnu++11 -c $<
111 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
112 $(CXXCOMPILE) -std=gnu++11 -c $<
114 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
115 $(LTCXXCOMPILE) -std=gnu++11 -c $<
116 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
117 $(CXXCOMPILE) -std=gnu++11 -c $<
119 # A note on compatibility and static libraries.
121 # static lib == linked against only this version, should not need compat
122 # shared lib == linked against potentially all compat versions
124 # Thus, the shared libs have more compat symbols, which can be found
125 # segregated in the sources with -D_GLIBCXX_SHARED.
127 # In the sub-directories of libsupc++, src/c++98, src/c++11, only
128 # -prefer-pic objects are generated for the convenience libraries.
130 # In the main src directory, make shared and static objects just for
131 # the compat libraries. Shared objects are compiled with -prefer-pic
132 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
133 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
134 # the main src directory.
136 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
137 # because -fPIC is not harmful to use for objects destined for static
138 # libraries. In addition, using -fPIC will allow the use of static
139 # libstdc++.a in the creation of other C++ shared libraries.
141 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
142 # modified in a per-library or per-sub-library way. Need to manually
143 # set this option because CONFIG_CXXFLAGS has to be after
144 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
145 # as the occasion calls for it.
147 $(glibcxx_compiler_pic_flag) \
149 $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
153 # 1) In general, libtool expects an argument such as `--tag=CXX' when
154 # using the C++ compiler, because that will enable the settings
155 # detected when C++ support was being configured. However, when no
156 # such flag is given in the command line, libtool attempts to figure
157 # it out by matching the compiler name in each configuration section
158 # against a prefix of the command line. The problem is that, if the
159 # compiler name and its initial flags stored in the libtool
160 # configuration file don't match those in the command line, libtool
161 # can't decide which configuration to use, and it gives up. The
162 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
163 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
164 # attempt to infer which configuration to use.
166 # The second tag argument, `--tag disable-shared` means that libtool
167 # only compiles each source once, for static objects. In actuality,
168 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
169 # the libtool command that is used create the object, which is
170 # suitable for shared libraries. The `--tag disable-shared` must be
171 # placed after --tag CXX lest things CXX undo the affect of
174 # 2) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is
175 # last. (That way, things like -O2 passed down from the toplevel can
176 # be overridden by --enable-debug.)
178 $(LIBTOOL) --tag CXX \
179 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
180 --mode=compile $(CXX) $(INCLUDES) \
181 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
183 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
185 # 3) We'd have a problem when building the shared libstdc++ object if
186 # the rules automake generates would be used. We cannot allow g++ to
187 # be used since this would add -lstdc++ to the link line which of
188 # course is problematic at this point. So, we get the top-level
189 # directory to configure libstdc++-v3 to use gcc as the C++
190 # compilation driver.
192 $(LIBTOOL) --tag CXX \
193 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
195 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
198 # Symbol versioning for shared libraries.
200 libstdc++-symbols.ver: ${glibcxx_srcdir}/$(SYMVER_FILE) \
201 $(port_specific_symbol_files)
202 cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
204 if test "x$(port_specific_symbol_files)" != x; then \
205 if grep '^# Appended to version file.' \
206 $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
207 cat $(port_specific_symbol_files) >> $@.tmp; \
209 sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
210 sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
211 cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
212 rm tmp.top tmp.bottom; \
215 $(EGREP) -v '^[ ]*#(#| |$$)' $@.tmp | \
216 $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
219 CLEANFILES = libstdc++-symbols.ver
221 if ENABLE_SYMVERS_GNU
222 version_arg = -Wl,--version-script=libstdc++-symbols.ver
223 version_dep = libstdc++-symbols.ver
225 if ENABLE_SYMVERS_GNU_NAMESPACE
226 version_arg = -Wl,--version-script=libstdc++-symbols.ver
227 version_dep = libstdc++-symbols.ver
229 if ENABLE_SYMVERS_SUN
230 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
231 version_dep = libstdc++-symbols.ver-sun
232 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
233 $(toplevel_srcdir)/contrib/make_sunver.pl \
234 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
235 CXXFILT="$(CXXFILT)"; export CXXFILT; \
236 perl $(toplevel_srcdir)/contrib/make_sunver.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)
243 if ENABLE_SYMVERS_DARWIN
244 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
245 version_dep = libstdc++-symbols.explist
246 libstdc++-symbols.explist : libstdc++-symbols.ver \
247 ${glibcxx_srcdir}/scripts/make_exports.pl \
248 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
249 perl ${glibcxx_srcdir}/scripts/make_exports.pl \
250 libstdc++-symbols.ver \
251 $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
252 `echo $(libstdc___la_LIBADD) | \
253 sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
254 > $@ || (rm -f $@ ; exit 1)
257 CLEANFILES += $(version_dep)
264 # Control additional build primary rules.
265 all-once: libstdc++convenience.la $(STAMP_DEBUG)
266 install-data-once: $(STAMP_INSTALL_DEBUG)
269 install-data-local: install-data-once
271 rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
273 # Make a non-installed convenience library, so that --disable-static
275 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
276 $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
277 if test ! -f .libs/libstdc++.a; then \
278 cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
280 echo `date` > stamp-libstdc++convenience;
284 # 2 supra-convenience library
285 if GLIBCXX_BUILD_DEBUG
286 STAMP_DEBUG = build-debug
287 STAMP_INSTALL_DEBUG = install-debug
291 STAMP_INSTALL_DEBUG =
295 # Build a debug variant.
296 # Take care to fix all possibly-relative paths.
297 debugdir = ${glibcxx_builddir}/src/debug
299 if test ! -d ${debugdir}; then \
300 mkdir -p ${debugdir}; \
301 for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
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 < ../Makefile > Makefile ; \
310 for d in . $(SUBDIRS); do \
311 sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
312 -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
313 -e 's/srcdir = \.\./srcdir = ..\/../' \
314 -e 's/VPATH = \.\./VPATH = ..\/../' \
315 -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
316 -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
317 < ../$$d/Makefile > $$d/Makefile ; \
320 echo `date` > stamp-debug;
322 build-debug: stamp-debug
324 mv Makefile Makefile.tmp; \
325 sed -e 's,all-local: all-once,all-local:,' \
326 -e 's,install-data-local: install-data-once,install-data-local:,' \
327 -e '/vpath/!s,src/c,src/debug/c,' \
328 < Makefile.tmp > Makefile ; \
329 $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
330 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
332 # Install debug library.
333 install-debug: build-debug
334 (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
335 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;