configure: Drop bogus xcb_event variables
[libav.git] / Makefile
1 include config.mak
2
3 vpath %.c $(SRC_PATH)
4 vpath %.m $(SRC_PATH)
5 vpath %.h $(SRC_PATH)
6 vpath %.S $(SRC_PATH)
7 vpath %.asm $(SRC_PATH)
8 vpath %.v $(SRC_PATH)
9 vpath %.texi $(SRC_PATH)
10
11 ifndef V
12 Q = @
13 ECHO = printf "$(1)\t%s\n" $(2)
14 BRIEF = CC HOSTCC HOSTLD AS YASM AR LD
15 SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM STRIP
16 MSG = $@
17 M = @$(call ECHO,$(TAG),$@);
18 $(foreach VAR,$(BRIEF), \
19 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
20 $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
21 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL))
22 endif
23
24 ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil swscale
25
26 IFLAGS := -I. -I$(SRC_PATH)
27 CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
28 CFLAGS += $(ECFLAGS)
29 CCFLAGS = $(CPPFLAGS) $(CFLAGS)
30 OBJCFLAGS += $(EOBJCFLAGS)
31 OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
32 ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
33 YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
34 HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
35 LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
36
37 define COMPILE
38 $(call $(1)DEP,$(1))
39 $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
40 endef
41
42 COMPILE_C = $(call COMPILE,CC)
43 COMPILE_S = $(call COMPILE,AS)
44 COMPILE_M = $(call COMPILE,OBJCC)
45 COMPILE_HOSTC = $(call COMPILE,HOSTCC)
46
47 %.o: %.c
48 $(COMPILE_C)
49
50 %.o: %.S
51 $(COMPILE_S)
52
53 %.o: %.m
54 $(COMPILE_M)
55
56 %_host.o: %.c
57 $(COMPILE_HOSTC)
58
59 %.o: %.asm
60 $(DEPYASM) $(YASMFLAGS) -I $(<D)/ -M -o $@ $< > $(@:.o=.d)
61 $(YASM) $(YASMFLAGS) -I $(<D)/ -o $@ $<
62 -$(STRIP) $(STRIPFLAGS) $@
63
64 %.i: %.c
65 $(CC) $(CCFLAGS) $(CC_E) $<
66
67 %.h.c:
68 $(Q)echo '#include "$*.h"' >$@
69
70 %.c %.h %.ver: TAG = GEN
71
72 AVPROGS-$(CONFIG_AVCONV) += avconv
73 AVPROGS-$(CONFIG_AVPLAY) += avplay
74 AVPROGS-$(CONFIG_AVPROBE) += avprobe
75
76 AVPROGS := $(AVPROGS-yes:%=%$(EXESUF))
77 PROGS += $(AVPROGS)
78
79 AVBASENAMES = avconv avplay avprobe
80 ALLAVPROGS = $(AVBASENAMES:%=%$(EXESUF))
81
82 $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
83
84 OBJS-avconv += avconv_opt.o avconv_filter.o
85 OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o
86 OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o
87 OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o
88 OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o
89 OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o
90
91 TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
92 HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
93 TOOLS = qt-faststart trasher
94 TOOLS-$(CONFIG_ZLIB) += cws2fws
95
96 # $(FFLIBS-yes) needs to be in linking order
97 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
98 FFLIBS-$(CONFIG_AVFILTER) += avfilter
99 FFLIBS-$(CONFIG_AVFORMAT) += avformat
100 FFLIBS-$(CONFIG_AVCODEC) += avcodec
101 FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
102 FFLIBS-$(CONFIG_SWSCALE) += swscale
103
104 FFLIBS := avutil
105
106 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset)
107
108 SKIPHEADERS = cmdutils_common_opts.h \
109 compat/w32pthreads.h
110
111 include $(SRC_PATH)/common.mak
112
113 FF_EXTRALIBS := $(FFEXTRALIBS)
114 FF_DEP_LIBS := $(DEP_LIBS)
115 FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
116
117 all: $(AVPROGS)
118
119 $(TOOLS): %$(EXESUF): %.o
120 $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
121
122 tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
123
124 CONFIGURABLE_COMPONENTS = \
125 $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
126 $(SRC_PATH)/libavcodec/bitstream_filters.c \
127 $(SRC_PATH)/libavformat/protocols.c \
128
129 config.h: .config
130 .config: $(CONFIGURABLE_COMPONENTS)
131 @-tput bold 2>/dev/null
132 @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
133 @-tput sgr0 2>/dev/null
134
135 SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
136 HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
137 ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
138 ALTIVEC-OBJS VSX-OBJS MMX-OBJS YASM-OBJS \
139 OBJS HOSTOBJS TESTOBJS
140
141 define RESET
142 $(1) :=
143 $(1)-yes :=
144 endef
145
146 define DOSUBDIR
147 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
148 SUBDIR := $(1)/
149 include $(SRC_PATH)/$(1)/Makefile
150 -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
151 -include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
152 include $(SRC_PATH)/library.mak
153 endef
154
155 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
156
157 include $(SRC_PATH)/doc/Makefile
158
159 define DOPROG
160 OBJS-$(1) += $(1).o $(OBJS-$(1)-yes)
161 $(1)$(EXESUF): $$(OBJS-$(1))
162 $$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
163 $(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
164 $(1)$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
165 -include $$(OBJS-$(1):.o=.d)
166 endef
167
168 $(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(EXESUF)=))))
169
170 $(PROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
171 $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
172
173 OBJDIRS += tools
174
175 -include $(wildcard tools/*.d)
176
177 VERSION_SH = $(SRC_PATH)/version.sh
178 GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
179
180 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
181 .version: M=@
182
183 cmdutils.o libavutil/utils.o: avversion.h
184 avversion.h .version:
185 $(M)$(VERSION_SH) $(SRC_PATH) avversion.h $(EXTRA_VERSION)
186 $(Q)touch .version
187
188 # force version.sh to run whenever version might have changed
189 -include .version
190
191 ifdef AVPROGS
192 install: install-progs install-data
193 endif
194
195 install: install-libs install-headers
196
197 install-libs: install-libs-yes
198
199 install-progs-yes:
200 install-progs-$(CONFIG_SHARED): install-libs
201
202 install-progs: install-progs-yes $(AVPROGS)
203 $(Q)mkdir -p "$(BINDIR)"
204 $(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
205
206 install-data: $(DATA_FILES)
207 $(Q)mkdir -p "$(DATADIR)"
208 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
209
210 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
211
212 uninstall-progs:
213 $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
214
215 uninstall-data:
216 $(RM) -r "$(DATADIR)"
217
218 clean::
219 $(RM) $(ALLAVPROGS)
220 $(RM) $(CLEANSUFFIXES)
221 $(RM) $(CLEANSUFFIXES:%=tools/%)
222 $(RM) -rf coverage.info lcov
223
224 distclean::
225 $(RM) $(DISTCLEANSUFFIXES)
226 $(RM) config.* .config libavutil/avconfig.h .version avversion.h \
227 mapfile libavcodec/bsf_list.c libavformat/protocol_list.c
228
229 config:
230 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
231
232 check: all alltools checkheaders examples testprogs fate
233
234 include $(SRC_PATH)/tests/Makefile
235
236 $(sort $(OBJDIRS)):
237 $(Q)mkdir -p $@
238
239 # Dummy rule to stop make trying to rebuild removed or renamed headers
240 %.h:
241 @:
242
243 # Disable suffix rules. Most of the builtin rules are suffix rules,
244 # so this saves some time on slow systems.
245 .SUFFIXES:
246
247 .PHONY: all all-yes alltools check *clean config examples install*
248 .PHONY: testprogs uninstall*