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