]> git.sesse.net Git - vlc/blob - modules/common.am
Makefile factorization
[vlc] / modules / common.am
1 # Common code for VLC modules/.../Makefile.am
2 #
3 # Copyright (C) 2005-2007 the VideoLAN team
4 # Copyright (C) 2005-2008 RĂ©mi Denis-Courmont
5 #
6 # Authors: Sam Hocevar <sam@zoy.org>
7
8 NULL =
9 SUFFIXES = _plugin$(LIBEXT) _plugin.la
10
11 libvlcdir = $(libdir)/vlc/$(basedir)
12 libvlc_LTLIBRARIES =
13 EXTRA_DIST = Modules.am
14 BUILT_SOURCES =
15 CLEANFILES =
16
17 include $(srcdir)/Modules.am
18
19 if HAVE_PLUGINS
20 LTLIBVLC = $(top_builddir)/src/libvlc.la
21
22 AM_CFLAGS = `$(VLC_CONFIG) --cflags plugin $@`
23 AM_CXXFLAGS = `$(VLC_CONFIG) --cxxflags plugin $@`
24 AM_OBJCFLAGS = `$(VLC_CONFIG) --objcflags plugin $@`
25 AM_LDFLAGS = -rpath '$(libvlcdir)' \
26         -avoid-version -module -no-undefined \
27         -shrext $(LIBEXT) \
28          `$(VLC_CONFIG) --ldflags plugin $@`
29 AM_LIBADD = $(LTLIBVLC)
30
31 if HAVE_COMPILER_EXPORT
32 AM_LDFLAGS += -export-dynamic
33 else
34 AM_LDFLAGS += -export-symbol-regex ^vlc_entry
35 endif
36 endif
37
38 all: all-modules
39
40 nice:
41         $(top_builddir)/compile
42
43 # Find out which modules were enabled and tell make to build them
44 all-modules:
45         @set fnord $$MAKEFLAGS; amf=$$2; targets=`\
46         z=$$($(VLC_CONFIG) --list plugin); for mod in $(mods); do case "$$z " in *\ $${mod}\ *) echo lib$${mod}_plugin.la;; esac; done; \
47         `; case "$$targets" in *lib*) $(MAKE) $(AM_MAKEFLAGS) $$targets || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; ;; esac; \
48         test -z "$$fail"
49
50 # Build a plugin with the adequate linker and linker's flags
51 _plugin.la_plugin$(LIBEXT):
52         @mod="$*" ; mod=$${mod#lib} ; \
53         ldfl="`$(VLC_CONFIG) --libs plugin $$mod` $(LIBVLC) -u $(SYMPREF)$(VLC_ENTRY)" ; \
54         case `$(VLC_CONFIG) --linkage $$mod` in \
55           c++)  ld="$(CXXLINK)" ;; \
56           objc) ld="$(OBJCLINK)" ;; \
57           c|*)  ld="$(LINK)" ;; \
58         esac ; \
59         echo $$ld $< $$ldfl ; \
60         $$ld $< $$ldfl
61
62 if MAINTAINER_MODE
63 $(srcdir)/Makefile.am: $(srcdir)/Modules.am $(top_srcdir)/modules/genmf
64         cd \$(top_srcdir) && \$(SHELL) modules/genmf ${dir}
65 endif
66
67 mostlyclean-local:
68         -rm -f -- *.la
69
70 ### automake creates libvlcdir after running install-*-local
71 ### so we have to create it ourselves first
72 install-exec-local: all-modules
73         @if test -z "$(libvlc_LTLIBRARIES)"; then \
74           z=$$($(VLC_CONFIG) --list plugin); \
75           m=`for mod in $(mods); do case "$$z " in *\ $${mod}\ *) printf " lib$${mod}_plugin.la" ;; esac; done` ; \
76           test -z "$$m" || \
77             $(MAKE) $(AM_MAKEFLAGS) libvlc_LTLIBRARIES="$$m" install-libvlcLTLIBRARIES || exit $$? ; \
78         fi
79
80 uninstall-local:
81         @if test -z "$(libvlc_LTLIBRARIES)"; then \
82           z=$$($(VLC_CONFIG) --list plugin); \
83           m=`for mod in $(mods); do case "$$z " in *\ $${mod}\ *) printf " lib$${mod}_plugin.la" ;; esac; done` ; \
84           test -z "$$m" || \
85             $(MAKE) $(AM_MAKEFLAGS) libvlc_LTLIBRARIES="$$m" uninstall-libvlcLTLIBRARIES || exit $$?; \
86         fi
87