Makefile.am 6.71 KB
Newer Older
1
2
3
4
###############################################################################
# Building the Mozilla plugin
###############################################################################

5
noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
6

7
8
9
MOSTLYCLEANFILES = $(npvlc_DATA) $(vlcintf_xpt_DATA)
CLEANFILES = stamp-pic $(BUILT_SOURCES)
EXTRA_DIST = $(DIST_sources) vlcintf.idl npvlc_rc.rc vlc.r
10

11
SOURCES_mozilla_common = \
12
13
14
15
16
	vlcshell.cpp \
	vlcplugin.cpp \
	vlcplugin.h \
	vlcpeer.cpp \
	vlcpeer.h \
17
18
	vlcruntime.cpp \
	vlcruntime.h \
19
	support/classinfo.h
20

21
DIST_sources = $(SOURCES_mozilla_common) \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
22
	support/npwin.cpp support/npmac.cpp support/npunix.c
gbazin's avatar
   
gbazin committed
23

24
if BUILD_SHARED
25
26
LIBRARIES_libvlc_pic = -Wl,-rpath '$(libdir)' -L$(top_builddir)/src -lvlc
LIBRARIES_libvlc_nopic = $(LIBRARIES_libvlc_pic)
27
else
28
29
LIBRARIES_libvlc_pic = $(top_builddir)/src/libvlc_pic.a
LIBRARIES_libvlc_nopic = $(top_builddir)/src/libvlc.a
30
endif
31

32
33
if BUILD_MOZILLA

34
35
36
37
# Under Win32, Mozilla plugins need to be named NP******.DLL, but under Unix
# the common naming scheme is lib******plugin.so. Also, we need npwin.cpp
# under Win32 and npunix.c under Unix.
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
45

SOURCES_support = support/npwin.cpp
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
50
51
noinst_npvlc_rc_DATA = npvlc_rc.$(OBJEXT)
noinst_npvlc_rcdir =

52
npvlc_rc.$(OBJEXT): npvlc_rc.rc
53
54
55
	$(WINDRES) -DVERSION=$(VERSION) \
		-DVERSION_NUMBER=`echo $(VERSION).0.0.0 | sed 's/\([0-9]*\)[^.]*\.*\([0-9]*\)[^.]*\.*\([0-9]*\)[^.]*\.*\([0-9]*\).*/\1,\2,\3,\4/'` \
		--include-dir $(srcdir) -i $< -o $@
56

57
58
else
if HAVE_DARWIN
59

60
LIBRARIES_libvlc = $(LIBRARIES_libvlc_nopic)
61
npvlc = npvlc$(LIBEXT)
62
npvlcdir = $(libdir)
63
64
65
noinst_DATA = npvlc.rsrc VLC\ Plugin.plugin
MOSTLYCLEANFILES += npvlc.rsrc
CLEANFILES += VLC\ Plugin.plugin
66
67

SOURCES_support = support/npmac.cpp
68
69
70
71
72
73
74
CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \
	-F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \
	-I/Developer/Headers/FlatCarbon -arch ppc -fno-common -fpascal-strings \
	-O0 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 \
	-DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0 -g \
	-include mozilla-config.h
LDFLAGS_npvlc = -arch ppc -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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#
# 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

