"libbar" everywhere?), it does make sense when it can be used
conditionally. See a little further below for an example.
+In some cases, it's desirable to include some source files in the
+shared form of a library only:
+
+ SHARED_SOURCE[libfoo]=dllmain.c
+
For any file to be built, it's also possible to tell what extra
include paths the build of their source files should use:
$OUT .= libobj2shlib(shlib => $unified_info{sharednames}->{$lib},
lib => $lib,
objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
- @{$unified_info{sources}->{$lib}} ],
+ (@{$unified_info{sources}->{$lib}},
+ @{$unified_info{shared_sources}->{$lib}}) ],
deps => [ reducedepends(resolvedepends($lib)) ],
%ordinals);
+ map { doobj($_, $lib, intent => "lib") } @{$unified_info{shared_sources}->{$lib}};
}
$OUT .= obj2lib(lib => $lib,
objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
return "" if $cache{$lib};
$OUT .= obj2dso(lib => $lib,
objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
- @{$unified_info{sources}->{$lib}} ],
+ (@{$unified_info{sources}->{$lib}},
+ @{$unified_info{shared_sources}->{$lib}}) ],
deps => [ resolvedepends($lib) ]);
- map { doobj($_, $lib, intent => "dso") } @{$unified_info{sources}->{$lib}};
+ map { doobj($_, $lib, intent => "dso") } (@{$unified_info{sources}->{$lib}},
+ @{$unified_info{shared_sources}->{$lib}});
$cache{$lib} = 1;
}
my %ordinals = ();
my %sources = ();
+ my %shared_sources = ();
my %includes = ();
my %depends = ();
my %renames = ();
qr/^\s*SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
=> sub { push @{$sources{$1}}, split(/\s+/, $2)
if !@skip || $skip[$#skip] > 0 },
+ qr/^\s*SHARED_SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
+ => sub { push @{$shared_sources{$1}}, split(/\s+/, $2)
+ if !@skip || $skip[$#skip] > 0 },
qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
=> sub { push @{$includes{$1}}, split(/\s+/, $2)
if !@skip || $skip[$#skip] > 0 },
}
}
+ foreach (keys %shared_sources) {
+ my $dest = $_;
+ my $ddest = cleanfile($buildd, $_, $blddir);
+ if ($unified_info{rename}->{$ddest}) {
+ $ddest = $unified_info{rename}->{$ddest};
+ }
+ foreach (@{$shared_sources{$dest}}) {
+ my $s = cleanfile($sourced, $_, $blddir);
+
+ # If it isn't in the source tree, we assume it's generated
+ # in the build tree
+ if (! -f $s) {
+ $s = cleanfile($buildd, $_, $blddir);
+ }
+ # We recognise C and asm files
+ if ($s =~ /\.[csS]\b$/) {
+ (my $o = $_) =~ s/\.[csS]\b$/.o/;
+ $o = cleanfile($buildd, $o, $blddir);
+ $unified_info{shared_sources}->{$ddest}->{$o} = 1;
+ $unified_info{sources}->{$o}->{$s} = 1;
+ } else {
+ die "unrecognised source file type for shared library: $s\n";
+ }
+ }
+ }
+
foreach (keys %generate) {
my $dest = $_;
my $ddest = cleanfile($buildd, $_, $blddir);
$unified_info{$_} = [ sort keys %{$unified_info{$_}} ];
}
# Two level structures
- foreach my $l1 (("sources", "ldadd", "depends")) {
+ foreach my $l1 (("sources", "shared_sources", "ldadd", "depends")) {
foreach my $l2 (sort keys %{$unified_info{$l1}}) {
$unified_info{$l1}->{$l2} =
[ sort keys %{$unified_info{$l1}->{$l2}} ];