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 60
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
61

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

66 67
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

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

75
FFLIBS := avutil
76

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

79 80
SKIPHEADERS = cmdutils_common_opts.h

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

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

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

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

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

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

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

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

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

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

119 120 121 122
TOOLS     = cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher
TOOLOBJS := $(TOOLS:%=tools/%.o)
TOOLS    := $(TOOLS:%=tools/%$(EXESUF))

123 124
alltools: $(TOOLS)

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

128
$(TOOLOBJS): %.o: %.c | tools
129
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
130

131 132
OBJDIRS += tools

133
-include $(wildcard tools/*.d)
134

135 136
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
137

138
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
139 140 141
.version: M=@

version.h .version:
142
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
143 144 145 146
	$(Q)touch .version

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

148 149 150 151 152
ifdef PROGS
install: install-progs install-data
endif

install: install-libs install-headers
153 154

install-libs: install-libs-yes
155

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

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

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

167
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
Ramiro Polla's avatar
Ramiro Polla committed
168 169

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

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

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

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

185
config:
186
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
187

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

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

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

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