common.mak 2.5 KB

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