add our -L flags before any other linker flags
[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 \
10 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat \
11 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE
12 LDFLAGS+= -g
13
14 ifeq ($(CONFIG_SWSCALER),yes)
15 CFLAGS := -I$(SRC_PATH)/libswscale $(CFLAGS)
16 endif
17
18 MANPAGES=doc/ffmpeg.1
19 PROGS_G+=ffmpeg_g$(EXESUF)
20 PROGS+=ffmpeg$(EXESUF)
21 PROGTEST=output_example$(EXESUF)
22 QTFASTSTART=qt-faststart$(EXESUF)
23
24 ifeq ($(CONFIG_FFSERVER),yes)
25 MANPAGES+=doc/ffserver.1
26 PROGS+=ffserver$(EXESUF)
27 endif
28
29 ifeq ($(CONFIG_FFPLAY),yes)
30 MANPAGES+=doc/ffplay.1
31 PROGS_G+=ffplay_g$(EXESUF)
32 PROGS+=ffplay$(EXESUF)
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 ($(BUILD_DOC),yes)
56 DOC=documentation
57 endif
58
59 OBJS = ffmpeg.o ffserver.o cmdutils.o ffplay.o
60 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
61 LDFLAGS := -L./libavformat -L./libavcodec -L./libavutil $(LDFLAGS)
62 EXTRALIBS := -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
63
64 ifeq ($(CONFIG_SWSCALER),yes)
65 LDFLAGS+=-L./libswscale
66 EXTRALIBS+=-lswscale$(BUILDSUF)
67 endif
68
69 all: version.h lib $(PROGS_G) $(PROGS) $(PROGTEST) $(VHOOK) $(QTFASTSTART) $(DOC)
70
71 lib:
72 $(MAKE) -C libavutil all
73 $(MAKE) -C libavcodec all
74 $(MAKE) -C libavformat all
75 ifeq ($(CONFIG_PP),yes)
76 $(MAKE) -C libpostproc all
77 endif
78 ifeq ($(CONFIG_SWSCALER),yes)
79 $(MAKE) -C libswscale all
80 endif
81
82 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
83 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
84
85 ffserver$(EXESUF): ffserver.o .libs
86 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o $(EXTRALIBS)
87
88 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
89 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
90
91 %$(EXESUF): %_g$(EXESUF)
92 cp -p $< $@
93 $(STRIP) $@
94
95 .PHONY: version.h
96 version.h:
97 $(SRC_PATH)/version.sh "$(SRC_PATH)"
98
99 output_example$(EXESUF): output_example.o .libs
100 $(CC) $(LDFLAGS) -o $@ output_example.o $(EXTRALIBS)
101
102 qt-faststart$(EXESUF): qt-faststart.c
103 $(CC) $(CFLAGS) $< -o $@
104
105 cws2fws$(EXESUF): cws2fws.c
106 $(CC) $< -o $@ -lz
107
108 ffplay.o: ffplay.c
109 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
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 .PHONY: install
121
122 install: install-progs install-libs install-headers install-man $(INSTALLVHOOK)
123
124 ifeq ($(BUILD_SHARED),yes)
125 install-progs: $(PROGS) install-libs
126 else
127 install-progs: $(PROGS)
128 endif
129 install -d "$(bindir)"
130 install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
131
132 # create the window installer
133 wininstaller: all install
134 makensis ffinstall.nsi
135
136 # install man from source dir if available
137 install-man:
138 ifneq ($(CONFIG_MINGW),yes)
139 if [ -f doc/ffmpeg.1 ] ; then \
140 install -d "$(mandir)/man1" ; \
141 install -m 644 $(MANPAGES) "$(mandir)/man1" ; \
142 fi
143 endif
144
145 install-vhook:
146 $(MAKE) -C vhook install
147
148 install-libs:
149 $(MAKE) -C libavutil install-libs
150 $(MAKE) -C libavcodec install-libs
151 $(MAKE) -C libavformat install-libs
152 ifeq ($(CONFIG_PP),yes)
153 $(MAKE) -C libpostproc install-libs
154 endif
155 ifeq ($(CONFIG_SWSCALER),yes)
156 $(MAKE) -C libswscale install-libs
157 endif
158
159 ifeq ($(BUILD_SHARED),yes)
160 -$(LDCONFIG)
161 endif
162
163 install-headers:
164 $(MAKE) -C libavutil install-headers
165 $(MAKE) -C libavcodec install-headers
166 $(MAKE) -C libavformat install-headers
167 ifeq ($(CONFIG_PP),yes)
168 $(MAKE) -C libpostproc install-headers
169 endif
170 ifeq ($(CONFIG_SWSCALER),yes)
171 $(MAKE) -C libswscale install-headers
172 endif
173
174 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
175
176 uninstall-progs:
177 rm -f $(addprefix $(bindir)/, $(ALLPROGS))
178
179 uninstall-man:
180 ifneq ($(CONFIG_MINGW),yes)
181 rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
182 endif
183
184 uninstall-vhook:
185 $(MAKE) -C vhook uninstall
186
187 uninstall-libs:
188 $(MAKE) -C libavutil uninstall-libs
189 $(MAKE) -C libavcodec uninstall-libs
190 $(MAKE) -C libavformat uninstall-libs
191 $(MAKE) -C libpostproc uninstall-libs
192
193 uninstall-headers:
194 $(MAKE) -C libavutil uninstall-headers
195 $(MAKE) -C libavcodec uninstall-headers
196 $(MAKE) -C libavformat uninstall-headers
197 $(MAKE) -C libpostproc uninstall-headers
198 -rmdir "$(incdir)"
199 -rmdir "$(prefix)/include/postproc"
200
201 dep: depend
202
203 depend: .depend
204 $(MAKE) -C libavutil depend
205 $(MAKE) -C libavcodec depend
206 $(MAKE) -C libavformat depend
207 ifeq ($(BUILD_VHOOK),yes)
208 $(MAKE) -C vhook depend
209 endif
210
211 .depend: $(SRCS) version.h
212 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(SRCS) 1>.depend
213
214 .libs: lib
215 @test -f .libs || touch .libs
216 @for i in $(DEP_LIBS) ; do if test $$i -nt .libs ; then touch .libs; fi ; done
217
218 clean:
219 $(MAKE) -C libavutil clean
220 $(MAKE) -C libavcodec clean
221 $(MAKE) -C libavformat clean
222 $(MAKE) -C libpostproc clean
223 $(MAKE) -C libswscale clean
224 $(MAKE) -C tests clean
225 $(MAKE) -C vhook clean
226 $(MAKE) -C doc clean
227 rm -f *.o *.d *~ .libs gmon.out TAGS \
228 $(ALLPROGS) $(ALLPROGS_G) $(PROGTEST) $(QTFASTSTART)
229
230 # Note well: config.log is NOT removed.
231 distclean: clean
232 $(MAKE) -C libavutil distclean
233 $(MAKE) -C libavcodec distclean
234 $(MAKE) -C libavformat distclean
235 $(MAKE) -C libpostproc distclean
236 $(MAKE) -C libswscale distclean
237 $(MAKE) -C tests distclean
238 $(MAKE) -C vhook distclean
239 rm -f .depend version.h config.* *.pc
240
241 TAGS:
242 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
243
244 # regression tests
245
246 libavtest test mpeg4 mpeg test-server fulltest: $(PROGS)
247 $(MAKE) -C tests $@
248
249 # tar release (use 'make -k tar' on a checkouted tree)
250 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " version.h | \
251 cut -d "\"" -f 2 )
252
253 tar:
254 rm -rf /tmp/$(FILE)
255 cp -r . /tmp/$(FILE)
256 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude .svn )
257 rm -rf /tmp/$(FILE)
258
259 .PHONY: lib
260
261 ifneq ($(wildcard .depend),)
262 include .depend
263 endif