$OpenBSD: patch-Makefile,v 1.2 2009/09/24 04:57:08 form Exp $
$RuOBSD: patch-Makefile,v 1.3 2009/02/07 10:28:03 form Exp $
--- Makefile.orig	Tue Sep 22 07:35:46 2009
+++ Makefile	Thu Sep 24 11:06:57 2009
@@ -6,33 +6,44 @@
 #
 # Path for the floppy disk device
 #
-FDISK=/dev/fd0
+FDISK=/dev/fd0c
 
 AS=as -32
-CC=gcc
+CC?=gcc
 
-CFLAGS= -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC
+CFLAGS= -Wall -march=i486 -m32 -O2 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector
 
-OBJS= head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \
+OBJS= head.o reloc.o main.o test.o init.o patn.o screen_buffer.o \
       config.o linuxbios.o memsize.o pci.o controller.o random.o spd.o \
       error.o dmi.o cpuid.o
 
-all: memtest.bin memtest
+all: memtest.bin memtest_s.bin memtest memtest_s
 
 # Link it statically once so I know I don't have undefined
 # symbols and then link it dynamically so I have full
 # relocation information
-memtest_shared: $(OBJS) memtest_shared.lds Makefile
+memtest_shared: $(OBJS) lib.o memtest_shared.lds Makefile
 	$(LD) --warn-constructors --warn-common -static -T memtest_shared.lds \
-	-o $@ $(OBJS) && \
-	$(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS)
+	-o $@ $(OBJS) lib.o && \
+	$(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS) lib.o
 
+memtest_shared_s: $(OBJS) lib_s.o memtest_shared.lds Makefile
+	$(LD) --warn-constructors --warn-common -static -T memtest_shared.lds \
+	-o $@ $(OBJS) lib_s.o && \
+	$(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS) lib_s.o
+
 memtest_shared.bin: memtest_shared
 	objcopy -O binary $< memtest_shared.bin
 
+memtest_shared_s.bin: memtest_shared_s
+	objcopy -O binary $< memtest_shared_s.bin
+
 memtest: memtest_shared.bin memtest.lds
 	$(LD) -s -T memtest.lds -b binary memtest_shared.bin -o $@
 
+memtest_s: memtest_shared_s.bin memtest.lds
+	$(LD) -s -T memtest.lds -b binary memtest_shared_s.bin -o $@
+
 head.s: head.S config.h defs.h test.h
 	$(CC) -E -traditional $< -o $@
 
@@ -46,6 +57,13 @@
 	$(LD) -T memtest.bin.lds bootsect.o setup.o -b binary \
 	memtest_shared.bin -o memtest.bin
 
+memtest_s.bin: memtest_shared_s.bin bootsect.o setup.o memtest.bin.lds
+	$(LD) -T memtest.bin.lds bootsect.o setup.o -b binary \
+	memtest_shared_s.bin -o memtest_s.bin
+
+lib_s.o: lib.c
+	$(CC) -c $(CFLAGS) -DSERIAL_CONSOLE_DEFAULT=1 $< -o $@
+
 reloc.o: reloc.c
 	$(CC) -c $(CFLAGS) -fno-strict-aliasing reloc.c
 
@@ -53,7 +71,7 @@
 	$(CC) -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding test.c
 
 clean:
-	rm -f *.o *.s *.iso memtest.bin memtest memtest_shared memtest_shared.bin
+	rm -f *.o *.s *.iso memtest.bin memtest_s.bin memtest memtest_s memtest_shared memtest_shared_s memtest_shared.bin memtest_shared_s.bin
 
 asm:
 	@./makedos.sh
