subdir.mak 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. SRC_DIR := $(SRC_PATH_BARE)/lib$(NAME)
  2. include $(SUBDIR)../common.mak
  3. LIBVERSION := $(lib$(NAME)_VERSION)
  4. LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
  5. INCINSTDIR := $(INCDIR)/lib$(NAME)
  6. THIS_LIB := $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
  7. all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME)
  8. all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME)
  9. $(SUBDIR)%-test.o: $(SUBDIR)%-test.c
  10. $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^
  11. $(SUBDIR)%-test.o: $(SUBDIR)%.c
  12. $(CC) $(CPPFLAGS) $(CFLAGS) -DTEST -c $(CC_O) $^
  13. $(SUBDIR)x86/%.o: $(SUBDIR)x86/%.asm
  14. $(YASMDEP) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
  15. $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<
  16. $(OBJS) $(SUBDIR)%.ho $(SUBDIR)%-test.o $(TESTOBJS): CPPFLAGS += -DHAVE_AV_CONFIG_H
  17. $(SUBDIR)$(LIBNAME): $(OBJS)
  18. $(RM) $@
  19. $(AR) rc $@ $^ $(EXTRAOBJS)
  20. $(RANLIB) $@
  21. install-headers: install-lib$(NAME)-headers install-lib$(NAME)-pkgconfig
  22. install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
  23. install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
  24. define RULES
  25. $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
  26. $$(LD) $(FFLDFLAGS) -o $$@ $$^ -l$(FULLNAME) $(FFEXTRALIBS) $$(ELIBS)
  27. $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
  28. $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
  29. $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
  30. $(SLIB_CREATE_DEF_CMD)
  31. $$(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
  32. $(SLIB_EXTRA_CMD)
  33. ifdef SUBDIR
  34. $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
  35. endif
  36. clean::
  37. $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
  38. $(foreach dir,$(DIRS),$(CLEANSUFFIXES:%=$(SUBDIR)$(dir)/%)) \
  39. $(HOSTOBJS) $(HOSTPROGS)
  40. distclean:: clean
  41. $(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) \
  42. $(foreach dir,$(DIRS),$(DISTCLEANSUFFIXES:%=$(SUBDIR)$(dir)/%))
  43. install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
  44. $(Q)mkdir -p "$(SHLIBDIR)"
  45. $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
  46. $$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
  47. $(Q)cd "$(SHLIBDIR)" && \
  48. $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
  49. $(Q)cd "$(SHLIBDIR)" && \
  50. $(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME)
  51. $(SLIB_INSTALL_EXTRA_CMD)
  52. install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
  53. $(Q)mkdir -p "$(LIBDIR)"
  54. $$(INSTALL) -m 644 $$< "$(LIBDIR)"
  55. $(LIB_INSTALL_EXTRA_CMD)
  56. install-lib$(NAME)-headers: $(addprefix $(SUBDIR),$(HEADERS) $(BUILT_HEADERS))
  57. $(Q)mkdir -p "$(INCINSTDIR)"
  58. $$(INSTALL) -m 644 $$^ "$(INCINSTDIR)"
  59. install-lib$(NAME)-pkgconfig: $(SUBDIR)lib$(NAME).pc
  60. $(Q)mkdir -p "$(LIBDIR)/pkgconfig"
  61. $$(INSTALL) -m 644 $$^ "$(LIBDIR)/pkgconfig"
  62. uninstall-libs::
  63. -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
  64. "$(SHLIBDIR)/$(SLIBNAME)" \
  65. "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
  66. -$(SLIB_UNINSTALL_EXTRA_CMD)
  67. -$(RM) "$(LIBDIR)/$(LIBNAME)"
  68. uninstall-headers::
  69. $(RM) $(addprefix "$(INCINSTDIR)/",$(HEADERS)) $(addprefix "$(INCINSTDIR)/",$(BUILT_HEADERS))
  70. $(RM) "$(LIBDIR)/pkgconfig/lib$(NAME).pc"
  71. -rmdir "$(INCINSTDIR)"
  72. endef
  73. $(eval $(RULES))
  74. $(EXAMPLES) $(TESTPROGS): $(THIS_LIB) $(DEP_LIBS)
  75. examples: $(EXAMPLES)
  76. testprogs: $(TESTPROGS)