libstdc++: Fix Unicode property detection functions
[official-gcc.git] / libstdc++-v3 / src / Makefile.am
blob7292ae70f812fe74ffff9ca4a5a13c6741cf7c84
1 ## Makefile for the C++11 sources of the GNU C++ Standard library.
2 ##
3 ## Copyright (C) 1997-2024 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 GLIBCXX_HOSTED
26 if ENABLE_FILESYSTEM_TS
27 filesystem_dir = filesystem
28 else
29 filesystem_dir =
30 endif
32 if ENABLE_BACKTRACE
33 backtrace_dir = libbacktrace
34 else
35 backtrace_dir =
36 endif
38 experimental_dir = experimental
39 else
40 filesystem_dir =
41 backtrace_dir =
42 experimental_dir =
43 endif
45 ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
46 SUBDIRS = c++98 c++11 c++17 c++20 c++23 \
47         $(filesystem_dir) $(backtrace_dir) $(experimental_dir)
49 # Cross compiler support.
50 if VTV_CYGMIN
51 toolexeclib_LTLIBRARIES = libvtv.la libstdc++.la
52 else
53 toolexeclib_LTLIBRARIES = libstdc++.la
54 endif
56 if VTV_CYGMIN
57 vtv_stubs.cc:
58         rm -f $@
59         $(LN_S) $(toplevel_srcdir)/libstdc++-v3/libsupc++/vtv_stubs.cc $@
61 libvtv_la_SOURCES = vtv_stubs.cc
62 libvtv_la_LDFLAGS = $(lt_host_flags)
64 libvtv_la_AM_CXXFLAGS = \
65         $(glibcxx_compiler_pic_flag) \
66         $(XTEMPLATE_FLAGS) \
67         -Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end \
68         $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
70 libvtv_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
71         $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(libvtv_la_AM_CXXFLAGS) \
72         $(CXXFLAGS) $(libvtv_la_LDFLAGS) $(LDFLAGS) -o $@
73 endif
75 vpath % $(top_srcdir)/src/c++98
76 vpath % $(top_srcdir)/src/c++11
77 vpath % $(top_srcdir)/src/c++17
78 vpath % $(top_srcdir)/src/c++20
79 vpath % $(top_srcdir)/src/c++23
80 if ENABLE_FILESYSTEM_TS
81 vpath % $(top_srcdir)/src/filesystem
82 endif
83 if ENABLE_BACKTRACE
84 vpath % $(top_srcdir)/src/libbacktrace
85 endif
86 vpath % $(top_srcdir)/src/experimental
88 if GLIBCXX_LDBL_COMPAT
89 ldbl_compat_sources = compatibility-ldbl.cc
90 else
91 ldbl_compat_sources =
92 endif
94 if GLIBCXX_LDBL_ALT128_COMPAT
95 if ENABLE_DUAL_ABI
96 ldbl_alt128_compat_cxx11_sources = \
97         compatibility-ldbl-alt128-cxx11.cc
98 else
99 ldbl_alt128_compat_cxx11_sources =
100 endif
101 ldbl_alt128_compat_sources = \
102         compatibility-ldbl-alt128.cc \
103         ${ldbl_alt128_compat_cxx11_sources}
104 else
105 ldbl_alt128_compat_sources =
106 endif
108 if ENABLE_SYMVERS_GNU_NAMESPACE
109 cxx0x_compat_sources =
110 else
111 cxx0x_compat_sources = \
112         compatibility-atomic-c++0x.cc \
113         compatibility-c++0x.cc \
114         compatibility-chrono.cc \
115         compatibility-condvar.cc \
116         compatibility-thread-c++0x.cc
117 endif
119 parallel_compat_sources = \
120         compatibility-parallel_list.cc  compatibility-parallel_list-2.cc
123 cxx98_sources = \
124         compatibility.cc \
125         compatibility-debug_list.cc \
126         compatibility-debug_list-2.cc \
127         ${ldbl_compat_sources}
129 cxx11_sources = \
130         ${cxx0x_compat_sources} \
131         ${ldbl_alt128_compat_sources}
133 if GLIBCXX_HOSTED
134 libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources)
135 else
136 # When freestanding, there's currently no compatibility to preserve.  Should
137 # that change, any compatibility sources can be added here.
138 libstdc___la_SOURCES =
139 endif
141 libstdc___la_LIBADD = \
142         $(GLIBCXX_LIBS) \
143         $(top_builddir)/libsupc++/libsupc++convenience.la \
144         $(top_builddir)/src/c++98/libc++98convenience.la \
145         $(top_builddir)/src/c++11/libc++11convenience.la \
146         $(top_builddir)/src/c++17/libc++17convenience.la \
147         $(top_builddir)/src/c++20/libc++20convenience.la
149 libstdc___la_DEPENDENCIES = \
150         ${version_dep} \
151         $(top_builddir)/libsupc++/libsupc++convenience.la \
152         $(top_builddir)/src/c++98/libc++98convenience.la \
153         $(top_builddir)/src/c++11/libc++11convenience.la \
154         $(top_builddir)/src/c++17/libc++17convenience.la \
155         $(top_builddir)/src/c++20/libc++20convenience.la
157 if ENABLE_DARWIN_AT_RPATH
158 libstdc___darwin_rpath = -Wc,-nodefaultrpaths
159 libstdc___darwin_rpath += -Wl,-rpath,@loader_path
160 endif
162 libstdc___la_LDFLAGS = \
163         -version-info $(libtool_VERSION) ${version_arg} -lm $(libstdc___darwin_rpath)
165 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags)
167 # Use special rules for compatibility-ldbl.cc compilation, as we need to
168 # pass -mlong-double-64, and not use -mabi={ieee,ibm}longdouble.
169 if GLIBCXX_LDBL_COMPAT
170 if GLIBCXX_LDBL_ALT128_COMPAT
171 LTCXXCOMPILE64 = \
172   $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(LTCXXCOMPILE))
173 CXXCOMPILE64 = \
174   $(filter-out -mabi=ieeelongdouble -mabi=ibmlongdouble,$(CXXCOMPILE))
175 else
176 LTCXXCOMPILE64 = $(LTCXXCOMPILE)
177 CXXCOMPILE64 = $(CXXCOMPILE)
178 endif
179 compatibility-ldbl.lo: compatibility-ldbl.cc
180         $(LTCXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
181 compatibility-ldbl.o: compatibility-ldbl.cc
182         $(CXXCOMPILE64) $(LONG_DOUBLE_COMPAT_FLAGS) -c $<
183 endif
185 # Use special rules for compatibility-ldbl-alt128.cc compilation, as we need to
186 # ensure it is compiled with the correct flag.
187 if GLIBCXX_LDBL_ALT128_COMPAT
188 compatibility-ldbl-alt128.lo: compatibility-ldbl-alt128.cc
189         $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
190 compatibility-ldbl-alt128.o: compatibility-ldbl-alt128.cc
191         $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
192 if ENABLE_DUAL_ABI
193 compatibility-ldbl-alt128-cxx11.lo: compatibility-ldbl-alt128-cxx11.cc
194         $(LTCXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
195 compatibility-ldbl-alt128-cxx11.o: compatibility-ldbl-alt128-cxx11.cc
196         $(CXXCOMPILE) $(LONG_DOUBLE_ALT128_COMPAT_FLAGS) -std=gnu++11 -c $<
197 endif
198 endif
200 # Use special rules for C++11 files/objects.
201 compatibility-c++0x.lo: compatibility-c++0x.cc
202         $(LTCXXCOMPILE) -std=gnu++11 -c $<
203 compatibility-c++0x.o: compatibility-c++0x.cc
204         $(CXXCOMPILE) -std=gnu++11 -c $<
206 compatibility-atomic-c++0x.lo: compatibility-atomic-c++0x.cc
207         $(LTCXXCOMPILE) -std=gnu++11 -c $<
208 compatibility-atomic-c++0x.o: compatibility-atomic-c++0x.cc
209         $(CXXCOMPILE) -std=gnu++11 -c $<
211 compatibility-thread-c++0x.lo: compatibility-thread-c++0x.cc
212         $(LTCXXCOMPILE) -std=gnu++11 -c $<
213 compatibility-thread-c++0x.o: compatibility-thread-c++0x.cc
214         $(CXXCOMPILE) -std=gnu++11 -c $<
216 compatibility-chrono.lo: compatibility-chrono.cc
217         $(LTCXXCOMPILE) -std=gnu++11 -c $<
218 compatibility-chrono.o: compatibility-chrono.cc
219         $(CXXCOMPILE) -std=gnu++11 -c $<
221 compatibility-condvar.lo: compatibility-condvar.cc
222         $(LTCXXCOMPILE) -std=gnu++11 -c $<
223 compatibility-condvar.o: compatibility-condvar.cc
224         $(CXXCOMPILE) -std=gnu++11 -c $<
226 # A note on compatibility and static libraries.
228 # static lib == linked against only this version, should not need compat
229 # shared lib == linked against potentially all compat versions
231 # Thus, the shared libs have more compat symbols, which can be found
232 # segregated in the sources with -D_GLIBCXX_SHARED.
234 # In the sub-directories of libsupc++, src/c++98, src/c++11, src/c++17,
235 # src/c++20, only -prefer-pic objects are generated for the convenience
236 # libraries.
238 # In the main src directory, make shared and static objects just for
239 # the compat libraries. Shared objects are compiled with -prefer-pic
240 # -D_GLIBCXX_SHARED and in the .libs sub-directory, static objects are
241 # compiled with -prefer-pic (ie, -fPIC but not -D_GLIBCXX_SHARED) and
242 # the main src directory.
244 # Why are objects destined for libstdc++.a compiled with -fPIC? First,
245 # because -fPIC is not harmful to use for objects destined for static
246 # libraries. In addition, using -fPIC will allow the use of static
247 # libstdc++.a in the creation of other C++ shared libraries.
249 # AM_CXXFLAGS needs to be in each sub-directory so that it can be
250 # modified in a per-library or per-sub-library way.  Need to manually
251 # set this option because CONFIG_CXXFLAGS has to be after
252 # OPTIMIZE_CXXFLAGS on the compile line so that -O2 can be overridden
253 # as the occasion calls for it.
254 AM_CXXFLAGS_PRE = \
255         -std=gnu++98 \
256         $(glibcxx_compiler_pic_flag) \
257         $(XTEMPLATE_FLAGS) $(VTV_CXXFLAGS) \
258         $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS)
260 AM_CXXFLAGS = $(filter-out -fvtable-verify=std,$(AM_CXXFLAGS_PRE))
262 # Libtool notes
264 # 1) In general, libtool expects an argument such as `--tag=CXX' when
265 # using the C++ compiler, because that will enable the settings
266 # detected when C++ support was being configured.  However, when no
267 # such flag is given in the command line, libtool attempts to figure
268 # it out by matching the compiler name in each configuration section
269 # against a prefix of the command line.  The problem is that, if the
270 # compiler name and its initial flags stored in the libtool
271 # configuration file don't match those in the command line, libtool
272 # can't decide which configuration to use, and it gives up.  The
273 # correct solution is to add `--tag CXX' to LTCXXCOMPILE and maybe
274 # CXXLINK, just after $(LIBTOOL), so that libtool doesn't have to
275 # attempt to infer which configuration to use.
277 # The second tag argument, `--tag disable-shared` means that libtool
278 # only compiles each source once, for static objects. In actuality,
279 # glibcxx_lt_pic_flag and glibcxx_compiler_shared_flag are added to
280 # the libtool command that is used create the object, which is
281 # suitable for shared libraries.  The `--tag disable-shared` must be
282 # placed after --tag CXX lest things CXX undo the affect of
283 # disable-shared.
285 # 2) Need to explicitly set LTCXXCOMPILE so that EXTRA_CXX_FLAGS is
286 # last. (That way, things like -O2 passed down from the toplevel can
287 # be overridden by --enable-debug and --enable-cxx-flags.)
288 LTCXXCOMPILE = \
289         $(LIBTOOL) --tag CXX \
290         $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
291         --mode=compile $(CXX) $(INCLUDES) \
292         $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(EXTRA_CXX_FLAGS)
294 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
296 # 3) We'd have a problem when building the shared libstdc++ object if
297 # the rules automake generates would be used.  We cannot allow g++ to
298 # be used since this would add -lstdc++ to the link line which of
299 # course is problematic at this point.  So, we get the top-level
300 # directory to configure libstdc++-v3 to use gcc as the C++
301 # compilation driver.
302 CXXLINK = \
303         $(LIBTOOL) --tag CXX \
304         $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
305         --mode=link $(CXX) \
306         $(VTV_CXXLINKFLAGS) \
307         $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) \
308         $(LTLDFLAGS) $(LTLIBICONV) \
309         -o $@
311 # Symbol versioning for shared libraries.
312 # See configure.host and configure.ac for port_specific_symbol_files.
313 if ENABLE_SYMVERS
314 libstdc++-symbols.ver:  ${glibcxx_srcdir}/$(SYMVER_FILE) \
315                 $(port_specific_symbol_files)
316         cp ${glibcxx_srcdir}/$(SYMVER_FILE) $@.tmp
317         chmod +w $@.tmp
318         if test "x$(port_specific_symbol_files)" != x; then \
319           if grep '^# Appended to version file.' \
320                $(port_specific_symbol_files) > /dev/null 2>&1; then \
321             cat $(port_specific_symbol_files) >> $@.tmp; \
322           else \
323             sed -n '1,/DO NOT DELETE/p' $@.tmp > tmp.top; \
324             sed -n '/DO NOT DELETE/,$$p' $@.tmp > tmp.bottom; \
325             cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@.tmp; \
326             rm tmp.top tmp.bottom; \
327           fi; \
328         fi
329         $(EGREP) -v '^[         ]*#(#| |$$)' $@.tmp | \
330           $(CC) -E -P -include $(CONFIG_HEADER) - > $@ || (rm -f $@ ; exit 1)
331         rm -f $@.tmp
333 CLEANFILES = libstdc++-symbols.ver
335 if ENABLE_SYMVERS_GNU
336 version_arg = -Wl,--version-script=libstdc++-symbols.ver
337 version_dep = libstdc++-symbols.ver
338 endif
339 if ENABLE_SYMVERS_GNU_NAMESPACE
340 version_arg = -Wl,--version-script=libstdc++-symbols.ver
341 version_dep = libstdc++-symbols.ver
342 endif
343 if ENABLE_SYMVERS_SUN
344 version_arg = -Wl,-M,libstdc++-symbols.ver-sun
345 version_dep = libstdc++-symbols.ver-sun
346 libstdc++-symbols.ver-sun : libstdc++-symbols.ver \
347                 $(toplevel_srcdir)/contrib/make_sunver.pl \
348                 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
349         CXXFILT="$(CXXFILT)"; export CXXFILT; \
350         perl $(toplevel_srcdir)/contrib/make_sunver.pl \
351           libstdc++-symbols.ver \
352           $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
353          `echo ' $(libstdc___la_LIBADD) ' | \
354             sed -e 's,/\([^/.]*\)\.la,/.libs/\1.a,g' -e 's/ -l[^ ]* / /'` \
355          > $@ || (rm -f $@ ; exit 1)
356 endif
357 if ENABLE_SYMVERS_DARWIN
358 version_arg = -Wl,-exported_symbols_list,libstdc++-symbols.explist
359 version_dep = libstdc++-symbols.explist
360 libstdc++-symbols.explist : libstdc++-symbols.ver \
361                 ${glibcxx_srcdir}/scripts/make_exports.pl \
362                 $(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
363         perl ${glibcxx_srcdir}/scripts/make_exports.pl \
364           libstdc++-symbols.ver \
365           $(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
366          `echo $(libstdc___la_LIBADD) | \
367             sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
368          > $@ || (rm -f $@ ; exit 1)
369 endif
371 CLEANFILES += $(version_dep)
372 else
373 version_arg =
374 version_dep =
375 endif
378 # Control additional build primary rules.
379 all-once: libstdc++convenience.la $(STAMP_DEBUG)
380 install-data-once: $(STAMP_INSTALL_DEBUG)
382 all-local: all-once
383 install-data-local: install-data-once
384 clean-local:
385         rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
387 # Make a non-installed convenience library, so that --disable-static
388 # may work.
389 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
390         $(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
391         if test ! -f .libs/libstdc++.a; then \
392           cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
393         fi; \
394         date > stamp-libstdc++convenience;
396 # Added rules.
397 # 1 debug library
398 # 2 supra-convenience library
399 if GLIBCXX_BUILD_DEBUG
400 STAMP_DEBUG = build-debug
401 STAMP_INSTALL_DEBUG = install-debug
402 CLEAN_DEBUG = debug
403 else
404 STAMP_DEBUG =
405 STAMP_INSTALL_DEBUG =
406 CLEAN_DEBUG =
407 endif
409 # Build a debug variant.
411 # Take care to fix all possibly-relative paths.
412 debug/%/Makefile: %/Makefile
413         $(MKDIR_P) $(dir $@)
414         sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
415             -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
416             -e 's/srcdir = \.\./srcdir = ..\/../' \
417             -e 's/VPATH = \.\./VPATH = ..\/../' \
418             -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
419             -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
420           < $< > $@
422 stamp-debug: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
423         mv debug/Makefile debug/Makefile.tmp
424         sed -e 's,all-local: all-once,all-local:,' \
425             -e 's,install-data-local: install-data-once,install-data-local:,' \
426             -e '/vpath/!s,src/c,src/debug/c,' \
427           < debug/Makefile.tmp > debug/Makefile
428         rm -f debug/Makefile.tmp
429         date > stamp-debug;
431 .SECONDARY: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile)
433 if ENABLE_BACKTRACE
434 backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h
435 debug_backtrace_supported_h = debug/$(backtrace_supported_h)
436 $(debug_backtrace_supported_h): $(backtrace_supported_h) stamp-debug
437         cp $< $@
438 else
439 debug_backtrace_supported_h =
440 endif
442 build-debug: stamp-debug $(debug_backtrace_supported_h)
443           $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
444             toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all
446 # Install debug library.
447 install-debug: build-debug
448         $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \
449           toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install