]>
git.saurik.com Git - apple/libc.git/blob - patchHeaders
3 # Copyright (c) 2006, 2007 Apple Inc. All rights reserved.
5 # @APPLE_LICENSE_HEADER_START@
7 # This file contains Original Code and/or Modifications of Original Code
8 # as defined in and that are subject to the Apple Public Source License
9 # Version 2.0 (the 'License'). You may not use this file except in
10 # compliance with the License. Please obtain a copy of the License at
11 # http://www.opensource.apple.com/apsl/ and read it before using this
14 # The Original Code and all software distributed under the License are
15 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 # Please see the License for the specific language governing rights and
20 # limitations under the License.
22 # @APPLE_LICENSE_HEADER_END@
24 # patchheaders srcdir destdir
26 # The last path component of srcdir is replicated in destdir, with the
27 # __DARWIN_ALIAS* and __DARWIN_EXTSN macro wrapped so that Libc can set
28 # the symbol decoration independently:
30 # #ifndef LIBC_ALIAS_FOO
31 # int foo(int) __DARWIN_ALIAS(foo);
32 # #else /* LIBC_ALIAS_FOO */
33 # int foo(int) LIBC_ALIAS(foo);
34 # #endif /* !LIBC_ALIAS_FOO */
38 use File
::Basename
();
43 my $MyName = File
::Basename
::basename
($0);
47 my($path, $file) = @_;
49 my $p = IO
::File-
>new($path, 'r');
50 die "$MyName: Can't open $path: $!\n" unless defined($p);
51 my $f = IO
::File-
>new($file, 'w');
52 die "$MyName: Can't open $file: $!\n" unless defined($f);
55 if(/^\S/ or /^\s*$/) {
56 my $n = scalar(@save);
59 my($sym) = ($save[$n - 1] =~ /__DARWIN_(?:10\d+|ALIAS|EXTSN|INODE64)[^(]*\(([^)]*)\)/);
68 $f->print("#ifndef LIBC_ALIAS_$sym\n");
72 $save[$n - 1] =~ s/__DARWIN_(10\d+|ALIAS|EXTSN|INODE64)/LIBC_$1/;
73 $f->print("#else /* LIBC_ALIAS_$sym */\n");
75 $f->print("#endif /* !LIBC_ALIAS_$sym */\n");
92 die "Usage: $MyName srcdir dstdir\n";
96 if(-d
$File::Find
::name
) {
97 #print "DIR: $File::Find::name\n";
98 my $dir = File
::Spec-
>join($dest, $File::Find
::name
);
99 File
::Path
::mkpath
($dir, 0, 0755);
101 #print "FIL: $File::Find::name\n";
102 my $file = File
::Spec-
>join($dest, $File::Find
::name
);
103 process
($File::Find
::name
, $file);
107 usage
() unless scalar(@ARGV) == 2;
108 my $start = File
::Basename
::dirname
($ARGV[0]);
109 chdir($start) || die "$MyName: chdir($start): $!\n";
111 File
::Path
::mkpath
($dest, 0, 0755);
112 File
::Find
::find
({wanted
=> \
&wanted
, no_chdir
=> 1}, File
::Basename
::basename
($ARGV[0]));