| 1 | #!/home/ben/software/install/bin/perl | ||
| 2 | use Z; | ||
| 3 | my $dir = '/home/ben/software/zopfli/zopfli-zopfli-1.0.3/src/zopfli'; | ||
| 4 | my @c = <$dir/*.c>; | ||
| 5 | my @h = <$dir/*.h>; | ||
| 6 | my %h2file; | ||
| 7 | for my $hfile (@h) { | ||
| 8 | my $h = $hfile; | ||
| 9 | $h =~ s!.*/!!; | ||
| 10 | $h2file{$h} = read_text ($hfile); | ||
| 11 | } | ||
| 12 | my $out = "$Bin/zopfli-one.c"; | ||
| 13 | my $c = ''; | ||
| 14 | for my $file (@c) { | ||
| 15 | my $text = read_text ($file); | ||
| 16 | $c .= $text; | ||
| 17 | } | ||
| 18 | # Do this until all the #include "" are gone. | ||
| 19 | while ($c =~ s!^#\s*include\s*"(.*?)"!/* $1 */\n$h2file{$1}!gm) { | ||
| 20 | } | ||
| 21 | # Suppress compiler warnings. | ||
| 22 | $c =~ s!(ZOPFLI_CACHE_LENGTH \* 3 \* blocksize)!(unsigned long) ($1)!g; | ||
| 23 | #$c =~ s!^#\s*include\s*"(.*?)"!/* $1 */\n$h2file{$1}!gm; | ||
| 24 | write_text ($out, $c); | ||
| 25 | do_system ("cc -Wall -c $out"); | ||
| 26 | my $o = $out; | ||
| 27 | $o =~ s!\.c!.o!; | ||
| 28 | unlink ($o) or die $!; |