Add Windows resource file support for shared libraries
[ffmpeg.git] / Makefile
1 MAIN_MAKEFILE=1
2 include config.mak
3
4 vpath %.c    $(SRC_PATH)
5 vpath %.cpp  $(SRC_PATH)
6 vpath %.h    $(SRC_PATH)
7 vpath %.S    $(SRC_PATH)
8 vpath %.asm  $(SRC_PATH)
9 vpath %.rc   $(SRC_PATH)
10 vpath %.v    $(SRC_PATH)
11 vpath %.texi $(SRC_PATH)
12 vpath %/fate_config.sh.template $(SRC_PATH)
13
14 AVPROGS-$(CONFIG_FFMPEG)   += ffmpeg
15 AVPROGS-$(CONFIG_FFPLAY)   += ffplay
16 AVPROGS-$(CONFIG_FFPROBE)  += ffprobe
17 AVPROGS-$(CONFIG_FFSERVER) += ffserver
18
19 AVPROGS    := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
20 INSTPROGS   = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
21 PROGS      += $(AVPROGS)
22
23 AVBASENAMES  = ffmpeg ffplay ffprobe ffserver
24 ALLAVPROGS   = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
25 ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
26
27 $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
28
29 OBJS-ffmpeg                   += ffmpeg_opt.o ffmpeg_filter.o
30 OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
31 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64
32 HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
33 TOOLS       = qt-faststart trasher
34 TOOLS-$(CONFIG_ZLIB) += cws2fws
35
36 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
37 FFLIBS-$(CONFIG_AVFILTER) += avfilter
38 FFLIBS-$(CONFIG_AVFORMAT) += avformat
39 FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
40 FFLIBS-$(CONFIG_AVCODEC)  += avcodec
41 FFLIBS-$(CONFIG_POSTPROC) += postproc
42 FFLIBS-$(CONFIG_SWRESAMPLE)+= swresample
43 FFLIBS-$(CONFIG_SWSCALE)  += swscale
44
45 FFLIBS := avutil
46
47 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
48 EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
49
50 SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
51
52 include $(SRC_PATH)/common.mak
53
54 FF_EXTRALIBS := $(FFEXTRALIBS)
55 FF_DEP_LIBS  := $(DEP_LIBS)
56
57 all: $(AVPROGS)
58
59 $(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
60         $(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS)
61
62 tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
63
64 config.h: .config
65 .config: $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))
66         @-tput bold 2>/dev/null
67         @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
68         @-tput sgr0 2>/dev/null
69
70 SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
71                HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
72                ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS                \
73                ALTIVEC-OBJS VIS-OBJS                                     \
74                MMX-OBJS YASM-OBJS                                        \
75                MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSPR1-OBJS MIPS32R2-OBJS  \
76                OBJS SLIBOBJS HOSTOBJS TESTOBJS
77
78 define RESET
79 $(1) :=
80 $(1)-yes :=
81 endef
82
83 define DOSUBDIR
84 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
85 SUBDIR := $(1)/
86 include $(SRC_PATH)/$(1)/Makefile
87 -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
88 include $(SRC_PATH)/library.mak
89 endef
90
91 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
92
93 include $(SRC_PATH)/doc/Makefile
94
95 define DOPROG
96 OBJS-$(1) += $(1).o $(EXEOBJS) $(OBJS-$(1)-yes)
97 $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
98 $$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
99 $(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
100 $(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(LIBS-$(1))
101 -include $$(OBJS-$(1):.o=.d)
102 endef
103
104 $(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
105
106 ffprobe.o cmdutils.o : libavutil/ffversion.h
107
108 $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
109         $(CP) $< $@
110         $(STRIP) $@
111
112 %$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
113         $(LD) $(LDFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
114
115 OBJDIRS += tools
116
117 -include $(wildcard tools/*.d)
118
119 VERSION_SH  = $(SRC_PATH)/version.sh
120 GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
121
122 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
123 .version: M=@
124
125 libavutil/ffversion.h .version:
126         $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
127         $(Q)touch .version
128
129 # force version.sh to run whenever version might have changed
130 -include .version
131
132 ifdef AVPROGS
133 install: install-progs install-data
134 endif
135
136 install: install-libs install-headers
137
138 install-libs: install-libs-yes
139
140 install-progs-yes:
141 install-progs-$(CONFIG_SHARED): install-libs
142
143 install-progs: install-progs-yes $(AVPROGS)
144         $(Q)mkdir -p "$(BINDIR)"
145         $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
146
147 install-data: $(DATA_FILES) $(EXAMPLES_FILES)
148         $(Q)mkdir -p "$(DATADIR)/examples"
149         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
150         $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
151
152 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
153
154 uninstall-progs:
155         $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
156
157 uninstall-data:
158         $(RM) -r "$(DATADIR)"
159
160 clean::
161         $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
162         $(RM) $(CLEANSUFFIXES)
163         $(RM) $(CLEANSUFFIXES:%=tools/%)
164         $(RM) -r coverage-html
165         $(RM) -rf coverage.info lcov
166
167 distclean::
168         $(RM) $(DISTCLEANSUFFIXES)
169         $(RM) config.* .config libavutil/avconfig.h .version version.h libavutil/ffversion.h libavcodec/codec_names.h
170
171 config:
172         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
173
174 check: all alltools examples testprogs fate
175
176 include $(SRC_PATH)/tests/Makefile
177
178 $(sort $(OBJDIRS)):
179         $(Q)mkdir -p $@
180
181 # Dummy rule to stop make trying to rebuild removed or renamed headers
182 %.h:
183         @:
184
185 # Disable suffix rules.  Most of the builtin rules are suffix rules,
186 # so this saves some time on slow systems.
187 .SUFFIXES:
188
189 .PHONY: all all-yes alltools check *clean config install*
190 .PHONY: testprogs uninstall*