mod_v8: Added configure flag --enable-static-v8 to enable static linking of the V8 lib. Also enabled this flag for the Debian packaging system. Please note the static linking has only been verified on Linux so far

This commit is contained in:
Peter Olsson 2014-01-20 11:32:28 +01:00
parent 9501911964
commit 2e32d10503
3 changed files with 56 additions and 21 deletions

View File

@ -1018,6 +1018,10 @@ fi
AX_CHECK_JAVA
# Option to enable static linking of Google's V8 inside mod_v8
AC_ARG_ENABLE(static-v8,
[AS_HELP_STRING([--enable-static-v8], [Statically link V8 into mod_v8])], [enable_static_v8="$enableval"], [enable_static_v8="no"])
AM_CONDITIONAL([ENABLE_STATIC_V8],[test "x$enable_static_v8" != "xno"])
AM_CONDITIONAL([HAVE_ODBC],[test "x$enable_core_odbc_support" != "xno"])
AM_CONDITIONAL([HAVE_LIBEDIT],[test "x$enable_core_libedit_support" != "xno"])

3
debian/rules vendored
View File

@ -79,7 +79,8 @@ override_dh_auto_clean:
--with-grammardir=/usr/share/freeswitch/grammar \
--with-certsdir=/etc/freeswitch/tls \
--with-scriptdir=/usr/share/freeswitch/scripts \
--with-recordingsdir=/var/lib/freeswitch/recordings
--with-recordingsdir=/var/lib/freeswitch/recordings \
--enable-static-v8
touch $@
override_dh_auto_configure: .stamp-configure

View File

