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