Commit 620f6923 authored by hrchilds's avatar hrchilds

Add initial support for linking the server statically.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@8950 18c085ea-50e0-402c-830e-de6fd14e8384
parent 9993605f
......@@ -177,6 +177,11 @@
# been defined by build_visit and it will contain the user's env. just
# after starting build_visit but before build_visit starts adding things
# to the user's environment.
#
# Hank Childs, Thu Nov 12 12:23:56 PST 2009
# Add variable for static link. This places the plugins before the
# components.
#
##############################################################################
@SET_MAKE@
......@@ -191,6 +196,9 @@ SUBDIRS_ENGINE_ONLY=include lib bin third_party_builtin common visit_vtk avt eng
SUBDIRS_SERVER_COMPONENTS_ONLY=include lib bin third_party_builtin common visit_vtk \
avt engine launcher mdserver sim plots operators databases
SUBDIRS_STATIC_LINK=include lib bin third_party_builtin common visit_vtk \
avt plots operators databases engine launcher mdserver
SUBDIRS_STD=include lib bin third_party_builtin common @VTKQT@ visit_vtk \
avt engine launcher @METADATA_SERVER@ winutil @VIEWER@ \
@GUI@ @VISITPY@ @JAVA_TARGET@ sim plots operators databases @HELP@ \
......
......@@ -95,6 +95,9 @@
# Brad Whitlock, Wed Jun 3 15:42:02 PST 2009
# I added an engine-only build option.
#
# Hank Childs, Thu Nov 12 13:42:52 PST 2009
# Added an option for static linking.
#
##############################################################################
@SET_MAKE@
......@@ -109,6 +112,8 @@ SUBDIRS_ENGINE_ONLY=DBAtts Math IVP Pipeline DDF MIR Shapelets\
SUBDIRS_SERVER_COMPONENTS_ONLY=$(SUBDIRS_ENGINE_ONLY)
SUBDIRS_STATIC_LINK=$(SUBDIRS_ENGINE_ONLY)
SUBDIRS_STD=$(SUBDIRS_ENGINE_ONLY) QtVisWindow
SUBDIRS=@SUBDIRS@
......
......@@ -80,6 +80,12 @@ using std::sort;
#define MAX_PLUGINERROR 500
#ifdef STATIC
extern void *fake_dlsym(const string &);
extern void StaticGetSupportedLibs(std::vector<std::pair<std::string, std::string> > &,
const string &);
#endif
// ****************************************************************************
// Method: PluginManager constructor
//
......@@ -496,11 +502,19 @@ PluginManager::EnablePlugin(const string &id)
// Hank Childs, Fri Nov 16 15:24:16 PST 2007
// Fix bug pointed out by Paul Selby of AWE.
//
// Hank Childs, Thu Nov 12 17:49:58 PST 2009
// Only read the supported libraries if we are doing a static link.
//
// ****************************************************************************
void
PluginManager::GetPluginList(vector<pair<string,string> > &libs)
{
#ifdef STATIC
StaticGetSupportedLibs(libs, managerName);
return;
#endif
// Read the files in the plugin directory.
vector< vector<pair<string,string> > > files;
ReadPluginDir(files);
......@@ -1471,6 +1485,10 @@ PluginManager::ReadPluginDir(vector< vector<pair<string,string> > > &files)
//
// Mark C. Miller, Thu Aug 14 01:22:59 PDT 2008
// Made messages reported to screen include plugin name and error msg.
//
// Hank Childs, Thu Nov 12 11:28:10 PST 2009
// Add support for static "plugins".
//
// ****************************************************************************
void
......@@ -1488,6 +1506,8 @@ PluginManager::PluginOpen(const string &pluginFile)
}
handle = (void *)lib;
#elif defined(STATIC)
debug1 << "Not opening " << pluginFile << " because this is a static build." << endl;
#else
// dlopen the plugin
handle = dlopen(pluginFile.c_str(), RTLD_LAZY);
......@@ -1543,15 +1563,16 @@ PluginManager::PluginOpen(const string &pluginFile)
// Cyrus Harrison, Wed Jun 20 14:05:58 PDT 2007
// Changed __DARWIN__ back to __APPLE__
//
// Hank Childs, Thu Nov 12 11:28:10 PST 2009
// Add support for static "plugins".
//
// ****************************************************************************
void *
PluginManager::PluginSymbol(const string &symbol, bool noError)
{
void *retval;
#if defined(_WIN32)
retval = (void *)GetProcAddress((HMODULE)handle, symbol.c_str());
#elif defined(__APPLE__)
string symbolName(symbol);
//
......@@ -1572,17 +1593,24 @@ PluginManager::PluginSymbol(const string &symbol, bool noError)
int len = openPlugin.size() - slashPos - suffixLen - 5 -
managerName.size() - ext.size();
string pluginPrefix(openPlugin.substr(slashPos + 5, len));
// debug4 << "PluginSymbol: prefix: " << pluginPrefix << endl;
// debug4 << "PluginSymbol: prefix: " << pluginPrefix << endl;
if(pluginVersion)
symbolName = string(pluginPrefix + symbol);
else
symbolName = string(pluginPrefix + "_" + symbol);
// debug4 << "PluginSymbol: sym: " << symbolName << endl;
// debug4 << "PluginSymbol: sym: " << symbolName << endl;
}
retval = dlsym(handle, symbolName.c_str());
#if defined(_WIN32)
retval = (void *)GetProcAddress((HMODULE)handle, symbol.c_str());
#else
retval = dlsym(handle, symbol.c_str());
#if defined(STATIC)
retval = fake_dlsym(symbolName);
if (retval == NULL)
debug1 << "fake_dlsym was not able to return " << symbolName << endl;
#else
retval = dlsym(handle, symbolName.c_str());
#endif
#endif
// If the symbol was not found, print the error message if appropriate.
......
This diff is collapsed.
......@@ -988,6 +988,14 @@ dnl
dnl Cyrus Harrison, Tue Oct 6 08:56:58 PDT 2009
dnl Changed vtk include paths to reflect a 'make install'ed vtk
dnl installation.
dnl
dnl Hank Childs, Thu Nov 12 11:48:11 PST 2009
dnl Add support for static linking of the server side components.
dnl Client side components have not been tested. Further, it is assumed
dnl that third party libraries have been linked statically. Dynamic
dnl libraries are nominally fine, but the symlinks in /lib will not work and
dnl you won't get a true "static" binary.
dnl
dnl --------------------------------------------------------------------------
dnl
......@@ -1176,6 +1184,30 @@ if test "$enable_server_components_only" = yes && test "$enable_engine_only" = y
enable_engine_only=no
fi
#
# Check for static builds.
#
AC_ARG_ENABLE(static,
AC_HELP_STRING([--enable-static], [build the server components statically (you must also issue --enable-server-components-only)]))
if test "$enable_static" = yes && test "$enable_server_components_only" != yes; then
AC_MSG_ERROR([--static requires --enable-server-components-only])
fi
STATIC_LINK=""
STATIC_LINK_PAR=""
STATIC_LINK_DBS=""
if test "$enable_static" = yes; then
STATIC_LINK="$""(STATIC_LINK)"
STATIC_LINK_PAR="$""(STATIC_LINK_PAR)"
STATIC_LINK_DBS="$""(STATIC_LINK_DBS)"
AC_DEFINE(STATIC, [1], [Preprocessor directive for a static link.])
SHLIB_CREATEPROG="ar rcs"
SHLIB_SOEXT="a"
SHLIB_LIBEXT="a"
fi
AC_SUBST(STATIC_LINK)
AC_SUBST(STATIC_LINK_PAR)
AC_SUBST(STATIC_LINK_DBS)
#
# Check for CMake
#
......@@ -1452,11 +1484,11 @@ if test -n "$VTK"; then
VTK_DIR=$VTK
VTK_INCROOT="$""(TOPDIR)/include/vtk"
VTK_INCLUDES="-I$VTK_INCROOT -I$VTK_INCROOT/vtk-5.0"
VTK_LIBS="-lvtkCommon -lvtkDICOMParser -lvtkFiltering -lvtkGraphics -lvtkHybrid -lvtkIO -lvtkImaging -lvtkRendering -lvtkzlib -lvtkexpat -lvtkjpeg -lvtkpng -lvtktiff -lvtkftgl -lvtkfreetype -lvtksys -lvtkMPEG2Encode "
VTK_LIBS="-lvtkDICOMParser -lvtkHybrid -lvtkIO -lvtkImaging -lvtkRendering -lvtkGraphics -lvtkFiltering -lvtkCommon -lvtkexpat -lvtkjpeg -lvtkpng -lvtktiff -lvtkftgl -lvtkfreetype -lvtkzlib -lvtksys -lvtkMPEG2Encode"
if test "$UNAME" = "Darwin"; then
VTK_LIGHTWEIGHT_LIBS=$VTK_LIBS
else
VTK_LIGHTWEIGHT_LIBS="-lvtkCommon -lvtkFiltering -lvtkzlib -lvtkexpat -lvtksys"
VTK_LIGHTWEIGHT_LIBS="-lvtkFiltering -lvtkCommon -lvtkzlib -lvtkexpat -lvtksys"
fi
# Determine whether VTK was built with mangled Mesa support. If it wasn't
......@@ -3928,9 +3960,13 @@ case $UNAME in
SHLIB_CREATEPROG="$""(CXX) -shared -o"
fi
# Set RPATH relative to executable
EXE_LDFLAGS="$EXE_LDFLAGS -Wl,--rpath,\\\$\$ORIGIN/../lib"
PLUGIN_LDFLAGS="$PLUGIN_LDFLAGS -Wl,--rpath,\\\$\$ORIGIN/../../lib"
DATA_EXE_LDFLAGS="$DATA_EXE_LDFLAGS -Wl,--rpath,\\\$\$ORIGIN/../src/lib"
if test "$enable_static" = yes; then
EXE_LDFLAGS="-L$""(TOPDIR)/lib/"
else
EXE_LDFLAGS="$EXE_LDFLAGS -Wl,--rpath,\\\$\$ORIGIN/../lib"
PLUGIN_LDFLAGS="$PLUGIN_LDFLAGS -Wl,--rpath,\\\$\$ORIGIN/../../lib"
DATA_EXE_LDFLAGS="$DATA_EXE_LDFLAGS -Wl,--rpath,\\\$\$ORIGIN/../src/lib"
fi
fi
;;
......@@ -4221,7 +4257,9 @@ operatorplugindir="$""(TOPDIR)/plugins/operators"
AC_SUBST(databaseplugindir)
databaseplugindir="$""(TOPDIR)/plugins/databases"
LDFLAGS="-L$libdir $LDFLAGS"
if test ! "$enable_static" = yes; then
LDFLAGS="-L$libdir $LDFLAGS"
fi
dnl
......@@ -4247,6 +4285,7 @@ if test -n "$METADATA_SERVER"; then
MDSERVER_FILES="mdserver/Makefile
mdserver/rpc/Makefile
mdserver/proxy/Makefile
mdserver/ssl/Makefile
mdserver/main/Makefile"
else
MDSERVER_FILES=""
......@@ -4279,6 +4318,7 @@ if test -n "$ENGINE"; then
ENGINE_FILES="engine/Makefile
engine/rpc/Makefile
engine/proxy/Makefile
engine/ssl/Makefile
engine/main/Makefile"
else
ENGINE_FILES=""
......@@ -4469,7 +4509,7 @@ if test "$enable_engine_only" = yes; then
VISITPY_FILES=""
CQSCORE_FILES=""
JAVA_FILES=""
TOOLS_FILES=""
TOOLS_FILES="tools/xml/Makefile"
COMPONENT_FILES="avt/Makefile
avt/DBAtts/Makefile
avt/DDF/Makefile
......@@ -4501,7 +4541,7 @@ if test "$enable_server_components_only" = yes; then
VISITPY_FILES=""
CQSCORE_FILES=""
JAVA_FILES=""
TOOLS_FILES=""
TOOLS_FILES="tools/xml/Makefile"
COMPONENT_FILES="avt/Makefile
avt/DBAtts/Makefile
avt/DDF/Makefile
......@@ -4520,6 +4560,9 @@ if test "$enable_server_components_only" = yes; then
avt/View/Makefile
avt/VisWindow/Makefile"
fi
if test "$enable_static" = yes; then
SUBDIRS="$""(SUBDIRS_STATIC_LINK)"
fi
AC_OUTPUT($STANDARD_FILES
$GUI_FILES
......
......@@ -38,10 +38,6 @@
#include <ANALYZEPluginInfo.h>
#if defined(__APPLE__)
#define GetEngineInfo ANALYZE_GetEngineInfo
#endif
// ****************************************************************************
// Function: GetEngineInfo
//
......@@ -52,7 +48,7 @@
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT EngineDatabasePluginInfo* GetEngineInfo()
extern "C" DBP_EXPORT EngineDatabasePluginInfo* ANALYZE_GetEngineInfo()
{
return new ANALYZEEnginePluginInfo;
}
......
......@@ -38,10 +38,6 @@
#include <ANALYZEPluginInfo.h>
#if defined(__APPLE__)
#define GetMDServerInfo ANALYZE_GetMDServerInfo
#endif
// ****************************************************************************
// Function: GetMDServerInfo
//
......@@ -52,7 +48,7 @@
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT MDServerDatabasePluginInfo* GetMDServerInfo()
extern "C" DBP_EXPORT MDServerDatabasePluginInfo* ANALYZE_GetMDServerInfo()
{
return new ANALYZEMDServerPluginInfo;
}
......
......@@ -43,15 +43,7 @@
#include <ANALYZEPluginInfo.h>
#include <visit-config.h>
#if defined(__APPLE__)
extern "C" DBP_EXPORT const char *ANALYZEVisItPluginVersion = VISIT_VERSION;
#else
extern "C" DBP_EXPORT const char *VisItPluginVersion = VISIT_VERSION;
#endif
#if defined(__APPLE__)
#define GetGeneralInfo ANALYZE_GetGeneralInfo
#endif
// ****************************************************************************
// Function: GetGeneralInfo
......@@ -63,7 +55,7 @@ extern "C" DBP_EXPORT const char *VisItPluginVersion = VISIT_VERSION;
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT GeneralDatabasePluginInfo* GetGeneralInfo()
extern "C" DBP_EXPORT GeneralDatabasePluginInfo* ANALYZE_GetGeneralInfo()
{
return new ANALYZEGeneralPluginInfo;
}
......
......@@ -38,10 +38,6 @@
#include <ANSYSPluginInfo.h>
#if defined(__APPLE__)
#define GetEngineInfo ANSYS_GetEngineInfo
#endif
// ****************************************************************************
// Function: GetEngineInfo
//
......@@ -52,7 +48,7 @@
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT EngineDatabasePluginInfo* GetEngineInfo()
extern "C" DBP_EXPORT EngineDatabasePluginInfo* ANSYS_GetEngineInfo()
{
return new ANSYSEnginePluginInfo;
}
......
......@@ -38,10 +38,6 @@
#include <ANSYSPluginInfo.h>
#if defined(__APPLE__)
#define GetMDServerInfo ANSYS_GetMDServerInfo
#endif
// ****************************************************************************
// Function: GetMDServerInfo
//
......@@ -52,7 +48,7 @@
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT MDServerDatabasePluginInfo* GetMDServerInfo()
extern "C" DBP_EXPORT MDServerDatabasePluginInfo* ANSYS_GetMDServerInfo()
{
return new ANSYSMDServerPluginInfo;
}
......
......@@ -43,15 +43,7 @@
#include <ANSYSPluginInfo.h>
#include <visit-config.h>
#if defined(__APPLE__)
extern "C" DBP_EXPORT const char *ANSYSVisItPluginVersion = VISIT_VERSION;
#else
extern "C" DBP_EXPORT const char *VisItPluginVersion = VISIT_VERSION;
#endif
#if defined(__APPLE__)
#define GetGeneralInfo ANSYS_GetGeneralInfo
#endif
// ****************************************************************************
// Function: GetGeneralInfo
......@@ -63,7 +55,7 @@ extern "C" DBP_EXPORT const char *VisItPluginVersion = VISIT_VERSION;
// Creation: omitted
//
// ****************************************************************************
extern "C" DBP_EXPORT GeneralDatabasePluginInfo* GetGeneralInfo()
extern "C" DBP_EXPORT GeneralDatabasePluginInfo* ANSYS_GetGeneralInfo()
{
return new ANSYSGeneralPluginInfo;
}
......
......@@ -38,10 +38,6 @@
#include <AUXFilePluginInfo.h>
#if defined(__APPLE__)
#define GetEngineInfo AUXFile_GetEngineInfo
#endif
// ****************************************************************************
// Function: GetEngineInfo
//
......@@ -52,7 +48,7 @@
// Creation: omitted