X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/ab8735ca7b98a0b0f92067cf4f42ec03a8182fe3..6080181b861dd0889598b54:/sys/boot/pc32/boot2/Makefile diff --git a/sys/boot/pc32/boot2/Makefile b/sys/boot/pc32/boot2/Makefile index d6ef958864..e8cc95a8d9 100644 --- a/sys/boot/pc32/boot2/Makefile +++ b/sys/boot/pc32/boot2/Makefile @@ -1,14 +1,10 @@ # $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $ -# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.17 2006/08/12 05:42:26 swildner Exp $ +# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.18 2008/09/13 11:45:45 corecode Exp $ -PROG= boot2 -NOMAN= -STRIP= BINDIR?= /boot BINMODE= 444 -CLEANFILES= boot boot1 boot1.out boot1.o \ - boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ - boot2.s sio.o +CLEANFILES= boot \ + sio.o NM?= nm NXCFLAGS= @@ -42,19 +38,15 @@ ORG1D = `${.OBJDIR}/bootasmdef.nx -d MEM_BIOS_LADDR` # ORG2= `${.OBJDIR}/bootasmdef.nx BOOT2_VORIGIN` -# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit. - -# BOOT2_UFS?= UFS2_ONLY -#BOOT2_UFS?= UFS1_AND_UFS2 -BOOT2_UFS?= UFS1_ONLY - # gcc3.x # -fno-guess-branch-probability # -mno-align-long-strings CFLAGS= -elf -ffreestanding -Os -fno-builtin \ -fomit-frame-pointer \ - -D${BOOT2_UFS} \ + -std=c99 \ + -DBOOT2 \ -I${.CURDIR}/../../common \ + -I${.CURDIR}/../../../../lib/libstand \ -I${.CURDIR}/../btx/lib -I. \ -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ @@ -73,67 +65,91 @@ CFLAGS+= -fno-unit-at-a-time CFLAGS+= -fno-stack-protector .endif +NSECT_32?= 16 +NSECT_64?= 18 LDFLAGS=-nostdlib -static -N --gc-sections -all: boot1 boot2 boot +all: boot + +boot: boot1_32 boot2_32 + cat ${.ALLSRC} > boot -boot: boot1 boot2 - cat boot1 boot2 > boot +.for s in _32 _64 + +_ADDCFLAGS$s:= -DNSECT=${NSECT$s} +_ts= $s +.if ${_ts} == "_64" +_ADDCFLAGS$s+= -DDISKLABEL64 +_ADDCFLAGS$s+= -DHAMMERFS +.else +_ADDCFLAGS$s+= -DUFS1_ONLY +.endif -boot1: boot1.out - objcopy -S -O binary boot1.out ${.TARGET} +all: boot1$s boot2$s -boot1.out: boot1.o bootasmdef.nx - ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o +boot1$s: boot1$s.out + objcopy -S -O binary boot1$s.out ${.TARGET} -boot1.o: boot1.S - ${CC} ${CFLAGS} -DFLAGS=${B1FLAGS} ${AFLAGS} \ - ${.IMPSRC} -o ${.TARGET} -c +boot1$s.out: boot1$s.o bootasmdef.nx + ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} ${.ALLSRC:M*.o} -boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c - ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC} - sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s - rm -f boot2.s.tmp - ${AS} ${AFLAGS} -o boot2.o boot2.s +boot1$s.o: boot1.S + ${CC} ${CFLAGS} ${_ADDCFLAGS$s} -DFLAGS=${B1FLAGS} \ + ${.ALLSRC} -o ${.TARGET} -c -boot2.h: boot1.out bootasmdef.nx +boot2$s.o: boot2.c ${.CURDIR}/../../common/ufsread.c ${.CURDIR}/../../../../lib/libstand/hammerread.c + ${CC} ${CFLAGS} ${_ADDCFLAGS$s} -S -o boot2$s.s.tmp boot2.c + sed -e '/align/d' -e '/nop/d' < boot2$s.s.tmp > boot2$s.s + rm -f boot2$s.s.tmp + ${AS} ${AFLAGS} -o boot2$s.o boot2$s.s + +boot2$s.h: boot1$s.out bootasmdef.nx @echo "NOTE: boot2 using xread from boot1 at ${REL1}" ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ { x = $$1 - ORG1; \ printf("#define XREADORG %#x\n", REL1 + x) }' \ - ORG1=${ORG1D} REL1=${REL1D} > boot2.h + ORG1=${ORG1D} REL1=${REL1D} > boot2$s.h -boot2: boot2.ldr boot2.bin ${BTX}/btx/btx - btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ - -o boot2.ld -P 1 boot2.bin - @stat boot2.ld | awk '{ x = 7680 - $$8; \ +boot2$s: boot2$s.ldr boot2$s.bin ${BTX}/btx/btx + btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2$s.ldr \ + -o boot2$s.ld -P 1 boot2$s.bin + stat boot2$s.ld | awk '{ x = (${NSECT$s} - 1) * 512 - $$8; \ print x " bytes available"; if (x < 0) exit 1 }' - dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null + dd if=boot2$s.ld of=${.TARGET} obs=$$(( (${NSECT$s} - 1) * 512)) conv=osync 2>/dev/null -boot2.ldr: +boot2$s.ldr: dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null -boot2.bin: boot2.out - objcopy -S -O binary boot2.out ${.TARGET} +boot2$s.bin: boot2$s.out + objcopy -S -O binary boot2$s.out ${.TARGET} -boot2.out: boot2.o sio.o +boot2$s.out: boot2$s.o sio.o ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ ${BTX}/lib/crt0.o ${.ALLSRC} -boot2.o: boot2.h +boot2$s.o: boot2$s.h + +CLEANFILES+= boot1$s boot1$s.out boot1$s.o \ + boot2$s boot2$s.ldr boot2$s.bin boot2$s.ld boot2$s.out boot2$s.o boot2$s.h boot2$s.s + +.endfor sio.o: sio.S ${CC} -DSIOPRT=${BOOT_COMCONSOLE_PORT} -DSIOFMT=${B2SIOFMT} \ - -DSIOSPD=${BOOT_COMCONSOLE_SPEED} ${AFLAGS} \ - ${.IMPSRC} -o ${.TARGET} -c + -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + ${.ALLSRC} -o ${.TARGET} -c install: ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ boot ${DESTDIR}${BINDIR}/boot ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - boot1 ${DESTDIR}${BINDIR}/boot1 + boot1_32 ${DESTDIR}${BINDIR}/boot1 + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + boot2_32 ${DESTDIR}${BINDIR}/boot2 + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + boot1_64 ${DESTDIR}${BINDIR}/boot1_64 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - boot2 ${DESTDIR}${BINDIR}/boot2 + boot2_64 ${DESTDIR}${BINDIR}/boot2_64 .include