configure: fix --cpu=host with gcc 4.6
[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)
13BRIEF = CC AS YASM AR LD HOSTCC
14SILENT = DEPCC YASMDEP RM RANLIB
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
23IFLAGS := -I. -I$(SRC_PATH)
24CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
25CFLAGS += $(ECFLAGS)
bc877faf 26CCFLAGS = $(CFLAGS)
bb524924
MR
27YASMFLAGS += $(IFLAGS) -Pconfig.asm
28HOSTCFLAGS += $(IFLAGS)
29
bc877faf
MR
30define COMPILE
31 $($(1)DEP)
32 $($(1)) $(CPPFLAGS) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $<
33endef
34
35COMPILE_C = $(call COMPILE,CC)
36COMPILE_S = $(call COMPILE,AS)
37
bb524924 38%.o: %.c
bc877faf 39 $(COMPILE_C)
bb524924
MR
40
41%.o: %.S
bc877faf 42 $(COMPILE_S)
bb524924
MR
43
44%.ho: %.h
45 $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
46
47%.ver: %.v
48 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
49
50%.c %.h: TAG = GEN
51
bde51e6a
JR
52PROGS-$(CONFIG_FFMPEG) += ffmpeg
53PROGS-$(CONFIG_FFPLAY) += ffplay
336ce917 54PROGS-$(CONFIG_FFPROBE) += ffprobe
bde51e6a
JR
55PROGS-$(CONFIG_FFSERVER) += ffserver
56
583fcb52 57PROGS := $(PROGS-yes:%=%$(EXESUF))
583fcb52 58OBJS = $(PROGS-yes:%=%.o) cmdutils.o
3d157bf3
MR
59TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
60HOSTPROGS := $(TESTTOOLS:%=tests/%)
bde51e6a 61
336ce917 62BASENAMES = ffmpeg ffplay ffprobe ffserver
583fcb52 63ALLPROGS = $(BASENAMES:%=%$(EXESUF))
583fcb52 64ALLMANPAGES = $(BASENAMES:%=%.1)
bde51e6a 65
cf53c486
MR
66ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
67
5a0f7131 68FFLIBS-$(CONFIG_AVDEVICE) += avdevice
bde51e6a 69FFLIBS-$(CONFIG_AVFILTER) += avfilter
5a0f7131 70FFLIBS-$(CONFIG_AVFORMAT) += avformat
97d5fa38 71FFLIBS-$(CONFIG_AVCODEC) += avcodec
bde51e6a 72FFLIBS-$(CONFIG_POSTPROC) += postproc
5a0f7131 73FFLIBS-$(CONFIG_SWSCALE) += swscale
bde51e6a 74
5a0f7131 75FFLIBS := avutil
bde51e6a 76
f038cf3c 77DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset)
a1a84f69 78
9b55e2e7
MR
79SKIPHEADERS = cmdutils_common_opts.h
80
57b4a3dd 81include $(SRC_PATH)/common.mak
bde51e6a
JR
82
83FF_LDFLAGS := $(FFLDFLAGS)
84FF_EXTRALIBS := $(FFEXTRALIBS)
85FF_DEP_LIBS := $(DEP_LIBS)
86
623ffe8c 87all: $(FF_DEP_LIBS) $(PROGS)
bde51e6a 88
86601915 89config.h: .config
f038cf3c 90.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
9d0b3042
MR
91 @-tput bold 2>/dev/null
92 @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
93 @-tput sgr0 2>/dev/null
86601915 94
95f2c769 95SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
de4070b5 96 ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
a7878c9f 97 HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
bde51e6a
JR
98
99define RESET
100$(1) :=
101$(1)-yes :=
102endef
103
104define DOSUBDIR
105$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
106SUBDIR := $(1)/
57b4a3dd 107include $(SRC_PATH)/$(1)/Makefile
bde51e6a
JR
108endef
109
110$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
111
d93d7349 112ffplay.o: CFLAGS += $(SDL_CFLAGS)
e0be794a
MR
113ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
114ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
bde51e6a 115
6d170962 116$(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
684b28e0 117 $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
bde51e6a 118
f6806986
MR
119TOOLS = cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher
120TOOLOBJS := $(TOOLS:%=tools/%.o)
121TOOLS := $(TOOLS:%=tools/%$(EXESUF))
122
d93d7349
MR
123alltools: $(TOOLS)
124
2dfa3054
MR
125tools/%$(EXESUF): tools/%.o
126 $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
127
f6806986 128$(TOOLOBJS): %.o: %.c | tools
4d1156cb 129 $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
08df7f86 130
5e27ec28
MR
131OBJDIRS += tools
132
08df7f86 133-include $(wildcard tools/*.d)
bde51e6a 134
f038cf3c
MR
135VERSION_SH = $(SRC_PATH)/version.sh
136GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
6a53fffd 137
faa6f1c3 138.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
6a53fffd
MR
139.version: M=@
140
141version.h .version:
0853a2b4 142 $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
6a53fffd
MR
143 $(Q)touch .version
144
145# force version.sh to run whenever version might have changed
146-include .version
36798f1b 147
623ffe8c
MR
148ifdef PROGS
149install: install-progs install-data
150endif
151
152install: install-libs install-headers
d7a72d25
MR
153
154install-libs: install-libs-yes
bde51e6a 155
151c5841 156install-progs-yes:
623ffe8c
MR
157install-progs-$(CONFIG_SHARED): install-libs
158
159install-progs: install-progs-yes $(PROGS)
63611f31 160 $(Q)mkdir -p "$(BINDIR)"
fd676deb 161 $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
bde51e6a 162
a1a84f69 163install-data: $(DATA_FILES)
63611f31 164 $(Q)mkdir -p "$(DATADIR)"
fd676deb 165 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
a1a84f69 166
f87b03b5 167uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
d3cb93b3
RP
168
169uninstall-progs:
50e10cbd 170 $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
d3cb93b3
RP
171
172uninstall-data:
50e10cbd 173 $(RM) -r "$(DATADIR)"
d3cb93b3 174
698a183e 175clean::
e0be794a 176 $(RM) $(ALLPROGS)
50e10cbd 177 $(RM) $(CLEANSUFFIXES)
50e10cbd 178 $(RM) $(TOOLS)
40321376 179 $(RM) $(CLEANSUFFIXES:%=tools/%)
bde51e6a
JR
180
181distclean::
50e10cbd 182 $(RM) $(DISTCLEANSUFFIXES)
59748689 183 $(RM) config.* .version version.h libavutil/avconfig.h
bde51e6a 184
9d0b3042 185config:
29ba0911 186 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
0c3b2d65 187
57b4a3dd
MR
188include $(SRC_PATH)/doc/Makefile
189include $(SRC_PATH)/tests/Makefile
d29d9ccc 190
5e27ec28
MR
191$(sort $(OBJDIRS)):
192 $(Q)mkdir -p $@
193
8d853efe
MR
194# Dummy rule to stop make trying to rebuild removed or renamed headers
195%.h:
196 @:
197
198# Disable suffix rules. Most of the builtin rules are suffix rules,
199# so this saves some time on slow systems.
200.SUFFIXES:
201
db54be09 202.PHONY: all all-yes alltools *clean config examples install*
698a183e 203.PHONY: testprogs uninstall*