build: Add rule for building host-specific object files
[libav.git] / Makefile
CommitLineData
bde51e6a
JR
1include config.mak
2
f038cf3c
MR
3vpath %.c $(SRC_PATH)
4vpath %.h $(SRC_PATH)
5vpath %.S $(SRC_PATH)
6vpath %.asm $(SRC_PATH)
7vpath %.v $(SRC_PATH)
8vpath %.texi $(SRC_PATH)
bde51e6a 9
bb524924
MR
10ifndef V
11Q = @
12ECHO = printf "$(1)\t%s\n" $(2)
095792f2 13BRIEF = CC HOSTCC HOSTLD AS YASM AR LD
c7f25d4c 14SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM STRIP
bb524924
MR
15MSG = $@
16M = @$(call ECHO,$(TAG),$@);
17$(foreach VAR,$(BRIEF), \
18 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
19$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
f038cf3c 20$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL))
bb524924
MR
21endif
22
c8af852b 23ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil swscale
371584c4 24
bb524924
MR
25IFLAGS := -I. -I$(SRC_PATH)
26CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
27CFLAGS += $(ECFLAGS)
a758c5e2
MR
28CCFLAGS = $(CPPFLAGS) $(CFLAGS)
29ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
04581c8c 30YASMFLAGS += $(IFLAGS:%=%/) -Pconfig.asm
4cc4b33f 31HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
8db73c61 32LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
bb524924 33
bc877faf 34define COMPILE
a758c5e2 35 $(call $(1)DEP,$(1))
23565c26 36 $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
bc877faf
MR
37endef
38
39COMPILE_C = $(call COMPILE,CC)
40COMPILE_S = $(call COMPILE,AS)
ad477710 41COMPILE_HOSTC = $(call COMPILE,HOSTCC)
bc877faf 42
bb524924 43%.o: %.c
bc877faf 44 $(COMPILE_C)
bb524924
MR
45
46%.o: %.S
bc877faf 47 $(COMPILE_S)
bb524924 48
5a9fcc7d
DB
49%_host.o: %.c
50 $(COMPILE_HOSTC)
51
c2626492
MR
52%.i: %.c
53 $(CC) $(CCFLAGS) $(CC_E) $<
54
dfd9159f
MR
55%.h.c:
56 $(Q)echo '#include "$*.h"' >$@
bb524924
MR
57
58%.ver: %.v
59 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
60
61%.c %.h: TAG = GEN
62
14abeaa4
DB
63AVPROGS-$(CONFIG_AVCONV) += avconv
64AVPROGS-$(CONFIG_AVPLAY) += avplay
65AVPROGS-$(CONFIG_AVPROBE) += avprobe
66AVPROGS-$(CONFIG_AVSERVER) += avserver
bde51e6a 67
14abeaa4
DB
68AVPROGS := $(AVPROGS-yes:%=%$(EXESUF))
69PROGS += $(AVPROGS)
7671dd7c 70
14abeaa4
DB
71AVBASENAMES = avconv avplay avprobe avserver
72ALLAVPROGS = $(AVBASENAMES:%=%$(EXESUF))
73
dc80e2f7 74$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
14abeaa4
DB
75
76OBJS-avconv += avconv_opt.o avconv_filter.o
7671dd7c
AK
77OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o
78
3d157bf3 79TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
0d0b81f9 80HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
28e1c979
MR
81TOOLS = qt-faststart trasher
82TOOLS-$(CONFIG_ZLIB) += cws2fws
bde51e6a 83
5a0f7131 84FFLIBS-$(CONFIG_AVDEVICE) += avdevice
bde51e6a 85FFLIBS-$(CONFIG_AVFILTER) += avfilter
5a0f7131 86FFLIBS-$(CONFIG_AVFORMAT) += avformat
c8af852b 87FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
97d5fa38 88FFLIBS-$(CONFIG_AVCODEC) += avcodec
5a0f7131 89FFLIBS-$(CONFIG_SWSCALE) += swscale
bde51e6a 90
5a0f7131 91FFLIBS := avutil
bde51e6a 92
8096fdf0 93DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset)
a1a84f69 94
90f9a583 95SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
9b55e2e7 96
57b4a3dd 97include $(SRC_PATH)/common.mak
bde51e6a 98
bde51e6a
JR
99FF_EXTRALIBS := $(FFEXTRALIBS)
100FF_DEP_LIBS := $(DEP_LIBS)
101
14abeaa4 102all: $(AVPROGS)
bde51e6a 103
80521c19
MR
104$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
105 $(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS)
28e1c979 106
7baa115a 107tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
28e1c979 108
86601915 109config.h: .config
f038cf3c 110.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
9d0b3042
MR
111 @-tput bold 2>/dev/null
112 @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
113 @-tput sgr0 2>/dev/null
86601915 114
e7e19b15 115SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
121604b0 116 HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
b3267559 117 ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS \
ca411fc1 118 ALTIVEC-OBJS VIS-OBJS \
5864eb42 119 MMX-OBJS YASM-OBJS \
24d3796d 120 OBJS HOSTOBJS TESTOBJS
bde51e6a
JR
121
122define RESET
123$(1) :=
124$(1)-yes :=
125endef
126
127define DOSUBDIR
128$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
129SUBDIR := $(1)/
57b4a3dd 130include $(SRC_PATH)/$(1)/Makefile
07a873a2 131-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
144904e9 132include $(SRC_PATH)/library.mak
bde51e6a
JR
133endef
134
135$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
136
ab81f24a
DB
137include $(SRC_PATH)/doc/Makefile
138
baac24e6 139define DOPROG
14abeaa4 140OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
07b3790d 141$(1)$(EXESUF): $$(OBJS-$(1))
baac24e6
MR
142$$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1))
143$(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
144$(1)$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
145-include $$(OBJS-$(1):.o=.d)
146endef
147
dc80e2f7 148$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(EXESUF)=))))
bde51e6a 149
07b3790d
MR
150$(PROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
151 $(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
bde51e6a 152
5e27ec28
MR
153OBJDIRS += tools
154
08df7f86 155-include $(wildcard tools/*.d)
bde51e6a 156
f038cf3c
MR
157VERSION_SH = $(SRC_PATH)/version.sh
158GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
6a53fffd 159
faa6f1c3 160.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
6a53fffd
MR
161.version: M=@
162
163version.h .version:
0853a2b4 164 $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
6a53fffd
MR
165 $(Q)touch .version
166
167# force version.sh to run whenever version might have changed
168-include .version
36798f1b 169
14abeaa4 170ifdef AVPROGS
623ffe8c
MR
171install: install-progs install-data
172endif
173
174install: install-libs install-headers
d7a72d25
MR
175
176install-libs: install-libs-yes
bde51e6a 177
151c5841 178install-progs-yes:
623ffe8c
MR
179install-progs-$(CONFIG_SHARED): install-libs
180
14abeaa4 181install-progs: install-progs-yes $(AVPROGS)
63611f31 182 $(Q)mkdir -p "$(BINDIR)"
14abeaa4 183 $(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
bde51e6a 184
a1a84f69 185install-data: $(DATA_FILES)
63611f31 186 $(Q)mkdir -p "$(DATADIR)"
fd676deb 187 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
a1a84f69 188
f87b03b5 189uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
d3cb93b3
RP
190
191uninstall-progs:
14abeaa4 192 $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
d3cb93b3
RP
193
194uninstall-data:
50e10cbd 195 $(RM) -r "$(DATADIR)"
d3cb93b3 196
698a183e 197clean::
14abeaa4 198 $(RM) $(ALLAVPROGS)
50e10cbd 199 $(RM) $(CLEANSUFFIXES)
40321376 200 $(RM) $(CLEANSUFFIXES:%=tools/%)
a862c7d3 201 $(RM) -rf coverage.info lcov
bde51e6a
JR
202
203distclean::
50e10cbd 204 $(RM) $(DISTCLEANSUFFIXES)
b4d24b47 205 $(RM) config.* .config libavutil/avconfig.h .version version.h
bde51e6a 206
9d0b3042 207config:
29ba0911 208 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
0c3b2d65 209
4982e1dd
DB
210check: all alltools checkheaders examples testprogs fate
211
57b4a3dd 212include $(SRC_PATH)/tests/Makefile
d29d9ccc 213
5e27ec28
MR
214$(sort $(OBJDIRS)):
215 $(Q)mkdir -p $@
216
8d853efe
MR
217# Dummy rule to stop make trying to rebuild removed or renamed headers
218%.h:
219 @:
220
221# Disable suffix rules. Most of the builtin rules are suffix rules,
222# so this saves some time on slow systems.
223.SUFFIXES:
224
4982e1dd 225.PHONY: all all-yes alltools check *clean config examples install*
698a183e 226.PHONY: testprogs uninstall*