Makefile.booters revision 1.39
1# $NetBSD: Makefile.booters,v 1.39 2003/01/28 16:21:58 dsl Exp $ 2 3.include <bsd.own.mk> 4 5STRIPFLAG= 6BINMODE=444 7 8LIBCRT0= # nothing 9LIBCRTBEGIN= # nothing 10LIBCRTEND= # nothing 11LIBC= # nothing 12 13# Make sure we override any optimization options specified by the 14# user. 15.if ${MACHINE_ARCH} == "x86_64" 16COPTS= -Os -m32 17CPPFLAGS+= -DBOOT_ELF64 18.else 19COPTS= -Os -mcpu=i386 20.endif 21COPTS+= -ffreestanding 22 23I386_STAND_DIR?= $S/arch/i386/stand 24 25.PATH: ${I386_STAND_DIR}/lib/crt/bootsect ${I386_STAND_DIR}/lib 26# ensure the stuff we need to load all of 'biosboot' in in the first few 27# sectors, and that anything that goes to real mode is in the first 64k. 28# (prot_to_real will bleat if the return address is >64k) 29BSSTART= start_bootsect.o fraglist.o bootsectmain.o biosdisk_ll.o \ 30 bios_disk.o diskbuf.o \ 31 biosdelay.o biosgetrtc.o biosmca.o biosmem.o biosmemx.o \ 32 biosreboot.o conio.o 33 34.PATH: ${I386_STAND_DIR}/lib/crt/rom 35ROMSTART= start_rom.o 36GENPROMDIR= ${I386_STAND_DIR}/genprom 37GENPROMOBJDIR!= cd ${GENPROMDIR} && ${PRINTOBJDIR} 38GENPROM= ${GENPROMOBJDIR}/genprom 39 40.PATH: ${I386_STAND_DIR}/lib/crt/dos 41DOSSTART= start_dos.o doscommain.o 42 43.PATH: ${I386_STAND_DIR}/lib/crt/pxe 44PXESTART= start_pxe.o 45 46CPPFLAGS += -nostdinc -I${.OBJDIR} -I$S -I${I386_STAND_DIR}/lib -I$S/lib/libsa 47CPPFLAGS+= -D_STANDALONE 48 49# XXX 50.if ${MACHINE_ARCH} == "x86_64" 51CPPFLAGS+=-m32 52LD+=-m elf_i386 53LIBKERN_ARCH=i386 54KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 55.endif 56 57CLEANFILES+= ${STARTFILE} vers.c ${BASE}.list 58SRCS+= vers.c 59 60.if !make(obj) && !make(clean) && !make(cleandir) 61.BEGIN: machine 62.NOPATH: machine 63.endif 64 65realdepend realall: machine 66CLEANFILES+= machine 67 68machine:: 69 -rm -f $@ 70 ln -s $S/arch/i386/include $@ 71 72${OBJS} ${BSSTART} ${ROMSTART} ${DOSSTART} ${PXESTART}: machine 73 74### find out what to use for libkern 75KERN_AS= library 76.include "${S}/lib/libkern/Makefile.inc" 77LIBKERN= ${KERNLIB} 78 79### find out what to use for libz 80Z_AS= library 81.include "${S}/lib/libz/Makefile.inc" 82LIBZ= ${ZLIB} 83 84### find out what to use for libsa 85SA_AS= library 86SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 87.include "${S}/lib/libsa/Makefile.inc" 88LIBSA= ${SALIB} 89 90### find out what to use for libi386 91I386DIR= ${I386_STAND_DIR}/lib 92.include "${I386DIR}/Makefile.inc" 93LIBI386= ${I386LIB} 94 95cleandir distclean: cleanlibdir 96 97cleanlibdir: 98 rm -rf lib 99 100.if ${OBJECT_FMT} == "ELF" 101LDFLAGS=-M -e start # -N does not work properly. 102.else 103LDFLAGS=-N -M -e _start 104.endif 105 106LIBLIST=${LIBI386} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} 107 108vers.c: ${VERSIONFILE} ${SOURCES} 109 sh ${S}conf/newvers_stand.sh ${.ALLSRC} 'i386' ${NEWVERSWHAT} 110 111CLEANFILES+= ${BASE}.sym 112${BASE}.sym: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 113 @# A default link has a 4k gap between the rodata and data. 114 @# We don't need it here - and are short of space! 115 @# The -N option might work - but it puts the code at offset 116 @# 0x80 in the file. 117 @# Get linker to tell us its link script and remove the line. 118 @rm -f ${BASE}.ldscript 119 @ ${LD} --verbose >${BASE}.ldscript 120 @ printf '%b' "1,/^===/d\nd\nd\n/ALIGN(0x1000)/\nd\n/^===/\nd\nwq\n" \ 121 | ed -s ${BASE}.ldscript >/dev/null 122 ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} -T ${BASE}.ldscript \ 123 ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list 124 @# The code, bss, data and stack are restricted to one 64k segment. 125 @# Check there is a 'moderate' amount (4k) of stack space. 126 @# 2k isn't enough, 3.5k might be (but harder to test for). 127 @# If the stack is too small hair starts being pulled out. 128 @ grep '^[ 0x]*[a-e].*PROVIDE (end, .)$$' ${BASE}.list >/dev/null || { \ 129 echo "*** Less that 4k stack space in biosboot" >&2; \ 130 rm -f ${BASE}.sym; \ 131 false; } 132 133CLEANFILES+= ${BASE}.rom 134${BASE}.rom: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 135 ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} ${STARTFILE} ${OBJS} \ 136 ${LIBLIST} >${BASE}.list 137 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin 138 ${GENPROM} ${ROM_SIZE} < ${BASE}.bin > ${BASE}.rom || \ 139 rm -f ${BASE}.rom 140 rm -f ${BASE}.bin 141 142CLEANFILES+= ${BASE}.com 143${BASE}.com: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 144 ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} ${STARTFILE} ${OBJS} \ 145 ${LIBLIST} >${BASE}.list 146 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.com 147 148CLEANFILES+= ${BASE}.bin 149${BASE}.bin: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 150 ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} ${STARTFILE} ${OBJS} \ 151 ${LIBLIST} > ${BASE}.list 152 ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin 153 154.include <bsd.prog.mk> 155