aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2003-01-29 05:47:50 +0000
committerhpa <hpa>2003-01-29 05:47:50 +0000
commit36ce74acb299c73fa77cdcdede2d23413a157c99 (patch)
treee26cef3472cf7aa110b3e522e2ad295c4e69623c
parent9652a3dc511e33351b729d6e1062a2482b3e59c3 (diff)
downloadsyslinux-36ce74acb299c73fa77cdcdede2d23413a157c99.tar.gz
syslinux-36ce74acb299c73fa77cdcdede2d23413a157c99.tar.xz
syslinux-36ce74acb299c73fa77cdcdede2d23413a157c99.zip
Make a small library (libsyslinux.a) of SYSLINUX; fix make depend
-rw-r--r--Makefile27
-rw-r--r--NEWS5
-rw-r--r--bin2c.pl5
-rw-r--r--memdisk/Makefile4
-rw-r--r--syslinux.c33
5 files changed, 41 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 1460bb43..b84a617d 100644
--- 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 df3093f0..d5f9d061 100644
--- 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.
diff --git a/bin2c.pl b/bin2c.pl
index 9dc8f9f8..feb3ee0e 100644
--- 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;
diff --git a/memdisk/Makefile b/memdisk/Makefile
index ebc572a9..97e06324 100644
--- a/memdisk/Makefile
+++ b/memdisk/Makefile
@@ -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
diff --git a/syslinux.c b/syslinux.c
index 1e9e4102..3aafc15a 100644
--- a/syslinux.c
+++ b/syslinux.c
@@ -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
@@ -47,12 +49,6 @@
#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();