ports

morpheus ports
git clone git://git.2f30.org/ports.git
Log | Files | Refs | LICENSE

commit 3595fda05738b7a29253724819a5d879e8fff74a
parent 232e950b8b68f912582085bf5f42341f9fc0434c
Author: Daniel Bainton <dpb@driftaway.org>
Date:   Sat Mar 29 22:03:57 +0000

Add extlinux

Diffstat:
extlinux/bin2c.c | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
extlinux/extlinux.mk | 31+++++++++++++++++++++++++++++++
extlinux/mkfile | 7+++++++
3 files changed, 141 insertions(+), 0 deletions(-)
diff --git a/extlinux/bin2c.c b/extlinux/bin2c.c @@ -0,0 +1,103 @@ +/* + * This is bin2c program, which allows you to convert binary file to + * C language array, for use as embedded resource, for instance you can + * embed graphics or audio file directly into your program. + * This is public domain software, use it on your own risk. + * Contact Serge Fukanchik at fuxx@mail.ru if you have any questions. + * + * Some modifications were made by Gwilym Kuiper (kuiper.gwilym@gmail.com) + * He decided not to change the licence. + * + * Some modifications were made by Daniel Bainton (dpb@driftaway.org) + * He decided not to change the licence. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> +#include <sys/stat.h> + +int +main(int argc, char* argv[]) +{ + char *buf; + char *ident; + unsigned int i, file_size, need_comma, n, pad; + struct stat st; + + FILE *f_input, *f_output; + + if (argc < 4) { + fprintf(stderr, "Usage: %s binary_file output_file array_name [pad]\n", argv[0]); + return -1; + } + + f_input = fopen(argv[1], "rb"); + if (f_input == NULL) { + fprintf(stderr, "%s: can't open %s for reading\n", argv[0], argv[1]); + return -1; + } + + // Get the file length + fseek(f_input, 0, SEEK_END); + file_size = ftell(f_input); + fseek(f_input, 0, SEEK_SET); + + buf = (char *)malloc(file_size); + assert(buf); + + fread(buf, file_size, 1, f_input); + fclose(f_input); + + f_output = fopen(argv[2], "w"); + if (f_output == NULL) + { + fprintf(stderr, "%s: can't open %s for writing\n", argv[0], argv[1]); + return -1; + } + + ident = argv[3]; + + need_comma = 0; + + fprintf (f_output, "unsigned char %s[] = {", ident); + for (i = 0; i < file_size; ++i) + { + if (need_comma) fprintf(f_output, ","); + else need_comma = 1; + if (( i % 8 ) == 0) fprintf(f_output, "\n\t"); + else fprintf(f_output, " "); + fprintf(f_output, "0x%.2x", buf[i] & 0xff); + } + + if (argc > 4) + pad = atoi(argv[4]); + else + pad = 1; + if (pad > 1) { + n = file_size % pad; + file_size += pad - n; + + for (; i < file_size; ++i) + { + if (need_comma) fprintf(f_output, ","); + else need_comma = 1; + if (( i % 8 ) == 0) fprintf(f_output, "\n\t"); + else fprintf(f_output, " "); + fprintf(f_output, "0x00"); + } + } + + fprintf(f_output, "\n};\n\n"); + + fprintf(f_output, "const unsigned int %s_len = %i;\n\n", ident, file_size); + + stat(argv[1], &st); + + fprintf(f_output, "const int %s_mtime = %i;\n", ident, st.st_mtim); + + fclose(f_output); + + return 0; +} diff --git a/extlinux/extlinux.mk b/extlinux/extlinux.mk @@ -0,0 +1,31 @@ +BIN = extlinux +OBJ = bootsect_bin.o ldlinux_bin.o ldlinuxc32_bin.o \ + ../libinstaller/syslxcom.o \ + ../libinstaller/syslxopt.o \ + ../libinstaller/syslxmod.o \ + ../libinstaller/setadv.o \ + ../libinstaller/advio.o \ + ../extlinux/main.o \ + ../extlinux/mountinfo.o + +INSTALL_BIN = extlinux +LOCAL_CFLAGS = -I../libinstaller -I../extlinux -I../bios -D_FILE_OFFSET_BITS=64 +DEPS = e2fsprogs + +<$mkbuild/mk.common + +CPPFLAGS = + +bin2c:Q: + echo "CC $target" + $CC -static -o $target ../../bin2c.c + +bootsect_bin.c:Q: bin2c + ./bin2c ../bios/core/ldlinux.bss $target syslinux_bootsect +ldlinux_bin.c:Q: bin2c + ./bin2c ../bios/core/ldlinux.sys $target syslinux_ldlinux 512 +ldlinuxc32_bin.c:Q: bin2c + ./bin2c ../bios/com32/elflink/ldlinux/ldlinux.c32 $target syslinux_ldlinuxc32 + +extlinux: $OBJ + diff --git a/extlinux/mkfile b/extlinux/mkfile @@ -0,0 +1,7 @@ +<$mkbuild/mk.3rdparty + +v = 6.02 +src = syslinux-$v/build +#url = $mirror/linux-$v.tar.gz +url = $mirror/syslinux-$v.tar.xz +mkfile = ../../extlinux.mk