aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-06 12:12:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-06 12:12:42 +0200
commitf0016899eec4ff2ad61ef56a21e4132dd314a37f (patch)
tree74601096d27e17fcfb34dcf9ae1094795006b6e0 /odb
parenta93f1b71722cc8862350614dca56e162aca2aa07 (diff)
Install plugin to pkgexecdir instead of bindir
Diffstat (limited to 'odb')
-rw-r--r--odb/Makefile.am4
-rw-r--r--odb/makefile2
-rw-r--r--odb/odb.cxx82
3 files changed, 56 insertions, 32 deletions
diff --git a/odb/Makefile.am b/odb/Makefile.am
index 1fa8298..5b976ea 100644
--- a/odb/Makefile.am
+++ b/odb/Makefile.am
@@ -2,7 +2,7 @@
# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
# license : GNU GPL v3; see accompanying LICENSE file
-plugindir = $(bindir)
+plugindir = $(pkglibexecdir)
bin_PROGRAMS = odb
plugin_LTLIBRARIES = odb.la
@@ -19,7 +19,7 @@ odb_la_LDFLAGS = -module -shrext .so -avoid-version
# Remove the .la file from the final install.
#
install-data-hook:
- rm -f '$(DESTDIR)/$(bindir)/odb.la'
+ rm -f '$(DESTDIR)$(pkglibexecdir)/odb.la'
# Driver.
#
diff --git a/odb/makefile b/odb/makefile
index c127ce5..f60da13 100644
--- a/odb/makefile
+++ b/odb/makefile
@@ -282,7 +282,7 @@ ifdef cxx_gnu
$(cxx_pobj) $(cxx_cobj): cxx_pic_options := -fPIC
$(cxx_cobj) $(cxx_cod): cpp_options := -I$(src_root)
-$(cxx_dobj) $(cxx_dod): cpp_options := -I$(src_root) '-DGXX_NAME="$(cxx_gnu)"'
+$(cxx_dobj) $(cxx_dod): cpp_options := -I$(src_root) '-DODB_GXX_NAME="$(cxx_gnu)"'
$(cxx_pobj) $(cxx_pod): cpp_options := -I$(src_root) \
-I$(shell $(cxx_gnu) -print-file-name=plugin)/include
diff --git a/odb/odb.cxx b/odb/odb.cxx
index 73aa6bd..2aa2ef2 100644
--- a/odb/odb.cxx
+++ b/odb/odb.cxx
@@ -141,7 +141,7 @@ main (int argc, char* argv[])
// Find the plugin. It should be in the same directory as the
// driver.
//
-#ifndef STATIC_PLUGIN
+#ifndef ODB_STATIC_PLUGIN
path plugin (plugin_path (path (argv[0])));
#else
// Use a dummy name if the plugin is linked into the compiler.
@@ -163,8 +163,8 @@ main (int argc, char* argv[])
// The first argument points to the program name, which is
// g++ by default.
//
-#ifdef GXX_NAME
- path gxx (GXX_NAME);
+#ifdef ODB_GXX_NAME
+ path gxx (ODB_GXX_NAME);
if (gxx.empty ())
{
@@ -224,7 +224,7 @@ main (int argc, char* argv[])
#else
args.push_back ("g++");
-#endif // GXX_NAME
+#endif // ODB_GXX_NAME
// Default options.
//
@@ -240,9 +240,9 @@ main (int argc, char* argv[])
//
strings def_inc_dirs;
strings def_defines;
-#ifdef DEFAULT_OPTIONS_FILE
+#ifdef ODB_DEFAULT_OPTIONS_FILE
{
- path file (DEFAULT_OPTIONS_FILE);
+ path file (ODB_DEFAULT_OPTIONS_FILE);
// If the path is relative, then use the driver's path as a base.
//
@@ -1389,40 +1389,64 @@ driver_path (path const& drv)
return drv.directory ().empty () ? path_search (drv) : drv;
}
-#ifndef STATIC_PLUGIN
+#ifndef ODB_STATIC_PLUGIN
static path
plugin_path (path const& drv)
{
+ // Figure out the plugin base name which is just the driver name.
+ // If the driver name starts with 'lt-', then we are running through
+ // the libtool script. Strip this prefix -- the shared object should
+ // be in the same directory.
+ //
+ string b (drv.leaf ().string ());
+ bool lt (b.size () > 3 && b[0] == 'l' && b[1] == 't' && b[2] == '-');
+ if (lt)
+ b = string (b, 3, string::npos);
+
path dp (driver_path (drv));
- if (!dp.empty ())
- {
- // If the driver name starts with 'lt-', then we are running through
- // the libtool script. Strip this prefix -- the shared object should
- // be in the same directory.
- //
- {
- string n (dp.leaf ().string ());
+ if (dp.empty ())
+ return path (); // Fail.
- if (n.size () > 3 && n[0] == 'l' && n[1] == 't' && n[2] == '-')
- dp = dp.directory () / path (string (n, 3, string::npos));
- }
+ dp = dp.directory ();
+ struct stat info;
- struct stat info;
+ // Regardless of whether we were given a plugin path, first try
+ // the current directory for the .la file. This will make sure
+ // running ODB from the build directory works as expected.
+ //
+ path pp (dp / path (b + ".la"));
+ if (stat (pp.string ().c_str (), &info) == 0)
+ {
+ pp = dp / path (".libs") / path (b + ".so");
+ if (stat (pp.string ().c_str (), &info) == 0)
+ return pp;
+ }
- path so (dp + ".so");
- if (stat (so.string ().c_str (), &info) == 0)
- return so;
+#ifdef ODB_PLUGIN_PATH
+ // If we were given a plugin path, use that unless we are running
+ // via libtool.
+ //
+ if (!lt)
+ {
+ string rp (ODB_PLUGIN_PATH);
+ pp = dp;
+ if (!rp.empty ())
+ pp /= path (rp);
+ pp /= path (b + ".so");
- path la (dp + ".la");
- if (stat (la.string ().c_str (), &info) == 0)
- {
- so = la.directory () / path (".libs") / dp.leaf () + ".so";
+ if (stat (pp.string ().c_str (), &info) == 0)
+ return pp;
- if (stat (so.string ().c_str (), &info) == 0)
- return so;
- }
+ return path (); // Fail.
}
+#endif
+
+ // Try .so in the current directory.
+ //
+ pp = dp / path (b + ".so");
+ if (stat (pp.string ().c_str (), &info) == 0)
+ return pp;
return path ();
}