1# $FreeBSD: stable/9/sys/boot/pc98/boot2/Makefile 279796 2015-03-08 22:50:45Z 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 -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 45 46CFLAGS.gcc+= --param max-inline-insns-single=100 47.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201 48CFLAGS.gcc+= -mno-align-long-strings 49.endif 50 51# Set machine type to PC98_SYSTEM_PARAMETER 52#CFLAGS+= -DSET_MACHINE_TYPE 53 54# Initialize the bi_bios_geom using the BIOS geometry 55#CFLAGS+= -DGET_BIOSGEOM 56 57LD_FLAGS=-static -N --gc-sections 58 59# Pick up ../Makefile.inc early. 60.include <bsd.init.mk> 61 62.PATH: ${.CURDIR}/../../i386/boot2 63 64CLEANFILES= boot 65 66boot: boot1 boot2 67 cat boot1 boot2 > boot 68 69CLEANFILES+= boot1 boot1.out boot1.o 70 71boot1: boot1.out 72 objcopy -S -O binary boot1.out ${.TARGET} 73 74boot1.out: boot1.o 75 ${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o 76 77CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ 78 boot2.s boot2.s.tmp boot2.h sio.o 79 80boot2: boot2.ld 81 @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ 82 echo "$$x bytes available"; test $$x -ge 0 83 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 84 85boot2.ld: boot2.ldr boot2.bin ${BTXKERN} 86 btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \ 87 -o ${.TARGET} -P 1 boot2.bin 88 89boot2.ldr: 90 dd if=/dev/zero of=${.TARGET} bs=276 count=1 91 92boot2.bin: boot2.out 93 objcopy -S -O binary boot2.out ${.TARGET} 94 95boot2.out: ${BTXCRT} boot2.o sio.o 96 ${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} 97 98boot2.o: boot2.s 99 100SRCS= boot2.c boot2.h 101 102boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c 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