OSDN Git Service

2012-01-20 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / src / Makefile.am
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.
9
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.
15
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.
20
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/>.
24
25 include $(top_srcdir)/fragment.am
26
27 SUBDIRS = c++98 c++11
28
29 # Cross compiler support.
30 toolexeclib_LTLIBRARIES = libstdc++.la
31
32 vpath % $(top_srcdir)/src
33 vpath % $(top_srcdir)
34
35 libstdc___la_SOURCES =
36
37 libstdc___la_LIBADD = \
38         $(GLIBCXX_LIBS) \
39         $(top_builddir)/libsupc++/libsupc++convenience.la \
40         $(top_builddir)/src/c++98/libc++98convenience.la \
41         $(top_builddir)/src/c++11/libc++11convenience.la
42
43 libstdc___la_DEPENDENCIES = \
44         ${version_dep} \
45         $(top_builddir)/libsupc++/libsupc++convenience.la \
46         $(top_builddir)/src/c++98/libc++98convenience.la \
47         $(top_builddir)/src/c++11/libc++11convenience.la
48
49 libstdc___la_LDFLAGS = \
50         -version-info $(libtool_VERSION) ${version_arg} -lm
51
52 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
53
54
55 # AM_CXXFLAGS needs to be in each subdirectory so that it can be
56 # modified in a per-library or per-sub-library way.  Need to manually
57 # set this option because CONFIG_CXXFLAGS has to be after
58 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
59 # as the occasion calls for it.
60 AM_CXXFLAGS = \
61         $(XTEMPLATE_FLAGS) \
62         $(WARN_CXXFLAGS) \
63         $(OPTIMIZE_CXXFLAGS) \
64         $(CONFIG_CXXFLAGS)
65
66
67 # libstdc++ libtool notes
68
69 # 1) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is
70 # last. (That way, things like -O2 passed down from the toplevel can
71 # be overridden by --enable-debug.)
72
73 # 2) In general, libtool expects an argument such as `--tag=CXX' when
74 # using the C++ compiler, because that will enable the settings
75 # detected when C++ support was being configured.  However, when no
76 # such flag is given in the command line, libtool attempts to figure
77 # it out by matching the compiler name in each configuration section
78 # against a prefix of the command line.  The problem is that, if the
79 # compiler name and its initial flags stored in the libtool
80 # configuration file don't match those in the command line, libtool
81 # can't decide which configuration to use, and it gives up.  The
82 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
83 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
84 # attempt to infer which configuration to use
85 LTCXXCOMPILE = $(LIBTOOL) --tag CXX \
86                $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
87                $(CXX) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
88                $(AM_CXXFLAGS) $(CXXFLAGS)
89
90 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
91
92 # 3) We'd have a problem when building the shared libstdc++ object if
93 # the rules automake generates would be used.  We cannot allow g++ to
94 # be used since this would add -lstdc++ to the link line which of
95 # course is problematic at this point.  So, we get the top-level
96 # directory to configure libstdc++-v3 to use gcc as the C++
97 # compilation driver.
98 CXXLINK = $(LIBTOOL) --tag CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
99           $(CXX) $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
100
101 # Symbol versioning for shared libraries.
102 if ENABLE_SYMVERS
103 libstdc++-symbols.ver:  ${glibcxx_srcdir}/$(SYMVER_FILE) \
104                 $(port_specific_symbol_files)
105         cp ${glibcxx_srcdir}/$(SYMVER_FILE) ./libstdc++-symbols.ver
106         chmod +w ./libstdc++-symbols.ver
107         if test "x$(port_specific_symbol_files)" != x; then \
108           if grep '^# Appended to version file.' \
109                $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
110             cat $(port_specific_symbol_files) >> $@; \
111           else \
112             sed -n '1,/DO NOT DELETE/p' $@ > tmp.top; \
113             sed -n '/DO NOT DELETE/,$$p' $@ > tmp.bottom; \
114             cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@; \
115             rm tmp.top tmp.bottom; \
116           fi; \
117         fi
118
119 CLEANFILES = libstdc++-symbols.ver
120
121 if ENABLE_SYMVERS_GNU
122 if ENABLE_SYMVERS_SOL2
123 version_arg = -Wl,--version-script,libstdc++-symbols.ver-sol2
124 version_dep = libstdc++-symbols.ver-sol2
125 libstdc++-symbols.ver-sol2 : libstdc++-symbols.ver
126         sed -e '/^#ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT/,/^#endif/d' $< \
127          > $@ || (rm -f $@ ; exit 1)
128 else
129 version_arg = -Wl,--version-script=libstdc++-symbols.ver
130 version_dep = libstdc++-symbols.ver
131 endif
132 endif
133 if ENABLE_SYMVERS_GNU_NAMESPACE
134 version_arg = -Wl,--version-script=libstdc++-symbols.ver
135 version_dep = libstdc++-symbols.ver
136 endif
137 if ENABLE_SYMVERS_SUN
138 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
139 version_dep = libstdc++-symbols.ver-sun
140 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
141                 $(toplevel_srcdir)/contrib/make_sunver.pl \
142                 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
143         CXXFILT="$(CXXFILT)"; export CXXFILT; \
144         perl $(toplevel_srcdir)/contrib/make_sunver.pl \
145           libstdc++-symbols.ver \
146           $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
147          `echo $(libstdc___la_LIBADD) | \
148             sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
149          > $@ || (rm -f $@ ; exit 1)
150 endif
151 if ENABLE_SYMVERS_DARWIN
152 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
153 version_dep = libstdc++-symbols.explist
154 libstdc++-symbols.explist : libstdc++-symbols.ver \
155                 ${glibcxx_srcdir}/scripts/make_exports.pl \
156                 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
157         perl ${glibcxx_srcdir}/scripts/make_exports.pl \
158           libstdc++-symbols.ver \
159           $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
160          `echo $(libstdc___la_LIBADD) | \
161             sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
162          > $@ || (rm -f $@ ; exit 1)
163 endif
164
165 CLEANFILES += $(version_dep)
166 else
167 version_arg =
168 version_dep =
169 endif
170
171 # Added rules.
172 # 1 debug library
173 # 2 supra-convenience library
174 if GLIBCXX_BUILD_DEBUG
175 all-local: libstdc++convenience.la build_debug
176 install-data-local: install_debug
177 else
178 all-local: libstdc++convenience.la
179 install-data-local:
180 endif
181
182 # Make a non-installed convenience library, so that --disable-static
183 # may work.
184 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
185         $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
186         if test ! -f .libs/libstdc++.a; then \
187           $(LN_S) .libs/libstdc++convenience.a .libs/libstdc++.a; \
188           stamp-libstdc++convenience; \
189         fi;
190
191 debugdir = debug
192
193 # Build a set of debug objects here.
194 # Take care to fix all possibly-relative paths.
195 stamp-debug:
196         if test ! -d ${debugdir}; then \
197           mkdir -p ${debugdir}; \
198           (cd ${debugdir}; \
199           sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
200               -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
201               -e 's/srcdir = \.\./srcdir = ..\/../' \
202               -e 's/VPATH = \.\./VPATH = ..\/../' \
203               -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
204               -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
205               -e 's/all-local: build_debug/all-local:/' \
206               -e 's/install-data-local: install_debug/install-data-local:/' \
207           < ../Makefile > Makefile) ; \
208         fi; \
209         echo `date` > stamp-debug;
210
211 build_debug: stamp-debug
212         (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' all)
213
214 # Install debug library here.
215 install_debug:
216         (cd ${debugdir} && $(MAKE) \
217         toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)