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