Makefile.libs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
  4. #
  5. # Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
  6. #
  7. #LIB_NAME:=libsome
  8. ifneq ($(strip $(LIB_NAME)),)
  9. ifeq ($(strip $(srcdir)),)
  10. srcdir=$(top_srcdir)$(LIB_NAME)
  11. endif
  12. ifeq ($(strip $($(LIB_NAME)_DIR)),)
  13. $(LIB_NAME)_DIR:=$(top_builddir)$(LIB_NAME)
  14. endif
  15. ifeq ($(strip $($(LIB_NAME)_FULL_NAME)),)
  16. $(LIB_NAME)_FULL_NAME:=$(LIB_NAME)-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
  17. endif
  18. ifeq ($(strip $($(LIB_NAME)_SRC)),)
  19. ifeq ($(strip $($(LIB_NAME)_MSRC)),)
  20. $(LIB_NAME)_SRC:=$(wildcard $(srcdir)/*.c)
  21. endif
  22. endif
  23. ifeq ($(strip $($(LIB_NAME)_OBJ)),)
  24. $(LIB_NAME)_OBJ:=$(patsubst $(srcdir)/%.c,$($(LIB_NAME)_DIR)/%.o,$($(LIB_NAME)_SRC))
  25. endif
  26. $(LIB_NAME)_OBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_OBJ))
  27. $(LIB_NAME)_MOBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_MOBJ))
  28. $(LIB_NAME)_SOBJ_PIC:=$(patsubst %.o,%.os,$($(LIB_NAME)_SOBJ))
  29. #libso-y+=$(top_builddir)lib/$(LIB_NAME).so
  30. #liba-y+=$(top_builddir)lib/$(LIB_NAME).a
  31. #libclean-y+=$(LIB_NAME)_clean
  32. $($(LIB_NAME)_OBJ): %.o : %.c
  33. $(compile.c)
  34. $($(LIB_NAME)_OBJ_PIC): %.os : %.c
  35. $(compile.c) $(PICFLAG)
  36. $($(LIB_NAME)_MOBJ): $($(LIB_NAME)_MSRC)
  37. $(compile.m)
  38. $($(LIB_NAME)_MOBJ_PIC): $($(LIB_NAME)_MSRC)
  39. $(compile.m) $(PICFLAG)
  40. $($(LIB_NAME)_SOBJ): %.o : %.S
  41. $(compile.S)
  42. $($(LIB_NAME)_SOBJ_PIC): %.os : %.S
  43. $(compile.S) $(PICFLAG)
  44. # this should be changed to .os after libc/misc/internals/ is done
  45. libc:=$(top_builddir)lib/libc.so
  46. interp:=$(top_builddir)libc/misc/internals/interp.o
  47. ifeq ($(strip $(EXTRA_LINK_LIBS)),)
  48. #EXTRA_LINK_LIBS:=$(interp) -L$(top_builddir)lib -lc $(LDADD_LIBFLOAT) $(LIBGCC)
  49. EXTRA_LINK_LIBS:=$(interp) $(libc) $(LDADD_LIBFLOAT) $(LIBGCC)
  50. endif
  51. $(top_builddir)lib/$(LIB_NAME).so: $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a $(interp) $(libc)
  52. $(INSTALL) -d $(top_builddir)lib
  53. $(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
  54. $(LD) $(LDFLAGS) $(EXTRA_LINK_OPTS) -soname=$(notdir $@).$(MAJOR_VERSION) \
  55. -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) $(SHARED_START_FILES) \
  56. --whole-archive $(firstword $^) --no-whole-archive \
  57. $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
  58. $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
  59. $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@
  60. $(top_builddir)lib/$(LIB_NAME).so1: $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC) $($(LIB_NAME)_SOBJ_PIC) $($(LIB_NAME)_SO_ADD)
  61. $(INSTALL) -d $(top_builddir)lib
  62. $(RM) $@ $@.$(MAJOR_VERSION) $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME)
  63. $(LD) $(LDFLAGS) $(EXTRA_LINK_OPTS) -soname=$(notdir $@).$(MAJOR_VERSION) \
  64. -o $(top_builddir)lib/$($(LIB_NAME)_FULL_NAME) $(SHARED_START_FILES) $^ \
  65. $(EXTRA_LINK_LIBS) $(SHARED_END_FILES)
  66. $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@.$(MAJOR_VERSION)
  67. $(LN) -sf $($(LIB_NAME)_FULL_NAME) $@
  68. $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a: $($(LIB_NAME)_OBJ_PIC) $($(LIB_NAME)_MOBJ_PIC) $($(LIB_NAME)_SOBJ_PIC) $($(LIB_NAME)_SO_ADD)
  69. ifneq ($(strip $(STRIP_FLAGS)),)
  70. $(STRIPTOOL) $(STRIP_FLAGS) $^
  71. else
  72. $(STRIPTOOL) -x -R .note -R .comment $^
  73. endif
  74. $(AR) $(ARFLAGS) $@ $^
  75. ifeq ($(DOPIC),y)
  76. $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_DIR)/$(LIB_NAME)_pic.a
  77. $(RM) $@
  78. cp $< $@
  79. else
  80. $(top_builddir)lib/$(LIB_NAME).a: $($(LIB_NAME)_OBJ) $($(LIB_NAME)_MOBJ) $($(LIB_NAME)_SOBJ) $($(LIB_NAME)_A_ADD)
  81. $(RM) $@
  82. $(STRIPTOOL) -x -R .note -R .comment $^
  83. $(AR) $(ARFLAGS) $@ $^
  84. endif
  85. $(LIB_NAME)_clean:
  86. rm -f $($(LIB_NAME)_DIR)/*.{o,os,a}
  87. endif
  88. include $(top_srcdir)Makerules