[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
constructing shared libraries
From: |
Steven_Shaw |
Subject: |
constructing shared libraries |
Date: |
Sat, 14 Apr 2001 01:03:26 +1000 |
Hi,
I'm attempting to build a cons::SharedLibrary that is able to build shared
libraries on AIX/HP-UX/Solaris/Linux/NT. I already have existing Makefiles which
do this so I've got somewhere to start from :-). I've worked with the code from
the faq a bit. I'm learning the more esoteric things about Perl all the time but
I'm still unsure of my code (I've been getting tricked up by references...). The
following is my cons::SharedLibrary (which so far appears to work on AIX). On
AIX you have to generate a .exp file to be used in the link process. I've
specified that this .exp file depends on the .o built from the .c files (but in
a truly hacky way - just search/replaced stuff). I know there is a better way
but I don't understand cons internals yet. Also, I'm unsure how to make this
portable.
# vim: syntax=perl tabstop=8 shiftwidth=4 expandtab
################################################################################
# cons::SharedLibrary
################################################################################
sub cons::SharedLibrary {
my($env) = shift;
my($target) = shift;
my(@sources) = @_;
my (@objects) = ();
# $env->debug();
foreach my $source (@sources) {
#print STDERR ">>> \$source = $source\n";
$object = $source;
$object =~ s/\.c$//; # XXX super dodgy code here
FIXME
$object = "$object.o";
#print STDERR ">>> \$object = ", $object, "\n";
@objects = ($object, @objects);
}
#foreach my $object (@objects) {
# print STDERR ">>> \$object = $object\n";
#}
# ensure shared library has prefix and suffix
$target = $env->{'PREFLIB'} . file::addsuffix($target, $env->{'SUFSHLIB'});
my ($expFile) = "$target.exp";
#print "cons::SharedLibrary \$target='$target'\n";
#print "cons::SharedLibrary \$expFile='$expFile'\n";
$env->Command("$expFile", @objects, "%EXPORTSFILE %> '' %<");
$env->Depends("$target", "$expFile");
my($lib) = $dir::cwd->lookup($target);
my($libenv) = $env->_resolve($lib);
my $builder = find build::command::link($libenv, $libenv->{'SHLINKCOM'});
$lib->bind($builder, $env->_Objects(map($dir::cwd->lookup($_), @sources)));
}
Can anyone point out a better way of doing this or just some nasty un-Perl-like
things in my code?
Anyone got a working cons::SharedLibrary that works for many platforms?
I had a feeling that cons::Module and/or cons::LinkedModule might come into the
good solution but I had no luck trying to use them...
cheers,
Steve.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- constructing shared libraries,
Steven_Shaw <=