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