Make a small library (libsyslinux.a) of SYSLINUX; fix make depend
authorhpa <hpa>
Wed, 29 Jan 2003 05:47:50 +0000 (05:47 +0000)
committerhpa <hpa>
Wed, 29 Jan 2003 05:47:50 +0000 (05:47 +0000)
Makefile
NEWS
bin2c.pl
memdisk/Makefile
syslinux.c

index 1460bb4..b84a617 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@ CC     = gcc
 INCLUDE  =
 CFLAGS  = -Wall -O2 -fomit-frame-pointer
 LDFLAGS         = -O2 -s
+AR      = ar
+RANLIB   = ranlib
 
 NASM    = nasm -O99
 NINCLUDE = 
@@ -37,12 +39,12 @@ VERSION  = $(shell cat version)
 # like to keep those uniform for debugging reasons; however, distributors 
 # want to recompile the installers (ITARGET).
 #
-CSRC    = syslinux.c gethostip.c
+CSRC    = syslinux.c syslxmod.c gethostip.c
 NASMSRC  = ldlinux.asm syslinux.asm copybs.asm \
          pxelinux.asm mbr.asm isolinux.asm isolinux-debug.asm
 SOURCES = $(CSRC) $(NASMSRC) *.inc
 BTARGET = kwdhash.gen version.gen ldlinux.bss ldlinux.sys ldlinux.bin \
-         pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin
+         pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin libsyslinux.a
 ITARGET = syslinux.com syslinux copybs.com gethostip mkdiskimage
 DOCS    = COPYING NEWS README TODO *.doc sample com32/include
 OTHER   = Makefile bin2c.pl now.pl genhash.pl keywords findpatch.pl \
@@ -126,16 +128,20 @@ copybs.com: copybs.asm
        $(NASM) -f bin -l copybs.lst -o copybs.com copybs.asm
 
 bootsect_bin.c: ldlinux.bss bin2c.pl
-       $(PERL) bin2c.pl bootsect < ldlinux.bss > bootsect_bin.c
+       $(PERL) bin2c.pl syslinux_bootsect < ldlinux.bss > bootsect_bin.c
 
 ldlinux_bin.c: ldlinux.sys bin2c.pl
-       $(PERL) bin2c.pl ldlinux < ldlinux.sys > ldlinux_bin.c
+       $(PERL) bin2c.pl syslinux_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
+libsyslinux.a: bootsect_bin.o ldlinux_bin.o syslxmod.o
+       rm -f $@
+       $(AR) cq $@ $^
+       $(RANLIB) $@
 
-syslinux.o: syslinux.c patch.offset
+syslinux: syslinux.o libsyslinux.a
+       $(CC) $(LDFLAGS) -o $@ $^
+
+syslxmod.o: syslxmod.c patch.offset
        $(CC) $(INCLUDE) $(CFLAGS) -DPATCH_OFFSET=`cat patch.offset` \
                -c -o $@ $<
 
@@ -184,10 +190,13 @@ spotless: local-clean dist local-spotless
        for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -M $$csrc >> .depend ; done
        for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
 
-depend:
+local-depend:
        rm -f .depend
        $(MAKE) .depend
 
+depend: local-depend
+       $(MAKE) -C memdisk depend
+
 # Hook to add private Makefile targets for the maintainer.
 -include Makefile.private
 
diff --git a/NEWS b/NEWS
index df3093f..d5f9d06 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,10 @@ Changes in 2.01:
          versions, and be able to generate disk images with DOSEMU
          headers (controlled by the -d option).
        * Fix the COM32 sample program.
-       * PXELINUX, ISOLINUX: Fix come COMBOOT API calls.
+       * PXELINUX, ISOLINUX: Fix some COMBOOT API calls.
+       * PXELINUX: Doc fix.
+       * Build SYSLINUX into a small library for encapsulation into
+         other programs.
 
 Changes in 2.00:
        * ALL: Add support for "COM32" (32-bit COMBOOT) images.
