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