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