]> git.sesse.net Git - vlc/blob - mozilla/Makefile.am
62d4fe6a1824163fcdb7886b608735b0a0414919
[vlc] / mozilla / Makefile.am
1 ###############################################################################
2 # Building the Mozilla plugin
3 ###############################################################################
4
5 noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
6
7 MOSTLYCLEANFILES = $(npvlc_DATA) $(vlcintf_xpt_DATA)
8 CLEANFILES = stamp-pic $(BUILT_SOURCES)
9 EXTRA_DIST = $(DIST_sources) vlcintf.idl npvlc_rc.rc vlc.r
10
11 SOURCES_mozilla_common = \
12         vlcshell.cpp \
13         vlcplugin.cpp \
14         vlcplugin.h \
15         vlcpeer.cpp \
16         vlcpeer.h \
17         vlcruntime.cpp \
18         vlcruntime.h \
19         support/classinfo.h
20
21 DIST_sources = $(SOURCES_mozilla_common) \
22         support/npwin.cpp support/npmac.cpp support/npunix.c
23
24 if BUILD_SHARED
25 LIBRARIES_libvlc_pic = -Wl,-rpath '$(libdir)' -L$(top_builddir)/src -lvlc
26 LIBRARIES_libvlc_nopic = $(LIBRARIES_libvlc_pic)
27 else
28 LIBRARIES_libvlc_pic = $(top_builddir)/src/libvlc_pic.a
29 LIBRARIES_libvlc_nopic = $(top_builddir)/src/libvlc.a
30 endif
31
32 if BUILD_MOZILLA
33
34 # Under Win32, Mozilla plugins need to be named NP******.DLL, but under Unix
35 # the common naming scheme is lib******plugin.so. Also, we need npwin.cpp
36 # under Win32 and npunix.c under Unix.
37 if HAVE_WIN32
38
39 LIBRARIES_libvlc = $(LIBRARIES_libvlc_nopic)
40 npvlc = npvlc$(LIBEXT)
41 npvlcdir = $(libdir)
42 noinst_DATA = npvlc_rc.$(OBJEXT)
43
44 SOURCES_support = support/npwin.cpp
45 CPPFLAGS_mozilla_EXTRA = -DXP_WIN -DXP_WIN32
46 LDFLAGS_npvlc = -shared -Wl,--kill-at $(LIBRARIES_libvlc)
47
48 DATA_npvlc_rc = $(noinst_npvlc_rc_DATA)
49 noinst_npvlc_rc_DATA = npvlc_rc.$(OBJEXT)
50 noinst_npvlc_rcdir =
51
52 npvlc_rc.$(OBJEXT): npvlc_rc.rc
53         $(WINDRES) -DVERSION=$(VERSION) \
54                 -DVERSION_NUMBER=`echo $(VERSION).0.0.0 | sed 's/\([0-9]*\)[^.]*\.*\([0-9]*\)[^.]*\.*\([0-9]*\)[^.]*\.*\([0-9]*\).*/\1,\2,\3,\4/'` \
55                 --include-dir $(srcdir) -i $< -o $@
56
57 else
58 if HAVE_DARWIN
59
60 LIBRARIES_libvlc = $(LIBRARIES_libvlc_nopic)
61 npvlc = npvlc$(LIBEXT)
62 npvlcdir = $(libdir)
63 noinst_DATA = npvlc.rsrc VLC\ Plugin.plugin
64 MOSTLYCLEANFILES += npvlc.rsrc
65 CLEANFILES += VLC\ Plugin.plugin
66
67 SOURCES_support = support/npmac.cpp
68 CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \
69         -F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \
70         -I/Developer/Headers/FlatCarbon -fno-common -fpascal-strings \
71         -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 \
72         -DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0 \
73         -include mozilla-config.h
74 LDFLAGS_npvlc = -bundle -read_only_relocs suppress \
75         $(LIBRARIES_libvlc) -dylib -headerpad_max_install_names 
76
77 npvlc.rsrc: $(srcdir)/vlc.r
78         /Developer/Tools/Rez -useDF /Developer/Headers/FlatCarbon/Types.r $< -o $@
79
80 #
81 # Plugin uses shared libraries that are located relatively through @executable_path,
82 # which unfortunately references the path of the App using the Plugin, rather than the
83 # Plugin itself. Since this Plugin should always be installed in '/Library/Internet Plug-Ins',
84 # it is safer to force dylibs to locate dependants through a fixed path
85 #
86 define FIXEXECPATH
87         otool -L "$$dylib" | \
88         awk -v libdylib="$$dylib" ' \
89         /@executable_path/ { \
90             newpath=$$1 ; \
91             sub("@executable_path","/Library/Internet Plug-Ins/VLC Plugin.plugin/Contents/MacOS",newpath) ; \
92             print "install_name_tool -change \""$$1"\" \""newpath"\" \""libdylib"\"" ; \
93         }' | sh -x
94 endef
95
96 VLC\ Plugin.plugin: npvlc.rsrc npvlc.dylib
97         rm -Rf "$@"
98         $(INSTALL) -d "./$@/Contents/MacOS"
99         $(INSTALL) npvlc.dylib "./$@/Contents/MacOS/VLC Plugin"
100         dylib="./$@/Contents/MacOS/VLC Plugin"; $(FIXEXECPATH) ;
101         $(INSTALL) -d "./$@/Contents/Resources"
102         $(INSTALL) npvlc.rsrc "./$@/Contents/Resources/VLC Plugin.rsrc"
103         cp -r "$(top_srcdir)/extras/MacOSX/plugin/English.lproj" "./$@/Contents/Resources/"
104         $(INSTALL) "$(top_srcdir)/extras/MacOSX/plugin/Info.plist" "./$@/Contents/Info.plist"
105         $(INSTALL) -d "./$@/Contents/MacOS/modules"
106         for i in "" `$(VLC_CONFIG) --target plugin` ; do \
107           if test -n "$$i" ; then \
108             dylib="./$@/Contents/MacOS/modules/`basename $$i$(LIBEXT)`"; \
109             $(INSTALL) "$$i$(LIBEXT)" "$$dylib"; \
110             $(FIXEXECPATH) ; \
111           fi ; \
112         done
113         if test -d $(top_srcdir)/extras/contrib/vlc-lib; then \
114           $(INSTALL) -d "./$@/Contents/MacOS/lib"; \
115           for i in $(top_srcdir)/extras/contrib/vlc-lib/*.dylib ; do \
116             dylib="./$@/Contents/MacOS/lib/`basename $${i}`" ; \
117             $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
118             $(FIXEXECPATH); \
119           done ; \
120         fi
121 # uncomment if dependencies on XPCOM libs is sought
122 #       if test -d "$(MOZILLA_SDK_PATH)/lib"; then \
123 #         for i in "$(MOZILLA_SDK_PATH)"/lib/*.dylib ; do \
124 #           dylib="./$@/Contents/MacOS/`basename $${i}`" ; \
125 #           $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
126 #           $(FIXEXECPATH); \
127 #         done ; \
128 #       fi
129
130 else
131
132 LIBRARIES_libvlc = $(LIBRARIES_libvlc_pic)
133 npvlc = libvlcplugin$(LIBEXT)
134 npvlcdir = $(libdir)/mozilla/plugins
135 SOURCES_support = support/npunix.c
136 noinst_DATA =
137
138 LDFLAGS_npvlc = -shared $(LIBRARIES_libvlc)
139 endif
140 endif
141
142 noinst_LIBRARIES_mozilla = libnpvlc.a
143
144 $(SOURCES_mozilla): vlcintf.h
145
146 BUILT_SOURCES = vlcintf.h
147 vlcintf_xpt_DATA = vlcintf.xpt
148
149 if USE_LIBTOOL
150 # FIXME: name is incorrect on Win32 & Darwin
151 npvlc_LTLIBRARIES = libvlcplugin.la
152 else
153 npvlc_DATA = $(npvlc)
154 EXTRA_LIBRARIES = libnpvlc.a
155 endif
156 endif
157
158 libvlcplugin_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
159 libvlcplugin_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla`
160 libvlcplugin_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla`
161 libvlcplugin_la_LDFLAGS = `$(VLC_CONFIG) --libs mozilla` -module -avoid-version -shrext $(LIBEXT)
162 libvlcplugin_la_LIBADD = ../src/libvlc.la
163
164 libnpvlc_a_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
165 libnpvlc_a_CFLAGS = `$(VLC_CONFIG) --cflags mozilla $(pic)` \
166                      $(CPPFLAGS_mozilla_EXTRA)
167 libnpvlc_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla $(pic)` \
168                        $(CPPFLAGS_mozilla_EXTRA)
169 LDFLAGS_libnpvlc = $(LDFLAGS_npvlc) `$(VLC_CONFIG) --libs mozilla vlc builtin $(pic)`
170 libnpvlc_a_DEPENDENCIES = $(DATA_npvlc_rc)
171
172 $(npvlc): $(libnpvlc_a_OBJECTS) $(libnpvlc_a_DEPENDENCIES) stamp-pic
173         $(CXXLINK) $(libnpvlc_a_OBJECTS) $(DATA_npvlc_rc) \
174          $(LDFLAGS_libnpvlc)
175 # Cygwin work-around
176         @if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi
177
178 vlcintf_xptdir = $(libdir)/mozilla/components
179 vlcintf.xpt: vlcintf.idl
180         $(XPIDL) $(XPIDL_INCL) \
181           -m typelib -o vlcintf $(srcdir)/vlcintf.idl
182
183 vlcintf.h: vlcintf.idl
184         $(XPIDL) $(XPIDL_INCL) \
185           -m header -o vlcintf $(srcdir)/vlcintf.idl
186
187 ###############################################################################
188 # Stamp rules
189 ###############################################################################
190 stamp-pic:
191         @for dep in "" `$(VLC_CONFIG) --target builtin $(pic)`; do \
192           if test "$${dep}" -nt "$(LIBRARIES_mozilla)"; then \
193             rm -f $@; \
194             break; \
195           fi; \
196         done
197         @if test ! -f $@; then printf "" > $@; fi
198
199 ###############################################################################
200 # Force rule
201 ###############################################################################
202 .PHONY: stamp-pic