• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# This is a Makefile stub which handles the creation of Linux ELF shared
3# libraries.
4#
5# In order to use this stub, the following makefile variables must be defined.
6#
7# ELF_VERSION = 1.0
8# ELF_SO_VERSION = 1
9# ELF_IMAGE = libce
10# ELF_MYDIR = et
11# ELF_INSTALL_DIR = $(SHLIBDIR)
12# ELF_OTHER_LIBS = -lc
13
14all:: image
15
16real-subdirs:: Makefile
17	$(E) "	MKDIR elfshared"
18	$(Q) mkdir -p elfshared
19
20ELF_LIB = $(ELF_IMAGE).so.$(ELF_VERSION)
21ELF_SONAME = $(ELF_IMAGE).so.$(ELF_SO_VERSION)
22
23image:		$(ELF_LIB)
24
25$(ELF_LIB): $(OBJS)
26	$(E) "	GEN_ELF_SOLIB $(ELF_LIB)"
27	$(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \
28		-L$(top_builddir)/../lib $(LDFLAGS) \
29		-Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
30	$(Q) $(MV) elfshared/$(ELF_LIB) .
31	$(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
32	$(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \
33		`echo $(my_dir) | sed -e 's;lib/;;'`/$(ELF_LIB) $(ELF_LIB))
34	$(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) $(ELF_LIB) $(ELF_IMAGE).so)
35	$(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) $(ELF_LIB) $(ELF_SONAME))
36
37installdirs-elf-lib::
38	$(E) "	MKINSTALLDIRS $(ELF_INSTALL_DIR) $(libdir)"
39	$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(ELF_INSTALL_DIR) \
40		$(DESTDIR)$(libdir)
41
42installdirs:: installdirs-elf-lib
43
44install-shlibs install:: $(ELF_LIB) installdirs-elf-lib $(DEP_INSTALL_SYMLINK)
45	$(E) "	INSTALL-ELF-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
46	$(Q) $(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
47	$(E) "	SYMLINK $(ELF_INSTALL_DIR)/$(ELF_SONAME)"
48	$(Q) $(INSTALL_SYMLINK) $(ELF_INSTALL_DIR)/$(ELF_LIB) \
49		$(ELF_INSTALL_DIR)/$(ELF_SONAME) $(DESTDIR)
50	$(E) "	SYMLINK $(libdir)/$(ELF_IMAGE).so"
51	$(Q) $(INSTALL_SYMLINK) $(ELF_INSTALL_DIR)/$(ELF_SONAME) \
52		$(libdir)/$(ELF_IMAGE).so $(DESTDIR)
53	$(E) "	LDCONFIG"
54	$(Q) -$(LDCONFIG)
55
56install-strip: install
57	$(E) "	STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
58	$(Q) $(STRIP) --strip-unneeded --remove-section=.comment \
59		--remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
60
61install-shlibs-strip: install-shlibs
62	$(E) "	STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
63	$(Q) $(STRIP) --strip-unneeded --remove-section=.comment \
64		--remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
65
66uninstall-shlibs uninstall::
67	$(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) \
68		$(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) \
69		$(DESTDIR)$(libdir)/$(ELF_IMAGE).so
70	-$(LDCONFIG)
71
72clean::
73	$(RM) -rf elfshared
74	$(RM) -f $(ELF_LIB)
75	$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
76