19780544fSAndrew Rist#**************************************************************
29780544fSAndrew Rist#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
109780544fSAndrew Rist#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
129780544fSAndrew Rist#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
199780544fSAndrew Rist#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage macosxotoolhelper;
25cdf0e10cSrcweirrequire Exporter;
26cdf0e10cSrcweirour @ISA = Exporter;
27cdf0e10cSrcweirour @EXPORT = otoolD;
28cdf0e10cSrcweir
29*8badc1b4SHerbert Dürruse File::Basename;
30*8badc1b4SHerbert Dürr$::CC_PATH=(fileparse( $ENV{"CC"}))[1];
31*8badc1b4SHerbert Dürr
32cdf0e10cSrcweirsub otoolD($) {
33cdf0e10cSrcweir    my ($file) = @_;
34cdf0e10cSrcweir    my $call = "otool -D $file";
35cdf0e10cSrcweir    open(IN, "-|", $call) or die "cannot $call";
36cdf0e10cSrcweir    my $line = <IN>;
37e0c61c1eSHerbert Dürr    if( $line !~ /^\Q$file\E:\n$/ ) {
38cdf0e10cSrcweir        die "unexpected otool -D output (\"$line\", expecting \"$file:\")";
39e0c61c1eSHerbert Dürr    }
40cdf0e10cSrcweir    $line = <IN>;
41cdf0e10cSrcweir    <IN> == undef or die "unexpected otool -D output";
42cdf0e10cSrcweir    close(IN);
43cdf0e10cSrcweir    return $line;
44cdf0e10cSrcweir}
45*8badc1b4SHerbert Dürr
46