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