@ -1,24 +1,44 @@
include $(top_srcdir)/build/modmake.rulesam
AUTOMAKE_OPTIONS = foreign
# V8 version to use
V8=v8-3.24.14
V8_DIR=$(switch_srcdir)/libs/$(V8)
V8_BUILDDIR=$(switch_builddir)/libs/$(V8)
if PLATFORM_MACOSX
# For some reason V8 puts the libraries somewhere else on Mac OSX
V8_LIBDIR=$(V8_DIR)/out/native
V8_LIBEXT=dylib
# Build with snapshot doesn't work for OSX right now
V8_BUILDPARAMS=snapshot=off
V8_SNAPSHOT=nosnapshot
else
V8_LIBDIR=$(V8_DIR)/out/native/lib.target
V8_LIBEXT=so
# Some gcc versions report warnings incorrectly
V8_BUILDPARAMS=strictaliasing=off werror=no
V8_SNAPSHOT=snapshot
endif
V8SO=$(V8_LIBDIR)/libv8.$(V8_LIBEXT)
if ENABLE_STATIC_V8
# Build the static lib version of V8
if PLATFORM_MACOSX
V8_STATIC_DIR=$(V8_DIR)/out/native
V8_ICU_STATIC_DIR=$(V8_DIR)/out/native
V8_CXXFLAGS =
else
V8_STATIC_DIR=$(V8_DIR)/out/native/obj.target/tools/gyp
V8_ICU_STATIC_DIR=$(V8_DIR)/out/native/obj.target/third_party/icu
V8_CXXFLAGS = -fPIC
endif
V8LIB=$(V8_STATIC_DIR)/libv8_base*.a
else
# Build the dynamic lib version of V8
V8_BUILDPARAMS += library=shared
V8LIB=$(V8_LIBDIR)/libv8.$(V8_LIBEXT)
endif
# Try to find the target platform for our configured CXX compiler
# Parse the result one extra time to handle different i386 platforms (i386, i486 etc)
@ -31,27 +51,34 @@ CURLLA=${switch_builddir}/libs/curl/lib/libcurl.la
MODNAME=mod_v8
AM_CFLAGS += -I. -I./include -I$(V8_DIR)/include
AM_CPPFLAGS += -I. -I./include -I$(V8_DIR)/include
AM_LIBADD = $(switch_builddir)/libfreeswitch.la -lv8 -licuuc -licui18n
AM_LDFLAGS += -avoid-version -module -no-undefined -shared
AM_LDFLAGS += -L$(V8_LIBDIR)
BUILT_SOURCES = $(V8SO) $(LIBCURL_DEPS)
AM_CFLAGS += -I. -I./include -I$(V8_DIR)/include
AM_CPPFLAGS += -I. -I./include -I$(V8_DIR)/include
AM_LDFLAGS += -avoid-version -module -no-undefined -shared
if HAVE_ODBC
AM_CFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS)
AM_CPPFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS)
AM_LDFLAGS += -DHAVE_ODBC
if ENABLE_STATIC_V8
AM_LIBADD = $(switch_builddir)/libfreeswitch.la
V8_LDFLAGS = $(V8_STATIC_DIR)/libv8_{base*,$(V8_SNAPSHOT)*}.a $(V8_ICU_STATIC_DIR)/libicu{i18n,uc,data}.a $(SOLINK)
else
AM_LIBADD = $(switch_builddir)/libfreeswitch.la -lv8 -licuuc -licui18n
AM_LDFLAGS += -L$(V8_LIBDIR)
endif
mod_LTLIBRARIES = mod_v8.la
mod_v8_la_SOURCES = mod_v8.cpp ./src/fscoredb.cpp ./src/fscurl.cpp ./src/fsdtmf.cpp ./src/fsevent.cpp ./src/fsfileio.cpp ./src/fsglobal.cpp ./src/fsodbc.cpp ./src/fspcre.cpp ./src/fsrequest.cpp ./src/fssession.cpp ./src/fssocket.cpp ./src/fsteletone.cpp ./src/fsxml.cpp ./src/fsfile.cpp ./src/jsbase.cpp ./src/jsmain.cpp
BUILT_SOURCES = $(V8LIB) $(LIBCURL_DEPS)
if HAVE_ODBC
AM_CFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS)
AM_CPPFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS)
AM_LDFLAGS += -DHAVE_ODBC
endif
mod_LTLIBRARIES = mod_v8.la
mod_v8_la_SOURCES = mod_v8.cpp src/fscoredb.cpp src/fscurl.cpp src/fsdtmf.cpp src/fsevent.cpp src/fsfileio.cpp src/fsglobal.cpp src/fsodbc.cpp src/fspcre.cpp src/fsrequest.cpp src/fssession.cpp src/fssocket.cpp src/fsteletone.cpp src/fsxml.cpp src/fsfile.cpp src/jsbase.cpp src/jsmain.cpp
mod_v8_la_CFLAGS = $(AM_CFLAGS) $(LIBCURL_CPPFLAGS) -I$(switch_srcdir)/libs/libteletone/src
mod_v8_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCURL_CPPFLAGS) -I$(switch_srcdir)/libs/libteletone/src
mod_v8_la_LIBADD = $(AM_LIBADD)
mod_v8_la_LDFLAGS = $(AM_LDFLAGS) $(LIBCURL)
mod_v8_la_LDFLAGS = $(AM_LDFLAGS) $(LIBCURL) $(V8_LDFLAGS)
#mod_LTLIBRARIES += mod_v8_skel.la
#mod_LTLIBRARIES += mod_v8_skel.la
#mod_v8_skel_la_SOURCES = mod_v8_skel.cpp
#mod_v8_skel_la_CFLAGS = $(AM_CFLAGS) -DJSMOD_IMPORT
#mod_v8_skel_la_CPPFLAGS = $(AM_CPPFLAGS) -DJSMOD_IMPORT
@ -63,7 +90,7 @@ $(SOURCES): $(BUILT_SOURCES)
$(V8_DIR):
$(GETLIB) $(V8).tar.bz2
$(V8SO): $(V8_DIR)
$(V8LIB): $(V8_DIR)
if test "$(CXX_TARGET_PLATFORM)" = "x86_64"; then \
defines="v8_target_arch=x64 target_arch=x64"; \
else \
@ -75,12 +102,15 @@ $(V8SO): $(V8_DIR)
fi; \
fi; \
fi; \
cd $(V8_BUILDDIR) && GYP_DEFINES="$$defines" $(MAKE) library=shared $(V8_BUILDPARAMS) native
cd $(V8_BUILDDIR) && CFLAGS="$(V8_CXXFLAGS)" CXXFLAGS="$(V8_CXXFLAGS)" GYP_DEFINES="$$defines" $(MAKE) $(V8_BUILDPARAMS) native
$(CURLLA):
@cd $(CURL_BUILDDIR) && $(MAKE)
$(TOUCH_TARGET)
if ENABLE_STATIC_V8
install-exec-local: $(V8LIB)
else
# This is a temporary solution to force Mac OSX build to load the libraries at the right place
if PLATFORM_MACOSX
install-exec-local: $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT)
@ -96,8 +126,8 @@ install-exec-local: $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT)
else
install-exec-local: $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT)
endif
$(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT): $(V8SO)
$(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT): $(V8LIB)
rm -f $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT) && cp -a $(V8_LIBDIR)/libv8.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libv8.$(V8_LIBEXT)
rm -f $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT) && cp -a $(V8_LIBDIR)/libicuuc.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicuuc.$(V8_LIBEXT)
rm -f $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT) && cp -a $(V8_LIBDIR)/libicui18n.$(V8_LIBEXT) $(DESTDIR)$(libdir)/libicui18n.$(V8_LIBEXT)
endif