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