simplify [TARGET_]ARCH_* setting
[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 endif
19
20 ifeq ($(CONFIG_FFSERVER),yes)
21 MANPAGES+=doc/ffserver.1
22 PROGS+=ffserver$(EXESUF)
23 endif
24
25 ifeq ($(CONFIG_FFPLAY),yes)
26 MANPAGES+=doc/ffplay.1
27 PROGS_G+=ffplay_g$(EXESUF)
28 PROGS+=ffplay$(EXESUF)
29 endif
30
31 BASENAMES=ffmpeg ffplay ffserver
32 ALLPROGS=$(addsuffix $(EXESUF), $(BASENAMES))
33 ALLPROGS_G=$(addsuffix _g$(EXESUF), $(BASENAMES))
34 ALLMANPAGES=$(addsuffix .1, $(BASENAMES))
35
36 ifeq ($(BUILD_SHARED),yes)
37 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
38 else
39 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
40 endif
41
42 ifeq ($(CONFIG_VHOOK),yes)
43 VHOOK=videohook
44 INSTALLVHOOK=install-vhook
45 endif
46
47 ifeq ($(BUILD_DOC),yes)
48 DOC=documentation
49 INSTALLMAN=install-man
50 endif
51
52 OBJS = ffmpeg.o ffserver.o cmdutils.o ffplay.o
53 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
54 LDFLAGS := -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
55 EXTRALIBS := -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
56
57 ifeq ($(CONFIG_SWSCALER),yes)
58 LDFLAGS+=-L./libswscale
59 EXTRALIBS+=-lswscale$(BUILDSUF)
60 endif
61
62 all: lib $(PROGS_G) $(PROGS) $(VHOOK) $(DOC)
63
64 lib:
65 $(MAKE) -C libavutil all
66 $(MAKE) -C libavcodec all
67 $(MAKE) -C libavformat all
68 ifeq ($(CONFIG_PP),yes)
69 $(MAKE) -C libpostproc all
70 endif
71 ifeq ($(CONFIG_SWSCALER),yes)
72 $(MAKE) -C libswscale all
73 endif
74
75 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
76 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
77
78 ffserver$(EXESUF): ffserver.o .libs
79 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o $(EXTRALIBS)
80
81 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
82 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
83
84 %$(EXESUF): %_g$(EXESUF)
85 cp -p $< $@
86 $(STRIP) $@
87
88 version.h:
89 $(SRC_PATH)/version.sh $(SRC_PATH)
90
91 output_example$(EXESUF): output_example.o .libs
92 $(CC) $(LDFLAGS) -o $@ output_example.o $(EXTRALIBS)
93
94 qt-faststart$(EXESUF): qt-faststart.c
95 $(CC) $(CFLAGS) $< -o $@
96
97 cws2fws$(EXESUF): cws2fws.c
98 $(CC) $< -o $@ -lz
99
100 ffplay.o: ffplay.c
101 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
102
103 ffmpeg.o ffplay.o ffserver.o: version.h
104
105 %.o: %.c
106 $(CC) $(CFLAGS) -c -o $@ $<
107
108 videohook: .libs
109 $(MAKE) -C vhook all
110
111 documentation:
112 $(MAKE) -C doc all
113
114 install: install-progs install-libs install-headers $(INSTALLMAN) $(INSTALLVHOOK)
115
116 ifeq ($(BUILD_SHARED),yes)
117 install-progs: $(PROGS) install-libs
118 else
119 install-progs: $(PROGS)
120 endif
121 install -d "$(bindir)"
122 install -c $(INSTALLSTRIP) -m 755 $(PROGS) "$(bindir)"
123
124 # create the window installer
125 wininstaller: all install
126 makensis ffinstall.nsi
127
128 install-man:
129 install -d "$(mandir)/man1"
130 install -m 644 $(MANPAGES) "$(mandir)/man1"
131
132 install-vhook:
133 $(MAKE) -C vhook install
134
135 install-libs:
136 $(MAKE) -C libavutil install-libs
137 $(MAKE) -C libavcodec install-libs
138 $(MAKE) -C libavformat install-libs
139 ifeq ($(CONFIG_PP),yes)
140 $(MAKE) -C libpostproc install-libs
141 endif
142 ifeq ($(CONFIG_SWSCALER),yes)
143 $(MAKE) -C libswscale install-libs
144 endif
145
146 ifeq ($(BUILD_SHARED),yes)
147 -$(LDCONFIG)
148 endif
149
150 install-headers:
151 $(MAKE) -C libavutil install-headers
152 $(MAKE) -C libavcodec install-headers
153 $(MAKE) -C libavformat install-headers
154 ifeq ($(CONFIG_PP),yes)
155 $(MAKE) -C libpostproc install-headers
156 endif
157 $(MAKE) -C libswscale install-headers
158
159 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
160
161 uninstall-progs:
162 rm -f $(addprefix $(bindir)/, $(ALLPROGS))
163
164 uninstall-man:
165 rm -f $(addprefix $(mandir)/man1/,$(ALLMANPAGES))
166
167 uninstall-vhook:
168 $(MAKE) -C vhook uninstall
169
170 uninstall-libs:
171 $(MAKE) -C libavutil uninstall-libs
172 $(MAKE) -C libavcodec uninstall-libs
173 $(MAKE) -C libavformat uninstall-libs
174 $(MAKE) -C libpostproc uninstall-libs
175
176 uninstall-headers:
177 $(MAKE) -C libavutil uninstall-headers
178 $(MAKE) -C libavcodec uninstall-headers
179 $(MAKE) -C libavformat uninstall-headers
180 $(MAKE) -C libpostproc uninstall-headers
181 -rmdir "$(incdir)"
182 -rmdir "$(prefix)/include/postproc"
183
184 depend dep: .depend
185 $(MAKE) -C libavutil depend
186 $(MAKE) -C libavcodec depend
187 $(MAKE) -C libavformat depend
188 ifeq ($(CONFIG_PP),yes)
189 $(MAKE) -C libpostproc depend
190 endif
191 ifeq ($(CONFIG_SWSCALER),yes)
192 $(MAKE) -C libswscale depend
193 endif
194 ifeq ($(CONFIG_VHOOK),yes)
195 $(MAKE) -C vhook depend
196 endif
197
198 .depend: $(SRCS) version.h
199 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
200
201 .libs: lib
202 @test -f .libs || touch .libs
203 @for i in $(DEP_LIBS) ; do if test $$i -nt .libs ; then touch .libs; fi ; done
204
205 clean:
206 $(MAKE) -C libavutil clean
207 $(MAKE) -C libavcodec clean
208 $(MAKE) -C libavformat clean
209 $(MAKE) -C libpostproc clean
210 $(MAKE) -C libswscale clean
211 $(MAKE) -C tests clean
212 $(MAKE) -C vhook clean
213 $(MAKE) -C doc clean
214 rm -f *.o *.d *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
215 output_example$(EXESUF) qt-faststart$(EXESUF) cws2fws$(EXESUF)
216
217 # Note well: config.log is NOT removed.
218 distclean: clean
219 $(MAKE) -C libavutil distclean
220 $(MAKE) -C libavcodec distclean
221 $(MAKE) -C libavformat distclean
222 $(MAKE) -C libpostproc distclean
223 $(MAKE) -C libswscale distclean
224 $(MAKE) -C tests distclean
225 $(MAKE) -C vhook distclean
226 rm -f .depend version.h config.* *.pc
227
228 TAGS:
229 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
230
231 # regression tests
232
233 codectest libavtest test-server fulltest test mpeg4 mpeg: $(PROGS)
234 $(MAKE) -C tests $@
235
236 .PHONY: all lib videohook documentation install* wininstaller uninstall*
237 .PHONY: dep depend clean distclean TAGS
238 .PHONY: codectest libavtest test-server fulltest test mpeg4 mpeg
239
240 ifneq ($(wildcard .depend),)
241 include .depend
242 endif