Home | History | Annotate | Download | only in lib
      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) $(LN) $(ELF_LIB) ../$(ELF_LIB)
     32 	$(Q) $(LN) ../$(ELF_LIB) ../$(ELF_IMAGE).so
     33 	$(Q) $(LN) ../$(ELF_LIB) ../$(ELF_SONAME)
     34 
     35 installdirs-elf-lib::
     36 	$(E) "	MKINSTALLDIRS $(ELF_INSTALL_DIR) $(libdir)"
     37 	$(Q) $(MKINSTALLDIRS) $(DESTDIR)$(ELF_INSTALL_DIR) \
     38 		$(DESTDIR)$(libdir)
     39 
     40 installdirs:: installdirs-elf-lib
     41 
     42 install-shlibs install:: $(ELF_LIB) installdirs-elf-lib
     43 	$(E) "	INSTALL-ELF-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
     44 	$(Q) $(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
     45 	$(E) "	SYMLINK $(ELF_INSTALL_DIR)/$(ELF_SONAME)"
     46 	$(Q) $(LN_S) -f $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME)
     47 	$(E) "	SYMLINK $(libdir)/$(ELF_IMAGE).so"
     48 	$(Q) if test "$(ELF_INSTALL_DIR)" = "$(libdir)"; then \
     49 		$(LN_S) -f $(ELF_SONAME) $(DESTDIR)$(libdir)/$(ELF_IMAGE).so ; \
     50 	else \
     51 		$(LN_S) -f $(ELF_INSTALL_DIR)/$(ELF_SONAME) \
     52 			$(DESTDIR)$(libdir)/$(ELF_IMAGE).so; \
     53 	fi			
     54 	$(E) "	LDCONFIG"
     55 	$(Q) -$(LDCONFIG)
     56 
     57 install-strip: install
     58 	$(E) "	STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
     59 	$(Q) $(STRIP) --strip-unneeded --remove-section=.comment \
     60 		--remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
     61 
     62 install-shlibs-strip: install-shlibs
     63 	$(E) "	STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
     64 	$(Q) $(STRIP) --strip-unneeded --remove-section=.comment \
     65 		--remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
     66 
     67 uninstall-shlibs uninstall::
     68 	$(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) \
     69 		$(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) \
     70 		$(DESTDIR)$(libdir)/$(ELF_IMAGE).so
     71 	-$(LDCONFIG)
     72 
     73 clean::
     74 	$(RM) -rf elfshared
     75 	$(RM) -f $(ELF_LIB)
     76 	$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
     77