Makefile 5.34 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
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:%=%/) -I$(SRC_PATH)/libavutil/x86/ -Pconfig.asm
31
HOSTCCFLAGS = $(IFLAGS) $(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 41
endef

COMPILE_C = $(call COMPILE,CC)
COMPILE_S = $(call COMPILE,AS)

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

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

48 49
%.h.c:
	$(Q)echo '#include "$*.h"' >$@
50 51 52 53 54 55

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

%.c %.h: TAG = GEN

56
PROGS-$(CONFIG_AVCONV)   += avconv
Anton Khirnov's avatar
Anton Khirnov committed
57
PROGS-$(CONFIG_AVPLAY)   += avplay
Anton Khirnov's avatar
Anton Khirnov committed
58
PROGS-$(CONFIG_AVPROBE)  += avprobe
Anton Khirnov's avatar
Anton Khirnov committed
59
PROGS-$(CONFIG_AVSERVER) += avserver
60

61
PROGS      := $(PROGS-yes:%=%$(EXESUF))
62
OBJS        = cmdutils.o
63
OBJS-avconv = avconv_opt.o avconv_filter.o
64
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
65
HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
66 67
TOOLS       = qt-faststart trasher
TOOLS-$(CONFIG_ZLIB) += cws2fws
68

Anton Khirnov's avatar
Anton Khirnov committed
69
BASENAMES   = avconv avplay avprobe avserver
70 71
ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
ALLMANPAGES = $(BASENAMES:%=%.1)
72

73
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
74
FFLIBS-$(CONFIG_AVFILTER) += avfilter
75
FFLIBS-$(CONFIG_AVFORMAT) += avformat
Justin Ruggles's avatar
Justin Ruggles committed
76
FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
Måns Rullgård's avatar
Måns Rullgård committed
77
FFLIBS-$(CONFIG_AVCODEC)  += avcodec
78
FFLIBS-$(CONFIG_SWSCALE)  += swscale
79

80
FFLIBS := avutil
81

82
DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset)
83

84 85
SKIPHEADERS = cmdutils_common_opts.h

86
include $(SRC_PATH)/common.mak
87 88 89 90

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

91
all: $(PROGS)
92

93
$(TOOLS): %$(EXESUF): %.o
94
	$(LD) $(LDFLAGS) $(LD_O) $< $(ELIBS)
95

96
tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
97

98
config.h: .config
99
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
100 101 102
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
103

104
SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
105
               ARCH_HEADERS BUILT_HEADERS SKIPHEADERS                    \
106 107 108
               ARMV5TE-OBJS ARMV6-OBJS ARMVFP-OBJS NEON-OBJS             \
               MMI-OBJS ALTIVEC-OBJS VIS-OBJS                            \
               MMX-OBJS YASM-OBJS                                        \
109
               OBJS HOSTOBJS TESTOBJS
110 111 112 113 114 115 116 117 118

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

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
119
include $(SRC_PATH)/$(1)/Makefile
120
-include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
121
include $(SRC_PATH)/library.mak
122 123 124 125
endef

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

126 127 128 129 130 131 132 133 134 135
define DOPROG
OBJS-$(1) += $(1).o
$(1)$(EXESUF): $(OBJS-$(1))
$$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
$(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
$(1)$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
-include $$(OBJS-$(1):.o=.d)
endef

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

137
$(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
138
	$(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) cmdutils.o $(FF_EXTRALIBS)
139

140 141
OBJDIRS += tools

142
-include $(wildcard tools/*.d)
143

144 145
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
146

147
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
148 149 150
.version: M=@

version.h .version:
151
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
152 153 154 155
	$(Q)touch .version

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

157 158 159 160 161
ifdef PROGS
install: install-progs install-data
endif

install: install-libs install-headers
162 163

install-libs: install-libs-yes
164

165
install-progs-yes:
166 167 168
install-progs-$(CONFIG_SHARED): install-libs

install-progs: install-progs-yes $(PROGS)
Måns Rullgård's avatar
Måns Rullgård committed
169
	$(Q)mkdir -p "$(BINDIR)"
170
	$(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
171

172
install-data: $(DATA_FILES)
Måns Rullgård's avatar
Måns Rullgård committed
173
	$(Q)mkdir -p "$(DATADIR)"
174
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
175

176
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
Ramiro Polla's avatar
Ramiro Polla committed
177 178

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

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

184
clean::
185
	$(RM) $(ALLPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
186 187
	$(RM) $(CLEANSUFFIXES)
	$(RM) $(TOOLS)
188
	$(RM) $(CLEANSUFFIXES:%=tools/%)
189 190

distclean::
Måns Rullgård's avatar
Måns Rullgård committed
191
	$(RM) $(DISTCLEANSUFFIXES)
192
	$(RM) config.* .version version.h libavutil/avconfig.h
193

194
config:
195
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
196

197 198
check: all alltools checkheaders examples testprogs fate

199 200
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/tests/Makefile
201

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

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

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