+
+#
+# MacOS X
+#
+
+lib_LTLIBRARIES = npvlc.la
+
+SOURCES_support = support/npmac.cpp
+CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \
+ -F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \
+ -I/Developer/Headers/FlatCarbon -fno-common -fpascal-strings \
+ -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 \
+ -DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0 \
+ -include mozilla-config.h
+LDFLAGS_mozilla_EXTRA = -no-undefined -bundle -Wl,-read_only_relocs -Wl,suppress \
+ -Wl,-headerpad_max_install_names -shrext $(LIBEXT) -Wl,-framework,Carbon -Wl,-framework,System
+
+npvlc_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
+npvlc_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla` $(CPPFLAGS_mozilla_EXTRA)
+npvlc_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla` $(CPPFLAGS_mozilla_EXTRA)
+npvlc_la_DEPENDENCIES = $(LIBRARIES_libvlc)
+npvlc_la_LDFLAGS = `$(VLC_CONFIG) --ldflags mozilla` -module -avoid-version \
+ $(LDFLAGS_mozilla_EXTRA)
+npvlc_la_LIBADD = `$(VLC_CONFIG) -libs mozilla` $(LIBRARIES_libvlc)
+
+
+noinst_DATA = npvlc.rsrc VLC\ Plugin.plugin
+MOSTLYCLEANFILES += npvlc.rsrc
+CLEANFILES += VLC\ Plugin.plugin
+
+npvlc.rsrc: $(srcdir)/vlc.r
+ /Developer/Tools/Rez -useDF /Developer/Headers/FlatCarbon/Types.r $< -o $@
+
+#
+# Plugin uses shared libraries that are located relatively through @executable_path,
+# which unfortunately references the path of the App using the Plugin, rather than the
+# Plugin itself. Since this Plugin should always be installed in '/Library/Internet Plug-Ins',
+# it is safer to force dylibs to locate dependants through a fixed path
+#
+define FIXEXECPATH
+ otool -L "$$dylib" | \
+ awk -v libdylib="$$dylib" ' \
+ /@executable_path/ { \
+ newpath=$$1 ; \
+ sub("@executable_path","/Library/Internet Plug-Ins/VLC Plugin.plugin/Contents/MacOS",newpath) ; \
+ print "install_name_tool -change \""$$1"\" \""newpath"\" \""libdylib"\"" ; \
+ }' | sh -x
+endef
+
+VLC\ Plugin.plugin: npvlc.rsrc $(lib_LTLIBRARIES)
+ rm -Rf "$@"
+ $(INSTALL) -d "$(srcdir)/$@/Contents/MacOS"
+ $(INSTALL) "$(srcdir)/.libs/npvlc.dylib" "$(srcdir)/$@/Contents/MacOS/VLC Plugin"
+ $(INSTALL) -d "$(srcdir)/$@/Contents/MacOS/lib"; \
+ install_name_tool -change "$(libdir)/libvlc.1.dylib" \
+ "@executable_path/lib/libvlc.dylib" \
+ "$(srcdir)/$@/Contents/MacOS/VLC Plugin"
+ install_name_tool -change "$(libdir)/libvlc-control.1.dylib" \
+ "@executable_path/lib/libvlc-control.dylib" \
+ "$(srcdir)/$@/Contents/MacOS/VLC Plugin"
+ $(INSTALL) "$(top_builddir)/src/.libs/libvlc.1.dylib" \
+ "$(srcdir)/$@/Contents/MacOS/lib/libvlc.dylib"
+ $(INSTALL) "$(top_builddir)/src/.libs/libvlc-control.1.dylib" \
+ "$(srcdir)/$@/Contents/MacOS/lib/libvlc-control.dylib"
+ install_name_tool -change "$(libdir)/libvlc.1.dylib" \
+ "@executable_path/lib/libvlc.dylib" \
+ "$(srcdir)/$@/Contents/MacOS/lib/libvlc-control.dylib"
+ dylib="$(srcdir)/$@/Contents/MacOS/VLC Plugin"; $(FIXEXECPATH) ;
+ dylib="$(srcdir)/$@/Contents/MacOS/lib/libvlc.dylib"; $(FIXEXECPATH) ;
+ dylib="$(srcdir)/$@/Contents/MacOS/lib/libvlc-control.dylib"; $(FIXEXECPATH) ;
+ $(INSTALL) -d "$(srcdir)/$@/Contents/Resources"
+ $(INSTALL) npvlc.rsrc "$(srcdir)/$@/Contents/Resources/VLC Plugin.rsrc"
+ cp -r "$(top_srcdir)/extras/MacOSX/plugin/English.lproj" "$(srcdir)/$@/Contents/Resources/"
+ $(INSTALL) "$(top_srcdir)/extras/MacOSX/plugin/Info.plist" "$(srcdir)/$@/Contents/Info.plist"
+ $(INSTALL) -d "$(srcdir)/$@/Contents/MacOS/modules"
+ for i in "" `$(VLC_CONFIG) --target plugin` ; do \
+ if test -n "$$i" ; then \
+ dylib="$(srcdir)/$@/Contents/MacOS/modules/`basename $$i$(LIBEXT)`"; \
+ $(INSTALL) "`dirname $$i`/.libs/`basename $$i`$(LIBEXT)" "$$dylib"; \
+ install_name_tool -change "$(libdir)/libvlc.1.dylib" \
+ "@executable_path/lib/libvlc.dylib" "$$dylib"; \
+ $(FIXEXECPATH) ; \
+ fi ; \
+ done
+ if test -d $(top_srcdir)/extras/contrib/vlc-lib; then \
+ for i in $(top_srcdir)/extras/contrib/vlc-lib/*.dylib ; do \
+ dylib="$(srcdir)/$@/Contents/MacOS/lib/`basename $${i}`" ; \
+ $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
+ $(FIXEXECPATH); \
+ done ; \
+ fi
+# uncomment if dependencies on XPCOM libs is sought
+# if test -d "$(MOZILLA_SDK_PATH)/lib"; then \
+# for i in "$(MOZILLA_SDK_PATH)"/lib/*.dylib ; do \
+# dylib="$(srcdir)/$@/Contents/MacOS/`basename $${i}`" ; \
+# $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
+# $(FIXEXECPATH); \
+# done ; \
+# fi