Remove my changes. PATH_PORTS is not checked for multiple entries as
[dragonfly.git] / sys / boot / pc32 / boot2 / Makefile
CommitLineData
5ee58eed 1# $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.47 2003/06/26 03:51:57 peter Exp $
04144d62 2# $DragonFly: src/sys/boot/pc32/boot2/Makefile,v 1.8 2004/07/19 01:24:58 dillon Exp $
984263bc
MD
3
4PROG= boot2
5NOMAN=
6STRIP=
7BINDIR?= /boot
8BINMODE= 444
5ee58eed 9CLEANFILES= boot boot1 boot1.out boot1.o \
984263bc 10 boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \
5ee58eed 11 boot2.s sio.o
984263bc
MD
12
13NM?= nm
14
15# A value of 0x80 enables LBA support.
16B1FLAGS= 0x80
17
18BOOT_COMCONSOLE_PORT?= 0x3f8
19BOOT_COMCONSOLE_SPEED?= 9600
20B2SIOFMT?= 0x3
21
22.if exists(${.OBJDIR}/../btx)
23BTX= ${.OBJDIR}/../btx
24.else
25BTX= ${.CURDIR}/../btx
26.endif
27
04144d62
MD
28# WARNING! These constants are also defined in bootasm.h
29#
5ee58eed 30REL1= 0x700
984263bc 31ORG1= 0x7c00
04144d62
MD
32
33# WARNING! The ORG2 calculation is the origin of boot2.bin relative to
34# the start of the BTX *USER* address space, not the start of physical
35# memory.
36#
5ee58eed 37ORG2= 0x2000
984263bc 38
5ee58eed
MD
39# Decide Level of UFS support. UFS1_AND_UFS2 doesn't fit.
40
41# BOOT2_UFS?= UFS2_ONLY
42#BOOT2_UFS?= UFS1_AND_UFS2
43BOOT2_UFS?= UFS1_ONLY
44
45# gcc3.x
46# -fno-guess-branch-probability
47# -mno-align-long-strings
48
9ca8a416 49CFLAGS= -elf -ffreestanding -Os -fno-builtin -fno-stack-protector \
5ee58eed
MD
50 -fomit-frame-pointer \
51 -mrtd \
52 -D${BOOT2_UFS} \
53 -I${.CURDIR}/../../common \
54 -I${.CURDIR}/../btx/lib -I. \
984263bc
MD
55 -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
56 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
57 -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
58
5ee58eed 59LDFLAGS=-nostdlib -static -N --gc-sections
984263bc 60
5ee58eed
MD
61all: boot1 boot2 boot
62
63boot: boot1 boot2
64 cat boot1 boot2 > boot
984263bc
MD
65
66boot1: boot1.out
67 objcopy -S -O binary boot1.out ${.TARGET}
68
69boot1.out: boot1.o
70 ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
71
409cbc03
MD
72boot1.o: boot1.S
73 ${CC} ${CFLAGS} -DFLAGS=${B1FLAGS} ${AFLAGS} \
74 ${.IMPSRC} -o ${.TARGET} -c
5ee58eed
MD
75
76boot2.o: boot2.c ${.CURDIR}/../../common/ufsread.c
77 ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.IMPSRC}
78 sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
79 rm -f boot2.s.tmp
80 ${AS} ${AFLAGS} -o boot2.o boot2.s
984263bc
MD
81
82boot2.h: boot1.out
83 ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \
5ee58eed
MD
84 { x = $$1 - ORG1; \
85 printf("#define XREADORG %#x\n", REL1 + x) }' \
86 ORG1=`printf "%d" ${ORG1}` \
87 REL1=`printf "%d" ${REL1}` > boot2.h
984263bc
MD
88
89boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
90 btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
91 -o boot2.ld -P 1 boot2.bin
92 @ls -l boot2.ld | awk '{ x = 7680 - $$5; \
93 print x " bytes available"; if (x < 0) exit 1 }'
94 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
95
96boot2.ldr:
2d7f6790 97 dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
984263bc
MD
98
99boot2.bin: boot2.out
100 objcopy -S -O binary boot2.out ${.TARGET}
101
102boot2.out: boot2.o sio.o
103 ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
5ee58eed 104 ${BTX}/lib/crt0.o ${.ALLSRC}
984263bc
MD
105
106boot2.o: boot2.h
107
409cbc03
MD
108sio.o: sio.S
109 ${CC} -DSIOPRT=${BOOT_COMCONSOLE_PORT} -DSIOFMT=${B2SIOFMT} \
110 -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
111 ${AFLAGS} ${.IMPSRC} -o ${.TARGET} -c
984263bc
MD
112
113install:
5ee58eed
MD
114 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
115 boot ${DESTDIR}${BINDIR}/boot
984263bc
MD
116 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
117 boot1 ${DESTDIR}${BINDIR}/boot1
118 ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
119 boot2 ${DESTDIR}${BINDIR}/boot2
120
121.include <bsd.prog.mk>
5ee58eed
MD
122
123.if defined(REALLY_AMD64)
124boot2.o: machine
125
126beforedepend ${OBJS}: machine
127
128machine:
129 ln -sf ${.CURDIR}/../../../i386/include machine
130
131CLEANFILES+= machine
132.endif
133