add831458369e7c5ebc0170c07566d3cbb61f31c
[libav.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000-2004 Fabrice Bellard
4 #
5 include config.mak
6
7 VPATH=$(SRC_PATH)
8
9 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
10 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat \
11 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE
12 LDFLAGS+= -g
13
14 ifeq ($(CONFIG_SWSCALER),yes)
15 CFLAGS := -I$(SRC_PATH)/libswscale $(CFLAGS)
16 endif
17
18 MANPAGES=doc/ffmpeg.1
19 PROGS_G+=ffmpeg_g$(EXESUF)
20 PROGS+=ffmpeg$(EXESUF)
21 PROGTEST=output_example$(EXESUF)
22 QTFASTSTART=qt-faststart$(EXESUF)
23
24 ifeq ($(CONFIG_FFSERVER),yes)
25 MANPAGES+=doc/ffserver.1
26 PROGS+=ffserver$(EXESUF)
27 endif
28
29 ifeq ($(CONFIG_FFPLAY),yes)
30 MANPAGES+=doc/ffplay.1
31 PROGS_G+=ffplay_g$(EXESUF)
32 PROGS+=ffplay$(EXESUF)
33 endif
34
35 BASENAMES=ffmpeg ffplay ffserver
36 ALLPROGS=$(addsuffix $(EXESUF), $(BASENAMES))
37 ALLPROGS_G=$(addsuffix _g$(EXESUF), $(BASENAMES))
38 ALLMANPAGES=$(addsuffix .1, $(BASENAMES))
39
40 ifeq ($(CONFIG_AUDIO_BEOS),yes)
41 EXTRALIBS+=-lmedia -lbe
42 endif
43
44 ifeq ($(BUILD_SHARED),yes)
45 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
46 else
47 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
48 endif
49
50 ifeq ($(BUILD_VHOOK),yes)
51 VHOOK=videohook
52 INSTALLVHOOK=install-vhook
53 endif
54
55 ifeq ($(BUILD_DOC),yes)
56 DOC=documentation
57 endif
58
59 OBJS = ffmpeg.o ffserver.o cmdutils.o ffplay.o
60 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
61 LDFLAGS := -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
62 EXTRALIBS := -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
63
64 ifeq ($(CONFIG_SWSCALER),yes)
65 LDFLAGS+=-L./libswscale
66 EXTRALIBS+=-lswscale$(BUILDSUF)
67 endif
68
69 all: lib $(PROGS_G) $(PROGS) $(PROGTEST) $(VHOOK) $(QTFASTSTART) $(DOC)
70
71 lib:
72 $(MAKE) -C libavutil all
73 $(MAKE) -C libavcodec all
74 $(MAKE) -C libavformat all
75 ifeq ($(CONFIG_PP),yes)
76 $(MAKE) -C libpostproc all
77 endif
78 ifeq ($(CONFIG_SWSCALER),yes)
79 $(MAKE) -C libswscale all
80 endif
81
82 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
83 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
84
85 ffserver$(EXESUF): ffserver.o .libs
86 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o $(EXTRALIBS)
87
88 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
89 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
90
91 %$(EXESUF): %_g$(EXESUF)
92 cp -p $< $@
93 $(STRIP) $@
94
95 version.h:
96 $(SRC_PATH)/version.sh "$(SRC_PATH)"
97
98 output_example$(EXESUF): output_example.o .libs
99 $(CC) $(LDFLAGS) -o $@ output_example.o $(EXTRALIBS)
100
101 qt-faststart$(EXESUF): qt-faststart.c
102 $(CC) $(CFLAGS) $< -o $@
103
104 cws2fws$(EXESUF): cws2fws.c
105 $(CC) $< -o $@ -lz
106
107 ffplay.o: ffplay.c
108 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
109
110 ffmpeg.o ffplay.o ffserver.o: version.h
111
112 %.o: %.c
113 $(CC) $(CFLAGS) -c -o $@ $<
114
115 videohook: .libs
116 $(MAKE) -C vhook all
117
118 documentation:
119 $(MAKE) -C doc all
120
121 install: install-progs install-libs install-headers install-man $(INSTALLVHOOK)
122
123 ifeq ($(BUILD_SHARED),yes)
124 install-progs: $(PROGS) install-libs
125 else
126 install-progs: $(PROGS)
127 endif
128 install -d "$(bindir)"
129 install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
130
131 # create the window installer
132 wininstaller: all install
133 makensis ffinstall.nsi
134
135 # install man from source dir if available
136 install-man:
137 ifneq ($(CONFIG_MINGW),yes)
138 if [ -f doc/ffmpeg.1 ] ; then \
139 install -d "$(mandir)/man1" ; \
140 install -m 644 $(MANPAGES) "$(mandir)/man1" ; \
141 fi
142 endif
143
144 install-vhook:
145 $(MAKE) -C vhook install
146
147 install-libs:
148 $(MAKE) -C libavutil install-libs
149 $(MAKE) -C libavcodec install-libs
150 $(MAKE) -C libavformat install-libs
151 ifeq ($(CONFIG_PP),yes)
152 $(MAKE) -C libpostproc install-libs
153 endif
154 ifeq ($(CONFIG_SWSCALER),yes)
155 $(MAKE) -C libswscale install-libs
156 endif
157
158 ifeq ($(BUILD_SHARED),yes)
159 -$(LDCONFIG)
160 endif
161
162 install-headers:
163 $(MAKE) -C libavutil install-headers
164 $(MAKE) -C libavcodec install-headers
165 $(MAKE) -C libavformat install-headers
166 ifeq ($(CONFIG_PP),yes)
167 $(MAKE) -C libpostproc install-headers
168 endif
169 ifeq ($(CONFIG_SWSCALER),yes)
170 $(MAKE) -C libswscale install-headers
171 endif
172
173 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
174
175 uninstall-progs:
176 rm -f $(addprefix $(bindir)/, $(ALLPROGS))
177
178 uninstall-man:
179 ifneq ($(CONFIG_MINGW),yes)
180 rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
181 endif
182
183 uninstall-vhook:
184 $(MAKE) -C vhook uninstall
185
186 uninstall-libs:
187 $(MAKE) -C libavutil uninstall-libs
188 $(MAKE) -C libavcodec uninstall-libs
189 $(MAKE) -C libavformat uninstall-libs
190 $(MAKE) -C libpostproc uninstall-libs
191
192 uninstall-headers:
193 $(MAKE) -C libavutil uninstall-headers
194 $(MAKE) -C libavcodec uninstall-headers
195 $(MAKE) -C libavformat uninstall-headers
196 $(MAKE) -C libpostproc uninstall-headers
197 -rmdir "$(incdir)"
198 -rmdir "$(prefix)/include/postproc"
199
200 dep: depend
201
202 depend: .depend
203 $(MAKE) -C libavutil depend
204 $(MAKE) -C libavcodec depend
205 $(MAKE) -C libavformat depend
206 ifeq ($(CONFIG_PP),yes)
207 $(MAKE) -C libpostproc depend
208 endif
209 ifeq ($(CONFIG_SWSCALER),yes)
210 $(MAKE) -C libswscale depend
211 endif
212 ifeq ($(BUILD_VHOOK),yes)
213 $(MAKE) -C vhook depend
214 endif
215
216 .depend: $(SRCS) version.h
217 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(SRCS) 1>.depend
218
219 .libs: lib
220 @test -f .libs || touch .libs
221 @for i in $(DEP_LIBS) ; do if test $$i -nt .libs ; then touch .libs; fi ; done
222
223 clean:
224 $(MAKE) -C libavutil clean
225 $(MAKE) -C libavcodec clean
226 $(MAKE) -C libavformat clean
227 $(MAKE) -C libpostproc clean
228 $(MAKE) -C libswscale clean
229 $(MAKE) -C tests clean
230 $(MAKE) -C vhook clean
231 $(MAKE) -C doc clean
232 rm -f *.o *.d *~ .libs gmon.out TAGS \
233 $(ALLPROGS) $(ALLPROGS_G) $(PROGTEST) $(QTFASTSTART)
234
235 # Note well: config.log is NOT removed.
236 distclean: clean
237 $(MAKE) -C libavutil distclean
238 $(MAKE) -C libavcodec distclean
239 $(MAKE) -C libavformat distclean
240 $(MAKE) -C libpostproc distclean
241 $(MAKE) -C libswscale distclean
242 $(MAKE) -C tests distclean
243 $(MAKE) -C vhook distclean
244 rm -f .depend version.h config.* *.pc
245
246 TAGS:
247 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
248
249 # regression tests
250
251 codectest libavtest test-server fulltest test mpeg4 mpeg: $(PROGS)
252 $(MAKE) -C tests $@
253
254 # tar release (use 'make -k tar' on a checkouted tree)
255 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " version.h | \
256 cut -d "\"" -f 2 )
257
258 tar:
259 rm -rf /tmp/$(FILE)
260 cp -r . /tmp/$(FILE)
261 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude .svn )
262 rm -rf /tmp/$(FILE)
263
264 .PHONY: all lib videohook documentation install* wininstaller uninstall*
265 .PHONY: dep depend clean distclean TAGS tar
266 .PHONY: codectest libavtest test-server fulltest test mpeg4 mpeg
267
268 ifneq ($(wildcard .depend),)
269 include .depend
270 endif