Makefile 5.24 KB
Newer Older
1
MAIN_MAKEFILE=1
2
3
include config.mak

4
vpath %.c    $(SRC_PATH)
Mohamed Naufal's avatar
Mohamed Naufal committed
5
vpath %.cpp  $(SRC_PATH)
6
7
8
9
10
vpath %.h    $(SRC_PATH)
vpath %.S    $(SRC_PATH)
vpath %.asm  $(SRC_PATH)
vpath %.v    $(SRC_PATH)
vpath %.texi $(SRC_PATH)
11
vpath %/fate_config.sh.template $(SRC_PATH)
12
13
14

PROGS-$(CONFIG_FFMPEG)   += ffmpeg
PROGS-$(CONFIG_FFPLAY)   += ffplay
Stefano Sabatini's avatar
Stefano Sabatini committed
15
PROGS-$(CONFIG_FFPROBE)  += ffprobe
16
17
PROGS-$(CONFIG_FFSERVER) += ffserver

18
PROGS      := $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
19
INSTPROGS   = $(PROGS-yes:%=%$(PROGSSUF)$(EXESUF))
20

21
OBJS        = cmdutils.o $(EXEOBJS)
22
OBJS-ffmpeg = ffmpeg_opt.o ffmpeg_filter.o
23
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
24
HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
25
26
TOOLS       = qt-faststart trasher
TOOLS-$(CONFIG_ZLIB) += cws2fws
27

Michael Niedermayer's avatar
Michael Niedermayer committed
28
BASENAMES   = ffmpeg ffplay ffprobe ffserver
29
30
ALLPROGS    = $(BASENAMES:%=%$(PROGSSUF)$(EXESUF))
ALLPROGS_G  = $(BASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
31
ALLMANPAGES = $(BASENAMES:%=%.1)
32

33
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
34
FFLIBS-$(CONFIG_AVFILTER) += avfilter
35
FFLIBS-$(CONFIG_AVFORMAT) += avformat
Justin Ruggles's avatar
Justin Ruggles committed
36
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
Måns Rullgård's avatar
Måns Rullgård committed
37
FFLIBS-$(CONFIG_AVCODEC)  += avcodec
38
FFLIBS-$(CONFIG_POSTPROC) += postproc
Michael Niedermayer's avatar
Michael Niedermayer committed
39
FFLIBS-$(CONFIG_SWRESAMPLE)+= swresample
40
FFLIBS-$(CONFIG_SWSCALE)  += swscale
41

42
FFLIBS := avutil
43

44
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
45
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
46

47
48
SKIPHEADERS = cmdutils_common_opts.h

49
include $(SRC_PATH)/common.mak
50
51
52
53

FF_EXTRALIBS := $(FFEXTRALIBS)
FF_DEP_LIBS  := $(DEP_LIBS)

54
all: $(PROGS)
55

56
57
58
$(PROGS): %$(EXESUF): %_g$(EXESUF)
	$(CP) $< $@
	$(STRIP) $@
59

60
61
$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
	$(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS)
62

63
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
64

65
config.h: .config
66
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
67
68
69
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
70

71
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
72
               HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
73
               ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS                \
74
               ALTIVEC-OBJS VIS-OBJS                                     \
75
               MMX-OBJS YASM-OBJS                                        \
76
               MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS  \
77
               OBJS HOSTOBJS TESTOBJS
78
79
80
81
82
83
84
85
86

define RESET
$(1) :=
$(1)-yes :=
endef

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
87
include $(SRC_PATH)/$(1)/Makefile
88
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
89
include $(SRC_PATH)/library.mak
90
91
92
93
endef

$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))

94
define DOPROG
95
OBJS-$(1) += $(1).o cmdutils.o $(EXEOBJS)
96
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
97
$$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
98
99
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
100
101
102
103
-include $$(OBJS-$(1):.o=.d)
endef

$(foreach P,$(PROGS-yes),$(eval $(call DOPROG,$(P))))
104

105
%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
106
	$(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
107

108
109
OBJDIRS += tools

110
-include $(wildcard tools/*.d)
111

112
113
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
114

115
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
116
117
118
.version: M=@

version.h .version:
119
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
120
121
122
123
	$(Q)touch .version

# force version.sh to run whenever version might have changed
-include .version
124

125
126
127
128
129
ifdef PROGS
install: install-progs install-data
endif

install: install-libs install-headers
130
131

install-libs: install-libs-yes
132

133
install-progs-yes:
134
135
136
install-progs-$(CONFIG_SHARED): install-libs

install-progs: install-progs-yes $(PROGS)
Måns Rullgård's avatar
Måns Rullgård committed
137
	$(Q)mkdir -p "$(BINDIR)"
138
	$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
139

140
141
install-data: $(DATA_FILES) $(EXAMPLES_FILES)
	$(Q)mkdir -p "$(DATADIR)/examples"
142
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
143
	$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
144

145
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
Ramiro Polla's avatar
Ramiro Polla committed
146
147

uninstall-progs:
Måns Rullgård's avatar
Måns Rullgård committed
148
	$(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
Ramiro Polla's avatar
Ramiro Polla committed
149
150

uninstall-data:
Måns Rullgård's avatar
Måns Rullgård committed
151
	$(RM) -r "$(DATADIR)"
Ramiro Polla's avatar
Ramiro Polla committed
152

153
clean::
154
	$(RM) $(ALLPROGS) $(ALLPROGS_G)
Måns Rullgård's avatar
Måns Rullgård committed
155
	$(RM) $(CLEANSUFFIXES)
156
	$(RM) $(CLEANSUFFIXES:%=tools/%)
Reimar Döffinger's avatar
Reimar Döffinger committed
157
158
	$(RM) coverage.info
	$(RM) -r coverage-html
159
160

distclean::
Måns Rullgård's avatar
Måns Rullgård committed
161
	$(RM) $(DISTCLEANSUFFIXES)
162
	$(RM) config.* .version version.h libavutil/avconfig.h libavcodec/codec_names.h
163

164
config:
165
	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
166

Reimar Döffinger's avatar
Reimar Döffinger committed
167
168
169
170
171
172
173
174
175
# Without the sed genthml thinks "libavutil" and "./libavutil" are two different things
coverage.info: $(wildcard *.gcda *.gcno */*.gcda */*.gcno */*/*.gcda */*/*.gcno)
	$(Q)lcov -c -d . -b . | sed -e 's#/./#/#g' > $@

coverage-html: coverage.info
	$(Q)mkdir -p $@
	$(Q)genhtml -o $@ $<
	$(Q)touch $@

176
check: all alltools examples testprogs fate
177

178
179
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/tests/Makefile
180

181
182
183
$(sort $(OBJDIRS)):
	$(Q)mkdir -p $@

184
185
186
187
188
189
190
191
# Dummy rule to stop make trying to rebuild removed or renamed headers
%.h:
	@:

# Disable suffix rules.  Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES:

192
.PHONY: all all-yes alltools check *clean config install*
193
.PHONY: testprogs uninstall*