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