]> git.sesse.net Git - ffmpeg/blob - Makefile
Merge commit 'af451ac0de6776e97d6a3ff95eac257b7964002e'
[ffmpeg] / Makefile
1 MAIN_MAKEFILE=1
2 include config.mak
3
4 vpath %.c    $(SRC_PATH)
5 vpath %.cpp  $(SRC_PATH)
6 vpath %.h    $(SRC_PATH)
7 vpath %.inc  $(SRC_PATH)
8 vpath %.m    $(SRC_PATH)
9 vpath %.S    $(SRC_PATH)
10 vpath %.asm  $(SRC_PATH)
11 vpath %.rc   $(SRC_PATH)
12 vpath %.v    $(SRC_PATH)
13 vpath %.texi $(SRC_PATH)
14 vpath %/fate_config.sh.template $(SRC_PATH)
15
16 AVPROGS-$(CONFIG_FFMPEG)   += ffmpeg
17 AVPROGS-$(CONFIG_FFPLAY)   += ffplay
18 AVPROGS-$(CONFIG_FFPROBE)  += ffprobe
19 AVPROGS-$(CONFIG_FFSERVER) += ffserver
20
21 AVPROGS    := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
22 INSTPROGS   = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
23 PROGS      += $(AVPROGS)
24
25 AVBASENAMES  = ffmpeg ffplay ffprobe ffserver
26 ALLAVPROGS   = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
27 ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
28
29 $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
30 $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
31
32 OBJS-ffmpeg                   += ffmpeg_opt.o ffmpeg_filter.o
33 OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
34 OBJS-ffmpeg-$(CONFIG_LIBMFX)  += ffmpeg_qsv.o
35 OBJS-ffmpeg-$(CONFIG_VAAPI)   += ffmpeg_vaapi.o
36 ifndef CONFIG_VIDEOTOOLBOX
37 OBJS-ffmpeg-$(CONFIG_VDA)     += ffmpeg_videotoolbox.o
38 endif
39 OBJS-ffmpeg-$(CONFIG_CUVID)   += ffmpeg_cuvid.o
40 OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
41 OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
42 OBJS-ffserver                 += ffserver_config.o
43
44 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
45 HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
46
47 # $(FFLIBS-yes) needs to be in linking order
48 FFLIBS-$(CONFIG_AVDEVICE)   += avdevice
49 FFLIBS-$(CONFIG_AVFILTER)   += avfilter
50 FFLIBS-$(CONFIG_AVFORMAT)   += avformat
51 FFLIBS-$(CONFIG_AVCODEC)    += avcodec
52 FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
53 FFLIBS-$(CONFIG_POSTPROC)   += postproc
54 FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
55 FFLIBS-$(CONFIG_SWSCALE)    += swscale
56
57 FFLIBS := avutil
58
59 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
60 EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
61
62 SKIPHEADERS = cmdutils_common_opts.h                                    \
63               compat/w32pthreads.h
64
65 # first so "all" becomes default target
66 all: all-yes
67
68 include $(SRC_PATH)/tools/Makefile
69 include $(SRC_PATH)/common.mak
70
71 FF_EXTRALIBS := $(FFEXTRALIBS)
72 FF_DEP_LIBS  := $(DEP_LIBS)
73 FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
74
75 all: $(AVPROGS)
76
77 $(TOOLS): %$(EXESUF): %.o
78         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
79
80 tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
81 tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
82 tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
83
84 CONFIGURABLE_COMPONENTS =                                           \
85     $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))                 \
86     $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/version.h))              \
87     $(SRC_PATH)/libavcodec/bitstream_filters.c                      \
88     $(SRC_PATH)/libavformat/protocols.c                             \
89
90 config.h: .config
91 .config: $(CONFIGURABLE_COMPONENTS)
92         @-tput bold 2>/dev/null
93         @-printf '\nWARNING: $(?) newer than config.h, rerun configure\n\n'
94         @-tput sgr0 2>/dev/null
95
96 SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
97                HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
98                ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS     \
99                ALTIVEC-OBJS VSX-OBJS MMX-OBJS YASM-OBJS                  \
100                MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS         \
101                MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
102
103 define RESET
104 $(1) :=
105 $(1)-yes :=
106 endef
107
108 define DOSUBDIR
109 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
110 SUBDIR := $(1)/
111 include $(SRC_PATH)/$(1)/Makefile
112 -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
113 -include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
114 include $(SRC_PATH)/library.mak
115 endef
116
117 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
118
119 include $(SRC_PATH)/doc/Makefile
120
121 define DOPROG
122 OBJS-$(1) += $(1).o $(OBJS-$(1)-yes)
123 $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
124 $$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
125 $(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
126 $(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
127 -include $$(OBJS-$(1):.o=.d)
128 endef
129
130 $(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
131
132 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
133
134 $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
135         $(CP) $< $@
136         $(STRIP) $@
137
138 %$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
139         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
140
141 VERSION_SH  = $(SRC_PATH)/version.sh
142 GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
143
144 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
145 .version: M=@
146
147 libavutil/ffversion.h .version:
148         $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
149         $(Q)touch .version
150
151 # force version.sh to run whenever version might have changed
152 -include .version
153
154 ifdef AVPROGS
155 install: install-progs install-data
156 endif
157
158 install: install-libs install-headers
159
160 install-libs: install-libs-yes
161
162 install-progs-yes:
163 install-progs-$(CONFIG_SHARED): install-libs
164
165 install-progs: install-progs-yes $(AVPROGS)
166         $(Q)mkdir -p "$(BINDIR)"
167         $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
168
169 install-data: $(DATA_FILES) $(EXAMPLES_FILES)
170         $(Q)mkdir -p "$(DATADIR)/examples"
171         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
172         $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
173
174 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
175
176 uninstall-progs:
177         $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
178
179 uninstall-data:
180         $(RM) -r "$(DATADIR)"
181
182 clean::
183         $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
184         $(RM) $(CLEANSUFFIXES)
185         $(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
186         $(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
187         $(RM) $(CLEANSUFFIXES:%=compat/%)
188         $(RM) -r coverage-html
189         $(RM) -rf coverage.info coverage.info.in lcov
190
191 distclean::
192         $(RM) $(DISTCLEANSUFFIXES)
193         $(RM) config.* .config libavutil/avconfig.h .version mapfile avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c
194 ifeq ($(SRC_LINK),src)
195         $(RM) src
196 endif
197         $(RM) -rf doc/examples/pc-uninstalled
198
199 config:
200         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
201
202 check: all alltools examples testprogs fate
203
204 include $(SRC_PATH)/tests/Makefile
205
206 $(sort $(OBJDIRS)):
207         $(Q)mkdir -p $@
208
209 # Dummy rule to stop make trying to rebuild removed or renamed headers
210 %.h:
211         @:
212
213 # Disable suffix rules.  Most of the builtin rules are suffix rules,
214 # so this saves some time on slow systems.
215 .SUFFIXES:
216
217 .PHONY: all all-yes alltools check *clean config install*
218 .PHONY: testprogs uninstall*