2006-03-15 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / gcc / config / t-slibgcc-darwin
blobe90f500d74c62b33eeb90411a4f7f5bec3ba6a45
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
5 SHLIB_SUFFIX = `if test @multilib_dir@ != . ; then echo _@multilib_dir@ ; fi`
6 SHLIB_SONAME = @shlib_base_name@$(SHLIB_SUFFIX).$(SHLIB_SOVERSION)$(SHLIB_EXT)
7 SHLIB_MAP = @shlib_map_file@
8 SHLIB_OBJS = @shlib_objs@
9 SHLIB_DIR = @multilib_dir@
11 # Darwin only searches in /usr/lib for shared libraries, not in subdirectories,
12 # so the libgcc variants have different names not different locations.
13 # Note that this version is used for the loader, not the linker; the linker
14 # uses the stub versions named by $(LIBGCC).
15 SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
16         -Wl,-install_name,$(slibdir)/$(SHLIB_SONAME) \
17         -single_module -o $(SHLIB_SONAME).tmp \
18         -Wl,-exported_symbols_list,$(SHLIB_MAP) \
19         $(SHLIB_VERSTRING) \
20         @multilib_flags@ $(SHLIB_OBJS) -lc && \
21         if [ -f $(SHLIB_SONAME) ]; then \
22           mv -f $(SHLIB_SONAME) $(SHLIB_SONAME).backup; \
23         else true; fi && \
24         mv $(SHLIB_SONAME).tmp $(SHLIB_SONAME)
26 # $(slibdir) double quoted to protect it from expansion while building
27 # libgcc.mk.  We want this delayed until actual install time.
28 SHLIB_INSTALL = \
29         $$(mkinstalldirs) $$(DESTDIR)$$(slibdir); \
30         $(INSTALL_DATA) $(SHLIB_SONAME) \
31           $$(DESTDIR)$$(slibdir)/$(SHLIB_SONAME)
33 SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
34 SHLIB_MKMAP_OPTS = -v leading_underscore=1
35 SHLIB_MAPFILES += $(srcdir)/libgcc-std.ver
37 # Must use a different directive for hidden visibility in assembly sources.
38 ASM_HIDDEN_OP = .private_extern
40 # In order to support -mmacosx-version-min, you need to have multiple
41 # different libgcc_s libraries that actually get linked against, one for
42 # each system version supported.  They are 'stub' libraries that
43 # contain no code, just a list of exported symbols.
44 # The actual use of the libraries is controlled by REAL_LIBGCC_SPEC.
45
46 # This assumes each multilib corresponds to a different architecture.
47 libgcc_s.%.dylib : $(SHLIB_VERPFX).%.ver libgcc.a
48         # When builting multilibbed target libraries, all the required
49         # libraries are expected to exist in the multilib directory.
50         MLIBS=`$(GCC_FOR_TARGET) --print-multi-lib \
51                 | sed -e 's/;.*$$//' -e '/^\.$$/d'` ; \
52         for mlib in $$MLIBS ; do \
53           rm -f $${mlib}/$@ || exit 1 ; \
54           $(LN_S) ../$@ $${mlib}/$@ || exit 1 ; \
55         done
56         MLIBS=`$(GCC_FOR_TARGET) --print-multi-lib \
57                 | sed -e 's/;.*$$//' -e '/^\.$$/d' -e 's/^/_/'` ; \
58         for mlib in '' $$MLIBS ; do \
59           $(STRIP_FOR_TARGET) -o $(@)_T$${mlib} \
60             -s $(SHLIB_VERPFX).$(*).ver -c -u \
61             libgcc_s$${mlib}.$(SHLIB_SOVERSION)$(SHLIB_EXT) || exit 1 ; \
62         done
63         $(LIPO_FOR_TARGET) -output $@ -create $(@)_T*
64         rm $(@)_T*
66 # From the point-of-view of the Makefiles, libgcc is built by the 'strip'
67 # and 'lipo' commands above.
68 LIBGCC=libgcc_s.10.4.dylib libgcc_s.10.5.dylib
70 install-darwin-libgcc-stubs : $(LIBGCC) installdirs
71         for d in $(LIBGCC) ; do \
72           $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
73         done
75 INSTALL_LIBGCC += install-darwin-libgcc-stubs