Makefile 4.76 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
endif

23 24
ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale

25 26 27
IFLAGS     := -I. -I$(SRC_PATH)
CPPFLAGS   := $(IFLAGS) $(CPPFLAGS)
CFLAGS     += $(ECFLAGS)
28
CCFLAGS     = $(CFLAGS)
29 30
YASMFLAGS  += $(IFLAGS) -Pconfig.asm
HOSTCFLAGS += $(IFLAGS)
31
LDFLAGS    := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS)
32

33 34 35 36 37 38 39 40
define COMPILE
	$($(1)DEP)
	$($(1)) $(CPPFLAGS) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $<
endef

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

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

%.o: %.S
45
	$(COMPILE_S)
46 47 48 49 50 51 52 53 54

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

55
PROGS-$(CONFIG_FFMPEG)   += ffmpeg
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 62
PROGS      := $(PROGS-yes:%=%$(EXESUF))
OBJS        = $(PROGS-yes:%=%.o) cmdutils.o
63 64
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
65 66
TOOLS       = qt-faststart trasher
TOOLS-$(CONFIG_ZLIB) += cws2fws
67

68
BASENAMES   = ffmpeg avconv avplay avprobe avserver
69 70
ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
ALLMANPAGES = $(BASENAMES:%=%.1)
71

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

79
FFLIBS := avutil
80

81
DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset)
82

83 84
SKIPHEADERS = cmdutils_common_opts.h

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

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

90
all: $(PROGS)
91

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

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

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

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

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

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

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

Anton Khirnov's avatar
Anton Khirnov committed
120 121
avplay.o: CFLAGS += $(SDL_CFLAGS)
avplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
Anton Khirnov's avatar
Anton Khirnov committed
122
avserver$(EXESUF): LDFLAGS += $(AVSERVERLDFLAGS)
123

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

127 128
OBJDIRS += tools

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

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

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

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

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

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

install: install-libs install-headers
149 150

install-libs: install-libs-yes
151

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

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

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

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

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

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

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

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

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

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

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

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

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