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