build: move test rules to tests/Makefile
[libav.git] / Makefile
1 include config.mak
2
3 SRC_DIR = $(SRC_PATH_BARE)
4
5 vpath %.c $(SRC_DIR)
6 vpath %.h $(SRC_DIR)
7 vpath %.S $(SRC_DIR)
8 vpath %.asm $(SRC_DIR)
9 vpath %.v $(SRC_DIR)
10 vpath %.texi $(SRC_PATH_BARE)
11
12 PROGS-$(CONFIG_FFMPEG) += ffmpeg
13 PROGS-$(CONFIG_FFPLAY) += ffplay
14 PROGS-$(CONFIG_FFPROBE) += ffprobe
15 PROGS-$(CONFIG_FFSERVER) += ffserver
16
17 PROGS := $(PROGS-yes:%=%$(EXESUF))
18 OBJS = $(PROGS-yes:%=%.o) cmdutils.o
19 MANPAGES = $(PROGS-yes:%=doc/%.1)
20 PODPAGES = $(PROGS-yes:%=doc/%.pod)
21 HTMLPAGES = $(PROGS-yes:%=doc/%.html)
22 TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
23 TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
24 HOSTPROGS := $(TESTTOOLS:%=tests/%)
25
26 BASENAMES = ffmpeg ffplay ffprobe ffserver
27 ALLPROGS = $(BASENAMES:%=%$(EXESUF))
28 ALLMANPAGES = $(BASENAMES:%=%.1)
29
30 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
31
32 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
33 FFLIBS-$(CONFIG_AVFILTER) += avfilter
34 FFLIBS-$(CONFIG_AVFORMAT) += avformat
35 FFLIBS-$(CONFIG_AVCODEC) += avcodec
36 FFLIBS-$(CONFIG_POSTPROC) += postproc
37 FFLIBS-$(CONFIG_SWSCALE) += swscale
38
39 FFLIBS := avutil
40
41 DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
42
43 SKIPHEADERS = cmdutils_common_opts.h
44
45 include common.mak
46
47 FF_LDFLAGS := $(FFLDFLAGS)
48 FF_EXTRALIBS := $(FFEXTRALIBS)
49 FF_DEP_LIBS := $(DEP_LIBS)
50
51 all-$(CONFIG_DOC): documentation
52
53 all: $(FF_DEP_LIBS) $(PROGS)
54
55 config.h: .config
56 .config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
57 @-tput bold 2>/dev/null
58 @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
59 @-tput sgr0 2>/dev/null
60
61 SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
62 ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
63 HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
64
65 define RESET
66 $(1) :=
67 $(1)-yes :=
68 endef
69
70 define DOSUBDIR
71 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
72 SUBDIR := $(1)/
73 include $(1)/Makefile
74 endef
75
76 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
77
78 ffplay.o: CFLAGS += $(SDL_CFLAGS)
79 ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
80 ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
81
82 $(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
83 $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
84
85 alltools: $(TOOLS)
86
87 tools/%$(EXESUF): tools/%.o
88 $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
89
90 tools/%.o: tools/%.c
91 $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
92
93 -include $(wildcard tools/*.d)
94
95 VERSION_SH = $(SRC_PATH_BARE)/version.sh
96 GIT_LOG = $(SRC_PATH_BARE)/.git/logs/HEAD
97
98 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
99 .version: M=@
100
101 version.h .version:
102 $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
103 $(Q)touch .version
104
105 # force version.sh to run whenever version might have changed
106 -include .version
107
108 DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
109
110 documentation: $(DOCS)
111
112 -include $(wildcard $(DOCS:%=%.d))
113
114 TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
115
116 doc/%.html: TAG = HTML
117 doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
118 $(Q)$(TEXIDEP)
119 $(M)texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init --output $@ $<
120
121 doc/%.pod: TAG = POD
122 doc/%.pod: doc/%.texi
123 $(Q)$(TEXIDEP)
124 $(M)doc/texi2pod.pl $< $@
125
126 doc/%.1: TAG = MAN
127 doc/%.1: doc/%.pod
128 $(M)pod2man --section=1 --center=" " --release=" " $< > $@
129
130 ifdef PROGS
131 install: install-progs install-data
132 endif
133
134 install: install-libs install-headers
135
136 install-libs: install-libs-yes
137
138 install-progs-yes:
139 install-progs-$(CONFIG_DOC): install-man
140 install-progs-$(CONFIG_SHARED): install-libs
141
142 install-progs: install-progs-yes $(PROGS)
143 $(Q)mkdir -p "$(BINDIR)"
144 $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
145
146 install-data: $(DATA_FILES)
147 $(Q)mkdir -p "$(DATADIR)"
148 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
149
150 install-man: $(MANPAGES)
151 $(Q)mkdir -p "$(MANDIR)/man1"
152 $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
153
154 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-man
155
156 uninstall-progs:
157 $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
158
159 uninstall-data:
160 $(RM) -r "$(DATADIR)"
161
162 uninstall-man:
163 $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
164
165 clean::
166 $(RM) $(ALLPROGS)
167 $(RM) $(CLEANSUFFIXES)
168 $(RM) doc/*.html doc/*.pod doc/*.1
169 $(RM) $(TOOLS)
170 $(RM) $(CLEANSUFFIXES:%=tools/%)
171
172 distclean::
173 $(RM) $(DISTCLEANSUFFIXES)
174 $(RM) config.* .version version.h libavutil/avconfig.h
175
176 config:
177 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
178
179 check: test checkheaders
180
181 include tests/Makefile
182
183 .PHONY: all alltools *clean check config documentation examples install*
184 .PHONY: testprogs uninstall*