index 9dc8f9f..feb3ee0 100644 (file)
--- a/bin2c.pl
+++ b/bin2c.pl
@@ -48,3 +48,8 @@ while ( ($n = read(STDIN, $data, 4096)) > 0 ) {
 
 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;
index ebc572a..97e0632 100644 (file)
@@ -88,6 +88,10 @@ memdisk.o: memdisk.bin
        for ssrc in $(SSRC) ; do $(CC) $(INCLUDE) -x c -traditional -M $$ssrc | sed -e 's/\.S16\.o/\.o16/' >> .depend ; done
        for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
 
+depend:
+       rm -f .depend
+       $(MAKE) .depend
+
 # This file contains the version number, so add a dependency for it
 setup.s: ../version
 
index 1e9e410..3aafc15 100644 (file)
@@ -1,7 +1,7 @@
 #ident "$Id$"
 /* ----------------------------------------------------------------------- *
  *   
- *   Copyright 1998-2002 H. Peter Anvin - All Rights Reserved
+ *   Copyright 1998-2001 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
@@ -39,6 +39,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "syslinux.h"
+
 #ifndef _PATH_MOUNT
 #define _PATH_MOUNT "/bin/mount"
 #endif
 #define _PATH_UMOUNT "/bin/umount"
 #endif
 
-extern unsigned char bootsect[];
-extern unsigned int  bootsect_len;
-
-extern unsigned char ldlinux[];
-extern unsigned int  ldlinux_len;
-
 char *program;                 /* Name of program */
 char *device;                  /* Device to install to */
 uid_t ruid;                    /* Real uid */
@@ -84,9 +80,6 @@ enum bs_offsets {
   bsSignature     = 0x1fe
 };
 
-#define bsCopyStart bsBytesPerSec
-#define bsCopyLen   (bsCode-bsBytesPerSec)
-
 /*
  * Access functions for littleendian numbers, possibly misaligned.
  */
@@ -101,13 +94,13 @@ static u_int32_t get_32(unsigned char *p)
     ((u_int32_t)p[2] << 16) + ((u_int32_t)p[3] << 24);
 }
 
+#if 0                          /* Not needed */
 static void set_16(unsigned char *p, u_int16_t v)
 {
   p[0] = (v & 0xff);
   p[1] = ((v >> 8) & 0xff);
 }
 
-#if 0                          /* Not needed */
 static void set_32(unsigned char *p, u_int32_t v)
 {
   p[0] = (v & 0xff);
@@ -117,12 +110,6 @@ static void set_32(unsigned char *p, u_int32_t v)
 }
 #endif
 
-/* Patch the code so that we're running in stupid mode */
-static void make_stupid(void)
-{
-  set_16(ldlinux+PATCH_OFFSET, 1); /* Access only one sector at a time */
-}
-
 void usage(void)
 {
   fprintf(stderr, "Usage: %s [-sf] [-o offset] device\n", program);
@@ -223,7 +210,7 @@ int main(int argc, char *argv[])
 
       while ( *opt ) {
        if ( *opt == 's' ) {
-         make_stupid();        /* Use "safe, slow and stupid" code */
+         syslinux_make_stupid();       /* Use "safe, slow and stupid" code */
        } else if ( *opt == 'f' ) {
          force = 1;            /* Force install */
        } else if ( *opt == 'o' && argp[1] ) {
@@ -474,8 +461,8 @@ int main(int argc, char *argv[])
     goto umount;
   }
 
-  cdp = ldlinux;
-  left = ldlinux_len;
+  cdp = syslinux_ldlinux;
+  left = syslinux_ldlinux_len;
   while ( left ) {
     nb = write(fd, cdp, left);
     if ( nb == -1 && errno == EINTR )
@@ -534,11 +521,11 @@ umount:
   /* Read the superblock again since it might have changed while mounted */
   xpread(dev_fd, sectbuf, 512, offset);
 
-  /* Copy the old superblock into the new boot sector */
-  memcpy(bootsect+bsCopyStart, sectbuf+bsCopyStart, bsCopyLen);
+  /* Copy the syslinux code into the boot sector */
+  syslinux_make_bootsect(sectbuf);
 
   /* Write new boot sector */
-  xpwrite(dev_fd, bootsect, 512, offset);
+  xpwrite(dev_fd, sectbuf, 512, offset);
 
   close(dev_fd);
   sync();