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.

98 lines
2.2KB

  1. #
  2. # common bits used by all libraries
  3. #
  4. SRC_DIR = $(SRC_PATH)/lib$(NAME)
  5. VPATH = $(SRC_DIR)
  6. SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S) $(CPPOBJS:.o=.cpp)
  7. OBJS := $(OBJS) $(ASM_OBJS) $(CPPOBJS)
  8. STATIC_OBJS := $(OBJS) $(STATIC_OBJS)
  9. SHARED_OBJS := $(OBJS) $(SHARED_OBJS)
  10. all: $(EXTRADEPS) $(LIB) $(SLIBNAME)
  11. $(LIB): $(STATIC_OBJS)
  12. rm -f $@
  13. $(AR) rc $@ $^ $(EXTRAOBJS)
  14. $(RANLIB) $@
  15. $(SLIBNAME): $(SLIBNAME_WITH_MAJOR)
  16. ln -sf $^ $@
  17. $(SLIBNAME_WITH_MAJOR): $(SHARED_OBJS)
  18. $(CC) $(SHFLAGS) $(LDFLAGS) -o $@ $^ $(EXTRALIBS) $(EXTRAOBJS)
  19. $(SLIB_EXTRA_CMD)
  20. %.o: %.c
  21. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  22. %.o: %.S
  23. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  24. # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
  25. %.o: %.cpp
  26. g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
  27. depend dep: $(SRCS)
  28. $(CC) -MM $(CFLAGS) $^ 1>.depend
  29. clean::
  30. rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
  31. *.lib *.def *.dll.a *.exp
  32. distclean: clean
  33. rm -f .depend
  34. ifeq ($(BUILD_SHARED),yes)
  35. INSTLIBTARGETS += install-lib-shared
  36. endif
  37. ifeq ($(BUILD_STATIC),yes)
  38. INSTLIBTARGETS += install-lib-static
  39. endif
  40. install: install-libs install-headers
  41. install-libs: $(INSTLIBTARGETS)
  42. install-lib-shared: $(SLIBNAME)
  43. install -d "$(shlibdir)"
  44. install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
  45. "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
  46. cd "$(shlibdir)" && \
  47. ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
  48. cd "$(shlibdir)" && \
  49. ln -sf $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
  50. install-lib-static: $(LIB)
  51. install -d "$(libdir)"
  52. install -m 644 $(LIB) "$(libdir)"
  53. $(LIB_INSTALL_EXTRA_CMD)
  54. install-headers:
  55. install -d "$(incdir)"
  56. install -d "$(libdir)/pkgconfig"
  57. install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
  58. install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
  59. uninstall: uninstall-libs uninstall-headers
  60. uninstall-libs:
  61. -rm -f "$(shlibdir)/$(SLIBNAME_WITH_MAJOR)" \
  62. "$(shlibdir)/$(SLIBNAME)" \
  63. "$(shlibdir)/$(SLIBNAME_WITH_VERSION)"
  64. -rm -f "$(libdir)/$(LIB)"
  65. uninstall-headers:
  66. rm -f "$(addprefix $(incdir)/,$(HEADERS))"
  67. rm -f "$(libdir)/pkgconfig/lib$(NAME).pc"
  68. .PHONY: all depend dep clean distclean install* uninstall*
  69. #
  70. # include dependency files if they exist
  71. #
  72. ifneq ($(wildcard .depend),)
  73. include .depend
  74. endif