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