Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. MAIN_MAKEFILE=1
  2. include config.mak
  3. vpath %.c $(SRC_PATH)
  4. vpath %.cpp $(SRC_PATH)
  5. vpath %.h $(SRC_PATH)
  6. vpath %.S $(SRC_PATH)
  7. vpath %.asm $(SRC_PATH)
  8. vpath %.v $(SRC_PATH)
  9. vpath %.texi $(SRC_PATH)
  10. vpath %/fate_config.sh.template $(SRC_PATH)
  11. PROGS-$(CONFIG_FFMPEG) += ffmpeg
  12. PROGS-$(CONFIG_FFPLAY) += ffplay
  13. PROGS-$(CONFIG_FFPROBE) += ffprobe
  14. PROGS-$(CONFIG_FFSERVER) += ffserver
  15. PROGS := $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
  16. INSTPROGS = $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
  17. OBJS = cmdutils.o $(EXEOBJS)
  18. OBJS-ffmpeg = ffmpeg_opt.o ffmpeg_filter.o
  19. TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
  20. HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
  21. TOOLS = qt-faststart trasher
  22. TOOLS-$(CONFIG_ZLIB) += cws2fws
  23. BASENAMES = ffmpeg ffplay ffprobe ffserver
  24. ALLPROGS = $(BASENAMES:%=%$(PROGSSUF)$(EXESUF))
  25. ALLPROGS_G = $(BASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
  26. FFLIBS-$(CONFIG_AVDEVICE) += avdevice
  27. FFLIBS-$(CONFIG_AVFILTER) += avfilter
  28. FFLIBS-$(CONFIG_AVFORMAT) += avformat
  29. FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
  30. FFLIBS-$(CONFIG_AVCODEC) += avcodec
  31. FFLIBS-$(CONFIG_POSTPROC) += postproc
  32. FFLIBS-$(CONFIG_SWRESAMPLE)+= swresample
  33. FFLIBS-$(CONFIG_SWSCALE) += swscale
  34. FFLIBS := avutil
  35. DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
  36. EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
  37. SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
  38. include $(SRC_PATH)/common.mak
  39. FF_EXTRALIBS := $(FFEXTRALIBS)
  40. FF_DEP_LIBS := $(DEP_LIBS)
  41. all: $(PROGS)
  42. $(PROGS): %$(EXESUF): %_g$(EXESUF)
  43. $(CP) $< $@
  44. $(STRIP) $@
  45. $(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
  46. $(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS)
  47. tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
  48. config.h: .config
  49. .config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
  50. @-tput bold 2>/dev/null
  51. @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
  52. @-tput sgr0 2>/dev/null
  53. SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
  54. HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
  55. ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS \
  56. ALTIVEC-OBJS VIS-OBJS \
  57. MMX-OBJS YASM-OBJS \
  58. MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS \
  59. OBJS HOSTOBJS TESTOBJS
  60. define RESET
  61. $(1) :=
  62. $(1)-yes :=
  63. endef
  64. define DOSUBDIR
  65. $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
  66. SUBDIR := $(1)/
  67. include $(SRC_PATH)/$(1)/Makefile
  68. -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
  69. include $(SRC_PATH)/library.mak
  70. endef
  71. $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
  72. define DOPROG
  73. OBJS-$(1) += $(1).o cmdutils.o $(EXEOBJS)
  74. $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
  75. $$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
  76. $(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
  77. $(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
  78. -include $$(OBJS-$(1):.o=.d)
  79. endef
  80. $(foreach P,$(PROGS-yes),$(eval $(call DOPROG,$(P))))
  81. %$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
  82. $(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
  83. OBJDIRS += tools
  84. -include $(wildcard tools/*.d)
  85. VERSION_SH = $(SRC_PATH)/version.sh
  86. GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
  87. .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
  88. .version: M=@
  89. version.h .version:
  90. $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
  91. $(Q)touch .version
  92. # force version.sh to run whenever version might have changed
  93. -include .version
  94. ifdef PROGS
  95. install: install-progs install-data
  96. endif
  97. install: install-libs install-headers
  98. install-libs: install-libs-yes
  99. install-progs-yes:
  100. install-progs-$(CONFIG_SHARED): install-libs
  101. install-progs: install-progs-yes $(PROGS)
  102. $(Q)mkdir -p "$(BINDIR)"
  103. $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
  104. install-data: $(DATA_FILES) $(EXAMPLES_FILES)
  105. $(Q)mkdir -p "$(DATADIR)/examples"
  106. $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
  107. $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
  108. uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
  109. uninstall-progs:
  110. $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
  111. uninstall-data:
  112. $(RM) -r "$(DATADIR)"
  113. clean::
  114. $(RM) $(ALLPROGS) $(ALLPROGS_G)
  115. $(RM) $(CLEANSUFFIXES)
  116. $(RM) $(CLEANSUFFIXES:%=tools/%)
  117. $(RM) -r coverage-html
  118. $(RM) -rf coverage.info lcov
  119. distclean::
  120. $(RM) $(DISTCLEANSUFFIXES)
  121. $(RM) config.* .config libavutil/avconfig.h .version version.h libavcodec/codec_names.h
  122. config:
  123. $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
  124. check: all alltools examples testprogs fate
  125. include $(SRC_PATH)/doc/Makefile
  126. include $(SRC_PATH)/tests/Makefile
  127. $(sort $(OBJDIRS)):
  128. $(Q)mkdir -p $@
  129. # Dummy rule to stop make trying to rebuild removed or renamed headers
  130. %.h:
  131. @:
  132. # Disable suffix rules. Most of the builtin rules are suffix rules,
  133. # so this saves some time on slow systems.
  134. .SUFFIXES:
  135. .PHONY: all all-yes alltools check *clean config install*
  136. .PHONY: testprogs uninstall*