1# Copyright (C) 2002-2020 Free Software Foundation, Inc.
2#
3# This file is part of GCC.
4#
5# GCC is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# GCC is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GCC; see the file COPYING3.  If not see
17# <http://www.gnu.org/licenses/>.
18
19# Build a shared libgcc library according to --with-aix-soname selection:
20# aix-soname=aix:
21#       libgcc_s.a(shr.o)                # traditional (-bnortl)
22#
23# aix-soname=both:
24#       libgcc_s.a(shr.o)                # traditional (-bnortl)
25#       libgcc_s.so.1(shrXX.o,shrXX.imp) # the SONAME (-G)
26#       libgcc_s.so -> libgcc_s.so.1     # the symlink
27#
28# aix-soname=svr4:
29#       libgcc_s.so.1(shrXX.o,shrXX.imp) # the SONAME (-G)
30#       libgcc_s.so -> libgcc_s.so.1     # the symlink
31SHLIB_EXT_aix = .a
32SHLIB_EXT_both = .so
33SHLIB_EXT_svr4 = .so
34SHLIB_EXT = $(SHLIB_EXT_$(with_aix_soname))
35SHLIB_SOVERSION = 1
36SHLIB_SONAME = @shlib_base_name@.so.$(SHLIB_SOVERSION)
37SHLIB_LINK = \
38	if test svr4 != $(with_aix_soname) ; then \
39	  $(CC) $(LIBGCC2_CFLAGS) -shared -Wl,-bnortl -nodefaultlibs \
40	  -Wl,-bE:@shlib_map_file@ -o @multilib_dir@/shr.o \
41	  @multilib_flags@ @shlib_objs@ -lc \
42	  `case @multilib_dir@ in \
43	  *pthread*) echo -L$(TARGET_SYSTEM_ROOT)/usr/lib/threads -lpthreads -lc_r $(TARGET_SYSTEM_ROOT)/usr/lib/libc.a ;; \
44	  *) echo -lc ;; esac` ; \
45	  rm -f @multilib_dir@/tmp-@shlib_base_name@.a ; \
46	  $(AR_CREATE_FOR_TARGET) @multilib_dir@/tmp-@shlib_base_name@.a \
47	    @multilib_dir@/shr.o ; \
48	  mv @multilib_dir@/tmp-@shlib_base_name@.a \
49	     @multilib_dir@/@shlib_base_name@.a ; \
50	  rm -f @multilib_dir@/shr.o ; \
51	fi ; \
52	if test aix != $(with_aix_soname) ; then \
53	  case @multilib_dir@ in *64*) shr='shr_64' ;; *) shr='shr' ;; esac ; \
54	  $(CC) $(LIBGCC2_CFLAGS) -shared -Wl,-G -nodefaultlibs \
55	  -Wl,-bE:@shlib_map_file@ -o @multilib_dir@/$$shr.o \
56	  @multilib_flags@ @shlib_objs@ -lc \
57	  `case @multilib_dir@ in \
58	  *pthread*) echo -L$(TARGET_SYSTEM_ROOT)/usr/lib/threads -lpthreads -lc_r $(TARGET_SYSTEM_ROOT)/usr/lib/libc.a ;; \
59	  *) echo -lc ;; esac` ; \
60	  $(STRIP_FOR_TARGET) -X32_64 -e @multilib_dir@/$$shr.o ; \
61	  { echo "\#! $(SHLIB_SONAME)($$shr.o)" ; \
62	    case @multilib_dir@ in *64*) echo '\# 64' ;; *) echo '\# 32' ;; esac ; \
63	    cat @shlib_map_file@ ; \
64	  } > @multilib_dir@/$$shr.imp ; \
65	  rm -f @multilib_dir@/tmp-$(SHLIB_SONAME) ; \
66	  $(AR_CREATE_FOR_TARGET) @multilib_dir@/tmp-$(SHLIB_SONAME) \
67	    @multilib_dir@/$$shr.imp @multilib_dir@/$$shr.o ; \
68	  mv @multilib_dir@/tmp-$(SHLIB_SONAME) \
69	     @multilib_dir@/$(SHLIB_SONAME) ; \
70	  rm -f @multilib_dir@/@shlib_base_name@.so ; \
71	  $(LN_S) $(SHLIB_SONAME) @multilib_dir@/@shlib_base_name@.so ; \
72	  rm -f @multilib_dir@/$$shr.imp @multilib_dir@/$$shr.o ; \
73	fi
74SHLIB_INSTALL = \
75	$(mkinstalldirs) $(DESTDIR)$(slibdir)@shlib_slibdir_qual@; \
76	if test svr4 != $(with_aix_soname) ; then \
77	  $(INSTALL_DATA) @multilib_dir@/@shlib_base_name@.a \
78		  $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/ ; \
79	fi ; \
80	if test aix != $(with_aix_soname) ; then \
81	  $(INSTALL_DATA) @multilib_dir@/$(SHLIB_SONAME) \
82		  $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/ ; \
83	  rm -f $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/@shlib_base_name@.so ; \
84	  $(LN_S) $(SHLIB_SONAME) \
85		  $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/@shlib_base_name@.so ; \
86	fi
87SHLIB_LIBS = -lc `case @multilib_dir@ in *pthread*) echo -lpthread ;; esac`
88SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
89SHLIB_MAPFILES = libgcc-std.ver
90SHLIB_NM_FLAGS = -Bpg -X32_64
91
92# Either 32-bit and 64-bit objects in archives.
93AR_FLAGS_FOR_TARGET = -X32_64
94