diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-27 19:15:00 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-27 19:15:00 -0700 |
commit | 6c9b3fcb03f5597954e00ef3303c769baf1336a6 (patch) | |
tree | 688c44db2524d32783321e6b8dd4908282319a38 /libinstaller | |
parent | 34763a8075ac5f9a7f5ea3d3e420d1efc67c4441 (diff) | |
download | lwip-6c9b3fcb03f5597954e00ef3303c769baf1336a6.tar.gz lwip-6c9b3fcb03f5597954e00ef3303c769baf1336a6.tar.xz lwip-6c9b3fcb03f5597954e00ef3303c769baf1336a6.zip |
Build _bin.c files in libinstaller; clean up B/I separation
Clean up the BSUBDIR/ISUBDIR separation further. Build _bin.c files,
which are an intermediate stage toward building the installers, in the
libinstaller directory, since that directory is used by all the
installers anyway. That also lets us get bin2c.pl out of the root.
Diffstat (limited to 'libinstaller')
-rw-r--r-- | libinstaller/Makefile | 35 | ||||
-rwxr-xr-x | libinstaller/bin2c.pl | 78 |
2 files changed, 113 insertions, 0 deletions
diff --git a/libinstaller/Makefile b/libinstaller/Makefile new file mode 100644 index 00000000..ef3711dd --- /dev/null +++ b/libinstaller/Makefile @@ -0,0 +1,35 @@ +# _bin.c files required by both BTARGET and ITARGET installers +BINFILES = bootsect_bin.c ldlinux_bin.c \ + extlinux_bss_bin.c extlinux_sys_bin.c \ + mbr_bin.c gptmbr_bin.c + +PERL = perl + +all: $(BINFILES) + +bootsect_bin.c: ../core/ldlinux.bss bin2c.pl + $(PERL) bin2c.pl syslinux_bootsect < $< > $@ + +ldlinux_bin.c: ../core/ldlinux.sys bin2c.pl + $(PERL) bin2c.pl syslinux_ldlinux < $< > $@ + +extlinux_bss_bin.c: ../core/extlinux.bss bin2c.pl + $(PERL) bin2c.pl extlinux_bootsect < $< > $@ + +extlinux_sys_bin.c: ../core/extlinux.sys bin2c.pl + $(PERL) bin2c.pl extlinux_image 512 < $< > $@ + +mbr_bin.c: ../mbr/mbr.bin bin2c.pl + $(PERL) bin2c.pl syslinux_mbr < $< > $@ + +gptmbr_bin.c: ../mbr/gptmbr.bin bin2c.pl + $(PERL) bin2c.pl syslinux_gptmbr < $< > $@ + +tidy: + rm -f $(BINFILES) + +clean: tidy + +dist: tidy + +spotless: clean diff --git a/libinstaller/bin2c.pl b/libinstaller/bin2c.pl new file mode 100755 index 00000000..5a60ca9e --- /dev/null +++ b/libinstaller/bin2c.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl +## ----------------------------------------------------------------------- +## +## Copyright 1998-2008 H. Peter Anvin - All Rights Reserved +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, Inc., 53 Temple Place Ste 330, +## Boston MA 02111-1307, USA; either version 2 of the License, or +## (at your option) any later version; incorporated herein by reference. +## +## ----------------------------------------------------------------------- + +# +# bin2c.pl: binary file to C source converter +# + +eval { use bytes; }; +eval { binmode STDIN; }; + +($table_name, $pad) = @ARGV; + +if ( !defined($table_name) ) { + print STDERR "Usage: $0 table_name [pad] < input_file > output_file\n"; + exit 1; +} + +$pad = 1 if ($pad < 1); + +printf "unsigned char %s[] = {\n", $table_name; + +$pos = 0; +$linelen = 8; + +$total_len = 0; + +while ( ($n = read(STDIN, $data, 4096)) > 0 ) { + $total_len += $n; + for ( $i = 0 ; $i < $n ; $i++ ) { + $byte = substr($data, $i, 1); + if ( $pos >= $linelen ) { + print ",\n\t"; + $pos = 0; + } elsif ( $pos > 0 ) { + print ", "; + } else { + print "\t"; + } + printf("0x%02x", unpack("C", $byte)); + $pos++; + } +} + +$align = $total_len % $pad; +if ($align != 0) { + $n = $pad - $align; + $total_len += $n; + for ( $i = 0 ; $i < $n ; $i++ ) { + if ( $pos >= $linelen ) { + print ",\n\t"; + $pos = 0; + } elsif ( $pos > 0 ) { + print ", "; + } else { + print "\t"; + } + print '0x00'; + $pos++; + } +} + +printf "\n};\n\nunsigned int %s_len = %u;\n", $table_name, $total_len; + +@st = stat STDIN; + +printf "\nint %s_mtime = %d;\n", $table_name, $st[9]; + +exit 0; |