build: move special targets to end of main 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 18OBJS = $(PROGS-yes:%=%.o) cmdutils.o
cd6a5a57 19TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
3d157bf3
MR
20TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64
21HOSTPROGS := $(TESTTOOLS:%=tests/%)
bde51e6a 22
336ce917 23BASENAMES = ffmpeg ffplay ffprobe ffserver
583fcb52 24ALLPROGS = $(BASENAMES:%=%$(EXESUF))
583fcb52 25ALLMANPAGES = $(BASENAMES:%=%.1)
bde51e6a 26
cf53c486
MR
27ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
28
5a0f7131 29FFLIBS-$(CONFIG_AVDEVICE) += avdevice
bde51e6a 30FFLIBS-$(CONFIG_AVFILTER) += avfilter
5a0f7131 31FFLIBS-$(CONFIG_AVFORMAT) += avformat
97d5fa38 32FFLIBS-$(CONFIG_AVCODEC) += avcodec
bde51e6a 33FFLIBS-$(CONFIG_POSTPROC) += postproc
5a0f7131 34FFLIBS-$(CONFIG_SWSCALE) += swscale
bde51e6a 35
5a0f7131 36FFLIBS := avutil
bde51e6a 37
a1a84f69
RS
38DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
39
9b55e2e7
MR
40SKIPHEADERS = cmdutils_common_opts.h
41
bde51e6a
JR
42include common.mak
43
44FF_LDFLAGS := $(FFLDFLAGS)
45FF_EXTRALIBS := $(FFEXTRALIBS)
46FF_DEP_LIBS := $(DEP_LIBS)
47
623ffe8c 48all: $(FF_DEP_LIBS) $(PROGS)
bde51e6a 49
86601915
MR
50config.h: .config
51.config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
9d0b3042
MR
52 @-tput bold 2>/dev/null
53 @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
54 @-tput sgr0 2>/dev/null
86601915 55
95f2c769 56SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
de4070b5 57 ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
a7878c9f 58 HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
bde51e6a
JR
59
60define RESET
61$(1) :=
62$(1)-yes :=
63endef
64
65define DOSUBDIR
66$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
67SUBDIR := $(1)/
68include $(1)/Makefile
69endef
70
71$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
72
d93d7349 73ffplay.o: CFLAGS += $(SDL_CFLAGS)
e0be794a
MR
74ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
75ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
bde51e6a 76
6d170962 77$(PROGS): %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
684b28e0 78 $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
bde51e6a 79
d93d7349
MR
80alltools: $(TOOLS)
81
2dfa3054
MR
82tools/%$(EXESUF): tools/%.o
83 $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
84
2205da0d 85tools/%.o: tools/%.c
4d1156cb 86 $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
08df7f86
MR
87
88-include $(wildcard tools/*.d)
bde51e6a 89
6a53fffd 90VERSION_SH = $(SRC_PATH_BARE)/version.sh
f82bf850 91GIT_LOG = $(SRC_PATH_BARE)/.git/logs/HEAD
6a53fffd 92
faa6f1c3 93.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
6a53fffd
MR
94.version: M=@
95
96version.h .version:
0853a2b4 97 $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
6a53fffd
MR
98 $(Q)touch .version
99
100# force version.sh to run whenever version might have changed
101-include .version
36798f1b 102
623ffe8c
MR
103ifdef PROGS
104install: install-progs install-data
105endif
106
107install: install-libs install-headers
d7a72d25
MR
108
109install-libs: install-libs-yes
bde51e6a 110
151c5841 111install-progs-yes:
623ffe8c
MR
112install-progs-$(CONFIG_SHARED): install-libs
113
114install-progs: install-progs-yes $(PROGS)
63611f31 115 $(Q)mkdir -p "$(BINDIR)"
fd676deb 116 $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
bde51e6a 117
a1a84f69 118install-data: $(DATA_FILES)
63611f31 119 $(Q)mkdir -p "$(DATADIR)"
fd676deb 120 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
a1a84f69 121
f87b03b5 122uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
d3cb93b3
RP
123
124uninstall-progs:
50e10cbd 125 $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
d3cb93b3
RP
126
127uninstall-data:
50e10cbd 128 $(RM) -r "$(DATADIR)"
d3cb93b3 129
698a183e 130clean::
e0be794a 131 $(RM) $(ALLPROGS)
50e10cbd 132 $(RM) $(CLEANSUFFIXES)
50e10cbd 133 $(RM) $(TOOLS)
40321376 134 $(RM) $(CLEANSUFFIXES:%=tools/%)
bde51e6a
JR
135
136distclean::
50e10cbd 137 $(RM) $(DISTCLEANSUFFIXES)
59748689 138 $(RM) config.* .version version.h libavutil/avconfig.h
bde51e6a 139
9d0b3042 140config:
29ba0911 141 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
0c3b2d65 142
5bab8536
DB
143check: test checkheaders
144
f87b03b5 145include doc/Makefile
698a183e 146include tests/Makefile
d29d9ccc 147
8d853efe
MR
148# Dummy rule to stop make trying to rebuild removed or renamed headers
149%.h:
150 @:
151
152# Disable suffix rules. Most of the builtin rules are suffix rules,
153# so this saves some time on slow systems.
154.SUFFIXES:
155
f87b03b5 156.PHONY: all alltools *clean check config examples install*
698a183e 157.PHONY: testprogs uninstall*