]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/boot/pc98/boot2/Makefile
MFC r257532 (by adrian):
[FreeBSD/stable/9.git] / sys / boot / pc98 / boot2 / Makefile
1 # $FreeBSD$
2
3 .include <bsd.own.mk>
4
5 # XXX: clang can compile the boot code just fine, but boot2 gets too big
6 CC:=            gcc
7 COMPILER_TYPE:= gcc
8
9 FILES=          boot boot1 boot2
10
11 NM?=            nm
12
13 BOOT_COMCONSOLE_PORT?= 0x238
14 BOOT_COMCONSOLE_SPEED?= 9600
15 B2SIOFMT?=      0x3
16
17 REL1=   0x700
18 ORG1=   0
19 ORG2=   0x2000
20
21 # Decide level of UFS support.
22 BOOT2_UFS?=     UFS1_AND_UFS2
23 #BOOT2_UFS?=    UFS2_ONLY
24 #BOOT2_UFS?=    UFS1_ONLY
25
26 CFLAGS= -Os \
27         -fno-guess-branch-probability \
28         -fomit-frame-pointer \
29         -fno-unit-at-a-time \
30         -mno-align-long-strings \
31         -mrtd \
32         -mregparm=3 \
33         -D${BOOT2_UFS} \
34         -DFLAGS=${BOOT_BOOT1_FLAGS} \
35         -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
36         -DSIOFMT=${B2SIOFMT} \
37         -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
38         -I${.CURDIR}/../../.. \
39         -I${.CURDIR}/../../i386/boot2 \
40         -I${.CURDIR}/../../common \
41         -I${.CURDIR}/../btx/lib -I. \
42         -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
43         -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
44         -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
45         -Winline --param max-inline-insns-single=100
46
47 # Set machine type to PC98_SYSTEM_PARAMETER
48 #CFLAGS+=       -DSET_MACHINE_TYPE
49
50 # Initialize the bi_bios_geom using the BIOS geometry
51 #CFLAGS+=       -DGET_BIOSGEOM
52
53 LDFLAGS=-static -N --gc-sections
54
55 # Pick up ../Makefile.inc early.
56 .include <bsd.init.mk>
57
58 .PATH:  ${.CURDIR}/../../i386/boot2
59
60 CLEANFILES=     boot
61
62 boot: boot1 boot2
63         cat boot1 boot2 > boot
64
65 CLEANFILES+=    boot1 boot1.out boot1.o
66
67 boot1: boot1.out
68         objcopy -S -O binary boot1.out ${.TARGET}
69
70 boot1.out: boot1.o
71         ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
72
73 CLEANFILES+=    boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
74                 boot2.s boot2.s.tmp boot2.h sio.o
75
76 boot2: boot2.ld
77         @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
78             echo "$$x bytes available"; test $$x -ge 0
79         dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
80
81 boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
82         btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
83             -o ${.TARGET} -P 1 boot2.bin
84
85 boot2.ldr:
86         dd if=/dev/zero of=${.TARGET} bs=276 count=1
87
88 boot2.bin: boot2.out
89         objcopy -S -O binary boot2.out ${.TARGET}
90
91 boot2.out: ${BTXCRT} boot2.o sio.o
92         ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
93
94 boot2.o: boot2.s
95
96 SRCS=   boot2.c boot2.h
97
98 boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
99         ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
100         sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
101         rm -f boot2.s.tmp
102
103 boot2.h: boot1.out
104         ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T (read|putc)/ \
105             { x = $$1 - ORG1; \
106             printf("#define %sORG %#x\n", toupper($$3), REL1 + x) }' \
107             ORG1=`printf "%d" ${ORG1}` \
108             REL1=`printf "%d" ${REL1}` > ${.TARGET}
109
110 .include <bsd.prog.mk>