1 |
272 |
jeremybenn |
# Build a shared libgcc library with the darwin linker.
|
2 |
|
|
SHLIB_SOVERSION = 1
|
3 |
|
|
SHLIB_VERSTRING = -compatibility_version $(SHLIB_SOVERSION) -current_version $(SHLIB_SOVERSION).0
|
4 |
|
|
SHLIB_EXT = .dylib
|
5 |
|
|
SHLIB_INSTALL_NAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
6 |
|
|
SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
|
7 |
|
|
SHLIB_SOLINK = @shlib_base_name@.so
|
8 |
|
|
SHLIB_MAP = @shlib_map_file@
|
9 |
|
|
SHLIB_OBJS = @shlib_objs@
|
10 |
|
|
SHLIB_DIR = @multilib_dir@
|
11 |
|
|
SHLIB_LC = -lc
|
12 |
|
|
|
13 |
|
|
# Darwin only searches in /usr/lib for shared libraries, not in subdirectories,
|
14 |
|
|
# so the libgcc variants have different names not different locations.
|
15 |
|
|
# Note that this version is used for the loader, not the linker; the linker
|
16 |
|
|
# uses the stub versions named by the versioned members of $(INSTALL_FILES).
|
17 |
|
|
|
18 |
|
|
SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
|
19 |
|
|
-install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
|
20 |
|
|
-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
|
21 |
|
|
-Wl,-exported_symbols_list,$(SHLIB_MAP) \
|
22 |
|
|
$(SHLIB_VERSTRING) \
|
23 |
|
|
@multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC)
|
24 |
|
|
|
25 |
|
|
SHLIB_MKMAP = $(gcc_srcdir)/mkmap-flat.awk
|
26 |
|
|
SHLIB_MKMAP_OPTS = -v leading_underscore=1
|
27 |
|
|
SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-std.ver $(gcc_srcdir)/libgcc-libsystem.ver
|
28 |
|
|
|
29 |
|
|
# we're only going to build the stubs if the target slib is /usr/lib
|
30 |
|
|
# there is no other case in which they're useful in a live system.
|
31 |
|
|
ifeq (/usr/lib,$(shlib_slibdir))
|
32 |
|
|
LGCC_STUBS = libgcc_s.10.4.dylib libgcc_s.10.5.dylib
|
33 |
|
|
else
|
34 |
|
|
LGCC_STUBS =
|
35 |
|
|
endif
|
36 |
|
|
|
37 |
|
|
LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
|
38 |
|
|
LGCC_FILES += $(LGCC_STUBS)
|
39 |
|
|
LEXT_STUBS = libgcc_ext.10.4$(SHLIB_EXT) libgcc_ext.10.5$(SHLIB_EXT)
|
40 |
|
|
LGCC_FILES += $(LEXT_STUBS)
|
41 |
|
|
INSTALL_FILES=$(LGCC_FILES)
|
42 |
|
|
|
43 |
|
|
# we do our own thing
|
44 |
|
|
SHLIB_INSTALL =
|
45 |
|
|
|
46 |
|
|
# For the toplevel multilib, build a fat archive including all the multilibs.
|
47 |
|
|
ifeq ($(MULTIBUILDTOP),)
|
48 |
|
|
|
49 |
|
|
ifeq ($(enable_shared),yes)
|
50 |
|
|
all: $(INSTALL_FILES)
|
51 |
|
|
install-leaf: install-darwin-libgcc-stubs
|
52 |
|
|
endif
|
53 |
|
|
|
54 |
|
|
# In order to support -mmacosx-version-min, you need to have multiple
|
55 |
|
|
# different libgcc_s libraries that actually get linked against, one for
|
56 |
|
|
# each system version supported. They are 'stub' libraries that
|
57 |
|
|
# contain no code, just a list of exported symbols.
|
58 |
|
|
# The actual use of the libraries is controlled by REAL_LIBGCC_SPEC.
|
59 |
|
|
#
|
60 |
|
|
# This assumes each multilib corresponds to a different architecture.
|
61 |
|
|
libgcc_s.%.dylib : all-multi $(SHLIB_VERPFX).%.ver libgcc_s$(SHLIB_EXT)
|
62 |
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
63 |
|
|
for mlib in $$MLIBS ; do \
|
64 |
|
|
$(STRIP) -o $(@)_T$${mlib} \
|
65 |
|
|
-s $(SHLIB_VERPFX).$(*).ver -c -u \
|
66 |
|
|
../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) || exit 1 ; \
|
67 |
|
|
done
|
68 |
|
|
$(LIPO) -output $@ -create $(@)_T*
|
69 |
|
|
rm $(@)_T*
|
70 |
|
|
|
71 |
|
|
libgcc_ext.%.dylib : all-multi $(SHLIB_VERPFX).%.ver libgcc_s$(SHLIB_EXT)
|
72 |
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
73 |
|
|
for mlib in $$MLIBS ; do \
|
74 |
|
|
$(STRIP) -o $(@)_T$${mlib} \
|
75 |
|
|
-R $(SHLIB_VERPFX).$(*).ver -c -urx \
|
76 |
|
|
../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) || exit 1 ; \
|
77 |
|
|
done
|
78 |
|
|
$(LIPO) -output $@ -create $(@)_T*
|
79 |
|
|
rm $(@)_T*
|
80 |
|
|
|
81 |
|
|
libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
|
82 |
|
|
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
|
83 |
|
|
for mlib in $$MLIBS ; do \
|
84 |
|
|
cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
|
85 |
|
|
./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
|
86 |
|
|
done
|
87 |
|
|
$(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
|
88 |
|
|
-create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
89 |
|
|
rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
|
90 |
|
|
|
91 |
|
|
install-darwin-libgcc-stubs :
|
92 |
|
|
$(mkinstalldirs) $(DESTDIR)$(slibdir)
|
93 |
|
|
for d in $(INSTALL_FILES) ; do \
|
94 |
|
|
$(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
|
95 |
|
|
done
|
96 |
|
|
if [ -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib ]; then \
|
97 |
|
|
rm -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib; \
|
98 |
|
|
else true; fi
|
99 |
|
|
$(LN_S) libgcc_s.1.dylib \
|
100 |
|
|
$(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib
|
101 |
|
|
if [ -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib ]; then \
|
102 |
|
|
rm -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib; \
|
103 |
|
|
else true; fi
|
104 |
|
|
$(LN_S) libgcc_s.1.dylib \
|
105 |
|
|
$(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib
|
106 |
|
|
|
107 |
|
|
else
|
108 |
|
|
|
109 |
|
|
# Do not install shared libraries for any other multilibs. Unless
|
110 |
|
|
# we're putting them in the gcc directory during a build, for
|
111 |
|
|
# compatibility with the pre-top-level layout. In that case we
|
112 |
|
|
# need symlinks.
|
113 |
|
|
|
114 |
|
|
ifeq ($(enable_shared),yes)
|
115 |
|
|
all: install-darwin-libgcc-links
|
116 |
|
|
endif
|
117 |
|
|
|
118 |
|
|
install-darwin-libgcc-links:
|
119 |
|
|
$(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
|
120 |
|
|
for file in $(INSTALL_FILES); do \
|
121 |
|
|
rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file; \
|
122 |
|
|
$(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/; \
|
123 |
|
|
done
|
124 |
|
|
|
125 |
|
|
rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
|
126 |
|
|
$(LN_S) libgcc_s.1.dylib \
|
127 |
|
|
$(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
|
128 |
|
|
|
129 |
|
|
rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
|
130 |
|
|
$(LN_S) libgcc_s.1.dylib \
|
131 |
|
|
$(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
|
132 |
|
|
|
133 |
|
|
endif
|