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