- Moving -Wall from the individual Makefiles to configure (and only
[libav.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000, 2001, 2002 Fabrice Bellard
4 #
5 include config.mak
6
7 VPATH=$(SRC_PATH)
8
9 CFLAGS=$(OPTFLAGS) -I. -I$(SRC_PATH) -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 PROG=ffmpeg$(EXESUF)
18 PROGTEST=output_example$(EXESUF)
19
20 ifeq ($(CONFIG_FFSERVER),yes)
21 PROG+=ffserver$(EXESUF)
22 endif
23
24 ifeq ($(CONFIG_FFPLAY),yes)
25 PROG+=ffplay$(EXESUF)
26 endif
27
28 ifeq ($(CONFIG_AUDIO_BEOS),yes)
29 EXTRALIBS+=-lmedia -lbe
30 endif
31
32 ifeq ($(BUILD_SHARED),yes)
33 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF)
34 else
35 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF)
36 ifeq ($(CONFIG_MP3LAME),yes)
37 EXTRALIBS+=-lmp3lame
38 endif
39 endif
40
41 ifeq ($(CONFIG_VORBIS),yes)
42 EXTRALIBS+=-logg -lvorbis -lvorbisenc
43 endif
44
45 ifeq ($(CONFIG_FAAD),yes)
46 ifeq ($(CONFIG_FAADBIN),yes)
47 # no libs needed
48 else
49 EXTRALIBS += -lfaad
50 endif
51 endif
52
53 ifeq ($(CONFIG_FAAC),yes)
54 EXTRALIBS+=-lfaac
55 endif
56
57 ifeq ($(BUILD_VHOOK),yes)
58 VHOOK=videohook
59 INSTALLVHOOK=install-vhook
60 CLEANVHOOK=clean-vhook
61 endif
62
63 ifeq ($(TARGET_OS), SunOS)
64 TEST=/usr/bin/test
65 else
66 TEST=test
67 endif
68
69 OBJS = ffmpeg.o ffserver.o cmdutils.o ffplay.o
70 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
71 FFLIBS = -L./libavformat -lavformat -L./libavcodec -lavcodec
72
73 all: lib $(PROG) $(PROGTEST) $(VHOOK)
74
75 lib:
76 $(MAKE) -C libavcodec all
77 $(MAKE) -C libavformat all
78
79 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
80 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(FFLIBS) $(EXTRALIBS)
81
82 ffmpeg$(EXESUF): ffmpeg_g$(EXESUF)
83 cp -p $< $@
84 $(STRIP) $@
85
86 ffserver$(EXESUF): ffserver.o .libs
87 $(CC) $(LDFLAGS) $(FFSLDFLAGS) -o $@ ffserver.o $(FFLIBS) $(EXTRALIBS)
88
89 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
90 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(FFLIBS) $(EXTRALIBS) $(SDL_LIBS)
91
92 ffplay$(EXESUF): ffplay_g$(EXESUF)
93 cp -p $< $@
94 $(STRIP) $@
95
96 output_example$(EXESUF): output_example.o .libs
97 $(CC) $(LDFLAGS) -o $@ output_example.o $(FFLIBS) $(EXTRALIBS)
98
99 ffplay.o: ffplay.c
100 $(CC) $(CFLAGS) $(SDL_CFLAGS) -c -o $@ $<
101
102 %.o: %.c
103 $(CC) $(CFLAGS) -c -o $@ $<
104
105 videohook: .libs
106 $(MAKE) -C vhook all
107
108 .PHONY: install
109
110 install: all install-man $(INSTALLVHOOK)
111 $(MAKE) -C libavcodec install
112 $(MAKE) -C libavformat install
113 install -d "$(bindir)"
114 install -c -s -m 755 $(PROG) "$(bindir)"
115
116 # create the window installer
117 wininstaller: all install
118 makensis ffinstall.nsi
119
120 # install man from source dir if available
121 install-man:
122 ifneq ($(CONFIG_WIN32),yes)
123 if [ -f $(SRC_PATH)/doc/ffmpeg.1 ] ; then \
124 install -d $(mandir)/man1 ; \
125 install -m 644 $(SRC_PATH)/doc/ffmpeg.1 $(SRC_PATH)/doc/ffplay.1 \
126 $(SRC_PATH)/doc/ffserver.1 $(mandir)/man1 ; \
127 fi
128 endif
129
130 install-vhook: $(prefix)/lib/vhook
131 $(MAKE) -C vhook install INSTDIR=$(prefix)/lib/vhook
132
133 $(prefix)/lib/vhook:
134 install -d $@
135
136 installlib:
137 $(MAKE) -C libavcodec installlib
138 $(MAKE) -C libavformat installlib
139
140 dep: depend
141
142 depend: .depend
143 make -C libavcodec depend
144 make -C libavformat depend
145 ifeq ($(BUILD_VHOOK),yes)
146 make -C vhook depend
147 endif
148
149 .depend: $(SRCS)
150 $(CC) -MM $(CFLAGS) $^ 1>.depend
151
152 .libs: lib
153 @test -f .libs || touch .libs
154 @for i in $(DEP_LIBS) ; do if $(TEST) $$i -nt .libs ; then touch .libs; fi ; done
155
156 clean: $(CLEANVHOOK)
157 $(MAKE) -C libavcodec clean
158 $(MAKE) -C libavformat clean
159 $(MAKE) -C tests clean
160 rm -f *.o *.d *~ .libs .depend gmon.out TAGS ffmpeg_g$(EXESUF) ffplay_g$(EXESUF) $(PROG) $(PROGTEST)
161
162 clean-vhook:
163 $(MAKE) -C vhook clean
164
165 distclean: clean
166 $(MAKE) -C libavcodec distclean
167 rm -f config.mak config.h
168
169 TAGS:
170 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
171
172 # regression tests
173
174 libavtest test mpeg4 mpeg test-server fulltest: ffmpeg$(EXESUF)
175 $(MAKE) -C tests $@
176
177 # tar release (use 'make -k tar' on a checkouted tree)
178 FILE=ffmpeg-$(shell grep "\#define FFMPEG_VERSION " libavcodec/avcodec.h | \
179 cut -d "\"" -f 2 )
180
181 tar:
182 rm -rf /tmp/$(FILE)
183 cp -r . /tmp/$(FILE)
184 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
185 rm -rf /tmp/$(FILE)
186
187 .PHONY: lib
188
189 ifneq ($(wildcard .depend),)
190 include .depend
191 endif