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