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