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