From: Antoine Leca Date: Tue, 17 Jan 2012 15:04:58 +0000 (+0100) Subject: Use objcopy to build ramdisk object X-Git-Tag: v3.2.0~20 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-checkds.html?a=commitdiff_plain;h=ab0a67f7af7bf6140a7cd2e3952e292fb0dc5924;p=minix.git Use objcopy to build ramdisk object . during build, uses much less memory, disk space, and time . lets us throw out bintoc --- diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile index 494f105c3..435ea62d4 100644 --- a/drivers/memory/Makefile +++ b/drivers/memory/Makefile @@ -1,6 +1,7 @@ # Makefile for memory driver (MEMORY) PROG= memory -SRCS= memory.c imgrd.c +SRCS= memory.c imgrd.mfs +OBJS= ${SRCS:N*.h:R:S/$/.o/g} DPADD+= ${LIBBLOCKDRIVER} ${LIBCHARDRIVER} ${LIBSYS} LDADD+= -lblockdriver -lchardriver -lsys @@ -10,6 +11,22 @@ MAN= BINDIR?= /usr/sbin CPPFLAGS.memory.c+= -I${MINIXSRCDIR} -CPPFLAGS.imgrd.c+= -I${.CURDIR}/../ramdisk + +imgrd.d: touch-genfiles +touch-genfiles: + [ -e ../ramdisk/image ] || touch -t 197001020000.00 ../ramdisk/image + + +.SUFFIXES: .mfs .c .o + +# 'elf32-${ARCH}-minix' below should really be ${MACHINE_GNU_PLATFORM} +# but bsd.own.mk has to be upgraded for that. +.mfs.o: + ${_MKTARGET_CREATE} + ${OBJCOPY} -Ibinary -B${ARCH} -Oelf32-${ARCH}-minix $< $@ + +imgrd.mfs: + ln -s ../ramdisk/image $@ +CLEANFILES+= imgrd.mfs .include diff --git a/drivers/memory/imgrd.c b/drivers/memory/imgrd.c deleted file mode 100644 index 947b7ffc3..000000000 --- a/drivers/memory/imgrd.c +++ /dev/null @@ -1,14 +0,0 @@ -/* -Ramdisk that is part of the image -*/ - -#include - -#include "local.h" - -unsigned char imgrd[]= -{ -#include "image.c" -}; - -size_t imgrd_size= sizeof(imgrd); diff --git a/drivers/memory/local.h b/drivers/memory/local.h index 91a9ad16a..498ef2757 100644 --- a/drivers/memory/local.h +++ b/drivers/memory/local.h @@ -2,5 +2,8 @@ local defines and declarations */ -extern unsigned char imgrd[]; -extern size_t imgrd_size; +extern unsigned char _binary_imgrd_mfs_start[], *_binary_imgrd_mfs_end; + +#define imgrd _binary_imgrd_mfs_start +#define imgrd_size \ + ((size_t)(_binary_imgrd_mfs_end - _binary_imgrd_mfs_start)) diff --git a/drivers/ramdisk/Makefile b/drivers/ramdisk/Makefile index 8585da396..7d3825c80 100644 --- a/drivers/ramdisk/Makefile +++ b/drivers/ramdisk/Makefile @@ -23,19 +23,11 @@ PROTO= proto.small EXTRA=system.conf master.passwd passwd pwd.db spwd.db rs.single CPPFLAGS+= -I${MINIXSRCDIR}/servers -I${MINIXSRCDIR} -CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) bintoc image image.c t proto.gen +CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) image image.c t proto.gen install: all -realall: image.c - -image.c: bintoc image - ./bintoc -o $@ image - -# Note for cross compilation: this executable has to be compiled for the -# host system -bintoc: bintoc.c - $(CC) -o $@ bintoc.c +realall: image image: proto.gen mtab rc $(EXTRA) mkfs.mfs image proto.gen || { rm -f image; false; } diff --git a/drivers/ramdisk/bintoc.c b/drivers/ramdisk/bintoc.c deleted file mode 100644 index b4c532026..000000000 --- a/drivers/ramdisk/bintoc.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -bintoc.c - -Convert a (binary) file to a series of comma separated hex values suitable -for initializing a character array in C. -*/ - -#define _POSIX_C_SOURCE 2 - -#include -#include -#include -#include -#include -#include - -static char *progname; -static unsigned char buf[1024]; - -static void fatal(char *fmt, ...); -static void usage(void); - -int main(int argc, char *argv[]) -{ - int c, i, r, first; - FILE *file_in, *file_out; - char *in_name; - char *o_arg; - - (progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]); - - o_arg= NULL; - while (c= getopt(argc, argv, "?o:"), c != -1) - { - switch(c) - { - case '?': usage(); - case 'o': o_arg= optarg; break; - default: fatal("getopt failed: '%c'\n", c); - } - } - - if (o_arg) - { - file_out= fopen(o_arg, "w"); - if (file_out == NULL) - { - fatal("unable to create '%s': %s\n", - o_arg, strerror(errno)); - exit(1); - } - } - else - file_out= stdout; - - if (optind < argc) - { - in_name= argv[optind]; - optind++; - file_in= fopen(in_name, "r"); - if (file_in == NULL) - { - fatal("unable to open '%s': %s", - in_name, strerror(errno)); - } - } - else - { - in_name= "(stdin)"; - file_in= stdin; - } - - if (optind != argc) - usage(); - - first= 1; - for (;;) - { - r= fread(buf, 1, sizeof(buf), file_in); - if (r == 0) - break; - for (i= 0; i] []\n"); - exit(1); -} diff --git a/tools/Makefile b/tools/Makefile index 6ad6574da..99a4ba9eb 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -90,11 +90,12 @@ hdboot: image cp $$i $$newname; \ if [ -d /boot/image ]; \ then ln -f $$newname /boot/`basename $$i`; \ - else gzip $$newname; \ + else strip -s $$newname; \ + gzip $$newname; \ fi \ done cp ../kernel/kernel /boot/minix/.temp/ - strip -s /boot/minix/.temp/* + strip -s /boot/minix/.temp/kernel [ -d /boot/image ] && ln -f /boot/minix/.temp/kernel /boot/kernel || true sh mkboot $@ minix exec sh update_bootcfg.sh