• 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_SHLIB) \
29		-Wl,-h,$(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	$(MKDIR_P) $(DESTDIR)$(ELF_INSTALL_DIR) \
39		$(DESTDIR)$(libdir)
40
41installdirs:: installdirs-elf-lib
42
43install-shlibs install:: $(ELF_LIB) installdirs-elf-lib
44	$(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
45	$(LN_S) -f $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME)
46	$(LN_S) -f $(ELF_INSTALL_DIR)/$(ELF_SONAME) \
47		$(DESTDIR)$(libdir)/$(ELF_IMAGE).so
48	-$(LDCONFIG)
49
50install-strip: install
51	$(STRIP) -x $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
52
53install-shlibs-strip:: install-shlibs
54	$(STRIP) -x $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
55
56uninstall-shlibs uninstall::
57	$(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) \
58		$(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) \
59		$(DESTDIR)$(libdir)/$(ELF_IMAGE).so
60	-$(LDCONFIG)
61
62clean::
63	$(RM) -rf elfshared
64	$(RM) -f $(ELF_LIB)
65	$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
66