incubator-lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject [lucy-dev] Header file installation
Date Fri, 24 Feb 2012 20:54:25 GMT
Greets,

One of the problems we must address in order to enable compiled extensions for
Lucy is the installation of the Lucy C header files.

Because Lucy gets compiled once for every host language installation rather
than once per system, the headers must go in a per-host-install location
rather than a global location such as /usr/local/include (which isn't portable
anyway).  For Perl, the logical place would seem to be the perl 5 lib
directories.

The DBI distro provides a useful example.  It installs its .h files into the
architecture-specific tree of the lib dirs, and the docs for DBI::DBD show how
to use the function dbd_dbi_arch_dir() to build a list of include dirs:

    http://search.cpan.org/perldoc?DBI::DBD

              my $dbi_arch_dir = dbd_dbi_arch_dir();
              if (exists($opts{INC})) {
                  return {INC => "$opts{INC} -I$dbi_arch_dir"};
              } else {
                  return {INC => "-I$dbi_arch_dir"};
              }

See also the Makefile.PL for DBD::Pg for an adaptation of the instructions in
DBI::DBD.

We can provide similar functionality from Lucy.pm.  Here's how a build script
for a distro which extends Lucy might use it:

  eval "use Lucy;";
  if ($@) {
    warn "Can't load Lucy;
    exit(0);
  }
  my $include_dirs = Lucy->include_dirs;
  my $inc = "";
  $inc .= "-I$_ " for @$include_dirs;

At first, I imagine include_dirs() returning only a single directory.
However, in the future we may break out Clownfish, and perhaps include_dirs()
should return the include paths for recursive dependencies:

  package Lucy;
  use Clownfish;

  sub include_dirs {
    my $dirs = Clownfish->include_dirs;
    push @$dirs, _lucy_include_dir();
    return $dirs;
  }

For the actual header tree, how about a dedicated directory at the following
location?

    catdir( $ARCH_DIR, 'auto', 'Lucy', '_include' );

Thoughts?

Marvin Humphrey


Mime
View raw message