2d9e4353a08b2118e558378e05d7efef52091556
[libav.git] / Makefile
1 include config.mak
2
3 vpath %.c $(SRC_PATH)
4 vpath %.h $(SRC_PATH)
5 vpath %.S $(SRC_PATH)
6 vpath %.asm $(SRC_PATH)
7 vpath %.v $(SRC_PATH)
8 vpath %.texi $(SRC_PATH)
9
10 ifndef V
11 Q = @
12 ECHO = printf "$(1)\t%s\n" $(2)
13 BRIEF = CC AS YASM AR LD HOSTCC
14 SILENT = DEPCC YASMDEP RM RANLIB
15 MSG = $@
16 M = @$(call ECHO,$(TAG),$@);
17 $(foreach VAR,$(BRIEF), \
18 $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
19 $(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
20 $(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_PATH)/%=%)); $(INSTALL))
21 endif
22
23 ALLFFLIBS = avcodec avdevice avfilter avformat avutil swscale
24
25 IFLAGS := -I. -I$(SRC_PATH)
26 CPPFLAGS := $(IFLAGS) $(CPPFLAGS)
27 CFLAGS += $(ECFLAGS)
28 CCFLAGS = $(CFLAGS)
29 YASMFLAGS += $(IFLAGS) -I$(SRC_PATH)/libavutil/x86/ -Pconfig.asm
30 HOSTCFLAGS += $(IFLAGS)
31 LDFLAGS := $(ALLFFLIBS:%=-Llib%) $(LDFLAGS)
32
33 define COMPILE
34 $($(1)DEP)
35 $($(1)) $(CPPFLAGS) $($(1)FLAGS) $($(1)_DEPFLAGS) -c $($(1)_O) $<
36 endef
37
38 COMPILE_C = $(call COMPILE,CC)
39 COMPILE_S = $(call COMPILE,AS)
40
41 %.o: %.c
42 $(COMPILE_C)
43
44 %.o: %.S
45 $(COMPILE_S)
46
47 %.ho: %.h
48 $(CC) $(CPPFLAGS) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
49
50 %.ver: %.v
51 $(Q)sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
52
53 %.c %.h: TAG = GEN
54
55 PROGS-$(CONFIG_AVCONV) += avconv
56 PROGS-$(CONFIG_AVPLAY) += avplay
57 PROGS-$(CONFIG_AVPROBE) += avprobe
58 PROGS-$(CONFIG_AVSERVER) += avserver
59
60 PROGS := $(PROGS-yes:%=%$(EXESUF))
61 OBJS = $(PROGS-yes:%=%.o) cmdutils.o
62 TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
63 HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options
64 TOOLS = qt-faststart trasher
65 TOOLS-$(CONFIG_ZLIB) += cws2fws
66
67 BASENAMES = avconv avplay avprobe avserver
68 ALLPROGS = $(BASENAMES:%=%$(EXESUF))
69 ALLMANPAGES = $(BASENAMES:%=%.1)
70
71 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
72 FFLIBS-$(CONFIG_AVFILTER) += avfilter
73 FFLIBS-$(CONFIG_AVFORMAT) += avformat
74 FFLIBS-$(CONFIG_AVCODEC) += avcodec
75 FFLIBS-$(CONFIG_SWSCALE) += swscale
76
77 FFLIBS := avutil
78
79 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset)
80
81 SKIPHEADERS = cmdutils_common_opts.h
82
83 include $(SRC_PATH)/common.mak
84
85 FF_EXTRALIBS := $(FFEXTRALIBS)
86 FF_DEP_LIBS := $(DEP_LIBS)
87
88 all: $(PROGS)
89
90 $(TOOLS): %$(EXESUF): %.o
91 $(LD) $(LDFLAGS) -o $@ $< $(ELIBS)
92
93 tools/cws2fws$(EXESUF): ELIBS = -lz
94
95 config.h: .config
96 .config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
97 @-tput bold 2>/dev/null
98 @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
99 @-tput sgr0 2>/dev/null
100
101 SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS \
102 ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
103 ALTIVEC-OBJS ARMV5TE-OBJS ARMV6-OBJS ARMVFP-OBJS MMI-OBJS \
104 MMX-OBJS NEON-OBJS VIS-OBJS YASM-OBJS \
105 OBJS TESTOBJS
106
107 define RESET
108 $(1) :=
109 $(1)-yes :=
110 endef
111
112 define DOSUBDIR
113 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
114 SUBDIR := $(1)/
115 include $(SRC_PATH)/$(1)/Makefile
116 -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
117 include $(SRC_PATH)/library.mak
118 endef
119
120 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
121
122 avplay.o: CFLAGS += $(SDL_CFLAGS)
123 avplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
124 avserver$(EXESUF): LDFLAGS += $(AVSERVERLDFLAGS)
125
126 $(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
127 $(LD) $(LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
128
129 OBJDIRS += tools
130
131 -include $(wildcard tools/*.d)
132
133 VERSION_SH = $(SRC_PATH)/version.sh
134 GIT_LOG = $(SRC_PATH)/.git/logs/HEAD
135
136 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
137 .version: M=@
138
139 version.h .version:
140 $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
141 $(Q)touch .version
142
143 # force version.sh to run whenever version might have changed
144 -include .version
145
146 ifdef PROGS
147 install: install-progs install-data
148 endif
149
150 install: install-libs install-headers
151
152 install-libs: install-libs-yes
153
154 install-progs-yes:
155 install-progs-$(CONFIG_SHARED): install-libs
156
157 install-progs: install-progs-yes $(PROGS)
158 $(Q)mkdir -p "$(BINDIR)"
159 $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
160
161 install-data: $(DATA_FILES)
162 $(Q)mkdir -p "$(DATADIR)"
163 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
164
165 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
166
167 uninstall-progs:
168 $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
169
170 uninstall-data:
171 $(RM) -r "$(DATADIR)"
172
173 clean::
174 $(RM) $(ALLPROGS)
175 $(RM) $(CLEANSUFFIXES)
176 $(RM) $(TOOLS)
177 $(RM) $(CLEANSUFFIXES:%=tools/%)
178
179 distclean::
180 $(RM) $(DISTCLEANSUFFIXES)
181 $(RM) config.* .version version.h libavutil/avconfig.h
182
183 config:
184 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
185
186 include $(SRC_PATH)/doc/Makefile
187 include $(SRC_PATH)/tests/Makefile
188
189 $(sort $(OBJDIRS)):
190 $(Q)mkdir -p $@
191
192 # Dummy rule to stop make trying to rebuild removed or renamed headers
193 %.h:
194 @:
195
196 # Disable suffix rules. Most of the builtin rules are suffix rules,
197 # so this saves some time on slow systems.
198 .SUFFIXES:
199
200 .PHONY: all all-yes alltools *clean config examples install*
201 .PHONY: testprogs uninstall*