CVS --> Subversion
[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. -I$(SRC_PATH) -I$(SRC_PATH)/libavutil -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
10 LDFLAGS+= -g
11
12 ifeq ($(TARGET_GPROF),yes)
13 CFLAGS+=-p
14 LDFLAGS+=-p
15 endif
16
17 MANPAGES=doc/ffmpeg.1
18 PROGS_G+=ffmpeg_g$(EXESUF)
19 PROGS+=ffmpeg$(EXESUF)
20 PROGTEST=output_example$(EXESUF)
21 QTFASTSTART=qt-faststart$(EXESUF)
22
23 ifeq ($(CONFIG_FFSERVER),yes)
24 MANPAGES+=doc/ffserver.1
25 PROGS+=ffserver$(EXESUF)
26 endif
27
28 ifeq ($(CONFIG_FFPLAY),yes)
29 MANPAGES+=doc/ffplay.1
30 PROGS_G+=ffplay_g$(EXESUF)
31 PROGS+=ffplay$(EXESUF)
32 FFPLAY_O=ffplay.o
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 ($(TARGET_OS), SunOS)
56 TEST=/usr/bin/test
57 else
58 TEST=test
59 endif
60
61 ifeq ($(BUILD_DOC),yes)
62 DOC=documentation
63 endif
64
65 OBJS = ffmpeg.o ffserver.o cmdutils.o $(FFPLAY_O)
66 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
67 FFLIBS = -L./libavformat -lavformat$(BUILDSUF) -L./libavcodec -lavcodec$(BUILDSUF) -L./libavutil -lavutil$(BUILDSUF)
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
79 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
80 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS)
81
82 ffmpeg$(EXESUF): ffmpeg_g$(EXESUF)
83 cp -p $< $@
84 $(STRIP) $@
85
86 ffserver$(EXESUF): ffserver.o .libs
87 $(CC) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS)
88
89 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
90 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(FFLIBS) $(EXTRALIBS) $(SDL_LIBS)
91
92 ffplay$(EXESUF): ffplay_g$(EXESUF)
93 cp -p $< $@
94 $(STRIP) $@
95
96 output_example$(EXESUF): output_example.o .libs
97 $(CC) $(LDFLAGS) -o $@ output_example.o $(FFLIBS) $(EXTRALIBS)
98
99 qt-faststart$(EXESUF): qt-faststart.c
100 $(CC) $(CFLAGS) $(SRC_PATH)/qt-faststart.c -o qt-faststart$(EXESUF)
101
102 cws2fws$(EXESUF): cws2fws.c
103 $(CC) $(SRC_PATH)/cws2fws.c -o cws2fws$(EXESUF) -lz
104
105 ffplay.o: ffplay.c
106 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
107
108 %.o: %.c
109 $(CC) $(CFLAGS) -c -o $@ $<
110
111 videohook: .libs
112 $(MAKE) -C vhook all
113
114 documentation:
115 $(MAKE) -C doc all
116
117 .PHONY: install
118
119 install: install-progs install-libs install-headers install-man $(INSTALLVHOOK)
120
121 ifeq ($(BUILD_SHARED),yes)
122 install-progs: $(PROGS) install-libs
123 else
124 install-progs: $(PROGS)
125 endif
126 install -d "$(bindir)"
127 install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
128
129 # create the window installer
130 wininstaller: all install
131 makensis ffinstall.nsi
132
133 # install man from source dir if available
134 install-man:
135 ifneq ($(CONFIG_WIN32),yes)
136 if [ -f doc/ffmpeg.1 ] ; then \
137 install -d "$(mandir)/man1" ; \
138 install -m 644 $(MANPAGES) "$(mandir)/man1" ; \
139 fi
140 endif
141
142 install-vhook:
143 $(MAKE) -C vhook install
144
145 install-libs:
146 $(MAKE) -C libavutil install-libs
147 $(MAKE) -C libavcodec install-libs
148 $(MAKE) -C libavformat install-libs
149 ifeq ($(CONFIG_PP),yes)
150 $(MAKE) -C libpostproc install-libs
151 endif
152 ifeq ($(BUILD_SHARED),yes)
153 -$(LDCONFIG)
154 endif
155
156 install-headers:
157 $(MAKE) -C libavutil install-headers
158 $(MAKE) -C libavcodec install-headers
159 $(MAKE) -C libavformat install-headers
160 ifeq ($(CONFIG_PP),yes)
161 $(MAKE) -C libpostproc install-headers
162 endif
163
164 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
165
166 uninstall-progs:
167 rm -f $(addprefix $(bindir)/, $(ALLPROGS))
168
169 uninstall-man:
170 ifneq ($(CONFIG_WIN32),yes)
171 rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
172 endif
173
174 uninstall-vhook:
175 $(MAKE) -C vhook uninstall
176
177 uninstall-libs:
178 $(MAKE) -C libavutil uninstall-libs
179 $(MAKE) -C libavcodec uninstall-libs
180 $(MAKE) -C libavformat uninstall-libs
181 $(MAKE) -C libpostproc uninstall-libs
182
183 uninstall-headers:
184 $(MAKE) -C libavutil uninstall-headers
185 $(MAKE) -C libavcodec uninstall-headers
186 $(MAKE) -C libavformat uninstall-headers
187 $(MAKE) -C libpostproc uninstall-headers
188 -rmdir "$(incdir)"
189 -rmdir "$(prefix)/include/postproc"
190
191 dep: depend
192
193 depend: .depend
194 $(MAKE) -C libavutil depend
195 $(MAKE) -C libavcodec depend
196 $(MAKE) -C libavformat depend
197 ifeq ($(BUILD_VHOOK),yes)
198 $(MAKE) -C vhook depend
199 endif
200
201 .depend: $(SRCS)
202 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $^ 1>.depend
203
204 .libs: lib
205 @test -f .libs || touch .libs
206 @for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
207
208 clean:
209 $(MAKE) -C libavutil clean
210 $(MAKE) -C libavcodec clean
211 $(MAKE) -C libavformat clean
212 $(MAKE) -C libpostproc clean
213 $(MAKE) -C tests clean
214 $(MAKE) -C vhook clean
215 rm -f *.o *.d *~ .libs gmon.out TAGS \
216 $(ALLPROGS) $(ALLPROGS_G) $(PROGTEST) $(QTFASTSTART)
217
218 # Note well: config.log is NOT removed.
219 distclean: clean
220 $(MAKE) -C libavutil distclean
221 $(MAKE) -C libavcodec distclean
222 $(MAKE) -C libavformat distclean
223 $(MAKE) -C libpostproc distclean
224 $(MAKE) -C tests distclean
225 $(MAKE) -C vhook distclean
226 rm -f .depend config.mak config.h *.pc
227
228 TAGS:
229 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
230
231 # regression tests
232
233 libavtest test mpeg4 mpeg test-server fulltest: $(PROGS)
234 $(MAKE) -C tests $@
235
236 # tar release (use 'make -k tar' on a checkouted tree)
237 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
238 cut -d "\"" -f 2 )
239
240 tar:
241 rm -rf /tmp/$(FILE)
242 cp -r . /tmp/$(FILE)
243 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude .svn )
244 rm -rf /tmp/$(FILE)
245
246 .PHONY: lib
247
248 ifneq ($(wildcard .depend),)
249 include .depend
250 endif