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 14 all:: image 15 16 real-subdirs:: Makefile 17 $(E) " MKDIR elfshared" 18 $(Q) mkdir -p elfshared 19 20 ELF_LIB = $(ELF_IMAGE).so.$(ELF_VERSION) 21 ELF_SONAME = $(ELF_IMAGE).so.$(ELF_SO_VERSION) 22 23 image: $(ELF_LIB) 24 25 $(ELF_LIB): $(OBJS) 26 $(E) " GEN_ELF_SOLIB $(ELF_LIB)" 27 $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \ 28 -Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) 29 $(Q) $(MV) elfshared/$(ELF_LIB) . 30 $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) 31 $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \ 32 `echo $(my_dir) | sed -e 's;lib/;;'`/$(ELF_LIB) $(ELF_LIB)) 33 $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) $(ELF_LIB) $(ELF_IMAGE).so) 34 $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) $(ELF_LIB) $(ELF_SONAME)) 35 36 installdirs-elf-lib:: 37 $(E) " MKINSTALLDIRS $(ELF_INSTALL_DIR) $(libdir)" 38 $(Q) $(MKINSTALLDIRS) $(DESTDIR)$(ELF_INSTALL_DIR) \ 39 $(DESTDIR)$(libdir) 40 41 installdirs:: installdirs-elf-lib 42 43 install-shlibs install:: $(ELF_LIB) installdirs-elf-lib 44 $(E) " INSTALL-ELF-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)" 45 $(Q) $(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) 46 $(E) " SYMLINK $(ELF_INSTALL_DIR)/$(ELF_SONAME)" 47 $(Q) $(LN_S) -f $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) 48 $(E) " SYMLINK $(libdir)/$(ELF_IMAGE).so" 49 $(Q) if test "$(ELF_INSTALL_DIR)" = "$(libdir)"; then \ 50 $(LN_S) -f $(ELF_SONAME) $(DESTDIR)$(libdir)/$(ELF_IMAGE).so ; \ 51 else \ 52 $(LN_S) -f $(ELF_INSTALL_DIR)/$(ELF_SONAME) \ 53 $(DESTDIR)$(libdir)/$(ELF_IMAGE).so; \ 54 fi 55 $(E) " LDCONFIG" 56 $(Q) -$(LDCONFIG) 57 58 install-strip: install 59 $(E) " STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)" 60 $(Q) $(STRIP) --strip-unneeded --remove-section=.comment \ 61 --remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) 62 63 install-shlibs-strip: install-shlibs 64 $(E) " STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)" 65 $(Q) $(STRIP) --strip-unneeded --remove-section=.comment \ 66 --remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) 67 68 uninstall-shlibs uninstall:: 69 $(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) \ 70 $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) \ 71 $(DESTDIR)$(libdir)/$(ELF_IMAGE).so 72 -$(LDCONFIG) 73 74 clean:: 75 $(RM) -rf elfshared 76 $(RM) -f $(ELF_LIB) 77 $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) 78