1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24use lib ("$ENV{SOLARENV}/bin/modules"); 25use macosxotoolhelper; 26 27sub locate($) 28{ 29 my ($lib) = @_; 30 my $dir; 31 foreach $dir (@dirs) 32 { 33 my $path = "$dir/$lib"; 34 if (-e $path) 35 { 36 return $path; 37 } 38 } 39 return; 40} 41 42sub handle($$) 43{ 44 my ($from, $to) = @_; 45 # wrap -dylib_file in -Wl so that hopefully any used tool whatsoever (e.g., 46 # libtool generated from xmlsec1-1.2.6/configure included in 47 # libxmlsec/download/xmlsec1-1.2.6.tar.gz:1.3) passes it through to the 48 # linker: 49 !($from =~ /,/ || $to =~ /,/) or 50 die "$from:$to contains commas and cannot go into -Wl"; 51 print " -Wl,-dylib_file,$from:$to"; 52 $done{$from} = 1; 53 push(@todo, $to) if (grep {$_ eq $to} @todo) == 0; 54} 55 56foreach (@ARGV) { push(@dirs, $1) if /^-L(.*)$/; } 57foreach (@ARGV) 58{ 59 if (/^-l(.*)$/) 60 { 61 my $loc = locate("lib$1.dylib"); 62 handle($1, $loc) if defined $loc && otoolD($loc) =~ m'^(@.+/.+)\n$'; 63 } 64} 65foreach $file (@todo) 66{ 67 my $call = "${::CC_PATH}otool -L $file"; 68 open(IN, "-|", $call) or die "cannot $call"; 69 while (<IN>) 70 { 71 if (m'^\s*(@.+/([^/]+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$') 72 { 73 my $full = $1; 74 my $loc = locate($2); 75 if (defined $loc) 76 { 77 handle($full, $loc) unless defined $done{$full}; 78 } 79 else 80 { 81 die "unknown $full (from $file)"; 82 } 83 } 84 } 85 close(IN); 86} 87print "\n"; 88