Makefile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. MAIN_MAKEFILE=1
  2. include ffbuild/config.mak
  3. vpath %.c $(SRC_PATH)
  4. vpath %.cpp $(SRC_PATH)
  5. vpath %.h $(SRC_PATH)
  6. vpath %.inc $(SRC_PATH)
  7. vpath %.m $(SRC_PATH)
  8. vpath %.S $(SRC_PATH)
  9. vpath %.asm $(SRC_PATH)
  10. vpath %.rc $(SRC_PATH)
  11. vpath %.v $(SRC_PATH)
  12. vpath %.texi $(SRC_PATH)
  13. vpath %.cu $(SRC_PATH)
  14. vpath %.ptx $(SRC_PATH)
  15. vpath %.metal $(SRC_PATH)
  16. vpath %/fate_config.sh.template $(SRC_PATH)
  17. TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
  18. HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
  19. ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale swresample
  20. # $(FFLIBS-yes) needs to be in linking order
  21. FFLIBS-$(CONFIG_AVDEVICE) += avdevice
  22. FFLIBS-$(CONFIG_AVFILTER) += avfilter
  23. FFLIBS-$(CONFIG_AVFORMAT) += avformat
  24. FFLIBS-$(CONFIG_AVCODEC) += avcodec
  25. FFLIBS-$(CONFIG_POSTPROC) += postproc
  26. FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
  27. FFLIBS-$(CONFIG_SWSCALE) += swscale
  28. FFLIBS := avutil
  29. DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
  30. SKIPHEADERS = compat/w32pthreads.h
  31. # first so "all" becomes default target
  32. all: all-yes
  33. include $(SRC_PATH)/tools/Makefile
  34. include $(SRC_PATH)/ffbuild/common.mak
  35. FF_EXTRALIBS := $(FFEXTRALIBS)
  36. FF_DEP_LIBS := $(DEP_LIBS)
  37. FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
  38. $(TOOLS): %$(EXESUF): %.o
  39. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter-out $(FF_DEP_LIBS), $^) $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS)
  40. target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
  41. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  42. target_enc_%_fuzzer$(EXESUF): target_enc_%_fuzzer.o $(FF_DEP_LIBS)
  43. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  44. tools/target_bsf_%_fuzzer$(EXESUF): tools/target_bsf_%_fuzzer.o $(FF_DEP_LIBS)
  45. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  46. target_dem_%_fuzzer$(EXESUF): target_dem_%_fuzzer.o $(FF_DEP_LIBS)
  47. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  48. tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS)
  49. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  50. tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS)
  51. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  52. tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS)
  53. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  54. tools/target_swr_fuzzer$(EXESUF): tools/target_swr_fuzzer.o $(FF_DEP_LIBS)
  55. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
  56. tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS)
  57. tools/enum_options$(EXESUF): $(FF_DEP_LIBS)
  58. tools/enc_recon_frame_test$(EXESUF): $(FF_DEP_LIBS)
  59. tools/enc_recon_frame_test$(EXESUF): ELIBS = $(FF_EXTRALIBS)
  60. tools/scale_slice_test$(EXESUF): $(FF_DEP_LIBS)
  61. tools/scale_slice_test$(EXESUF): ELIBS = $(FF_EXTRALIBS)
  62. tools/sofa2wavs$(EXESUF): ELIBS = $(FF_EXTRALIBS)
  63. tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
  64. tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
  65. tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
  66. tools/target_dem_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
  67. CONFIGURABLE_COMPONENTS = \
  68. $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
  69. $(SRC_PATH)/libavcodec/bitstream_filters.c \
  70. $(SRC_PATH)/libavcodec/hwaccels.h \
  71. $(SRC_PATH)/libavcodec/parsers.c \
  72. $(SRC_PATH)/libavformat/protocols.c \
  73. config_components.h: ffbuild/.config
  74. ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
  75. @-tput bold 2>/dev/null
  76. @-printf '\nWARNING: $(?) newer than config_components.h, rerun configure\n\n'
  77. @-tput sgr0 2>/dev/null
  78. SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS \
  79. HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
  80. ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
  81. ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \
  82. MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
  83. MMI-OBJS LSX-OBJS LASX-OBJS RV-OBJS RVV-OBJS RVVB-OBJS \
  84. OBJS SLIBOBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS
  85. define RESET
  86. $(1) :=
  87. $(1)-yes :=
  88. endef
  89. define DOSUBDIR
  90. $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
  91. SUBDIR := $(1)/
  92. include $(SRC_PATH)/$(1)/Makefile
  93. -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
  94. -include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
  95. include $(SRC_PATH)/ffbuild/library.mak
  96. endef
  97. $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
  98. include $(SRC_PATH)/fftools/Makefile
  99. include $(SRC_PATH)/doc/Makefile
  100. include $(SRC_PATH)/doc/examples/Makefile
  101. $(ALLFFLIBS:%=lib%/version.o): libavutil/ffversion.h
  102. $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
  103. ifeq ($(STRIPTYPE),direct)
  104. $(STRIP) -o $@ $<
  105. else
  106. $(RM) $@
  107. $(CP) $< $@
  108. $(STRIP) $@
  109. endif
  110. %$(PROGSSUF)_g$(EXESUF): $(FF_DEP_LIBS)
  111. $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
  112. VERSION_SH = $(SRC_PATH)/ffbuild/version.sh
  113. ifeq ($(VERSION_TRACKING),yes)
  114. GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
  115. endif
  116. .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) ffbuild/config.mak
  117. .version: M=@
  118. ifneq ($(VERSION_TRACKING),yes)
  119. libavutil/ffversion.h .version: REVISION=unknown
  120. endif
  121. libavutil/ffversion.h .version:
  122. $(M)revision=$(REVISION) $(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
  123. $(Q)touch .version
  124. # force version.sh to run whenever version might have changed
  125. -include .version
  126. install: install-libs install-headers
  127. install-libs: install-libs-yes
  128. install-data: $(DATA_FILES)
  129. $(Q)mkdir -p "$(DATADIR)"
  130. $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
  131. uninstall: uninstall-data uninstall-headers uninstall-libs uninstall-pkgconfig
  132. uninstall-data:
  133. $(RM) -r "$(DATADIR)"
  134. clean::
  135. $(RM) $(CLEANSUFFIXES)
  136. $(RM) $(addprefix compat/,$(CLEANSUFFIXES)) $(addprefix compat/*/,$(CLEANSUFFIXES)) $(addprefix compat/*/*/,$(CLEANSUFFIXES))
  137. $(RM) -r coverage-html
  138. $(RM) -rf coverage.info coverage.info.in lcov
  139. distclean:: clean
  140. $(RM) .version config.asm config.h config_components.h mapfile \
  141. ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
  142. version.h libavutil/ffversion.h libavcodec/codec_names.h \
  143. libavcodec/bsf_list.c libavformat/protocol_list.c \
  144. libavcodec/codec_list.c libavcodec/parser_list.c \
  145. libavfilter/filter_list.c libavdevice/indev_list.c libavdevice/outdev_list.c \
  146. libavformat/muxer_list.c libavformat/demuxer_list.c
  147. ifeq ($(SRC_LINK),src)
  148. $(RM) src
  149. endif
  150. $(RM) -rf doc/examples/pc-uninstalled
  151. config:
  152. $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
  153. build: all alltools examples testprogs
  154. check: all alltools examples testprogs fate
  155. include $(SRC_PATH)/tests/Makefile
  156. $(sort $(OUTDIRS)):
  157. $(Q)mkdir -p $@
  158. # Dummy rule to stop make trying to rebuild removed or renamed headers
  159. %.h:
  160. @:
  161. # Disable suffix rules. Most of the builtin rules are suffix rules,
  162. # so this saves some time on slow systems.
  163. .SUFFIXES:
  164. .PHONY: all all-yes alltools build check config testprogs
  165. .PHONY: *clean install* uninstall*