Makefile 5.74 KB
Newer Older
1 2
include config.mak

3 4 5 6 7 8
vpath %.c    $(SRC_PATH)
vpath %.h    $(SRC_PATH)
vpath %.S    $(SRC_PATH)
vpath %.asm  $(SRC_PATH)
vpath %.v    $(SRC_PATH)
vpath %.texi $(SRC_PATH)
9

10 11 12
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
13
BRIEF  = CC HOSTCC HOSTLD AS YASM AR LD
14
SILENT = DEPCC DEPHOSTCC DEPAS DEPYASM RANLIB RM STRIP
15 16 17 18 19
MSG    = $@
M      = @$(call ECHO,$(TAG),$@);
$(foreach VAR,$(BRIEF), \
    $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
20
$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL))
21 22
endif

Justin Ruggles's avatar
Justin Ruggles committed
23
ALLFFLIBS = avcodec avdevice avfilter avformat avresample avutil swscale
24

25 26 27
IFLAGS     := -I. -I$(SRC_PATH)
CPPFLAGS   := $(IFLAGS) $(CPPFLAGS)
CFLAGS     += $(ECFLAGS)
28 29
CCFLAGS     = $(CPPFLAGS) $(CFLAGS)
ASFLAGS    := $(CPPFLAGS) $(ASFLAGS)
30
YASMFLAGS  += $(IFLAGS:%=%/) -Pconfig.asm
31
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
32
LDFLAGS    := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS)
33

34
define COMPILE
35
	$(call $(1)DEP,$(1))
36
	$($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $<
37 38 39 40
endef

COMPILE_C = $(call COMPILE,CC)
COMPILE_S = $(call COMPILE,AS)
41
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
42

43
%.o: %.c
44
	$(COMPILE_C)
45 46

%.o: %.S
47
	$(COMPILE_S)
48

49 50 51
%_host.o: %.c
	$(COMPILE_HOSTC)

52 53 54
%.i: %.c
	$(CC) $(CCFLAGS) $(CC_E) $<

55 56
%.h.c:
	$(Q)echo '#include "$*.h"' >$@
57 58 59 60 61 62

%.ver: %.v
	$(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@

%.c %.h: TAG = GEN

63 64 65
AVPROGS-$(CONFIG_AVCONV)   += avconv
AVPROGS-$(CONFIG_AVPLAY)   += avplay
AVPROGS-$(CONFIG_AVPROBE)  += avprobe
66

67 68
AVPROGS    := $(AVPROGS-yes:%=%$(EXESUF))
PROGS      += $(AVPROGS)
69

Anton Khirnov's avatar
Anton Khirnov committed
70
AVBASENAMES = avconv avplay avprobe
71 72
ALLAVPROGS  = $(AVBASENAMES:%=%$(EXESUF))

73
$(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
74 75

OBJS-avconv                   += avconv_opt.o avconv_filter.o
76
OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o
77
OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o
78
OBJS-avconv-$(CONFIG_VDA)     += avconv_vda.o
79

80
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
81
HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
82 83
TOOLS       = qt-faststart trasher
TOOLS-$(CONFIG_ZLIB) += cws2fws
84

85 86 87 88 89
# $(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
90
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
91
FFLIBS-$(CONFIG_SWSCALE)    += swscale
92

93
FFLIBS := avutil
94

95
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset)
96

97
SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
98

99
include $(SRC_PATH)/common.mak
100 101 102 103

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

104
all: $(AVPROGS)
105

106
$(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
107
	$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
108

109
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
110

111
config.h: .config
112
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
113 114 115
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
116

117
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
118
               HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
119
               ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS     \
120
               ALTIVEC-OBJS MMX-OBJS YASM-OBJS                           \
121
               OBJS HOSTOBJS TESTOBJS
122 123 124 125 126 127 128 129 130

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

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
131
include $(SRC_PATH)/$(1)/Makefile
132
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
133
-include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
134
include $(SRC_PATH)/library.mak
135 136 137 138
endef

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

139 140
include $(SRC_PATH)/doc/Makefile

141
define DOPROG
142
OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
143
$(1)$(EXESUF): $$(OBJS-$(1))
144 145 146 147 148 149
$$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
$(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
$(1)$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
-include $$(OBJS-$(1):.o=.d)
endef

150
$(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(EXESUF)=))))
151

152
$(PROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
153
	$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
154

155 156
OBJDIRS += tools

157
-include $(wildcard tools/*.d)
158

159 160
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
161

162
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
163 164 165
.version: M=@

version.h .version:
166
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
167 168 169 170
	$(Q)touch .version

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

172
ifdef AVPROGS
173 174 175 176
install: install-progs install-data
endif

install: install-libs install-headers
177 178

install-libs: install-libs-yes
179

180
install-progs-yes:
181 182
install-progs-$(CONFIG_SHARED): install-libs

183
install-progs: install-progs-yes $(AVPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
184
	$(Q)mkdir -p "$(BINDIR)"
185
	$(INSTALL) -c -m 755 $(AVPROGS) "$(BINDIR)"
186

187
install-data: $(DATA_FILES)
Måns Rullgård's avatar
Måns Rullgård committed
188
	$(Q)mkdir -p "$(DATADIR)"
189
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
190

191
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
192 193

uninstall-progs:
194
	$(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
195 196

uninstall-data:
197
	$(RM) -r "$(DATADIR)"
198

199
clean::
200
	$(RM) $(ALLAVPROGS)
201
	$(RM) $(CLEANSUFFIXES)
202
	$(RM) $(CLEANSUFFIXES:%=tools/%)
203
	$(RM) -rf coverage.info lcov
204 205

distclean::
206
	$(RM) $(DISTCLEANSUFFIXES)
207
	$(RM) config.* .config libavutil/avconfig.h .version version.h
208

209
config:
210
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
211

212 213
check: all alltools checkheaders examples testprogs fate

214
include $(SRC_PATH)/tests/Makefile
215

216 217 218
$(sort $(OBJDIRS)):
	$(Q)mkdir -p $@

219 220 221 222 223 224 225 226
# 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:

227
.PHONY: all all-yes alltools check *clean config examples install*
228
.PHONY: testprogs uninstall*