OSDN Git Service

Latest updates from FSF 4.7 branch
[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/c++98
33 vpath % $(top_srcdir)/src/c++11
34
35 if GLIBCXX_LDBL_COMPAT
36 ldbl_compat_sources = compatibility-ldbl.cc
37 else
38 ldbl_compat_sources =
39 endif
40
41 if ENABLE_PARALLEL
42 parallel_compat_sources = \
43         compatibility-parallel_list.cc  compatibility-parallel_list-2.cc
44 else
45 parallel_compat_sources =
46 endif
47
48 cxx98_sources = \
49         compatibility.cc \
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}
56
57 cxx11_sources = \
58         compatibility-c++0x.cc \
59         compatibility-atomic-c++0x.cc \
60         compatibility-thread-c++0x.cc
61
62 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
63
64 libstdc___la_LIBADD = \
65         $(GLIBCXX_LIBS) \
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
69
70 libstdc___la_DEPENDENCIES = \
71         ${version_dep} \
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
75
76 if GLIBCXX_USE_LIBM
77 libstdc___la_LDFLAGS = \
78         -version-info $(libtool_VERSION) ${version_arg} -lm 
79 else
80 libstdc___la_LDFLAGS = \
81         -version-info $(libtool_VERSION) ${version_arg} 
82 endif
83
84 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS)
85
86
87 # Use special rules for parallel mode compilation.
88 PARALLEL_FLAGS = -fopenmp -D_GLIBCXX_PARALLEL -I$(glibcxx_builddir)/../libgomp
89 compatibility-parallel_list.lo: compatibility-parallel_list.cc
90         $(LTCXXCOMPILE) -c $<
91 compatibility-parallel_list.o: compatibility-parallel_list.cc
92         $(CXXCOMPILE) -c $<
93
94 compatibility-parallel_list-2.lo: compatibility-parallel_list-2.cc
95         $(LTCXXCOMPILE) -c $<
96 compatibility-parallel_list-2.o: compatibility-parallel_list-2.cc
97         $(CXXCOMPILE) -c $<
98
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 $<
106 endif
107
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 $<
113
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 $<
118
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 $<
123
124 # AM_CXXFLAGS needs to be in each subdirectory 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         $(XTEMPLATE_FLAGS) \
131         $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
132
133 # Libtool notes
134
135 # 1) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is
136 # last. (That way, things like -O2 passed down from the toplevel can
137 # be overridden by --enable-debug.)
138
139 # 2) In general, libtool expects an argument such as `--tag=CXX' when
140 # using the C++ compiler, because that will enable the settings
141 # detected when C++ support was being configured.  However, when no
142 # such flag is given in the command line, libtool attempts to figure
143 # it out by matching the compiler name in each configuration section
144 # against a prefix of the command line.  The problem is that, if the
145 # compiler name and its initial flags stored in the libtool
146 # configuration file don't match those in the command line, libtool
147 # can't decide which configuration to use, and it gives up.  The
148 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
149 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
150 # attempt to infer which configuration to use
151 LTCXXCOMPILE = \
152         $(LIBTOOL) --tag CXX \
153         $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
154         --mode=compile $(CXX) $(INCLUDES) \
155         $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
156
157 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
158
159 # 3) We'd have a problem when building the shared libstdc++ object if
160 # the rules automake generates would be used.  We cannot allow g++ to
161 # be used since this would add -lstdc++ to the link line which of
162 # course is problematic at this point.  So, we get the top-level
163 # directory to configure libstdc++-v3 to use gcc as the C++
164 # compilation driver.
165 CXXLINK = \
166         $(LIBTOOL) --tag CXX \
167         $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
168         --mode=link $(CXX) \
169         $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
170
171
172 # Symbol versioning for shared libraries.
173 if ENABLE_SYMVERS
174 libstdc++-symbols.ver:  ${glibcxx_srcdir}/$(SYMVER_FILE) \
175                 $(port_specific_symbol_files)
176         cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
177         chmod +w $@.tmp
178         if test "x$(port_specific_symbol_files)" != x; then \
179           if grep '^# Appended to version file.' \
180                $(port_specific_symbol_files) /dev/null > /dev/null 2>&1; then \
181             cat $(port_specific_symbol_files) >> $@.tmp; \
182           else \
183             sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
184             sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
185             cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
186             rm tmp.top tmp.bottom; \
187           fi; \
188         fi
189         $(EGREP) -v '^[         ]*#(#| |$$)' $@.tmp | \
190           $(CC) -E -P -include ../config.h - > $@ || (rm -f $@ ; exit 1)
191         rm -f $@.tmp
192
193 CLEANFILES = libstdc++-symbols.ver
194
195 if ENABLE_SYMVERS_GNU
196 version_arg = -Wl,--version-script=libstdc++-symbols.ver
197 version_dep = libstdc++-symbols.ver
198 endif
199 if ENABLE_SYMVERS_GNU_NAMESPACE
200 version_arg = -Wl,--version-script=libstdc++-symbols.ver
201 version_dep = libstdc++-symbols.ver
202 endif
203 if ENABLE_SYMVERS_SUN
204 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
205 version_dep = libstdc++-symbols.ver-sun
206 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
207                 $(toplevel_srcdir)/contrib/make_sunver.pl \
208                 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
209         CXXFILT="$(CXXFILT)"; export CXXFILT; \
210         perl $(toplevel_srcdir)/contrib/make_sunver.pl \
211           libstdc++-symbols.ver \
212           $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
213          `echo $(libstdc___la_LIBADD) | \
214             sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
215          > $@ || (rm -f $@ ; exit 1)
216 endif
217 if ENABLE_SYMVERS_DARWIN
218 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
219 version_dep = libstdc++-symbols.explist
220 libstdc++-symbols.explist : libstdc++-symbols.ver \
221                 ${glibcxx_srcdir}/scripts/make_exports.pl \
222                 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
223         perl ${glibcxx_srcdir}/scripts/make_exports.pl \
224           libstdc++-symbols.ver \
225           $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
226          `echo $(libstdc___la_LIBADD) | \
227             sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
228          > $@ || (rm -f $@ ; exit 1)
229 endif
230
231 CLEANFILES += $(version_dep)
232 else
233 version_arg =
234 version_dep =
235 endif
236
237
238 # Control additional build primary rules.
239 all-once: libstdc++convenience.la $(STAMP_DEBUG)
240 install-data-once: $(STAMP_INSTALL_DEBUG)
241
242 all-local: all-once
243 install-data-local: install-data-once
244 clean-local:
245         rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
246
247 # Make a non-installed convenience library, so that --disable-static
248 # may work.
249 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
250         $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
251         if test ! -f .libs/libstdc++.a; then \
252           cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
253         fi; \
254         echo `date` > stamp-libstdc++convenience;
255
256 # Added rules.
257 # 1 debug library
258 # 2 supra-convenience library
259 if GLIBCXX_BUILD_DEBUG
260 STAMP_DEBUG = build-debug
261 STAMP_INSTALL_DEBUG = install-debug
262 CLEAN_DEBUG = debug
263 else
264 STAMP_DEBUG =
265 STAMP_INSTALL_DEBUG =
266 CLEAN_DEBUG =
267 endif
268
269 # Build a debug variant.
270 # Take care to fix all possibly-relative paths.
271 debugdir = ${glibcxx_builddir}/src/debug
272 stamp-debug:
273         if test ! -d ${debugdir}; then \
274           mkdir -p ${debugdir}; \
275           for d in $(SUBDIRS); do mkdir -p  ${debugdir}/$$d; done; \
276           (cd ${debugdir}; \
277           sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
278               -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
279               -e 's/srcdir = \.\./srcdir = ..\/../' \
280               -e 's/VPATH = \.\./VPATH = ..\/../' \
281               -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
282               -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
283           < ../Makefile > Makefile ; \
284           for d in . $(SUBDIRS); do \
285           sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
286               -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
287               -e 's/srcdir = \.\./srcdir = ..\/../' \
288               -e 's/VPATH = \.\./VPATH = ..\/../' \
289               -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
290               -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
291           < ../$$d/Makefile > $$d/Makefile ; \
292           done) ; \
293         fi; \
294         echo `date` > stamp-debug;
295
296 build-debug: stamp-debug
297           (cd ${debugdir}; \
298           mv Makefile Makefile.tmp; \
299           sed -e 's,all-local: all-once,all-local:,' \
300               -e 's,install-data-local: install-data-once,install-data-local:,' \
301               -e '/vpath/!s,src/c,src/debug/c,' \
302           < Makefile.tmp > Makefile ; \
303           $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
304           toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ;
305
306 # Install debug library.
307 install-debug: build-debug
308         (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
309         toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;