$OpenBSD: patch-Makefile,v 1.1.1.1 2009/02/09 14:54:40 form Exp $
$RuOBSD: patch-Makefile,v 1.3 2009/02/07 10:28:03 form Exp $
--- Makefile.orig	Sun Nov 16 06:30:50 2008
+++ Makefile	Sat Feb  7 15:47:01 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 -Os -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC
+CFLAGS=-Wall -march=i486 -m32 -Os -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 extra.o \
       spd.o error.o dmi.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 $@
 
@@ -45,6 +56,13 @@ setup.s: setup.S config.h defs.h
 memtest.bin: memtest_shared.bin bootsect.o setup.o memtest.bin.lds
 	$(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
