Create installation directories in the common install-* targets.
[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 $(MAKE) -C libavutil install-libs
142 $(MAKE) -C libavcodec install-libs
143 $(MAKE) -C libavformat install-libs
144 ifeq ($(CONFIG_PP),yes)
145 $(MAKE) -C libavcodec/libpostproc install-libs
146 endif
147 ifeq ($(BUILD_SHARED),yes)
148 $(LDCONFIG) || true
149 endif
150
151 install-headers:
152 $(MAKE) -C libavutil install-headers
153 $(MAKE) -C libavcodec install-headers
154 $(MAKE) -C libavformat install-headers
155 ifeq ($(CONFIG_PP),yes)
156 $(MAKE) -C libavcodec/libpostproc install-headers
157 endif
158
159 dep: depend
160
161 depend: .depend
162 $(MAKE) -C libavcodec depend
163 $(MAKE) -C libavformat depend
164 ifeq ($(BUILD_VHOOK),yes)
165 $(MAKE) -C vhook depend
166 endif
167
168 .depend: $(SRCS)
169 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $^ 1>.depend
170
171 .libs: lib
172 @test -f .libs || touch .libs
173 @for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
174
175 clean:
176 $(MAKE) -C libavutil clean
177 $(MAKE) -C libavcodec clean
178 $(MAKE) -C libavformat clean
179 $(MAKE) -C libavcodec/libpostproc clean
180 $(MAKE) -C tests clean
181 $(MAKE) -C vhook clean
182 rm -f *.o *.d *~ .libs gmon.out TAGS \
183 $(PROG) $(PROG_G) $(PROGTEST) $(QTFASTSTART)
184
185 # Note well: config.log is NOT removed.
186 distclean: clean
187 $(MAKE) -C libavutil distclean
188 $(MAKE) -C libavcodec distclean
189 $(MAKE) -C libavformat distclean
190 $(MAKE) -C libavcodec/libpostproc distclean
191 $(MAKE) -C tests distclean
192 $(MAKE) -C vhook distclean
193 rm -f .depend config.mak config.h *.pc
194
195 TAGS:
196 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
197
198 # regression tests
199
200 libavtest test mpeg4 mpeg test-server fulltest: $(PROG)
201 $(MAKE) -C tests $@
202
203 # tar release (use 'make -k tar' on a checkouted tree)
204 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
205 cut -d "\"" -f 2 )
206
207 tar:
208 rm -rf /tmp/$(FILE)
209 cp -r . /tmp/$(FILE)
210 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
211 rm -rf /tmp/$(FILE)
212
213 .PHONY: lib
214
215 ifneq ($(wildcard .depend),)
216 include .depend
217 endif