Makefile 4.89 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 13 14 15 16 17 18 19
ifndef V
Q      = @
ECHO   = printf "$(1)\t%s\n" $(2)
BRIEF  = CC AS YASM AR LD HOSTCC
SILENT = DEPCC YASMDEP RM RANLIB
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 23 24 25
endif

IFLAGS     := -I. -I$(SRC_PATH)
CPPFLAGS   := $(IFLAGS) $(CPPFLAGS)
CFLAGS     += $(ECFLAGS)
26
CCFLAGS     = $(CFLAGS)
27 28 29
YASMFLAGS  += $(IFLAGS) -Pconfig.asm
HOSTCFLAGS += $(IFLAGS)

30 31 32 33 34 35 36 37
define COMPILE
	$($(1)DEP)
	$($(1)) $(CPPFLAGS) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $<
endef

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

38
%.o: %.c
39
	$(COMPILE_C)
40 41

%.o: %.S
42
	$(COMPILE_S)
43 44 45 46 47 48 49 50 51

%.ho: %.h
	$(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<

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

%.c %.h: TAG = GEN

52 53
PROGS-$(CONFIG_FFMPEG)   += ffmpeg
PROGS-$(CONFIG_FFPLAY)   += ffplay
Stefano Sabatini's avatar
Stefano Sabatini committed
54
PROGS-$(CONFIG_FFPROBE)  += ffprobe
55 56
PROGS-$(CONFIG_FFSERVER) += ffserver

57 58
PROGS      := $(PROGS-yes:%=%$(EXESUF))
OBJS        = $(PROGS-yes:%=%.o) cmdutils.o
59
TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
60 61
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
62

Stefano Sabatini's avatar
Stefano Sabatini committed
63
BASENAMES   = ffmpeg ffplay ffprobe ffserver
64 65
ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
ALLMANPAGES = $(BASENAMES:%=%.1)
66

67 68
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

69
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
70
FFLIBS-$(CONFIG_AVFILTER) += avfilter
71
FFLIBS-$(CONFIG_AVFORMAT) += avformat
Måns Rullgård's avatar
Måns Rullgård committed
72
FFLIBS-$(CONFIG_AVCODEC)  += avcodec
73
FFLIBS-$(CONFIG_POSTPROC) += postproc
74
FFLIBS-$(CONFIG_SWSCALE)  += swscale
75

76
FFLIBS := avutil
77

78
DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset)
79

80 81
SKIPHEADERS = cmdutils_common_opts.h

82
include $(SRC_PATH)/common.mak
83 84 85 86 87

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

88
all: $(FF_DEP_LIBS) $(PROGS)
89

90
config.h: .config
91
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
92 93 94
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
95

96
SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
97
               ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
98
               HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
99 100 101 102 103 104 105 106 107

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

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
108
include $(SRC_PATH)/$(1)/Makefile
109 110 111 112
endef

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

113
ffplay.o: CFLAGS += $(SDL_CFLAGS)
114 115
ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
116

117
$(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
118
	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
119

120 121
alltools: $(TOOLS)

Måns Rullgård's avatar
Måns Rullgård committed
122 123 124
tools/%$(EXESUF): tools/%.o
	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)

125
tools/%.o: tools/%.c | tools
126
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
127

128 129
OBJDIRS += tools

130
-include $(wildcard tools/*.d)
131

132 133
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
134

135
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
136 137 138
.version: M=@

version.h .version:
139
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
140 141 142 143
	$(Q)touch .version

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

145 146 147 148 149
ifdef PROGS
install: install-progs install-data
endif

install: install-libs install-headers
150 151

install-libs: install-libs-yes
152

153
install-progs-yes:
154 155 156
install-progs-$(CONFIG_SHARED): install-libs

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

160
install-data: $(DATA_FILES)
Måns Rullgård's avatar
Måns Rullgård committed
161
	$(Q)mkdir -p "$(DATADIR)"
162
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
163

164
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
Ramiro Polla's avatar
Ramiro Polla committed
165 166

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

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

172
clean::
173
	$(RM) $(ALLPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
174 175
	$(RM) $(CLEANSUFFIXES)
	$(RM) $(TOOLS)
176
	$(RM) $(CLEANSUFFIXES:%=tools/%)
177 178

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

182
config:
183
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
184

185 186
check: test checkheaders

187 188
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/tests/Makefile
189

190 191 192
$(sort $(OBJDIRS)):
	$(Q)mkdir -p $@

193 194 195 196 197 198 199 200
# 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:

201
.PHONY: all all-yes alltools *clean check config examples install*
202
.PHONY: testprogs uninstall*