Makefile 5.43 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
vpath %.h    $(SRC_PATH)
7
vpath %.m    $(SRC_PATH)
8 9
vpath %.S    $(SRC_PATH)
vpath %.asm  $(SRC_PATH)
10
vpath %.rc   $(SRC_PATH)
11 12
vpath %.v    $(SRC_PATH)
vpath %.texi $(SRC_PATH)
13
vpath %/fate_config.sh.template $(SRC_PATH)
14

15 16 17 18
AVPROGS-$(CONFIG_FFMPEG)   += ffmpeg
AVPROGS-$(CONFIG_FFPLAY)   += ffplay
AVPROGS-$(CONFIG_FFPROBE)  += ffprobe
AVPROGS-$(CONFIG_FFSERVER) += ffserver
19

20 21
AVPROGS    := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
INSTPROGS   = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
22
PROGS      += $(AVPROGS)
23

24 25 26
AVBASENAMES  = ffmpeg ffplay ffprobe ffserver
ALLAVPROGS   = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
27

28
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
29
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
30

31
OBJS-ffmpeg                   += ffmpeg_opt.o ffmpeg_filter.o
32
OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
Loren Merritt's avatar
Loren Merritt committed
33
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
34
HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
35
TOOLS       = qt-faststart trasher uncoded_frame
36
TOOLS-$(CONFIG_ZLIB) += cws2fws
37

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

47
FFLIBS := avutil
48

49
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
50
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
51

52
SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
53

54
include $(SRC_PATH)/common.mak
55 56 57 58

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

59
all: $(AVPROGS)
60

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

64
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
65 66
tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
67

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

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

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

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

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

96 97
include $(SRC_PATH)/doc/Makefile

98
define DOPROG
99
OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
100
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
101
$$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
102 103
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
104 105 106
-include $$(OBJS-$(1):.o=.d)
endef

107
$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
108

109 110
ffprobe.o cmdutils.o : libavutil/ffversion.h

111
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
112 113 114
	$(CP) $< $@
	$(STRIP) $@

115
%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
116
	$(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
117

118 119
OBJDIRS += tools

120
-include $(wildcard tools/*.d)
121

122 123
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
124

125
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
126 127
.version: M=@

128 129
libavutil/ffversion.h .version:
	$(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
130 131 132 133
	$(Q)touch .version

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

135
ifdef AVPROGS
136 137 138 139
install: install-progs install-data
endif

install: install-libs install-headers
140 141

install-libs: install-libs-yes
142

143
install-progs-yes:
144 145
install-progs-$(CONFIG_SHARED): install-libs

146
install-progs: install-progs-yes $(AVPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
147
	$(Q)mkdir -p "$(BINDIR)"
148
	$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
149

150 151
install-data: $(DATA_FILES) $(EXAMPLES_FILES)
	$(Q)mkdir -p "$(DATADIR)/examples"
152
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
153
	$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
154

155
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
156 157

uninstall-progs:
158
	$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
159 160

uninstall-data:
161
	$(RM) -r "$(DATADIR)"
162

163
clean::
164
	$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
165
	$(RM) $(CLEANSUFFIXES)
166
	$(RM) $(CLEANSUFFIXES:%=tools/%)
167
	$(RM) -r coverage-html
168
	$(RM) -rf coverage.info lcov
169 170

distclean::
171
	$(RM) $(DISTCLEANSUFFIXES)
172
	$(RM) config.* .config libavutil/avconfig.h .version version.h libavutil/ffversion.h libavcodec/codec_names.h
173

174
config:
175
	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
176

177
check: all alltools examples testprogs fate
178

179
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*