19bd43d863c8e8e00baa2b84460213d00ca7f400
[vlc.git] / mozilla / Makefile.am
1 ###############################################################################
2 # Building the Mozilla plugin
3 ###############################################################################
4
5 MOSTLYCLEANFILES = 
6 CLEANFILES = $(BUILT_SOURCES)
7 EXTRA_DIST = $(DIST_sources) install.js npvlc_rc.rc vlc.r
8
9 SOURCES_mozilla_common = \
10         vlcshell.cpp \
11         vlcplugin.cpp \
12         vlcplugin.h \
13         control/npolibvlc.cpp \
14         control/npolibvlc.h \
15         control/npovlc.cpp \
16         control/npovlc.h \
17         control/nporuntime.cpp \
18         control/nporuntime.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_MOZILLA
25
26 LIBRARIES_libvlc = $(top_builddir)/src/libvlc-control.la \
27                                    $(top_builddir)/src/libvlc.la
28
29 if HAVE_WIN32
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 #
35 lib_LTLIBRARIES = npvlc.la
36
37 SOURCES_support = support/npwin.cpp
38 CPPFLAGS_mozilla_EXTRA = -DXP_WIN -DXP_WIN32
39 LDFLAGS_mozilla_EXTRA = -no-undefined -Wl,--kill-at -Wl,$(DATA_npvlc_rc)
40
41 npvlc_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
42 npvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla` $(CPPFLAGS_mozilla_extra)
43 npvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla_extra)
44 npvlc_la_DEPENDENCIES = $(DATA_npvlc_rc) $(LIBRARIES_libvlc)
45 npvlc_la_LDFLAGS = `$(VLC_CONFIG) --libs mozilla` -module -avoid-version \
46                                    $(LDFLAGS_mozilla_EXTRA)
47 npvlc_la_LIBADD = $(LIBRARIES_libvlc)
48
49 DATA_npvlc_rc = $(noinst_npvlc_rc_DATA)
50 noinst_npvlc_rc_DATA = npvlc_rc.$(OBJEXT)
51 noinst_npvlc_rcdir =
52
53 npvlc_rc.$(OBJEXT): npvlc_rc.rc
54         $(WINDRES) -DVERSION=$(VERSION) \
55                 -DVERSION_NUMBER=`echo $(VERSION).0.0.0 | sed 's/\([0-9]*\)[^.]*\.*\([0-9]*\)[^.]*\.*\([0-9]*\)[^.]*\.*\([0-9]*\).*/\1,\2,\3,\4/'` \
56                 --include-dir $(srcdir) -i $< -o $@
57
58 else
59 if HAVE_DARWIN
60
61 #
62 # MacOS X
63 #
64
65 lib_LTLIBRARIES = npvlc.la
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_mozilla_EXTRA = -no-undefined -bundle -Wl,-read_only_relocs -Wl,suppress \
75         -Wl,-headerpad_max_install_names -shrext $(LIBEXT) -Wl,-framework,Carbon -Wl,-framework,System
76
77 npvlc_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
78 npvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla` $(CPPFLAGS_mozilla_EXTRA)
79 npvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla_EXTRA) 
80 npvlc_la_DEPENDENCIES = $(LIBRARIES_libvlc)
81 npvlc_la_LDFLAGS = `$(VLC_CONFIG) --libs mozilla` -module -avoid-version \
82                                    $(LDFLAGS_mozilla_EXTRA)
83 npvlc_la_LIBADD = $(LIBRARIES_libvlc)
84
85 noinst_DATA = npvlc.rsrc VLC\ Plugin.plugin
86 MOSTLYCLEANFILES += npvlc.rsrc
87 CLEANFILES += VLC\ Plugin.plugin
88
89 npvlc.rsrc: $(srcdir)/vlc.r
90         /Developer/Tools/Rez -useDF /Developer/Headers/FlatCarbon/Types.r $< -o $@
91
92 #
93 # Plugin uses shared libraries that are located relatively through @executable_path,
94 # which unfortunately references the path of the App using the Plugin, rather than the
95 # Plugin itself. Since this Plugin should always be installed in '/Library/Internet Plug-Ins',
96 # it is safer to force dylibs to locate dependants through a fixed path
97 #
98 define FIXEXECPATH
99         otool -L "$$dylib" | \
100         awk -v libdylib="$$dylib" ' \
101         /@executable_path/ { \
102             newpath=$$1 ; \
103             sub("@executable_path","/Library/Internet Plug-Ins/VLC Plugin.plugin/Contents/MacOS",newpath) ; \
104             print "install_name_tool -change \""$$1"\" \""newpath"\" \""libdylib"\"" ; \
105         }' | sh -x
106 endef
107
108 VLC\ Plugin.plugin: npvlc.rsrc $(lib_LTLIBRARIES)
109         rm -Rf "$@"
110         $(INSTALL) -d "$(srcdir)/$@/Contents/MacOS"
111         $(INSTALL) "$(srcdir)/.libs/npvlc.dylib" "$(srcdir)/$@/Contents/MacOS/VLC Plugin"
112         $(INSTALL) -d "$(srcdir)/$@/Contents/MacOS/lib"; \
113         install_name_tool -change "$(libdir)/libvlc.1.dylib" \
114             "@executable_path/lib/libvlc.dylib" \
115             "$(srcdir)/$@/Contents/MacOS/VLC Plugin"
116         install_name_tool -change "$(libdir)/libvlc-control.0.dylib" \
117             "@executable_path/lib/libvlc-control.dylib" \
118             "$(srcdir)/$@/Contents/MacOS/VLC Plugin"
119         $(INSTALL) "$(top_builddir)/src/.libs/libvlc.1.dylib" \
120             "$(srcdir)/$@/Contents/MacOS/lib/libvlc.dylib"
121         $(INSTALL) "$(top_builddir)/src/.libs/libvlc-control.0.dylib" \
122             "$(srcdir)/$@/Contents/MacOS/lib/libvlc-control.dylib"
123         install_name_tool -change "$(libdir)/libvlc.1.dylib" \
124             "@executable_path/lib/libvlc.dylib" \
125             "$(srcdir)/$@/Contents/MacOS/lib/libvlc-control.dylib"
126         dylib="$(srcdir)/$@/Contents/MacOS/VLC Plugin"; $(FIXEXECPATH) ;
127         dylib="$(srcdir)/$@/Contents/MacOS/lib/libvlc.dylib"; $(FIXEXECPATH) ;
128         dylib="$(srcdir)/$@/Contents/MacOS/lib/libvlc-control.dylib"; $(FIXEXECPATH) ;
129         $(INSTALL) -d "$(srcdir)/$@/Contents/Resources"
130         $(INSTALL) npvlc.rsrc "$(srcdir)/$@/Contents/Resources/VLC Plugin.rsrc"
131         cp -r "$(top_srcdir)/extras/MacOSX/plugin/English.lproj" "$(srcdir)/$@/Contents/Resources/"
132         $(INSTALL) "$(top_srcdir)/extras/MacOSX/plugin/Info.plist" "$(srcdir)/$@/Contents/Info.plist"
133         $(INSTALL) -d "$(srcdir)/$@/Contents/MacOS/modules"
134         for i in "" `$(VLC_CONFIG) --target plugin` ; do \
135           if test -n "$$i" ; then \
136             dylib="$(srcdir)/$@/Contents/MacOS/modules/`basename $$i$(LIBEXT)`"; \
137             $(INSTALL) "`dirname $$i`/.libs/`basename $$i`$(LIBEXT)" "$$dylib"; \
138             install_name_tool -change "$(libdir)/libvlc.1.dylib" \
139                 "@executable_path/lib/libvlc.dylib" "$$dylib"; \
140             $(FIXEXECPATH) ; \
141           fi ; \
142         done
143         if test -d $(top_srcdir)/extras/contrib/vlc-lib; then \
144           for i in $(top_srcdir)/extras/contrib/vlc-lib/*.dylib ; do \
145             dylib="$(srcdir)/$@/Contents/MacOS/lib/`basename $${i}`" ; \
146             $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
147             $(FIXEXECPATH); \
148           done ; \
149         fi
150 # uncomment if dependencies on XPCOM libs is sought
151 #       if test -d "$(MOZILLA_SDK_PATH)/lib"; then \
152 #         for i in "$(MOZILLA_SDK_PATH)"/lib/*.dylib ; do \
153 #           dylib="$(srcdir)/$@/Contents/MacOS/`basename $${i}`" ; \
154 #           $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
155 #           $(FIXEXECPATH); \
156 #         done ; \
157 #       fi
158
159 else
160
161 #
162 # UNIX/Others platforms
163 #
164
165 npvlc_LTLIBRARIES = libvlcplugin.la
166
167 npvlc = libvlcplugin$(LIBEXT)
168 npvlcdir = $(libdir)/mozilla/plugins
169 SOURCES_support = support/npunix.c
170
171 libvlcplugin_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
172 libvlcplugin_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla`
173 libvlcplugin_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla`
174 libvlcplugin_la_LDFLAGS = `$(VLC_CONFIG) --libs mozilla` -module -avoid-version -shrext $(LIBEXT)
175 libvlcplugin_la_LIBADD = $(LIBRARIES_libvlc)
176
177 endif
178 endif
179 endif
180