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