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