common.mak 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. ifeq ($(CONFIG_MINGW),yes)
  20. -lib /machine:i386 /def:$(@:.dll=.def)
  21. endif
  22. %.o: %.c
  23. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  24. %.o: %.S
  25. $(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
  26. # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
  27. %.o: %.cpp
  28. g++ $(subst -Wall,,$(CFLAGS)) -c -o $@ $<
  29. depend: $(SRCS)
  30. $(CC) -MM $(CFLAGS) $^ 1>.depend
  31. dep: depend
  32. clean::
  33. rm -f *.o *.d *~ *.a *.lib *.so *.so.* *.dylib *.dll \
  34. *.lib *.def *.dll.a *.exp
  35. distclean: clean
  36. rm -f .depend
  37. ifeq ($(BUILD_SHARED),yes)
  38. INSTLIBTARGETS += install-lib-shared
  39. endif
  40. ifeq ($(BUILD_STATIC),yes)
  41. INSTLIBTARGETS += install-lib-static
  42. endif
  43. install: install-libs install-headers
  44. install-libs: $(INSTLIBTARGETS)
  45. install-lib-shared: $(SLIBNAME)
  46. install -d "$(libdir)"
  47. ifeq ($(CONFIG_MINGW),yes)
  48. install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
  49. else
  50. install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
  51. $(shlibdir)/$(SLIBNAME_WITH_VERSION)
  52. ln -sf $(SLIBNAME_WITH_VERSION) \
  53. $(shlibdir)/$(SLIBNAME_WITH_MAJOR)
  54. ln -sf $(SLIBNAME_WITH_VERSION) \
  55. $(shlibdir)/$(SLIBNAME)
  56. endif
  57. install-lib-static: $(LIB)
  58. install -d "$(libdir)"
  59. install -m 644 $(LIB) "$(libdir)"
  60. install-headers:
  61. install -d "$(incdir)"
  62. install -d "$(libdir)/pkgconfig"
  63. install -m 644 $(addprefix "$(SRC_DIR)"/,$(HEADERS)) "$(incdir)"
  64. install -m 644 $(BUILD_ROOT)/lib$(NAME).pc "$(libdir)/pkgconfig"
  65. uninstall: uninstall-libs uninstall-headers
  66. uninstall-libs:
  67. ifeq ($(CONFIG_MINGW),yes)
  68. -rm -f $(prefix)/$(SLIBNAME)
  69. else
  70. -rm -f $(libdir)/$(SLIBNAME_WITH_MAJOR) \
  71. $(libdir)/$(SLIBNAME) \
  72. $(libdir)/$(SLIBNAME_WITH_VERSION)
  73. endif
  74. -rm -f $(libdir)/$(LIB)
  75. uninstall-headers:
  76. rm -f $(addprefix $(incdir)/,$(HEADERS))
  77. rm -f $(libdir)/pkgconfig/lib$(NAME).pc
  78. #
  79. # include dependency files if they exist
  80. #
  81. ifneq ($(wildcard .depend),)
  82. include .depend
  83. endif