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

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

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

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

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

32
OBJS-ffmpeg                   += ffmpeg_opt.o ffmpeg_filter.o
33
OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
34
OBJS-ffmpeg-$(CONFIG_LIBMFX)  += ffmpeg_qsv.o
35
OBJS-ffmpeg-$(CONFIG_VAAPI)   += ffmpeg_vaapi.o
36 37 38
ifndef CONFIG_VIDEOTOOLBOX
OBJS-ffmpeg-$(CONFIG_VDA)     += ffmpeg_videotoolbox.o
endif
39
OBJS-ffmpeg-$(CONFIG_CUVID)   += ffmpeg_cuvid.o
40 41
OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
42
OBJS-ffserver                 += ffserver_config.o
43

44
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
45
HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
46
TOOLS       = qt-faststart trasher uncoded_frame
47
TOOLS-$(CONFIG_ZLIB) += cws2fws
48

49 50 51 52 53
# $(FFLIBS-yes) needs to be in linking order
FFLIBS-$(CONFIG_AVDEVICE)   += avdevice
FFLIBS-$(CONFIG_AVFILTER)   += avfilter
FFLIBS-$(CONFIG_AVFORMAT)   += avformat
FFLIBS-$(CONFIG_AVCODEC)    += avcodec
Justin Ruggles's avatar
Justin Ruggles committed
54
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
55 56
FFLIBS-$(CONFIG_POSTPROC)   += postproc
FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
57
FFLIBS-$(CONFIG_SWSCALE)    += swscale
58

59
FFLIBS := avutil
60

61
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
62
EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
63

64 65
SKIPHEADERS = cmdutils_common_opts.h                                    \
              compat/w32pthreads.h
66

67
include $(SRC_PATH)/common.mak
68 69 70

FF_EXTRALIBS := $(FFEXTRALIBS)
FF_DEP_LIBS  := $(DEP_LIBS)
71
FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
72

73
all: $(AVPROGS)
74

75
$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
76
	$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
77

78
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
79 80
tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
81

82
config.h: .config
83
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
84 85 86
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
87

88
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
89
               HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
90
               ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS     \
91
               ALTIVEC-OBJS MMX-OBJS YASM-OBJS                           \
92
               MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS         \
93
               MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
94 95 96 97 98 99 100 101 102

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

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
103
include $(SRC_PATH)/$(1)/Makefile
104
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
105
-include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
106
include $(SRC_PATH)/library.mak
107 108 109 110
endef

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

111 112
include $(SRC_PATH)/doc/Makefile

113
define DOPROG
114
OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
115
$(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
116
$$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
117 118
$(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
$(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
119 120 121
-include $$(OBJS-$(1):.o=.d)
endef

122
$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
123

124
ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
125

126
$(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
127 128 129
	$(CP) $< $@
	$(STRIP) $@

130
%$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
131
	$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
132

133 134
OBJDIRS += tools

135
-include $(wildcard tools/*.d)
136

137 138
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
139

140
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
141 142
.version: M=@

143 144
libavutil/ffversion.h .version:
	$(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
145 146 147 148
	$(Q)touch .version

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

150
ifdef AVPROGS
151 152 153 154
install: install-progs install-data
endif

install: install-libs install-headers
155 156

install-libs: install-libs-yes
157

158
install-progs-yes:
159 160
install-progs-$(CONFIG_SHARED): install-libs

161
install-progs: install-progs-yes $(AVPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
162
	$(Q)mkdir -p "$(BINDIR)"
163
	$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
164

165 166
install-data: $(DATA_FILES) $(EXAMPLES_FILES)
	$(Q)mkdir -p "$(DATADIR)/examples"
167
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
168
	$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
169

170
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
171 172

uninstall-progs:
173
	$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
174 175

uninstall-data:
176
	$(RM) -r "$(DATADIR)"
177

178
clean::
179
	$(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
180
	$(RM) $(CLEANSUFFIXES)
181
	$(RM) $(CLEANSUFFIXES:%=tools/%)
182
	$(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
183
	$(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
184
	$(RM) $(CLEANSUFFIXES:%=compat/%)
185
	$(RM) -r coverage-html
186
	$(RM) -rf coverage.info coverage.info.in lcov
187 188

distclean::
189
	$(RM) $(DISTCLEANSUFFIXES)
190
	$(RM) config.* .config libavutil/avconfig.h .version mapfile avversion.h version.h libavutil/ffversion.h libavcodec/codec_names.h libavcodec/bsf_list.c libavformat/protocol_list.c
191 192 193
ifeq ($(SRC_LINK),src)
	$(RM) src
endif
194
	$(RM) -rf doc/examples/pc-uninstalled
195

196
config:
197
	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
198

199
check: all alltools examples testprogs fate
200

201
include $(SRC_PATH)/tests/Makefile
202

203 204 205
$(sort $(OBJDIRS)):
	$(Q)mkdir -p $@

206 207 208 209 210 211 212 213
# 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:

214
.PHONY: all all-yes alltools check *clean config install*
215
.PHONY: testprogs uninstall*