add quotes around $(libdir)
[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 ifeq ($(CONFIG_PP),yes)
71 $(MAKE) -C libavcodec/libpostproc all
72 endif
73
74 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
75 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS)
76
77 ffmpeg$(EXESUF): ffmpeg_g$(EXESUF)
78 cp -p $< $@
79 $(STRIP) $@
80
81 ffserver$(EXESUF): ffserver.o .libs
82 $(CC) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS)
83
84 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
85 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(FFLIBS) $(EXTRALIBS) $(SDL_LIBS)
86
87 ffplay$(EXESUF): ffplay_g$(EXESUF)
88 cp -p $< $@
89 $(STRIP) $@
90
91 output_example$(EXESUF): output_example.o .libs
92 $(CC) $(LDFLAGS) -o $@ output_example.o $(FFLIBS) $(EXTRALIBS)
93
94 qt-faststart$(EXESUF): qt-faststart.c
95 $(CC) $(SRC_PATH)/qt-faststart.c -o qt-faststart$(EXESUF)
96
97 cws2fws$(EXESUF): cws2fws.c
98 $(CC) $(SRC_PATH)/cws2fws.c -o cws2fws$(EXESUF) -lz
99
100 ffplay.o: ffplay.c
101 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
102
103 %.o: %.c
104 $(CC) $(CFLAGS) -c -o $@ $<
105
106 videohook: .libs
107 $(MAKE) -C vhook all
108
109 documentation:
110 $(MAKE) -C doc all
111
112 .PHONY: install
113
114 install: install-progs install-libs install-headers install-man $(INSTALLVHOOK)
115
116 ifeq ($(BUILD_SHARED),yes)
117 install-progs: $(PROG) install-libs
118 else
119 install-progs: $(PROG)
120 endif
121 install -d "$(bindir)"
122 install -c $(INSTALLSTRIP) -m 755 $(PROG) "$(bindir)"
123
124 # create the window installer
125 wininstaller: all install
126 makensis ffinstall.nsi
127
128 # install man from source dir if available
129 install-man:
130 ifneq ($(CONFIG_WIN32),yes)
131 if [ -f doc/ffmpeg.1 ] ; then \
132 install -d "$(mandir)/man1" ; \
133 install -m 644 $(MANPAGE) "$(mandir)/man1" ; \
134 fi
135 endif
136
137 install-vhook:
138 $(MAKE) -C vhook install
139
140 install-libs:
141 install -d "$(libdir)"
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 libavcodec/libpostproc install-libs
147 endif
148 ifeq ($(BUILD_SHARED),yes)
149 $(LDCONFIG) || true
150 endif
151
152 install-headers:
153 install -d "$(incdir)"
154 install -d "$(libdir)/pkgconfig"
155 $(MAKE) -C libavutil install-headers
156 $(MAKE) -C libavcodec install-headers
157 $(MAKE) -C libavformat install-headers
158 ifeq ($(CONFIG_PP),yes)
159 $(MAKE) -C libavcodec/libpostproc install-headers
160 endif
161
162 dep: depend
163
164 depend: .depend
165 $(MAKE) -C libavcodec depend
166 $(MAKE) -C libavformat depend
167 ifeq ($(BUILD_VHOOK),yes)
168 $(MAKE) -C vhook depend
169 endif
170
171 .depend: $(SRCS)
172 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $^ 1>.depend
173
174 .libs: lib
175 @test -f .libs || touch .libs
176 @for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
177
178 clean:
179 $(MAKE) -C libavutil clean
180 $(MAKE) -C libavcodec clean
181 $(MAKE) -C libavformat clean
182 $(MAKE) -C libavcodec/libpostproc clean
183 $(MAKE) -C tests clean
184 $(MAKE) -C vhook clean
185 rm -f *.o *.d *~ .libs gmon.out TAGS \
186 $(PROG) $(PROG_G) $(PROGTEST) $(QTFASTSTART)
187
188 # Note well: config.log is NOT removed.
189 distclean: clean
190 $(MAKE) -C libavutil distclean
191 $(MAKE) -C libavcodec distclean
192 $(MAKE) -C libavformat distclean
193 $(MAKE) -C libavcodec/libpostproc distclean
194 $(MAKE) -C tests distclean
195 $(MAKE) -C vhook distclean
196 rm -f .depend config.mak config.h *.pc
197
198 TAGS:
199 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
200
201 # regression tests
202
203 libavtest test mpeg4 mpeg test-server fulltest: $(PROG)
204 $(MAKE) -C tests $@
205
206 # tar release (use 'make -k tar' on a checkouted tree)
207 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
208 cut -d "\"" -f 2 )
209
210 tar:
211 rm -rf /tmp/$(FILE)
212 cp -r . /tmp/$(FILE)
213 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
214 rm -rf /tmp/$(FILE)
215
216 .PHONY: lib
217
218 ifneq ($(wildcard .depend),)
219 include .depend
220 endif