2 eval 'exec perl -S $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: make_patched_header.pl,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
35 # make_patched_header - make patched header
43 my $patched_file = shift @ARGV;
44 $patched_file =~ s/\\/\//g
;
45 my $module = shift @ARGV;
46 my $patch_dir = dirname
($patched_file);
47 my $orig_file = $patched_file;
48 $orig_file =~ s/\/patched\//\//;
50 if (!-f
$orig_file) { carp
("Cannot find file $orig_file\n"); };
52 mkpath
($patch_dir, 0, 0775);
53 if (!-d
$patch_dir) {("mkdir: could not create directory $patch_dir\n"); };
56 open(PATCHED_FILE
, ">$patched_file") or carp
("Cannot open file $patched_file\n");
57 open(ORIG_FILE
, "<$orig_file") or carp
("Cannot open file $orig_file\n");
58 foreach (<ORIG_FILE
>) {
59 if (/#include\s*"(\w+\.h\w*)"/) {
61 s/#include "$include"/#include <$module\/$include>/g
;
63 print PATCHED_FILE
$_;