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