1 # Build a shared libgcc library with the darwin linker.
3 SHLIB_VERSTRING = -compatibility_version $(SHLIB_SOVERSION) -current_version $(SHLIB_SOVERSION).0
5 SHLIB_SUFFIX = `if test @multilib_dir@ = ppc64 ; then echo _@multilib_dir@ ; fi`
6 SHLIB_INSTALL_NAME = @shlib_base_name@$(SHLIB_SUFFIX).$(SHLIB_SOVERSION)$(SHLIB_EXT)
7 SHLIB_SONAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
8 SHLIB_SOLINK = @shlib_base_name@.so
9 SHLIB_MAP = @shlib_map_file@
10 SHLIB_OBJS = @shlib_objs@
11 SHLIB_DIR = @multilib_dir@
14 # Darwin only searches in /usr/lib for shared libraries, not in subdirectories,
15 # so the libgcc variants have different names not different locations.
16 # Note that this version is used for the loader, not the linker; the linker
17 # uses the stub versions named by the versioned members of $(INSTALL_FILES).
18 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
19 -install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
20 -single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp \
21 -Wl,-exported_symbols_list,$(SHLIB_MAP) \
23 @multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC)
25 SHLIB_MKMAP = $(gcc_srcdir)/mkmap-flat.awk
26 SHLIB_MKMAP_OPTS = -v leading_underscore=1
27 SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-std.ver
29 INSTALL_FILES=libgcc_s.10.4.dylib libgcc_s.10.5.dylib libgcc_s.1.dylib
31 # For the toplevel multilib, build a fat archive including all the multilibs.
32 ifeq ($(MULTIBUILDTOP),)
35 $(mkinstalldirs) $(DESTDIR)$(slibdir); \
36 $(INSTALL_DATA) $(SHLIB_SONAME) \
37 $(DESTDIR)$(slibdir)/$(SHLIB_SONAME)
39 ifeq ($(enable_shared),yes)
41 install-leaf: install-darwin-libgcc-stubs
44 # In order to support -mmacosx-version-min, you need to have multiple
45 # different libgcc_s libraries that actually get linked against, one for
46 # each system version supported. They are 'stub' libraries that
47 # contain no code, just a list of exported symbols.
48 # The actual use of the libraries is controlled by REAL_LIBGCC_SPEC.
50 # This assumes each multilib corresponds to a different architecture.
51 libgcc_s.%.dylib : $(SHLIB_VERPFX).%.ver libgcc_s$(SHLIB_EXT) all-multi
53 -s $(SHLIB_VERPFX).$(*).ver -c -u \
54 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp
55 MLIBS=`$(CC) --print-multi-lib \
56 | sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
57 for mlib in $$MLIBS ; do \
58 $(STRIP) -o $(@)_T$${mlib} \
59 -s $(SHLIB_VERPFX).$(*).ver -c -u \
60 ../$${mlib}/libgcc/$${mlib}/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp || exit 1 ; \
62 $(LIPO) -output $@ -create $(@)_T*
65 libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT) \
66 libgcc_s.10.4.dylib libgcc_s.10.5.dylib
67 cp libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp \
68 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_ || exit 1 ; \
69 MLIBS=`$(CC) --print-multi-lib \
70 | sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
71 for mlib in $$MLIBS ; do \
72 cp ../$${mlib}/libgcc/$${mlib}/libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT).tmp \
73 ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
75 $(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
76 -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
77 rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
79 install-darwin-libgcc-stubs : $(INSTALL_FILES)
80 $(mkinstalldirs) $(DESTDIR)$(slibdir)
81 for d in $(INSTALL_FILES) ; do \
82 $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
84 if [ -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib ]; then \
85 rm -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib; \
87 $(LN_S) libgcc_s.1.dylib \
88 $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib
89 if [ -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib ]; then \
90 rm -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib; \
92 $(LN_S) libgcc_s.1.dylib \
93 $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib
97 # Do not install shared libraries for any other multilibs. Unless
98 # we're putting them in the gcc directory during a build, for
99 # compatibility with the pre-top-level layout. In that case we
103 ifeq ($(enable_shared),yes)
104 all: install-darwin-libgcc-links
107 install-darwin-libgcc-links:
108 $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
109 for file in $(INSTALL_FILES); do \
110 rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
111 $(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/; \
114 rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
115 $(LN_S) libgcc_s.1.dylib \
116 $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
118 rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
119 $(LN_S) libgcc_s.1.dylib \
120 $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib