put local -L flags first in link commands
[libav.git] / Makefile
CommitLineData
a1b63811 1#
85f07f22 2# Main ffmpeg Makefile
38100e8c 3# (c) 2000-2004 Fabrice Bellard
85f07f22 4#
980fc7b8 5include config.mak
85f07f22 6
dd9ca370
FB
7VPATH=$(SRC_PATH)
8
c11c2bc2 9CFLAGS=$(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
115329f1 10LDFLAGS+= -g
37736979 11
980fc7b8 12ifeq ($(TARGET_GPROF),yes)
85f07f22
FB
13CFLAGS+=-p
14LDFLAGS+=-p
15endif
16
7d2f4546
DB
17MANPAGES=doc/ffmpeg.1
18PROGS_G+=ffmpeg_g$(EXESUF)
19PROGS+=ffmpeg$(EXESUF)
951bf3e6 20PROGTEST=output_example$(EXESUF)
38100e8c 21QTFASTSTART=qt-faststart$(EXESUF)
01310af2
FB
22
23ifeq ($(CONFIG_FFSERVER),yes)
7d2f4546
DB
24MANPAGES+=doc/ffserver.1
25PROGS+=ffserver$(EXESUF)
01310af2
FB
26endif
27
28ifeq ($(CONFIG_FFPLAY),yes)
7d2f4546
DB
29MANPAGES+=doc/ffplay.1
30PROGS_G+=ffplay_g$(EXESUF)
31PROGS+=ffplay$(EXESUF)
426c31a1 32FFPLAY_O=ffplay.o
f3ec2d46 33endif
85f07f22 34
6b991cb2
DB
35BASENAMES=ffmpeg ffplay ffserver
36ALLPROGS=$(addsuffix $(EXESUF), $(BASENAMES))
37ALLPROGS_G=$(addsuffix _g$(EXESUF), $(BASENAMES))
38ALLMANPAGES=$(addsuffix .1, $(BASENAMES))
39
dfdfa47c
FR
40ifeq ($(CONFIG_AUDIO_BEOS),yes)
41EXTRALIBS+=-lmedia -lbe
42endif
a1b63811 43
0fd94442 44ifeq ($(BUILD_SHARED),yes)
6bc114b2 45DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
0fd94442 46else
f3ec2d46 47DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
f02be79d
RS
48endif
49
142fc6b9
PG
50ifeq ($(BUILD_VHOOK),yes)
51VHOOK=videohook
52INSTALLVHOOK=install-vhook
47930f09 53endif
142fc6b9 54
6e023978
RS
55ifeq ($(TARGET_OS), SunOS)
56TEST=/usr/bin/test
57else
58TEST=test
59endif
60
146ea952
NB
61ifeq ($(BUILD_DOC),yes)
62DOC=documentation
63endif
64
426c31a1 65OBJS = ffmpeg.o ffserver.o cmdutils.o $(FFPLAY_O)
57514323 66SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
5d38ba33
MR
67FFLIBDIRS = -L./libavformat -L./libavcodec -L./libavutil
68FFLIBS = -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF)
57514323 69
7d2f4546 70all: lib $(PROGS_G) $(PROGS) $(PROGTEST) $(VHOOK) $(QTFASTSTART) $(DOC)
85f07f22 71
951bf3e6 72lib:
5d22ccf7
DB
73 $(MAKE) -C libavutil all
74 $(MAKE) -C libavcodec all
abac6175 75 $(MAKE) -C libavformat all
1a9150b1 76ifeq ($(CONFIG_PP),yes)
6d9a2421 77 $(MAKE) -C libpostproc all
1a9150b1 78endif
85f07f22 79
951bf3e6 80ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
5d38ba33 81 $(CC) $(FFLIBDIRS) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS)
85f07f22 82
951bf3e6 83ffmpeg$(EXESUF): ffmpeg_g$(EXESUF)
f3ec2d46
SG
84 cp -p $< $@
85 $(STRIP) $@
37736979 86
951bf3e6 87ffserver$(EXESUF): ffserver.o .libs
5d38ba33 88 $(CC) $(FFLIBDIRS) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS)
85f07f22 89
951bf3e6 90ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
5d38ba33 91 $(CC) $(FFLIBDIRS) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(FFLIBS) $(EXTRALIBS) $(SDL_LIBS)
01310af2 92
951bf3e6 93ffplay$(EXESUF): ffplay_g$(EXESUF)
01310af2
FB
94 cp -p $< $@
95 $(STRIP) $@
96
951bf3e6 97output_example$(EXESUF): output_example.o .libs
5d38ba33 98 $(CC) $(FFLIBDIRS) $(LDFLAGS) -o $@ output_example.o $(FFLIBS) $(EXTRALIBS)
8de65d4f 99
38100e8c 100qt-faststart$(EXESUF): qt-faststart.c
95ca7c94 101 $(CC) $(CFLAGS) $(SRC_PATH)/qt-faststart.c -o qt-faststart$(EXESUF)
38100e8c 102
f7599d5f
AB
103cws2fws$(EXESUF): cws2fws.c
104 $(CC) $(SRC_PATH)/cws2fws.c -o cws2fws$(EXESUF) -lz
105
01310af2 106ffplay.o: ffplay.c
115329f1 107 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
2744a37f 108
85f07f22 109%.o: %.c
115329f1 110 $(CC) $(CFLAGS) -c -o $@ $<
85f07f22 111
be12b2a4 112videohook: .libs
142fc6b9
PG
113 $(MAKE) -C vhook all
114
146ea952
NB
115documentation:
116 $(MAKE) -C doc all
117
d35ff76b
FB
118.PHONY: install
119
b12f8273 120install: install-progs install-libs install-headers install-man $(INSTALLVHOOK)
81dcdc53 121
a4848db6 122ifeq ($(BUILD_SHARED),yes)
7d2f4546 123install-progs: $(PROGS) install-libs
a4848db6 124else
7d2f4546 125install-progs: $(PROGS)
a4848db6 126endif
951bf3e6 127 install -d "$(bindir)"
7d2f4546 128 install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
85f07f22 129
d35ff76b
FB
130# create the window installer
131wininstaller: all install
132 makensis ffinstall.nsi
133
23a65308
FB
134# install man from source dir if available
135install-man:
951bf3e6 136ifneq ($(CONFIG_WIN32),yes)
8b8e1c55 137 if [ -f doc/ffmpeg.1 ] ; then \
aa99b8ff 138 install -d "$(mandir)/man1" ; \
7d2f4546 139 install -m 644 $(MANPAGES) "$(mandir)/man1" ; \
23a65308 140 fi
951bf3e6 141endif
23a65308 142
aa99b8ff
MN
143install-vhook:
144 $(MAKE) -C vhook install
142fc6b9 145
b12f8273 146install-libs:
8b2121e3
MR
147 $(MAKE) -C libavutil install-libs
148 $(MAKE) -C libavcodec install-libs
149 $(MAKE) -C libavformat install-libs
1a9150b1 150ifeq ($(CONFIG_PP),yes)
6d9a2421 151 $(MAKE) -C libpostproc install-libs
1a9150b1 152endif
8b2121e3 153ifeq ($(BUILD_SHARED),yes)
1e7ffa50 154 -$(LDCONFIG)
b12f8273 155endif
37736979 156
f29f3b5d
DB
157install-headers:
158 $(MAKE) -C libavutil install-headers
159 $(MAKE) -C libavcodec install-headers
160 $(MAKE) -C libavformat install-headers
1a9150b1 161ifeq ($(CONFIG_PP),yes)
6d9a2421 162 $(MAKE) -C libpostproc install-headers
1a9150b1 163endif
f29f3b5d 164
f9edb717
DB
165uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
166
f9edb717
DB
167uninstall-progs:
168 rm -f $(addprefix $(bindir)/, $(ALLPROGS))
169
f9edb717
DB
170uninstall-man:
171ifneq ($(CONFIG_WIN32),yes)
172 rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
173endif
174
175uninstall-vhook:
176 $(MAKE) -C vhook uninstall
177
178uninstall-libs:
179 $(MAKE) -C libavutil uninstall-libs
180 $(MAKE) -C libavcodec uninstall-libs
181 $(MAKE) -C libavformat uninstall-libs
6d9a2421 182 $(MAKE) -C libpostproc uninstall-libs
f9edb717
DB
183
184uninstall-headers:
185 $(MAKE) -C libavutil uninstall-headers
186 $(MAKE) -C libavcodec uninstall-headers
187 $(MAKE) -C libavformat uninstall-headers
6d9a2421 188 $(MAKE) -C libpostproc uninstall-headers
f9edb717
DB
189 -rmdir "$(incdir)"
190 -rmdir "$(prefix)/include/postproc"
191
57514323
ZK
192dep: depend
193
4b8b2edb 194depend: .depend
ea0f0681 195 $(MAKE) -C libavutil depend
5d22ccf7 196 $(MAKE) -C libavcodec depend
c80d990f 197 $(MAKE) -C libavformat depend
811b32ed 198ifeq ($(BUILD_VHOOK),yes)
5d22ccf7 199 $(MAKE) -C vhook depend
811b32ed 200endif
4b8b2edb
FB
201
202.depend: $(SRCS)
148beec7 203 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $^ 1>.depend
57514323 204
cf2818b0 205.libs: lib
127d5c8d 206 @test -f .libs || touch .libs
6e023978 207 @for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
cf2818b0 208
98013cc1 209clean:
5d22ccf7
DB
210 $(MAKE) -C libavutil clean
211 $(MAKE) -C libavcodec clean
abac6175 212 $(MAKE) -C libavformat clean
6d9a2421 213 $(MAKE) -C libpostproc clean
5d22ccf7
DB
214 $(MAKE) -C tests clean
215 $(MAKE) -C vhook clean
98013cc1 216 rm -f *.o *.d *~ .libs gmon.out TAGS \
6b991cb2 217 $(ALLPROGS) $(ALLPROGS_G) $(PROGTEST) $(QTFASTSTART)
142fc6b9 218
f255e0ab 219# Note well: config.log is NOT removed.
85f07f22 220distclean: clean
98013cc1
DB
221 $(MAKE) -C libavutil distclean
222 $(MAKE) -C libavcodec distclean
223 $(MAKE) -C libavformat distclean
6d9a2421 224 $(MAKE) -C libpostproc distclean
98013cc1
DB
225 $(MAKE) -C tests distclean
226 $(MAKE) -C vhook distclean
04c07634 227 rm -f .depend config.mak config.h *.pc
85f07f22
FB
228
229TAGS:
abac6175 230 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
57514323 231
dd9ca370
FB
232# regression tests
233
7d2f4546 234libavtest test mpeg4 mpeg test-server fulltest: $(PROGS)
ec9fca31 235 $(MAKE) -C tests $@
dd9ca370 236
ac977341 237# tar release (use 'make -k tar' on a checkouted tree)
951bf3e6
FB
238FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
239 cut -d "\"" -f 2 )
ac977341
FB
240
241tar:
242 rm -rf /tmp/$(FILE)
243 cp -r . /tmp/$(FILE)
36b1b0bc 244 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude .svn )
ac977341
FB
245 rm -rf /tmp/$(FILE)
246
cf2818b0
ZK
247.PHONY: lib
248
57514323
ZK
249ifneq ($(wildcard .depend),)
250include .depend
251endif