You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.7KB

  1. #
  2. # common bits used by all libraries
  3. #
  4. SRC_DIR = $(SRC_PATH)/lib$(NAME)
  5. VPATH = $(SRC_DIR)
  6. #FIXME: This should be in configure/config.mak
  7. ifeq ($(CONFIG_WIN32),yes)
  8. LDFLAGS = -Wl,--output-def,$(@:.dll=.def),--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
  9. endif
  10. ifeq ($(TARGET_GPROF),yes)
  11. CFLAGS+=-p
  12. LDFLAGS+=-p
  13. endif
  14. #FIXME: This should be in configure/config.mak
  15. ifeq ($(TARGET_ARCH_SPARC64),yes)
  16. CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
  17. endif
  18. SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
  19. OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
  20. STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
  21. SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
  22. all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
  23. $(LIB): $(STATIC_OBJS)
  24. rm -f $@
  25. $(AR) rc $@ $^ $(EXTRAOBJS)
  26. $(RANLIB) $@
  27. $(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
  28. ln -sf $^ $@
  29. $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
  30. $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
  31. ifeq ($(CONFIG_WIN32),yes)
  32. -lib /machine:i386 /def:$(@:.dll=.def)
  33. endif
  34. %.o: %.c
  35. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  36. %.o: %.S
  37. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  38. # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
  39. %.o: %.cpp
  40. g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
  41. depend: $(SRCS)
  42. $(CC) -MM $(CFLAGS) $^ 1>.depend
  43. dep: depend
  44. clean::
  45. rm -f *.o *.d *~ *.a *.lib *.so *.dylib *.dll \
  46. *.lib *.def *.dll.a *.exp
  47. distclean: clean
  48. rm -f .depend
  49. ifeq ($(BUILD_SHARED),yes)
  50. INSTLIBTARGETS += install-lib-shared
  51. endif
  52. ifeq ($(BUILD_STATIC),yes)
  53. INSTLIBTARGETS += install-lib-static
  54. endif
  55. install: install-libs install-headers
  56. install-libs: $(INSTLIBTARGETS)
  57. install-lib-shared: $(SLIBNAME)
  58. install -d "$(libdir)"
  59. ifeq ($(CONFIG_WIN32),yes)
  60. install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
  61. else
  62. install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
  63. $(libdir)/$(SLIBNAME_WITH_VERSION)
  64. ln -sf $(SLIBNAME_WITH_VERSION) \
  65. $(libdir)/$(SLIBNAME_WITH_MAJOR)
  66. ln -sf $(SLIBNAME_WITH_VERSION) \
  67. $(libdir)/$(SLIBNAME)
  68. endif
  69. install-lib-static: $(LIB)
  70. install -d "$(libdir)"
  71. install -m 644 $(LIB) "$(libdir)"
  72. install-headers:
  73. install -d "$(incdir)"
  74. install -d "$(libdir)/pkgconfig"
  75. install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
  76. install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
  77. uninstall: uninstall-libs uninstall-headers
  78. uninstall-libs:
  79. ifeq ($(CONFIG_WIN32),yes)
  80. -rm -f $(prefix)/$(SLIBNAME)
  81. else
  82. -rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \
  83. $(libdir)/$(SLIBNAME) \
  84. $(libdir)/$(SLIBNAME_WITH_VERSION)
  85. endif
  86. -rm -f $(libdir)/$(LIB)
  87. uninstall-headers:
  88. rm -f $(addprefix $(incdir)/,$(HEADERS))
  89. rm -f $(libdir)/pkgconfig/lib$(NAME).pc
  90. #
  91. # include dependency files if they exist
  92. #
  93. ifneq ($(wildcard .depend),)
  94. include .depend
  95. endif