df3d5ec8dbaf3f2070e9bd2acde309c1953c7f19
[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 MANPAGE=doc/ffmpeg.1
18 PROG=ffmpeg$(EXESUF)
19 PROGTEST=output_example$(EXESUF)
20 QTFASTSTART=qt-faststart$(EXESUF)
21
22 ifeq ($(CONFIG_FFSERVER),yes)
23 MANPAGE+=doc/ffserver.1
24 PROG+=ffserver$(EXESUF)
25 endif
26
27 ifeq ($(CONFIG_FFPLAY),yes)
28 MANPAGE+=doc/ffplay.1
29 PROG+=ffplay$(EXESUF)
30 FFPLAY_O=ffplay.o
31 endif
32
33 ifeq ($(CONFIG_AUDIO_BEOS),yes)
34 EXTRALIBS+=-lmedia -lbe
35 endif
36
37 ifeq ($(BUILD_SHARED),yes)
38 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
39 else
40 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
41 ifeq ($(CONFIG_MP3LAME),yes)
42 EXTRALIBS+=-lmp3lame
43 endif
44 endif
45
46 ifeq ($(CONFIG_LIBOGG),yes)
47 ifeq ($(CONFIG_LIBVORBIS),yes)
48 EXTRALIBS+= -lvorbisenc -lvorbis
49 endif
50 ifeq ($(CONFIG_LIBTHEORA),yes)
51 EXTRALIBS+= -ltheora
52 endif
53 EXTRALIBS+= -logg
54 endif
55
56 ifeq ($(CONFIG_FAAD),yes)
57 ifeq ($(CONFIG_FAADBIN),yes)
58 # no libs needed
59 else
60 EXTRALIBS += -lfaad
61 endif
62 endif
63
64 ifeq ($(CONFIG_FAAC),yes)
65 EXTRALIBS+=-lfaac
66 endif
67
68 ifeq ($(CONFIG_XVID),yes)
69 EXTRALIBS+=-lxvidcore
70 endif
71
72 ifeq ($(CONFIG_LIBGSM),yes)
73 EXTRALIBS+=-lgsm
74 endif
75
76 ifeq ($(CONFIG_DC1394),yes)
77 EXTRALIBS+=-ldc1394_control -lraw1394
78 endif
79
80 ifeq ($(BUILD_VHOOK),yes)
81 VHOOK=videohook
82 INSTALLVHOOK=install-vhook
83 CLEANVHOOK=clean-vhook
84 endif
85
86 ifeq ($(TARGET_OS), SunOS)
87 TEST=/usr/bin/test
88 else
89 TEST=test
90 endif
91
92 ifeq ($(BUILD_DOC),yes)
93 DOC=documentation
94 endif
95
96 OBJS = ffmpeg.o ffserver.o cmdutils.o $(FFPLAY_O)
97 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
98 FFLIBS = -L./libavformat -lavformat$(BUILDSUF) -L./libavcodec -lavcodec$(BUILDSUF) -L./libavutil -lavutil$(BUILDSUF)
99
100 all: lib $(PROG) $(PROGTEST) $(VHOOK) $(QTFASTSTART) $(DOC)
101
102 lib:
103 $(MAKE) -C libavutil all
104 $(MAKE) -C libavcodec all
105 $(MAKE) -C libavformat all
106
107 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
108 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS)
109
110 ffmpeg$(EXESUF): ffmpeg_g$(EXESUF)
111 cp -p $< $@
112 $(STRIP) $@
113
114 ffserver$(EXESUF): ffserver.o .libs
115 $(CC) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS)
116
117 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
118 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(FFLIBS) $(EXTRALIBS) $(SDL_LIBS)
119
120 ffplay$(EXESUF): ffplay_g$(EXESUF)
121 cp -p $< $@
122 $(STRIP) $@
123
124 output_example$(EXESUF): output_example.o .libs
125 $(CC) $(LDFLAGS) -o $@ output_example.o $(FFLIBS) $(EXTRALIBS)
126
127 qt-faststart$(EXESUF): qt-faststart.c
128 $(CC) $(SRC_PATH)/qt-faststart.c -o qt-faststart$(EXESUF)
129
130 cws2fws$(EXESUF): cws2fws.c
131 $(CC) $(SRC_PATH)/cws2fws.c -o cws2fws$(EXESUF) -lz
132
133 ffplay.o: ffplay.c
134 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
135
136 %.o: %.c
137 $(CC) $(CFLAGS) -c -o $@ $<
138
139 videohook: .libs
140 $(MAKE) -C vhook all
141
142 documentation:
143 $(MAKE) -C doc all
144
145 .PHONY: install
146
147 install: all install-man $(INSTALLVHOOK)
148 $(MAKE) -C libavutil install
149 $(MAKE) -C libavcodec install
150 $(MAKE) -C libavformat install
151 install -d "$(bindir)"
152 install -c $(INSTALLSTRIP) -m 755 $(PROG) "$(bindir)"
153
154 # create the window installer
155 wininstaller: all install
156 makensis ffinstall.nsi
157
158 # install man from source dir if available
159 install-man:
160 ifneq ($(CONFIG_WIN32),yes)
161 if [ -f doc/ffmpeg.1 ] ; then \
162 install -d "$(mandir)/man1" ; \
163 install -m 644 $(MANPAGE) "$(mandir)/man1" ; \
164 fi
165 endif
166
167 install-vhook:
168 $(MAKE) -C vhook install
169
170 installlib:
171 $(MAKE) -C libavutil installlib
172 $(MAKE) -C libavcodec installlib
173 $(MAKE) -C libavformat installlib
174
175 dep: depend
176
177 depend: .depend
178 $(MAKE) -C libavcodec depend
179 $(MAKE) -C libavformat depend
180 ifeq ($(BUILD_VHOOK),yes)
181 $(MAKE) -C vhook depend
182 endif
183
184 .depend: $(SRCS)
185 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $^ 1>.depend
186
187 .libs: lib
188 @test -f .libs || touch .libs
189 @for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
190
191 clean: $(CLEANVHOOK)
192 $(MAKE) -C libavutil clean
193 $(MAKE) -C libavcodec clean
194 $(MAKE) -C libavformat clean
195 $(MAKE) -C tests clean
196 rm -f *.o *.d *~ .libs .depend gmon.out TAGS ffmpeg_g$(EXESUF) \
197 ffplay_g$(EXESUF) $(PROG) $(PROGTEST) $(QTFASTSTART)
198
199 clean-vhook:
200 $(MAKE) -C vhook clean
201
202 # Note well: config.log is NOT removed.
203 distclean: clean
204 $(MAKE) -C libavcodec distclean
205 rm -f config.mak config.h
206
207 TAGS:
208 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
209
210 # regression tests
211
212 libavtest test mpeg4 mpeg test-server fulltest: ffmpeg$(EXESUF)
213 $(MAKE) -C tests $@
214
215 # tar release (use 'make -k tar' on a checkouted tree)
216 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
217 cut -d "\"" -f 2 )
218
219 tar:
220 rm -rf /tmp/$(FILE)
221 cp -r . /tmp/$(FILE)
222 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
223 rm -rf /tmp/$(FILE)
224
225 .PHONY: lib
226
227 ifneq ($(wildcard .depend),)
228 include .depend
229 endif