From f8b0329393561cd85cbdb27f32822cdb66b9be23 Mon Sep 17 00:00:00 2001 From: hpa Date: Tue, 3 Feb 1998 17:46:02 +0000 Subject: [PATCH] Changing Linux installer to be a C program. --- Makefile | 22 +++++++++++++++------- bin2c.pl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ syslinux.pl.in | 30 ------------------------------ 3 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 bin2c.pl delete mode 100644 syslinux.pl.in diff --git a/Makefile b/Makefile index 7dc8e0f..9eb9d91 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,12 @@ # NASM = nasm +CC = gcc +CFLAGS = -Wall -O2 -fomit-frame-pointer +LDFLAGS = -O2 -s + +.c.o: + $(CC) $(CFLAGS) -c $< all: bootsect.bin ldlinux.sys syslinux.com syslinux @@ -34,15 +40,17 @@ syslinux.com: syslinux.asm bootsect.bin ldlinux.sys $(NASM) -f bin -l syslinux.lst -o syslinux.com syslinux.asm ls -l syslinux.com -syslinux: syslinux.pl.in bootsect.bin ldlinux.sys - @if [ ! -x `which perl` ]; then \ - echo 'ERROR: cannot find perl'; exit 1 ; fi - echo '#!' `which perl` > syslinux - cat syslinux.pl.in bootsect.bin ldlinux.sys >> syslinux - chmod a+x syslinux +bootsect_bin.c: bootsect.bin bin2c.pl + perl bin2c.pl bootsect < bootsect.bin > bootsect_bin.c + +ldlinux_bin.c: ldlinux.sys bin2c.pl + perl bin2c.pl ldlinux < ldlinux.sys > ldlinux_bin.c + +syslinux: syslinux.o bootsect_bin.o ldlinux_bin.o + $(CC) $(LDFLAGS) -o syslinux syslinux.o bootsect_bin.o ldlinux_bin.o clean: - rm -f *.bin *.lst *.sys + rm -f *.bin *.lst *.sys *_bin.c syslinux syslinux.com distclean: clean rm -f *~ \#* diff --git a/bin2c.pl b/bin2c.pl new file mode 100644 index 0000000..2a9c0f8 --- /dev/null +++ b/bin2c.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# $Id$ +# ----------------------------------------------------------------------- +# +# Copyright 1998 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., 675 Mass Ave, Cambridge MA 02139, +# 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 +# + +if ( $#ARGV != 0 ) { + print STDERR "Usage: $0 table_name < input_file > output_file\n"; + exit 1; +} + +($table_name) = @ARGV; + +printf "const 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++; + } +} + +printf "\n};\n\nconst unsigned int %s_len = %u;\n", $table_name, $total_len; + diff --git a/syslinux.pl.in b/syslinux.pl.in deleted file mode 100644 index cf326fa..0000000 --- a/syslinux.pl.in +++ /dev/null @@ -1,30 +0,0 @@ -# Hey, Emacs, this is -*- perl -*- -# $Id$ -## ----------------------------------------------------------------------- -## -## Copyright 1998 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., 675 Mass Ave, Cambridge MA 02139, -## USA; either version 2 of the License, or (at your option) any later -## version; incorporated herein by reference. -## -## ----------------------------------------------------------------------- -# -# SYSLINUX install script for use in a Linux environment -# - -# -# 1. Find out a location where we can mount the device -# - -if ( getuid() == 0 ) { - $tmp = 0; - while ( -e "/tmp/mnt.$$.$tmp" ) { $tmp++; } - $mntdir = "/tmp/mnt.$$.$tmp"; - mkdir($mntdir, 0700); -} else { - # Search fstab for device -} - -- 2.7.4