simplification
[mplayer.git] / Makefile
blob63b7d130185312d9d064fff380b1a68f2c585809
1 # LINUX Makefile made by A'rpi / Astral
2 # Some cleanup by LGB: * 'make -C dir' instead of 'cd dir;make;cd..'
3 # * for loops instead of linear sequence of make directories
4 # * some minor problems with make clean and distclean were corrected
5 # * DVD support
7 include config.mak
9 PRG_CFG = codec-cfg
11 LIBAV_INC =
12 ifeq ($(CONFIG_LIBAVUTIL),yes)
13 LIBAV_INC += -I./libavutil
14 endif
15 ifeq ($(CONFIG_LIBAVCODEC),yes)
16 LIBAV_INC += -I./libavcodec
17 endif
19 # Do not strip the binaries at installation
20 ifeq ($(STRIPBINARIES),yes)
21 INSTALLSTRIP = -s
22 endif
24 # These subdirectories require installation due to binaries within them.
25 ifeq ($(VIDIX),yes)
26 SUBDIRS += libdha vidix
27 DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
28 endif
30 SRCS_COMMON = asxparser.c \
31 codec-cfg.c \
32 cpudetect.c \
33 edl.c \
34 find_sub.c \
35 m_config.c \
36 m_option.c \
37 m_struct.c \
38 parser-cfg.c \
39 playtree.c \
40 playtreeparser.c \
41 spudec.c \
42 sub_cc.c \
43 subreader.c \
44 vobsub.c \
46 SRCS_MENCODER = mencoder.c \
47 mp_msg-mencoder.c \
48 $(SRCS_COMMON) \
49 divx4_vbr.c \
50 libvo/aclib.c \
51 libvo/font_load.c \
52 libvo/font_load_ft.c \
53 libvo/osd.c \
54 libvo/sub.c \
55 parser-mecmd.c \
56 xvid_vbr.c \
58 SRCS_MPLAYER = mplayer.c \
59 mp_msg.c \
60 $(SRCS_COMMON) \
61 mixer.c \
62 parser-mpcmd.c \
63 subopt-helper.c \
65 ifeq ($(UNRARLIB),yes)
66 SRCS_COMMON += unrarlib.c
67 endif
69 OBJS_MENCODER = $(SRCS_MENCODER:.c=.o)
70 OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o)
72 VO_LIBS = $(AA_LIB) \
73 $(X_LIB) \
74 $(SDL_LIB) \
75 $(GGI_LIB) \
76 $(MP1E_LIB) \
77 $(MLIB_LIB) \
78 $(SVGA_LIB) \
79 $(DIRECTFB_LIB) \
80 $(CACA_LIB) \
81 $(VESA_LIB) \
83 AO_LIBS = $(ARTS_LIB) \
84 $(ESD_LIB) \
85 $(JACK_LIB) \
86 $(NAS_LIB) \
87 $(SGIAUDIO_LIB) \
88 $(POLYP_LIB) \
90 CODEC_LIBS = $(AV_LIB) \
91 $(FAME_LIB) \
92 $(MAD_LIB) \
93 $(VORBIS_LIB) \
94 $(THEORA_LIB) \
95 $(FAAD_LIB) \
96 $(LIBLZO_LIB) \
97 $(DECORE_LIB) \
98 $(XVID_LIB) \
99 $(DTS_LIB) \
100 $(PNG_LIB) \
101 $(Z_LIB) \
102 $(JPEG_LIB) \
103 $(ALSA_LIB) \
104 $(XMMS_LIB) \
105 $(X264_LIB) \
106 $(MUSEPACK_LIB) \
108 COMMON_LIBS = libmpcodecs/libmpcodecs.a \
109 $(W32_LIB) \
110 $(DS_LIB) \
111 libaf/libaf.a \
112 libmpdemux/libmpdemux.a \
113 input/libinput.a \
114 postproc/libswscale.a \
115 osdep/libosdep.a \
116 $(DVDREAD_LIB) \
117 $(CODEC_LIBS) \
118 $(FREETYPE_LIB) \
119 $(TERMCAP_LIB) \
120 $(CDPARANOIA_LIB) \
121 $(MPLAYER_NETWORK_LIB) \
122 $(WIN32_LIB) \
123 $(GIF_LIB) \
124 $(MACOSX_FRAMEWORKS) \
125 $(SMBSUPPORT_LIB) \
126 $(FRIBIDI_LIB) \
127 $(FONTCONFIG_LIB) \
128 $(ENCA_LIB) \
130 CFLAGS = $(OPTFLAGS) -I. \
131 $(CACA_INC) \
132 $(CDPARANOIA_INC) \
133 $(DVB_INC) \
134 $(EXTRA_INC) \
135 $(FONTCONFIG_INC) \
136 $(FREETYPE_INC) \
137 $(FRIBIDI_INC) \
138 $(SDL_INC) \
139 $(X11_INC) \
140 $(XVID_INC) \
141 $(LIBAV_INC) \
143 #CFLAGS += -Wall
145 ifeq ($(TOOLAME),yes)
146 CFLAGS += $(TOOLAME_EXTRAFLAGS)
147 CODEC_LIBS += $(TOOLAME_LIB)
148 endif
150 ifeq ($(TWOLAME),yes)
151 CODEC_LIBS += $(TWOLAME_LIB)
152 endif
154 ifeq ($(FAAC),yes)
155 CODEC_LIBS += $(FAAC_LIB)
156 endif
158 PARTS = libmpdemux \
159 libmpcodecs \
160 libavutil \
161 libavcodec \
162 libavformat \
163 libao2 \
164 osdep \
165 postproc \
166 input \
167 libvo \
168 libaf \
170 ifeq ($(MP3LIB),yes)
171 PARTS += mp3lib
172 endif
173 ifeq ($(LIBA52),yes)
174 PARTS += liba52
175 endif
176 ifeq ($(LIBMPEG2),yes)
177 PARTS += libmpeg2
178 endif
179 ifeq ($(INTERNAL_FAAD),yes)
180 COMMON_LIBS += libfaad2/libfaad2.a
181 PARTS += libfaad2
182 endif
183 ifeq ($(VIDIX),yes)
184 PARTS += libdha vidix
185 endif
186 ifeq ($(FAME),yes)
187 PARTS += libfame
188 endif
189 ifeq ($(DVDKIT2),yes)
190 PARTS += libmpdvdkit2
191 else
192 ifeq ($(DVDKIT),yes)
193 PARTS += libmpdvdkit
194 endif
195 endif
196 ifeq ($(GUI),yes)
197 PARTS += Gui
198 endif
199 ifneq ($(W32_LIB),)
200 PARTS += loader loader/dshow loader/dmo
201 endif
202 ifeq ($(LIBMENU),yes)
203 PARTS += libmenu
204 endif
205 ifeq ($(TREMOR),yes)
206 PARTS += tremor
207 endif
209 ALL_PRG = $(PRG)
210 ifeq ($(MENCODER),yes)
211 ALL_PRG += $(PRG_MENCODER)
212 endif
214 COMMON_DEPS = $(W32_DEP) \
215 $(DS_DEP) \
216 $(MP1E_DEP) \
217 $(AV_DEP) \
218 libmpdemux/libmpdemux.a \
219 libmpcodecs/libmpcodecs.a \
220 libao2/libao2.a \
221 osdep/libosdep.a \
222 postproc/libswscale.a \
223 input/libinput.a \
224 libvo/libvo.a \
225 libaf/libaf.a \
227 ifeq ($(MP3LIB),yes)
228 COMMON_DEPS += mp3lib/libMP3.a
229 COMMON_LIBS += mp3lib/libMP3.a
230 endif
231 ifeq ($(LIBA52),yes)
232 COMMON_DEPS += liba52/liba52.a
233 COMMON_LIBS += liba52/liba52.a
234 endif
235 ifeq ($(LIBMPEG2),yes)
236 COMMON_DEPS += libmpeg2/libmpeg2.a
237 COMMON_LIBS += libmpeg2/libmpeg2.a
238 endif
239 ifeq ($(INTERNAL_FAAD),yes)
240 COMMON_DEPS += libfaad2/libfaad2.a
241 endif
242 ifeq ($(TREMOR),yes)
243 COMMON_DEPS += tremor/libvorbisidec.a
244 COMMON_LIBS += tremor/libvorbisidec.a
245 endif
246 ifeq ($(VIDIX),yes)
247 COMMON_DEPS += libdha/libdha.so vidix/libvidix.a
248 endif
249 ifeq ($(FAME),yes)
250 COMMON_DEPS += libfame/libfame.a
251 endif
252 ifeq ($(DVDKIT2),yes)
253 ifeq ($(DVDKIT_SHARED),yes)
254 COMMON_DEPS += libmpdvdkit2/libmpdvdkit.so
255 else
256 COMMON_DEPS += libmpdvdkit2/libmpdvdkit.a
257 endif
258 endif
260 ifeq ($(GUI),yes)
261 COMMON_DEPS += Gui/libgui.a
262 GUI_LIBS = Gui/libgui.a
263 endif
265 .SUFFIXES: .cc .c .o
267 #.PHONY: $(COMMON_DEPS)
269 all: version.h $(ALL_PRG)
271 .c.o:
272 $(CC) -c $(CFLAGS) -o $@ $<
274 libaf/libaf.a:
275 $(MAKE) -C libaf
277 libmpdvdkit2/libmpdvdkit.a:
278 $(MAKE) -C libmpdvdkit2
280 libmpdvdkit2/libmpdvdkit.so:
281 $(MAKE) -C libmpdvdkit2 libmpdvdkit.so
283 loader/libloader.a:
284 $(MAKE) -C loader
286 libfame/libfame.a:
287 $(MAKE) -C libfame
289 libmpdemux/libmpdemux.a:
290 $(MAKE) -C libmpdemux
292 libmpcodecs/libmpcodecs.a:
293 $(MAKE) -C libmpcodecs
295 loader/dshow/libDS_Filter.a:
296 $(MAKE) -C loader/dshow
298 loader/dmo/libDMO_Filter.a:
299 $(MAKE) -C loader/dmo
301 libavutil/libavutil.a:
302 $(MAKE) -C libavutil LIBPREF=lib LIBSUF=.a
304 libavcodec/libavcodec.a:
305 $(MAKE) -C libavcodec LIBPREF=lib LIBSUF=.a
307 libavformat/libavformat.a:
308 $(MAKE) -C libavformat LIBPREF=lib LIBSUF=.a
310 libmpeg2/libmpeg2.a:
311 $(MAKE) -C libmpeg2
313 libvo/libvo.a:
314 $(MAKE) -C libvo
316 libao2/libao2.a:
317 $(MAKE) -C libao2
319 liba52/liba52.a:
320 $(MAKE) -C liba52
322 libfaad2/libfaad2.a:
323 $(MAKE) -C libfaad2
325 mp3lib/libMP3.a:
326 $(MAKE) -C mp3lib
328 tremor/libvorbisidec.a:
329 $(MAKE) -C tremor
331 libdha/libdha.so:
332 $(MAKE) -C libdha
334 vidix/libvidix.a:
335 $(MAKE) -C vidix
337 Gui/libgui.a:
338 $(MAKE) -C Gui
340 osdep/libosdep.a:
341 $(MAKE) -C osdep
343 postproc/libswscale.a:
344 $(MAKE) -C postproc
346 input/libinput.a:
347 $(MAKE) -C input
349 libmenu/libmenu.a:
350 $(MAKE) -C libmenu
352 libavcodec/libpostproc/libpostproc.so:
353 $(MAKE) -C libavcodec/libpostproc
355 MPLAYER_DEP = $(OBJS_MPLAYER) $(COMMON_DEPS)
357 ifeq ($(LIBMENU),yes)
358 MPLAYER_DEP += libmenu/libmenu.a
359 MENU_LIBS = libmenu/libmenu.a
360 PARTS += libmenu
361 else
362 MENU_LIBS =
363 endif
365 MENCODER_DEP = $(OBJS_MENCODER) $(COMMON_DEPS) libmpcodecs/libmpencoders.a
367 ifeq ($(VIDIX),yes)
368 VIDIX_LIBS = vidix/libvidix.a
369 else
370 VIDIX_LIBS =
371 endif
373 ifeq ($(TARGET_WIN32),yes)
374 OBJS_MPLAYER += osdep/mplayer-rc.o
375 endif
377 LIBS_MPLAYER = libvo/libvo.a \
378 libao2/libao2.a \
379 $(MENU_LIBS) \
380 $(VIDIX_LIBS) \
381 $(GUI_LIBS) \
382 $(COMMON_LIBS) \
383 $(GTK_LIBS) \
384 $(VO_LIBS) \
385 $(AO_LIBS) \
386 $(EXTRA_LIB)\
387 $(LIRC_LIB) \
388 $(LIRCC_LIB) \
389 $(STATIC_LIB) \
390 $(ARCH_LIB) \
391 $(I18NLIBS) \
392 $(MATH_LIB) \
394 $(PRG): $(MPLAYER_DEP)
395 ifeq ($(TARGET_WIN32),yes)
396 windres -o osdep/mplayer-rc.o osdep/mplayer.rc
397 endif
398 $(CC) $(CFLAGS) -o $(PRG) $(OBJS_MPLAYER) $(LIBS_MPLAYER)
400 mplayer.exe.spec.c: libmpcodecs/libmpcodecs.a
401 winebuild -fPIC -o mplayer.exe.spec.c -exe mplayer.exe -mcui \
402 libmpcodecs/ad_qtaudio.o libmpcodecs/vd_qtvideo.o \
403 -L/usr/local/lib/wine -lkernel32
405 mplayer.exe.so: $(MPLAYER_DEP) mplayer.exe.spec.c
406 $(CC) $(CFLAGS) -Wall -shared -Wl,-rpath,/usr/local/lib -Wl,-Bsymbolic -o mplayer.exe.so $(OBJS_MPLAYER) mplayer.exe.spec.c libvo/libvo.a libao2/libao2.a $(MENU_LIBS) $(VIDIX_LIBS) $(GUI_LIBS) $(COMMON_LIBS) $(GTK_LIBS) $(VO_LIBS) $(AO_LIBS) $(EXTRA_LIB) $(LIRC_LIB) $(LIRCC_LIB) $(STATIC_LIB) $(ARCH_LIB) -lwine $(MATH_LIB)
408 mplayer_wine.so: $(MPLAYER_DEP)
409 $(CC) $(CFLAGS) -shared -Wl,-Bsymbolic -o mplayer_wine.so mplayer_wine.spec.c $(OBJS_MPLAYER) libvo/libvo.a libao2/libao2.a $(MENU_LIBS) $(VIDIX_LIBS) $(GUI_LIBS) $(COMMON_LIBS) $(GTK_LIBS) $(VO_LIBS) $(AO_LIBS) $(EXTRA_LIB) $(LIRC_LIB) $(LIRCC_LIB) $(STATIC_LIB) -lwine $(ARCH_LIB) $(MATH_LIB)
411 ifeq ($(MENCODER),yes)
412 LIBS_MENCODER = libmpcodecs/libmpencoders.a \
413 $(ENCORE_LIB) \
414 $(COMMON_LIBS) \
415 $(EXTRA_LIB) \
416 $(MLIB_LIB) \
417 $(LIRC_LIB) \
418 $(LIRCC_LIB) \
419 $(ARCH_LIB) \
420 $(I18NLIBS) \
421 $(MATH_LIB) \
423 $(PRG_MENCODER): $(MENCODER_DEP)
424 $(CC) $(CFLAGS) -o $(PRG_MENCODER) $(OBJS_MENCODER) $(LIBS_MENCODER)
425 endif
427 codecs.conf.h: $(PRG_CFG) etc/codecs.conf
428 ./$(PRG_CFG) ./etc/codecs.conf > $@
430 codec-cfg.o: codecs.conf.h
432 # Every mplayer dependency depends on version.h, to force building version.h
433 # first (in serial mode) before any other of the dependencies for a parallel make
434 # run. This is necessary, because the make rule for version.h removes objects
435 # in a recursive "make distclean" and we must wait for this "make distclean" to
436 # finish before we can start building new object files.
437 # help_mp.h is also required by a lot of files, so force generating it early.
438 $(MPLAYER_DEP): version.h help_mp.h
439 $(MENCODER_DEP): version.h help_mp.h
441 $(PRG_CFG): version.h codec-cfg.c codec-cfg.h
442 $(HOST_CC) $(HOST_CFLAGS) -I. -g codec-cfg.c mp_msg.c -o $(PRG_CFG) -DCODECS2HTML $(EXTRA_LIB) $(EXTRA_INC) $(I18NLIBS)
444 install: $(ALL_PRG)
445 ifeq ($(VIDIX),yes)
446 $(DO_MAKE)
447 endif
448 if test ! -d $(BINDIR) ; then mkdir -p $(BINDIR) ; fi
449 $(INSTALL) -m 755 $(INSTALLSTRIP) $(PRG) $(BINDIR)/$(PRG)
450 ifeq ($(GUI),yes)
451 -ln -sf $(PRG) $(BINDIR)/gmplayer
452 endif
453 if test ! -d $(MANDIR)/man1 ; then mkdir -p $(MANDIR)/man1; fi
454 for i in $(MAN_LANG); do \
455 if test "$$i" = en ; then \
456 $(INSTALL) -c -m 644 DOCS/man/en/mplayer.1 $(MANDIR)/man1/mplayer.1 ; \
457 else \
458 mkdir -p $(MANDIR)/$$i/man1 ; \
459 $(INSTALL) -c -m 644 DOCS/man/$$i/mplayer.1 $(MANDIR)/$$i/man1/mplayer.1 ; \
460 fi ; \
461 done
462 ifeq ($(MENCODER),yes)
463 $(INSTALL) -m 755 $(INSTALLSTRIP) $(PRG_MENCODER) $(BINDIR)/$(PRG_MENCODER)
464 for i in $(MAN_LANG); do \
465 if test "$$i" = en ; then \
466 ln -sf mplayer.1 $(MANDIR)/man1/mencoder.1 ; \
467 else \
468 ln -sf mplayer.1 $(MANDIR)/$$i/man1/mencoder.1 ; \
469 fi ; \
470 done
471 endif
472 @if test ! -d $(DATADIR) ; then mkdir -p $(DATADIR) ; fi
473 @if test ! -d $(DATADIR)/font ; then mkdir -p $(DATADIR)/font ; fi
474 @if test ! -f $(DATADIR)/font/font.desc ; then \
475 echo "*** Download font at http://www.mplayerhq.hu/homepage/dload.html" ; \
476 echo "*** for OSD/Subtitles support and extract to $(DATADIR)/font/" ; \
478 ifeq ($(GUI),yes)
479 @if test ! -d $(DATADIR)/Skin ; then mkdir -p $(DATADIR)/Skin ; fi
480 @echo "*** Download skin(s) at http://www.mplayerhq.hu/homepage/dload.html"
481 @echo "*** for GUI, and extract to $(DATADIR)/Skin/"
482 @if test ! -d $(prefix)/share/pixmaps ; then mkdir -p $(prefix)/share/pixmaps ; fi
483 $(INSTALL) -m 644 Gui/mplayer/pixmaps/mplayer-desktop.xpm $(prefix)/share/pixmaps/mplayer-desktop.xpm
484 @if test ! -d $(prefix)/share/applications ; then mkdir -p $(prefix)/share/applications ; fi
485 $(INSTALL) -m 644 etc/mplayer.desktop $(prefix)/share/applications/mplayer.desktop
486 endif
487 @if test ! -d $(CONFDIR) ; then mkdir -p $(CONFDIR) ; fi
488 @if test -f $(CONFDIR)/codecs.conf ; then mv -f $(CONFDIR)/codecs.conf $(CONFDIR)/codecs.conf.old ; fi
489 ifeq ($(DVDKIT_SHARED),yes)
490 ifeq ($(DVDKIT2),yes)
491 if test ! -d $(LIBDIR) ; then mkdir -p $(LIBDIR) ; fi
492 $(INSTALL) -m 755 $(INSTALLSTRIP) libmpdvdkit2/libmpdvdkit.so $(LIBDIR)/libmpdvdkit.so
493 else
494 ifeq ($(DVDKIT),yes)
495 if test ! -d $(LIBDIR) ; then mkdir -p $(LIBDIR) ; fi
496 $(INSTALL) -m 755 $(INSTALLSTRIP) libmpdvdkit/libmpdvdkit.so $(LIBDIR)/libmpdvdkit.so
497 endif
498 endif
499 endif
501 uninstall:
502 -rm -f $(BINDIR)/$(PRG) $(BINDIR)/gmplayer $(MANDIR)/man1/mplayer.1
503 -rm -f $(BINDIR)/$(PRG_MENCODER) $(MANDIR)/man1/mencoder.1
504 -rm -f $(prefix)/share/pixmaps/mplayer-desktop.xpm
505 -rm -f $(prefix)/share/applications/mplayer.desktop
506 -rm -f $(LIBDIR)/libmpdvdkit.so
507 for l in $(MAN_LANG); do \
508 if test "i$$l" != "en"; then \
509 -rm -f $(MANDIR)/$$l/man1/mplayer.1 $(MANDIR)/$$l/man1/mencoder.1 \
510 -rm -f $(MANDIR)/$$l/man1/gmplayer.1 \
511 fi \
512 done
513 ifeq ($(VIDIX),yes)
514 $(DO_MAKE)
515 endif
516 @echo "Uninstall completed"
518 clean:
519 -rm -f *.o *~ $(OBJS) codecs.conf.h
521 distclean: doxygen_clean
522 -rm -f *~ $(PRG) $(PRG_MENCODER) $(PRG_CFG) $(OBJS)
523 -rm -f *.o *.a .depend configure.log codecs.conf.h help_mp.h
524 @for a in $(PARTS); do $(MAKE) -C $$a distclean; done
526 strip:
527 strip -s $(ALL_PRG)
529 dep: depend
531 depend: help_mp.h
532 ./version.sh `$(CC) -dumpversion`
533 $(CC) -MM $(CFLAGS) -DCODECS2HTML mplayer.c mencoder.c $(SRCS_MPLAYER) $(SRCS_MENCODER) 1>.depend
534 @for a in $(PARTS); do $(MAKE) -C $$a dep; done
536 # ./configure must be run if it changed in CVS
537 config.h: configure
538 @echo "############################################################"
539 @echo "####### Please run ./configure again - it's changed! #######"
540 @echo "############################################################"
541 ifeq ($(wildcard .developer),)
542 @exit 1
543 endif
545 # do not rebuild after cvs commits if .developer file is present!
547 # rebuild at every config.h/config.mak change:
548 version.h:
549 ./version.sh `$(CC) -dumpversion`
550 ifeq ($(wildcard .developer),)
551 $(MAKE) distclean
552 endif
553 $(MAKE) depend
555 doxygen:
556 doxygen DOCS/tech/Doxyfile
558 doxygen_clean:
559 -rm -rf DOCS/tech/doxygen
561 help_mp.h: help/help_mp-en.h $(HELP_FILE)
562 @echo '// WARNING! This is a generated file. Do NOT edit.' > help_mp.h
563 @echo '// See the help/ subdir for the editable files.' >> help_mp.h
564 ifeq ($(CHARSET),)
565 @echo '#include "$(HELP_FILE)"' >> help_mp.h
566 else
567 iconv -f `cat $(HELP_FILE).charset` -t $(CHARSET) "$(HELP_FILE)" >> help_mp.h
568 endif
570 ifneq ($(HELP_FILE),help/help_mp-en.h)
571 @echo "Adding untranslated messages to help_mp.h"
572 @echo '// untranslated messages from the English master file:' >> help_mp.h
573 @help/help_diff.sh $(HELP_FILE) < help/help_mp-en.h >> help_mp.h
574 endif
576 # rebuild at every CVS update or config/makefile change:
577 ifeq ($(wildcard .developer),)
578 ifneq ($(wildcard CVS/Entries),)
579 version.h: CVS/Entries
580 endif
581 version.h: config.h config.mak Makefile
582 endif
585 # include dependencies to get make to recurse into lib dirs,
586 # if the user desires such behavior
588 ifneq ($(wildcard .libdeps),)
589 include .libdeps
590 endif
593 # include dependency files if they exist
595 ifneq ($(wildcard .depend),)
596 include .depend
597 endif