Correcting installation path for /etc/extlinux.d scripts.
[syslinux-debian/hramrach.git] / version.pl
bloba08ce8357900c36019d8705a8e535b80d30f7aeb
1 #!/usr/bin/perl
3 # Read the "version" file and produce some macro declarations
6 use Fcntl;
8 sub defx($$$) {
9 my($def, $name, $val) = @_;
11 $def =~ s/\</${name}/g;
12 $def =~ s/\@/${val}/g;
14 return $def."\n";
17 ($vfile, $vout, $def) = @ARGV;
18 sysopen(VERSION, $vfile, O_RDONLY) or die "$0: Cannot open $vfile\n";
19 $vfile = <VERSION>;
20 chomp $vfile;
21 close(VERSION);
23 unless ( $vfile =~ /^(([0-9]+)\.([0-9]+))\s+([0-9]+)$/ ) {
24 die "$0: Cannot parse version format\n";
26 $version = $1;
27 $vma = $2+0;
28 $vmi = $3+0;
29 $year = $4;
31 sysopen(VI, $vout, O_WRONLY|O_CREAT|O_TRUNC)
32 or die "$0: Cannot create $vout: $!\n";
33 print VI defx($def, 'VERSION', $version);
34 print VI defx($def, 'VERSION_STR', '"'.$version.'"');
35 print VI defx($def, 'VERSION_MAJOR', $vma);
36 print VI defx($def, 'VERSION_MINOR', $vmi);
37 print VI defx($def, 'YEAR', $year);
38 print VI defx($def, 'YEAR_STR', '"'.$year.'"');
39 close(VI);