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