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