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