1# $FreeBSD: head/sys/boot/i386/boot2/Makefile 125517 2004-02-06 12:58:32Z ru $
| 1# $FreeBSD: head/sys/boot/i386/boot2/Makefile 125537 2004-02-06 21:58:32Z ru $
|
2
| 2
|
3PROG= boot2 4NOMAN= 5STRIP= 6BINMODE= 444 7CLEANFILES= boot boot1 boot1.out boot1.o \ 8 boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ 9 boot2.s sio.o
| 3FILES= boot boot1 boot2
|
10 11NM?= nm 12 13# A value of 0x80 enables LBA support. 14B1FLAGS= 0x80 15 16BOOT_COMCONSOLE_PORT?= 0x3f8 17BOOT_COMCONSOLE_SPEED?= 9600 18B2SIOFMT?= 0x3 19
| 4 5NM?= nm 6 7# A value of 0x80 enables LBA support. 8B1FLAGS= 0x80 9 10BOOT_COMCONSOLE_PORT?= 0x3f8 11BOOT_COMCONSOLE_SPEED?= 9600 12B2SIOFMT?= 0x3 13
|
20.if exists(${.OBJDIR}/../btx) 21BTX= ${.OBJDIR}/../btx 22.else 23BTX= ${.CURDIR}/../btx 24.endif 25
| |
26REL1= 0x700 27ORG1= 0x7c00 28ORG2= 0x2000 29
| 14REL1= 0x700 15ORG1= 0x7c00 16ORG2= 0x2000 17
|
30# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit. 31 32# BOOT2_UFS?= UFS2_ONLY
| 18# Decide level of UFS support.
|
33BOOT2_UFS?= UFS1_AND_UFS2
| 19BOOT2_UFS?= UFS1_AND_UFS2
|
34# BOOT2_UFS?= UFS1_ONLY
| 20#BOOT2_UFS?= UFS2_ONLY 21#BOOT2_UFS?= UFS1_ONLY
|
35
| 22
|
| 23AFLAGS+=--defsym FLAGS=${B1FLAGS} \ 24 --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ 25 --defsym SIOFMT=${B2SIOFMT} \ 26 --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} 27
|
36CFLAGS= -elf -ffreestanding -Os -fno-builtin \ 37 -fno-guess-branch-probability -fomit-frame-pointer\ 38 -mno-align-long-strings \ 39 -mrtd \ 40 -D${BOOT2_UFS} \ 41 -I${.CURDIR}/../../common \ 42 -I${.CURDIR}/../btx/lib -I. \ 43 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 44 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 45 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 46 47LDFLAGS=-nostdlib -static -N --gc-sections 48
| 28CFLAGS= -elf -ffreestanding -Os -fno-builtin \ 29 -fno-guess-branch-probability -fomit-frame-pointer\ 30 -mno-align-long-strings \ 31 -mrtd \ 32 -D${BOOT2_UFS} \ 33 -I${.CURDIR}/../../common \ 34 -I${.CURDIR}/../btx/lib -I. \ 35 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ 36 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ 37 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 38 39LDFLAGS=-nostdlib -static -N --gc-sections 40
|
49all: boot1 boot2 boot
| 41# Pick up ../Makefile.inc early. 42.include <bsd.init.mk>
|
50
| 43
|
| 44CLEANFILES= boot 45
|
51boot: boot1 boot2 52 cat boot1 boot2 > boot 53
| 46boot: boot1 boot2 47 cat boot1 boot2 > boot 48
|
| 49CLEANFILES+= boot1 boot1.out boot1.o 50
|
54boot1: boot1.out 55 objcopy -S -O binary boot1.out ${.TARGET} 56 57boot1.out: boot1.o 58 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 59 60boot1.o: boot1.s
| 51boot1: boot1.out 52 objcopy -S -O binary boot1.out ${.TARGET} 53 54boot1.out: boot1.o 55 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 56 57boot1.o: boot1.s
|
61 ${CPP} ${CFLAGS} ${.IMPSRC} | \ 62 ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} -o ${.TARGET}
| 58 ${CPP} ${CFLAGS} ${.CURDIR}/boot1.s | \ 59 ${AS} ${AFLAGS} -o ${.TARGET}
|
63
| 60
|
64boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c 65 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC} 66 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 67 rm -f boot2.s.tmp 68 ${AS} ${AFLAGS} -o boot2.o boot2.s
| 61CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 62 boot2.s boot2.s.tmp boot2.h sio.o
|
69
| 63
|
70boot2.h: boot1.out 71 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 72 { x = $$1 - ORG1; \ 73 printf("#define XREADORG %#x\n", REL1 + x) }' \ 74 ORG1=`printf "%d" ${ORG1}` \ 75 REL1=`printf "%d" ${REL1}` > boot2.h
| 64boot2: boot2.ld 65 @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ 66 echo "$$x bytes available"; test $$x -ge 0 67 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
|
76
| 68
|
77boot2: boot2.ldr boot2.bin ${BTX}/btx/btx 78 btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ 79 -o boot2.ld -P 1 boot2.bin 80 @ls -l boot2.ld | awk '{ x = 7680 - $$5; \ 81 print x " bytes available"; if (x < 0) exit 1 }' 82 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
| 69boot2.ld: boot2.ldr boot2.bin ${BTXKERN} 70 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 71 -o ${.TARGET} -P 1 boot2.bin
|
83 84boot2.ldr:
| 72 73boot2.ldr:
|
85 dd if=/dev/zero of=${.TARGET} bs=276 count=1 2>/dev/null
| 74 dd if=/dev/zero of=${.TARGET} bs=276 count=1
|
86 87boot2.bin: boot2.out 88 objcopy -S -O binary boot2.out ${.TARGET} 89
| 75 76boot2.bin: boot2.out 77 objcopy -S -O binary boot2.out ${.TARGET} 78
|
90boot2.out: boot2.o sio.o 91 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ 92 ${BTX}/lib/crt0.o ${.ALLSRC}
| 79boot2.out: ${BTXCRT} boot2.o sio.o 80 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
|
93
| 81
|
94boot2.o: boot2.h
| 82boot2.o: boot2.s
|
95
| 83
|
96sio.o: sio.s 97 ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ 98 --defsym SIOFMT=${B2SIOFMT} \ 99 --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \ 100 ${.IMPSRC} -o ${.TARGET}
| 84boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c 85 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c 86 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s 87 rm -f boot2.s.tmp
|
101
| 88
|
102install: 103 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 104 boot ${DESTDIR}${BINDIR}/boot 105 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 106 boot1 ${DESTDIR}${BINDIR}/boot1 107 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 108 boot2 ${DESTDIR}${BINDIR}/boot2
| 89boot2.h: boot1.out 90 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ 91 { x = $$1 - ORG1; \ 92 printf("#define XREADORG %#x\n", REL1 + x) }' \ 93 ORG1=`printf "%d" ${ORG1}` \ 94 REL1=`printf "%d" ${REL1}` > ${.TARGET}
|
109
| 95
|
110.include <bsd.prog.mk> 111
| |
112.if defined(REALLY_AMD64)
| 96.if defined(REALLY_AMD64)
|
113boot2.o: machine
| 97boot2.s: machine
|
114
| 98
|
115beforedepend ${OBJS}: machine 116
| |
117machine: 118 ln -sf ${.CURDIR}/../../../i386/include machine 119 120CLEANFILES+= machine 121.endif 122
| 99machine: 100 ln -sf ${.CURDIR}/../../../i386/include machine 101 102CLEANFILES+= machine 103.endif 104
|
| 105.include <bsd.prog.mk>
|
| |