Minor syntactical changes for readability.
[xuni.git] / src / gendepend.pl
blob841255861e035749c0af0aa4d879e5d961bac71a
1 #!/usr/bin/perl
3 use strict;
5 print "# Dependency list automatically generated by gendepend.pl\n\n";
7 &concatenate_lines();
9 sub process_line {
10 my $line = shift;
11 my $max = 78;
12 my $first = 1;
14 $line =~ s|/usr/include/\S+||g; # remove SDL etc header files
15 $line =~ s/ +/ /g; # remove duplicate spaces
17 while($line =~ /(.{1,$max})(\s|$)/g) {
18 if($first) {
19 $first = 0;
20 $max -= 4;
22 else {
23 print " \\\n ";
26 print "$1";
29 print "\n\n";
32 sub concatenate_lines {
33 my $line = '';
35 while(<>) {
36 chomp; # remove newline
38 if(!/:/) {
39 $line =~ s/\\$//; # remove trailing backslash
40 $line .= ' ' . $_;
42 else {
43 if($line ne '') { # if it's not the first line
44 &process_line($line);
47 $line = $_;
51 if($line ne '') {
52 &process_line($line);