bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / build / mkdep.perl
1 #!/usr/bin/perl
2 #
3 # $Id: mkdep.perl 106510 2004-11-25 00:08:45Z nd $
4 #
5 # Created: Thu Aug 15 11:57:33 1996 too
6 # Last modified: Mon Dec 27 09:23:56 1999 too
7 #
8 # Copyright (c) 1996-1999 Tomi Ollila.  All rights reserved.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
12 # are met:
13 # 1. Redistributions of source code must retain the above copyright
14 #    notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 #    notice, this list of conditions and the following disclaimer in the
17 #    documentation and/or other materials provided with the distribution.
18
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
22 # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 die "Usage: mkdep CPP-command [CPP options] file1 [file2...]\n"
31   if ($#ARGV < 1);
32
33 $cmdl = shift(@ARGV);
34
35 $cmdl = "$cmdl " . shift (@ARGV) while ($ARGV[0] =~ /^-[A-Z]/);
36   
37 while ($file = shift(@ARGV))
38 {
39     $file =~ s/\.o$/.c/;
40
41     open(F, "$cmdl $file|");
42
43     &parseout;
44
45     close(F);
46 }
47
48
49 sub initinit
50 {
51     %used = ();
52     $of = $file;
53     $of =~ s/\.c$/.lo/;
54     $str = "$of:\t$file";
55     $len = length $str;
56 }
57         
58 sub initstr
59 {
60     $str = "\t";
61     $len = length $str;
62 }
63
64 sub parseout
65 {
66     &initinit;
67     while (<F>)
68     {
69         s/\\\\/\//g;
70         next unless (/^# [0-9]* "(.*\.h)"/);
71
72         next if ($1 =~ /^\//);
73
74         next if $used{$1};
75
76         $used{$1} = 1;
77
78         $nlen = length($1) + 1;
79
80         if ($len + $nlen > 72)
81         {
82             print $str, "\\\n";
83             &initstr;
84             $str = $str . $1;
85         }
86         else { $str = $str . " " . $1; }
87                      
88         $len += $nlen;  
89                      
90     }
91     print $str, "\n";
92 }