1# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2011
2# Free Software Foundation, Inc.
3#
4# This file is part of GCC.
5#
6# GCC is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3, or (at your option)
9# any later version.
10#
11# GCC is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with GCC; see the file COPYING3.  If not see
18# <http://www.gnu.org/licenses/>.
19
20# Build a shared libgcc library.
21
22SHLIB_EXT = .so
23SHLIB_SOLINK = @shlib_base_name@.so
24SHLIB_SOVERSION = 1
25SHLIB_SONAME = @shlib_base_name@.so.$(SHLIB_SOVERSION)
26SHLIB_MAP = @shlib_map_file@
27SHLIB_OBJS = @shlib_objs@
28SHLIB_DIR = @multilib_dir@
29SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@
30SHLIB_LC = -lc
31SHLIB_MAKE_SOLINK = $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
32SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
33	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
34
35SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
36	$(SHLIB_LDFLAGS) \
37	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
38	$(SHLIB_OBJS) $(SHLIB_LC) && \
39	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
40	if [ -f $(SHLIB_DIR)/$(SHLIB_SONAME) ]; then \
41	  mv -f $(SHLIB_DIR)/$(SHLIB_SONAME) \
42		$(SHLIB_DIR)/$(SHLIB_SONAME).backup; \
43	else true; fi && \
44	mv $(SHLIB_DIR)/$(SHLIB_SONAME).tmp $(SHLIB_DIR)/$(SHLIB_SONAME) && \
45	$(SHLIB_MAKE_SOLINK)
46
47INSTALL_SHLIB = $(INSTALL_DATA)
48
49SHLIB_INSTALL = \
50	$(mkinstalldirs) $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL); \
51	$(INSTALL_SHLIB) $(SHLIB_DIR)/$(SHLIB_SONAME) \
52	  $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME); \
53	rm -f $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK); \
54	$(SHLIB_INSTALL_SOLINK)
55