Makefile revision 260497
1# $FreeBSD: stable/10/sys/boot/pc98/boot2/Makefile 260497 2014-01-09 23:08:56Z dim $
2
3.include <bsd.own.mk>
4
5# XXX: clang can compile the boot code just fine, but boot2 gets too big
6CC:=		gcc
7COMPILER_TYPE:=	gcc
8
9FILES=		boot boot1 boot2
10
11NM?=		nm
12
13BOOT_COMCONSOLE_PORT?= 0x238
14BOOT_COMCONSOLE_SPEED?= 9600
15B2SIOFMT?=	0x3
16
17REL1=	0x700
18ORG1=	0
19ORG2=	0x2000
20
21# Decide level of UFS support.
22BOOT2_UFS?=	UFS1_AND_UFS2
23#BOOT2_UFS?=	UFS2_ONLY
24#BOOT2_UFS?=	UFS1_ONLY
25
26CFLAGS=	-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
46
47CFLAGS.gcc+=	--param max-inline-insns-single=100
48
49# Set machine type to PC98_SYSTEM_PARAMETER
50#CFLAGS+=	-DSET_MACHINE_TYPE
51
52# Initialize the bi_bios_geom using the BIOS geometry
53#CFLAGS+=	-DGET_BIOSGEOM
54
55LD_FLAGS=-static -N --gc-sections
56
57# Pick up ../Makefile.inc early.
58.include <bsd.init.mk>
59
60.PATH:	${.CURDIR}/../../i386/boot2
61
62CLEANFILES=	boot
63
64boot: boot1 boot2
65	cat boot1 boot2 > boot
66
67CLEANFILES+=	boot1 boot1.out boot1.o
68
69boot1: boot1.out
70	objcopy -S -O binary boot1.out ${.TARGET}
71
72boot1.out: boot1.o
73	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
74
75CLEANFILES+=	boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
76		boot2.s boot2.s.tmp boot2.h sio.o
77
78boot2: 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
83boot2.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
87boot2.ldr:
88	dd if=/dev/zero of=${.TARGET} bs=276 count=1
89
90boot2.bin: boot2.out
91	objcopy -S -O binary boot2.out ${.TARGET}
92
93boot2.out: ${BTXCRT} boot2.o sio.o
94	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
95
96boot2.o: boot2.s
97
98SRCS=	boot2.c boot2.h
99
100boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
101	${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
102	sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
103	rm -f boot2.s.tmp
104
105boot2.h: boot1.out
106	${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T (read|putc)/ \
107	    { x = $$1 - ORG1; \
108	    printf("#define %sORG %#x\n", toupper($$3), REL1 + x) }' \
109	    ORG1=`printf "%d" ${ORG1}` \
110	    REL1=`printf "%d" ${REL1}` > ${.TARGET}
111
112.include <bsd.prog.mk>
113