Makefile.am 6.51 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

damienf's avatar
damienf committed
7
MOSTLYCLEANFILES = $(npvlc_DATA)
8
CLEANFILES = stamp-pic $(BUILT_SOURCES)
damienf's avatar
damienf committed
9
EXTRA_DIST = $(DIST_sources) npvlc_rc.rc vlc.r
10

11
SOURCES_mozilla_common = \
12
13
14
	vlcshell.cpp \
	vlcplugin.cpp \
	vlcplugin.h \
damienf's avatar
damienf committed
15
16
17
18
19
20
	control/npolibvlc.cpp \
	control/npolibvlc.h \
	control/npovlc.cpp \
	control/npovlc.h \
	control/nporuntime.cpp \
	control/nporuntime.h \
21
	support/classinfo.h
22

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

26
if BUILD_SHARED
27
28
LIBRARIES_libvlc_pic = -Wl,-rpath '$(libdir)' -L$(top_builddir)/src -lvlc
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
35
if BUILD_MOZILLA

36
37
38
39
# 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
40

41
LIBRARIES_libvlc = $(LIBRARIES_libvlc_nopic)
42
npvlc = npvlc$(LIBEXT)
43
npvlcdir = $(libdir)
44
noinst_DATA = npvlc_rc.$(OBJEXT)
45
46
47

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

54
npvlc_rc.$(OBJEXT): npvlc_rc.rc
55
56
57
	$(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 $@
58

59
60
else
if HAVE_DARWIN
61

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

SOURCES_support = support/npmac.cpp
70
71
CPPFLAGS_mozilla_EXTRA = -I. -I$(top_builddir) -I$(srcdir)/../include -c \
	-F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) \
72
73
74
	-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 \
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
# 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

98
VLC\ Plugin.plugin: npvlc.rsrc npvlc.dylib
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
	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
123
124
125
126
127
128
129
130
# 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="./$@/Contents/MacOS/`basename $${i}`" ; \
#	    $(INSTALL) -m 644 "$${i}" "$$dylib" ; \
#	    $(FIXEXECPATH); \
#	  done ; \
#	fi
131

132
else
133

134
LIBRARIES_libvlc = $(LIBRARIES_libvlc_pic)
135
npvlc = libvlcplugin$(LIBEXT)
136
137
npvlcdir = $(libdir)/mozilla/plugins
SOURCES_support = support/npunix.c
138
noinst_DATA =
139

140
LDFLAGS_npvlc = -shared $(LIBRARIES_libvlc)
141
endif
142
143
endif

144
145
noinst_LIBRARIES_mozilla = libnpvlc.a

146
147
148
149
150
151
152
153
154
if USE_LIBTOOL
# FIXME: name is incorrect on Win32 & Darwin
npvlc_LTLIBRARIES = libvlcplugin.la
else
npvlc_DATA = $(npvlc)
EXTRA_LIBRARIES = libnpvlc.a
endif
endif

Sam Hocevar's avatar
Sam Hocevar committed
155
156
157
158
159
160
if HAVE_WIN32
pic =
else
pic = pic
endif

161
162
163
libvlcplugin_la_SOURCES = $(SOURCES_mozilla_common) $(SOURCES_support)
libvlcplugin_la_CFLAGS = `$(VLC_CONFIG) --cflags mozilla`
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-control.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
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
179
	@if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi
180
181
182
183

###############################################################################
# Stamp rules
###############################################################################
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
184
stamp-pic:
185
	@for dep in "" `$(VLC_CONFIG) --target builtin pic`; do \
186
187
188
189
190
191
192
193
194
195
	  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
196
.PHONY: stamp-pic