summaryrefslogtreecommitdiff
path: root/makeheader.pl
blob: 58d587ea31dfe6e892b72eb7827b95e704f3e63b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl -w

use strict;

my ($basename, $midname, $endname, $infilename, $outfilename) = @ARGV;

my $perl = $ENV{PERL};

my $output_text = `$perl bin2c.pl THINGY < $infilename`;

$output_text =~ s/unsigned char THINGY\[\]/const unsigned char $basename\[\]/;

my $objlen = ($output_text =~ /unsigned int THINGY_len = (\d+)/)[0];

$output_text =~ s/unsigned int THINGY_len = (\d+)/const unsigned char \*$endname = $basename + $1/;

my $repltext = "const unsigned char \*$midname = $basename + $objlen - 4;";
$repltext = "" if ($midname eq '');

$output_text =~ s/int THINGY_mtime = \d+;/$repltext/;

open JELLY, ">", $outfilename;

print JELLY $output_text;

close JELLY;