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