Makefile 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. include config.mak
  2. SRC_DIR = $(SRC_PATH_BARE)
  3. vpath %.c $(SRC_DIR)
  4. vpath %.h $(SRC_DIR)
  5. vpath %.S $(SRC_DIR)
  6. vpath %.asm $(SRC_DIR)
  7. vpath %.v $(SRC_DIR)
  8. vpath %.texi $(SRC_PATH_BARE)
  9. PROGS-$(CONFIG_FFMPEG) += ffmpeg
  10. PROGS-$(CONFIG_FFPLAY) += ffplay
  11. PROGS-$(CONFIG_FFPROBE) += ffprobe
  12. PROGS-$(CONFIG_FFSERVER) += ffserver
  13. PROGS := $(PROGS-yes:%=%$(EXESUF))
  14. PROGS_G = $(PROGS-yes:%=%_g$(EXESUF))
  15. OBJS = $(PROGS-yes:%=%.o) cmdutils.o
  16. MANPAGES = $(PROGS-yes:%=doc/%.1)
  17. PODPAGES = $(PROGS-yes:%=doc/%.pod)
  18. HTMLPAGES = $(PROGS-yes:%=doc/%.html)
  19. TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
  20. TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
  21. HOSTPROGS := $(TESTTOOLS:%=tests/%)
  22. BASENAMES = ffmpeg ffplay ffprobe ffserver
  23. ALLPROGS = $(BASENAMES:%=%$(EXESUF))
  24. ALLPROGS_G = $(BASENAMES:%=%_g$(EXESUF))
  25. ALLMANPAGES = $(BASENAMES:%=%.1)
  26. ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
  27. FFLIBS-$(CONFIG_AVDEVICE) += avdevice
  28. FFLIBS-$(CONFIG_AVFILTER) += avfilter
  29. FFLIBS-$(CONFIG_AVFORMAT) += avformat
  30. FFLIBS-$(CONFIG_AVCODEC) += avcodec
  31. FFLIBS-$(CONFIG_POSTPROC) += postproc
  32. FFLIBS-$(CONFIG_SWSCALE) += swscale
  33. FFLIBS := avutil
  34. DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
  35. SKIPHEADERS = cmdutils_common_opts.h
  36. include common.mak
  37. FF_LDFLAGS := $(FFLDFLAGS)
  38. FF_EXTRALIBS := $(FFEXTRALIBS)
  39. FF_DEP_LIBS := $(DEP_LIBS)
  40. all-$(CONFIG_DOC): documentation
  41. all: $(FF_DEP_LIBS) $(PROGS)
  42. $(PROGS): %$(EXESUF): %_g$(EXESUF)
  43. $(CP) $< $@
  44. $(STRIP) $@
  45. config.h: .config
  46. .config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
  47. @-tput bold 2>/dev/null
  48. @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
  49. @-tput sgr0 2>/dev/null
  50. SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
  51. ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
  52. HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
  53. define RESET
  54. $(1) :=
  55. $(1)-yes :=
  56. endef
  57. define DOSUBDIR
  58. $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
  59. SUBDIR := $(1)/
  60. include $(1)/Makefile
  61. endef
  62. $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
  63. ffplay.o: CFLAGS += $(SDL_CFLAGS)
  64. ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
  65. ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
  66. %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
  67. $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
  68. alltools: $(TOOLS)
  69. tools/%$(EXESUF): tools/%.o
  70. $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
  71. tools/%.o: tools/%.c
  72. $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
  73. -include $(wildcard tools/*.d)
  74. -include $(wildcard tests/*.d)
  75. VERSION_SH = $(SRC_PATH_BARE)/version.sh
  76. GIT_LOG = $(SRC_PATH_BARE)/.git/logs/HEAD
  77. .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
  78. .version: M=@
  79. version.h .version:
  80. $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
  81. $(Q)touch .version
  82. # force version.sh to run whenever version might have changed
  83. -include .version
  84. DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
  85. documentation: $(DOCS)
  86. -include $(wildcard $(DOCS:%=%.d))
  87. TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
  88. doc/%.html: TAG = HTML
  89. doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
  90. $(Q)$(TEXIDEP)
  91. $(M)texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init --output $@ $<
  92. doc/%.pod: TAG = POD
  93. doc/%.pod: doc/%.texi
  94. $(Q)$(TEXIDEP)
  95. $(M)doc/texi2pod.pl $< $@
  96. doc/%.1: TAG = MAN
  97. doc/%.1: doc/%.pod
  98. $(M)pod2man --section=1 --center=" " --release=" " $< > $@
  99. ifdef PROGS
  100. install: install-progs install-data
  101. endif
  102. install: install-libs install-headers
  103. install-libs: install-libs-yes
  104. install-progs-yes:
  105. install-progs-$(CONFIG_DOC): install-man
  106. install-progs-$(CONFIG_SHARED): install-libs
  107. install-progs: install-progs-yes $(PROGS)
  108. $(Q)mkdir -p "$(BINDIR)"
  109. $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
  110. install-data: $(DATA_FILES)
  111. $(Q)mkdir -p "$(DATADIR)"
  112. $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
  113. install-man: $(MANPAGES)
  114. $(Q)mkdir -p "$(MANDIR)/man1"
  115. $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
  116. uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-man
  117. uninstall-progs:
  118. $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
  119. uninstall-data:
  120. $(RM) -r "$(DATADIR)"
  121. uninstall-man:
  122. $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
  123. testclean:
  124. $(RM) -r tests/vsynth1 tests/vsynth2 tests/data
  125. $(RM) $(addprefix tests/,$(CLEANSUFFIXES))
  126. $(RM) tests/seek_test$(EXESUF) tests/seek_test.o
  127. $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
  128. clean:: testclean
  129. $(RM) $(ALLPROGS) $(ALLPROGS_G)
  130. $(RM) $(CLEANSUFFIXES)
  131. $(RM) doc/*.html doc/*.pod doc/*.1 doc/*.d doc/*~
  132. $(RM) $(TOOLS)
  133. $(RM) $(CLEANSUFFIXES:%=tools/%)
  134. distclean::
  135. $(RM) $(DISTCLEANSUFFIXES)
  136. $(RM) config.* .version version.h libavutil/avconfig.h
  137. config:
  138. $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
  139. # regression tests
  140. check: test
  141. fulltest test: codectest lavftest lavfitest seektest
  142. FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
  143. codectest: fate-codec
  144. lavftest: fate-lavf
  145. lavfitest: fate-lavfi
  146. seektest: fate-seek
  147. AREF = fate-acodec-aref
  148. VREF = fate-vsynth1-vref fate-vsynth2-vref
  149. REFS = $(AREF) $(VREF)
  150. $(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
  151. $(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
  152. ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
  153. @echo
  154. @echo "Unfortunately ffserver is broken and therefore its regression"
  155. @echo "test fails randomly. Treat the results accordingly."
  156. @echo
  157. $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
  158. tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
  159. @mkdir -p tests/vsynth1
  160. $(M)./$< 'tests/vsynth1/'
  161. tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
  162. @mkdir -p tests/vsynth2
  163. $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
  164. tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
  165. @mkdir -p tests/data
  166. $(M)./$< $@
  167. tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
  168. tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
  169. $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
  170. tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS)
  171. $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
  172. include $(SRC_PATH_BARE)/tests/fate.mak
  173. include $(SRC_PATH_BARE)/tests/fate2.mak
  174. include $(SRC_PATH_BARE)/tests/fate/aac.mak
  175. include $(SRC_PATH_BARE)/tests/fate/als.mak
  176. include $(SRC_PATH_BARE)/tests/fate/fft.mak
  177. include $(SRC_PATH_BARE)/tests/fate/h264.mak
  178. include $(SRC_PATH_BARE)/tests/fate/mp3.mak
  179. include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
  180. include $(SRC_PATH_BARE)/tests/fate/vp8.mak
  181. FATE_ACODEC = $(ACODEC_TESTS:%=fate-acodec-%)
  182. FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
  183. FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
  184. FATE_VCODEC = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
  185. FATE_LAVF = $(LAVF_TESTS:%=fate-lavf-%)
  186. FATE_LAVFI = $(LAVFI_TESTS:%=fate-lavfi-%)
  187. FATE_SEEK = $(SEEK_TESTS:seek_%=fate-seek-%)
  188. FATE = $(FATE_ACODEC) \
  189. $(FATE_VCODEC) \
  190. $(FATE_LAVF) \
  191. $(FATE_SEEK) \
  192. FATE-$(CONFIG_AVFILTER) += $(FATE_LAVFI)
  193. FATE += $(FATE-yes)
  194. $(filter-out %-aref,$(FATE_ACODEC)): $(AREF)
  195. $(filter-out %-vref,$(FATE_VCODEC)): $(VREF)
  196. $(FATE_LAVF): $(REFS)
  197. $(FATE_LAVFI): $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
  198. $(FATE_SEEK): fate-codec fate-lavf tests/seek_test$(EXESUF)
  199. $(FATE_ACODEC): CMD = codectest acodec
  200. $(FATE_VSYNTH1): CMD = codectest vsynth1
  201. $(FATE_VSYNTH2): CMD = codectest vsynth2
  202. $(FATE_LAVF): CMD = lavftest
  203. $(FATE_LAVFI): CMD = lavfitest
  204. $(FATE_SEEK): CMD = seektest
  205. fate-codec: fate-acodec fate-vcodec
  206. fate-acodec: $(FATE_ACODEC)
  207. fate-vcodec: $(FATE_VCODEC)
  208. fate-lavf: $(FATE_LAVF)
  209. fate-lavfi: $(FATE_LAVFI)
  210. fate-seek: $(FATE_SEEK)
  211. ifdef SAMPLES
  212. FATE += $(FATE_TESTS) $(FATE_TESTS-yes)
  213. fate-rsync:
  214. rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES)
  215. else
  216. fate-rsync:
  217. @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite"
  218. $(FATE_TESTS):
  219. @echo "SAMPLES not specified, cannot run FATE. See doc/fate.txt for more information."
  220. endif
  221. FATE_UTILS = base64 tiny_psnr
  222. fate: $(FATE)
  223. $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
  224. @echo "TEST $(@:fate-%=%)"
  225. $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)'
  226. fate-list:
  227. @printf '%s\n' $(sort $(FATE))
  228. .PHONY: all alltools *clean check config documentation examples install*
  229. .PHONY: *test testprogs uninstall*