96
VLC\ Plugin.plugin: npvlc.rsrc npvlc.dylib
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
	rm -Rf "$@"
	$(INSTALL) -d "./$@/Contents/MacOS"
	$(INSTALL) npvlc.dylib "./$@/Contents/MacOS/VLC Plugin"
	dylib="./$@/Contents/MacOS/VLC Plugin"; $(FIXEXECPATH) ;
	$(INSTALL) -d "./$@/Contents/Resources"
	$(INSTALL) npvlc.rsrc "./$@/Contents/Resources/VLC Plugin.rsrc"
	cp -r "$(top_srcdir)/extras/MacOSX/plugin/English.lproj" "./$@/Contents/Resources/"
	$(INSTALL) "$(top_srcdir)/extras/MacOSX/plugin/Info.plist" "./$@/Contents/Info.plist"
	$(INSTALL) -d "./$@/Contents/MacOS/modules"
	for i in "" `$(VLC_CONFIG) --target plugin` ; do \
	  if test -n "$$i" ; then \
	    dylib="./$@/Contents/MacOS/modules/`basename $$i$(LIBEXT)`"; \
	    $(INSTALL) "$$i$(LIBEXT)" "$$dylib"; \
	    $(FIXEXECPATH) ; \
	  fi ; \
	done
	if test -d $(top_srcdir)/extras/contrib/vlc-lib; then \
	  $(INSTALL) -d "./$@/Contents/MacOS/lib"; \
	  for i in $(top_srcdir)/extras/contrib/vlc-lib/*.dylib ; do \
	    dylib="./$@/Contents/MacOS/lib/`basename $${i}`" ; \
	    $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
	    $(FIXEXECPATH); \
	  done ; \
	fi
	if test -d "$(MOZILLA_SDK_PATH)/lib"; then \
	  for i in "$(MOZILLA_SDK_PATH)"/lib/*.dylib ; do \
	    dylib="./$@/Contents/MacOS/`basename $${i}`" ; \
	    $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
	    $(FIXEXECPATH); \
	  done ; \
	fi
128

129
else
130

131
LIBRARIES_libvlc = $(LIBRARIES_libvlc_pic)
132
npvlc = libvlcplugin$(LIBEXT)
133
134
npvlcdir = $(libdir)/mozilla/plugins
SOURCES_support = support/npunix.c
135
noinst_DATA =
136

137
LDFLAGS_npvlc = -shared $(LIBRARIES_libvlc)
138
endif
139
140
endif

141
142
noinst_LIBRARIES_mozilla = libnpvlc.a

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
$(SOURCES_mozilla): vlcintf.h

BUILT_SOURCES = vlcintf.h
vlcintf_xpt_DATA = vlcintf.xpt

if USE_LIBTOOL
# FIXME: name is incorrect on Win32 & Darwin
npvlc_LTLIBRARIES = libvlcplugin.la
else
npvlc_DATA = $(npvlc)
EXTRA_LIBRARIES = libnpvlc.a
endif
endif

libvlcplugin_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
libvlcplugin_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla`
libvlcplugin_la_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla`
libvlcplugin_la_LDFLAGS = `$(VLC_CONFIG) --libs mozilla` -module -shrext $(LIBEXT)
libvlcplugin_la_LIBADD = ../src/libvlc.la

libnpvlc_a_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
164
165
166
167
libnpvlc_a_CFLAGS = `$(VLC_CONFIG) --cflags mozilla $(pic)` \
	             $(CPPFLAGS_mozilla_EXTRA)
libnpvlc_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags mozilla $(pic)` \
	               $(CPPFLAGS_mozilla_EXTRA)
168
LDFLAGS_libnpvlc = $(LDFLAGS_npvlc) `$(VLC_CONFIG) --libs mozilla vlc builtin $(pic)`
169
libnpvlc_a_DEPENDENCIES = $(DATA_npvlc_rc)
170

171
$(npvlc): $(libnpvlc_a_OBJECTS) $(libnpvlc_a_DEPENDENCIES) stamp-pic
172
	$(CXXLINK) $(libnpvlc_a_OBJECTS) $(DATA_npvlc_rc) \
173
	 $(LDFLAGS_libnpvlc)
174
# Cygwin work-around
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
175
	@if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi
176
177
178

vlcintf_xptdir = $(libdir)/mozilla/components
vlcintf.xpt: vlcintf.idl
179
	$(XPIDL) $(XPIDL_INCL) \
180
181
182
	  -m typelib -o vlcintf $(srcdir)/vlcintf.idl

vlcintf.h: vlcintf.idl
183
	$(XPIDL) $(XPIDL_INCL) \
184
185
186
187
188
	  -m header -o vlcintf $(srcdir)/vlcintf.idl

###############################################################################
# Stamp rules
###############################################################################
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
189
stamp-pic:
190
	@for dep in "" `$(VLC_CONFIG) --target builtin $(pic)`; do \
191
192
193
194
195
196
197
198
199
200
	  if test "$${dep}" -nt "$(LIBRARIES_mozilla)"; then \
	    rm -f $@; \
	    break; \
	  fi; \
	done
	@if test ! -f $@; then printf "" > $@; fi

###############################################################################
# Force rule
###############################################################################
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
201
.PHONY: stamp-pic