improve broken shell detection, and give a better error message
[libav.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000-2004 Fabrice Bellard
4 #
5 include config.mak
6
7 VPATH=$(SRC_PATH_BARE)
8
9 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
10 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
11 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE
12 LDFLAGS+= -g
13
14 ifeq ($(CONFIG_FFMPEG),yes)
15 MANPAGES=doc/ffmpeg.1
16 PROGS_G+=ffmpeg_g$(EXESUF)
17 PROGS+=ffmpeg$(EXESUF)
18 PROGTEST=output_example$(EXESUF)
19 QTFASTSTART=qt-faststart$(EXESUF)
20 endif
21
22 ifeq ($(CONFIG_FFSERVER),yes)
23 MANPAGES+=doc/ffserver.1
24 PROGS+=ffserver$(EXESUF)
25 endif
26
27 ifeq ($(CONFIG_FFPLAY),yes)
28 MANPAGES+=doc/ffplay.1
29 PROGS_G+=ffplay_g$(EXESUF)
30 PROGS+=ffplay$(EXESUF)
31 endif
32
33 BASENAMES=ffmpeg ffplay ffserver
34 ALLPROGS=$(addsuffix $(EXESUF), $(BASENAMES))
35 ALLPROGS_G=$(addsuffix _g$(EXESUF), $(BASENAMES))
36 ALLMANPAGES=$(addsuffix .1, $(BASENAMES))
37
38 ifeq ($(CONFIG_AUDIO_BEOS),yes)
39 EXTRALIBS+=-lmedia -lbe
40 endif
41
42 ifeq ($(BUILD_SHARED),yes)
43 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
44 else
45 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
46 endif
47
48 ifeq ($(CONFIG_VHOOK),yes)
49 VHOOK=videohook
50 INSTALLVHOOK=install-vhook
51 endif
52
53 ifeq ($(BUILD_DOC),yes)
54 DOC=documentation
55 INSTALLMAN=install-man
56 endif
57
58 OBJS = ffmpeg.o ffserver.o cmdutils.o ffplay.o
59 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
60 LDFLAGS := -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
61 EXTRALIBS := -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
62
63 ifeq ($(CONFIG_SWSCALER),yes)
64 LDFLAGS+=-L./libswscale
65 EXTRALIBS+=-lswscale$(BUILDSUF)
66 endif
67
68 all: lib $(PROGS_G) $(PROGS) $(PROGTEST) $(VHOOK) $(QTFASTSTART) $(DOC)
69
70 lib:
71 $(MAKE) -C libavutil all
72 $(MAKE) -C libavcodec all
73 $(MAKE) -C libavformat all
74 ifeq ($(CONFIG_PP),yes)
75 $(MAKE) -C libpostproc all
76 endif
77 ifeq ($(CONFIG_SWSCALER),yes)
78 $(MAKE) -C libswscale all
79 endif
80
81 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
82 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
83
84 ffserver$(EXESUF): ffserver.o .libs
85 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o $(EXTRALIBS)
86
87 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
88 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
89
90 %$(EXESUF): %_g$(EXESUF)
91 cp -p $< $@
92 $(STRIP) $@
93
94 version.h:
95 $(SRC_PATH)/version.sh $(SRC_PATH)
96
97 output_example$(EXESUF): output_example.o .libs
98 $(CC) $(LDFLAGS) -o $@ output_example.o $(EXTRALIBS)
99
100 qt-faststart$(EXESUF): qt-faststart.c
101 $(CC) $(CFLAGS) $< -o $@
102
103 cws2fws$(EXESUF): cws2fws.c
104 $(CC) $< -o $@ -lz
105
106 ffplay.o: ffplay.c
107 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
108
109 ffmpeg.o ffplay.o ffserver.o: version.h
110
111 %.o: %.c
112 $(CC) $(CFLAGS) -c -o $@ $<
113
114 videohook: .libs
115 $(MAKE) -C vhook all
116
117 documentation:
118 $(MAKE) -C doc all
119
120 install: install-progs install-libs install-headers $(INSTALLMAN) $(INSTALLVHOOK)
121
122 ifeq ($(BUILD_SHARED),yes)
123 install-progs: $(PROGS) install-libs
124 else
125 install-progs: $(PROGS)
126 endif
127 install -d "$(bindir)"
128 install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
129
130 # create the window installer
131 wininstaller: all install
132 makensis ffinstall.nsi
133
134 install-man:
135 install -d "$(mandir)/man1"
136 install -m 644 $(MANPAGES) "$(mandir)/man1"
137
138 install-vhook:
139 $(MAKE) -C vhook install
140
141 install-libs:
142 $(MAKE) -C libavutil install-libs
143 $(MAKE) -C libavcodec install-libs
144 $(MAKE) -C libavformat install-libs
145 ifeq ($(CONFIG_PP),yes)
146 $(MAKE) -C libpostproc install-libs
147 endif
148 ifeq ($(CONFIG_SWSCALER),yes)
149 $(MAKE) -C libswscale install-libs
150 endif
151
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 $(MAKE) -C libswscale install-headers
164
165 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
166
167 uninstall-progs:
168 rm -f $(addprefix $(bindir)/, $(ALLPROGS))
169
170 uninstall-man:
171 ifneq ($(CONFIG_MINGW),yes)
172 rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
173 endif
174
175 uninstall-vhook:
176 $(MAKE) -C vhook uninstall
177
178 uninstall-libs:
179 $(MAKE) -C libavutil uninstall-libs
180 $(MAKE) -C libavcodec uninstall-libs
181 $(MAKE) -C libavformat uninstall-libs
182 $(MAKE) -C libpostproc uninstall-libs
183
184 uninstall-headers:
185 $(MAKE) -C libavutil uninstall-headers
186 $(MAKE) -C libavcodec uninstall-headers
187 $(MAKE) -C libavformat uninstall-headers
188 $(MAKE) -C libpostproc uninstall-headers
189 -rmdir "$(incdir)"
190 -rmdir "$(prefix)/include/postproc"
191
192 depend dep: .depend
193 $(MAKE) -C libavutil depend
194 $(MAKE) -C libavcodec depend
195 $(MAKE) -C libavformat depend
196 ifeq ($(CONFIG_PP),yes)
197 $(MAKE) -C libpostproc depend
198 endif
199 ifeq ($(CONFIG_SWSCALER),yes)
200 $(MAKE) -C libswscale depend
201 endif
202 ifeq ($(CONFIG_VHOOK),yes)
203 $(MAKE) -C vhook depend
204 endif
205
206 .depend: $(SRCS) version.h
207 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
208
209 .libs: lib
210 @test -f .libs || touch .libs
211 @for i in $(DEP_LIBS) ; do if test $$i -nt .libs ; then touch .libs; fi ; done
212
213 clean:
214 $(MAKE) -C libavutil clean
215 $(MAKE) -C libavcodec clean
216 $(MAKE) -C libavformat clean
217 $(MAKE) -C libpostproc clean
218 $(MAKE) -C libswscale clean
219 $(MAKE) -C tests clean
220 $(MAKE) -C vhook clean
221 $(MAKE) -C doc clean
222 rm -f *.o *.d *~ .libs gmon.out TAGS \
223 $(ALLPROGS) $(ALLPROGS_G) $(PROGTEST) $(QTFASTSTART)
224
225 # Note well: config.log is NOT removed.
226 distclean: clean
227 $(MAKE) -C libavutil distclean
228 $(MAKE) -C libavcodec distclean
229 $(MAKE) -C libavformat distclean
230 $(MAKE) -C libpostproc distclean
231 $(MAKE) -C libswscale distclean
232 $(MAKE) -C tests distclean
233 $(MAKE) -C vhook distclean
234 rm -f .depend version.h config.* *.pc
235
236 TAGS:
237 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
238
239 # regression tests
240
241 codectest libavtest test-server fulltest test mpeg4 mpeg: $(PROGS)
242 $(MAKE) -C tests $@
243
244 # tar release (use 'make -k tar' on a checkouted tree)
245 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " version.h | \
246 cut -d "\"" -f 2 )
247
248 tar:
249 rm -rf /tmp/$(FILE)
250 cp -r . /tmp/$(FILE)
251 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude .svn )
252 rm -rf /tmp/$(FILE)
253
254 .PHONY: all lib videohook documentation install* wininstaller uninstall*
255 .PHONY: dep depend clean distclean TAGS tar
256 .PHONY: codectest libavtest test-server fulltest test mpeg4 mpeg
257
258 ifneq ($(wildcard .depend),)
259 include .depend
260 endif