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