switch to a 60 bit hash
[httpd-crcsyncproxy.git] / build / mkdep.perl
blob10815d2483628bc18cc7d392248e20876217f13e
1 #!/usr/bin/perl
3 # $Id$
5 # Created: Thu Aug 15 11:57:33 1996 too
6 # Last modified: Mon Dec 27 09:23:56 1999 too
8 # Copyright (c) 1996-1999 Tomi Ollila. All rights reserved.
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.
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.
30 die "Usage: mkdep CPP-command [CPP options] file1 [file2...]\n"
31 if ($#ARGV < 1);
33 $cmdl = shift(@ARGV);
35 $cmdl = "$cmdl " . shift (@ARGV) while ($ARGV[0] =~ /^-[A-Z]/);
37 while ($file = shift(@ARGV))
39 $file =~ s/\.o$/.c/;
41 open(F, "$cmdl $file|");
43 &parseout;
45 close(F);
49 sub initinit
51 %used = ();
52 $of = $file;
53 $of =~ s/\.c$/.lo/;
54 $str = "$of:\t$file";
55 $len = length $str;
58 sub initstr
60 $str = "\t";
61 $len = length $str;
64 sub parseout
66 &initinit;
67 while (<F>)
69 s/\\\\/\//g;
70 next unless (/^# [0-9]* "(.*\.h)"/);
72 next if ($1 =~ /^\//);
74 next if $used{$1};
76 $used{$1} = 1;
78 $nlen = length($1) + 1;
80 if ($len + $nlen > 72)
82 print $str, "\\\n";
83 &initstr;
84 $str = $str . $1;
86 else { $str = $str . " " . $1; }
88 $len += $nlen;
91 print $str, "\n";