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