Makefile 5.9 KB

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