Makefile 4.73 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 60
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
61 62
TOOLS       = qt-faststart trasher
TOOLS-$(CONFIG_ZLIB) += cws2fws
63

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

68 69
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

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

77
FFLIBS := avutil
78

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

81 82
SKIPHEADERS = cmdutils_common_opts.h

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

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

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

91 92 93 94 95
$(TOOLS): %$(EXESUF): %.o
	$(LD) $(LDFLAGS) -o $@ $< $(ELIBS)

tools/cws2fws$(EXESUF): ELIBS = -lz

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

102
SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
103
               ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
104
               HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS TOOLS
105 106 107 108 109 110 111 112 113

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

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
114
include $(SRC_PATH)/$(1)/Makefile
115 116 117 118
endef

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

119
ffplay.o: CFLAGS += $(SDL_CFLAGS)
120 121
ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
122

123
$(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
124
	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
125

126 127
OBJDIRS += tools

128
-include $(wildcard tools/*.d)
129

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

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

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

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

143 144 145 146 147
ifdef PROGS
install: install-progs install-data
endif

install: install-libs install-headers
148 149

install-libs: install-libs-yes
150

151
install-progs-yes:
152 153 154
install-progs-$(CONFIG_SHARED): install-libs

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

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

162
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
Ramiro Polla's avatar
Ramiro Polla committed
163 164

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

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

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

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

180
config:
181
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
182

183 184
include $(SRC_PATH)/doc/Makefile
include $(SRC_PATH)/tests/Makefile
185

186 187 188
$(sort $(OBJDIRS)):
	$(Q)mkdir -p $@

189 190 191 192 193 194 195 196
# 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:

197
.PHONY: all all-yes alltools *clean config examples install*
198
.PHONY: testprogs uninstall*