Makefile 4.69 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
endif

IFLAGS     := -I. -I$(SRC_PATH)
CPPFLAGS   := $(IFLAGS) $(CPPFLAGS)
CFLAGS     += $(ECFLAGS)
YASMFLAGS  += $(IFLAGS) -Pconfig.asm
HOSTCFLAGS += $(IFLAGS)

%.o: %.c
	$(CCDEP)
	$(CC) $(CPPFLAGS) $(CFLAGS) $(CC_DEPFLAGS) -c $(CC_O) $<

%.o: %.S
	$(ASDEP)
	$(AS) $(CPPFLAGS) $(ASFLAGS) $(AS_DEPFLAGS) -c -o $@ $<

%.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

45 46
PROGS-$(CONFIG_FFMPEG)   += ffmpeg
PROGS-$(CONFIG_FFPLAY)   += ffplay
Stefano Sabatini's avatar
Stefano Sabatini committed
47
PROGS-$(CONFIG_FFPROBE)  += ffprobe
48 49
PROGS-$(CONFIG_FFSERVER) += ffserver

50 51
PROGS      := $(PROGS-yes:%=%$(EXESUF))
OBJS        = $(PROGS-yes:%=%.o) cmdutils.o
52
TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
53 54
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
55

Stefano Sabatini's avatar
Stefano Sabatini committed
56
BASENAMES   = ffmpeg ffplay ffprobe ffserver
57 58
ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
ALLMANPAGES = $(BASENAMES:%=%.1)
59

60 61
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

62
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
63
FFLIBS-$(CONFIG_AVFILTER) += avfilter
64
FFLIBS-$(CONFIG_AVFORMAT) += avformat
Måns Rullgård's avatar
Måns Rullgård committed
65
FFLIBS-$(CONFIG_AVCODEC)  += avcodec
66
FFLIBS-$(CONFIG_POSTPROC) += postproc
67
FFLIBS-$(CONFIG_SWSCALE)  += swscale
68

69
FFLIBS := avutil
70

71
DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset)
72

73 74
SKIPHEADERS = cmdutils_common_opts.h

75 76 77 78 79 80
include common.mak

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

81
all: $(FF_DEP_LIBS) $(PROGS)
82

83
config.h: .config
84
.config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
85 86 87
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
88

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

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

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
include $(1)/Makefile
endef

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

106
ffplay.o: CFLAGS += $(SDL_CFLAGS)
107 108
ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
109

110
$(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
111
	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
112

113 114
alltools: $(TOOLS)

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

118
tools/%.o: tools/%.c
119
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
120 121

-include $(wildcard tools/*.d)
122

123 124
VERSION_SH  = $(SRC_PATH)/version.sh
GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
125

126
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
127 128 129
.version: M=@

version.h .version:
130
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
131 132 133 134
	$(Q)touch .version

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

136 137 138 139 140
ifdef PROGS
install: install-progs install-data
endif

install: install-libs install-headers
141 142

install-libs: install-libs-yes
143

144
install-progs-yes:
145 146 147
install-progs-$(CONFIG_SHARED): install-libs

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

151
install-data: $(DATA_FILES)
Måns Rullgård's avatar
Måns Rullgård committed
152
	$(Q)mkdir -p "$(DATADIR)"
153
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
154

155
uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
Ramiro Polla's avatar
Ramiro Polla committed
156 157

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

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

163
clean::
164
	$(RM) $(ALLPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
165 166
	$(RM) $(CLEANSUFFIXES)
	$(RM) $(TOOLS)
167
	$(RM) $(CLEANSUFFIXES:%=tools/%)
168 169

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

173
config:
174
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
175

176 177
check: test checkheaders

178
include doc/Makefile
179
include tests/Makefile
180

181 182 183 184 185 186 187 188
# 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:

189
.PHONY: all alltools *clean check config examples install*
190
.PHONY: testprogs uninstall*