Makefile.booters revision 1.39
11.39Sdsl# $NetBSD: Makefile.booters,v 1.39 2003/01/28 16:21:58 dsl Exp $ 21.32Sthorpej 31.32Sthorpej.include <bsd.own.mk> 41.1Sperry 51.2SthorpejSTRIPFLAG= 61.1SperryBINMODE=444 71.38Sthorpej 81.38SthorpejLIBCRT0= # nothing 91.38SthorpejLIBCRTBEGIN= # nothing 101.38SthorpejLIBCRTEND= # nothing 111.38SthorpejLIBC= # nothing 121.29Stls 131.33Sthorpej# Make sure we override any optimization options specified by the 141.33Sthorpej# user. 151.37Sfvdl.if ${MACHINE_ARCH} == "x86_64" 161.37SfvdlCOPTS= -Os -m32 171.37SfvdlCPPFLAGS+= -DBOOT_ELF64 181.37Sfvdl.else 191.35SpookaCOPTS= -Os -mcpu=i386 201.37Sfvdl.endif 211.34SthorpejCOPTS+= -ffreestanding 221.1Sperry 231.8SdrochnerI386_STAND_DIR?= $S/arch/i386/stand 241.8Sdrochner 251.8Sdrochner.PATH: ${I386_STAND_DIR}/lib/crt/bootsect ${I386_STAND_DIR}/lib 261.39Sdsl# ensure the stuff we need to load all of 'biosboot' in in the first few 271.39Sdsl# sectors, and that anything that goes to real mode is in the first 64k. 281.39Sdsl# (prot_to_real will bleat if the return address is >64k) 291.32SthorpejBSSTART= start_bootsect.o fraglist.o bootsectmain.o biosdisk_ll.o \ 301.39Sdsl bios_disk.o diskbuf.o \ 311.39Sdsl biosdelay.o biosgetrtc.o biosmca.o biosmem.o biosmemx.o \ 321.39Sdsl biosreboot.o conio.o 331.32Sthorpej 341.8Sdrochner.PATH: ${I386_STAND_DIR}/lib/crt/rom 351.16SchristosROMSTART= start_rom.o 361.8SdrochnerGENPROMDIR= ${I386_STAND_DIR}/genprom 371.32SthorpejGENPROMOBJDIR!= cd ${GENPROMDIR} && ${PRINTOBJDIR} 381.32SthorpejGENPROM= ${GENPROMOBJDIR}/genprom 391.32Sthorpej 401.8Sdrochner.PATH: ${I386_STAND_DIR}/lib/crt/dos 411.16SchristosDOSSTART= start_dos.o doscommain.o 421.32Sthorpej 431.31Sthorpej.PATH: ${I386_STAND_DIR}/lib/crt/pxe 441.31SthorpejPXESTART= start_pxe.o 451.1Sperry 461.13ScgdCPPFLAGS += -nostdinc -I${.OBJDIR} -I$S -I${I386_STAND_DIR}/lib -I$S/lib/libsa 471.5SdrochnerCPPFLAGS+= -D_STANDALONE 481.37Sfvdl 491.37Sfvdl# XXX 501.37Sfvdl.if ${MACHINE_ARCH} == "x86_64" 511.37SfvdlCPPFLAGS+=-m32 521.37SfvdlLD+=-m elf_i386 531.37SfvdlLIBKERN_ARCH=i386 541.37SfvdlKERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 551.37Sfvdl.endif 561.1Sperry 571.32SthorpejCLEANFILES+= ${STARTFILE} vers.c ${BASE}.list 581.26SjdolecekSRCS+= vers.c 591.7Sthorpej 601.30Sjmc.if !make(obj) && !make(clean) && !make(cleandir) 611.25Smycroft.BEGIN: machine 621.25Smycroft.NOPATH: machine 631.30Sjmc.endif 641.30Sjmc 651.25Smycroftrealdepend realall: machine 661.25SmycroftCLEANFILES+= machine 671.6Sdrochner 681.25Smycroftmachine:: 691.10Shubertf -rm -f $@ 701.6Sdrochner ln -s $S/arch/i386/include $@ 711.23Sdrochner 721.31Sthorpej${OBJS} ${BSSTART} ${ROMSTART} ${DOSSTART} ${PXESTART}: machine 731.6Sdrochner 741.1Sperry### find out what to use for libkern 751.1SperryKERN_AS= library 761.1Sperry.include "${S}/lib/libkern/Makefile.inc" 771.1SperryLIBKERN= ${KERNLIB} 781.1Sperry 791.1Sperry### find out what to use for libz 801.1SperryZ_AS= library 811.1Sperry.include "${S}/lib/libz/Makefile.inc" 821.1SperryLIBZ= ${ZLIB} 831.1Sperry 841.1Sperry### find out what to use for libsa 851.1SperrySA_AS= library 861.22SchristosSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 871.1Sperry.include "${S}/lib/libsa/Makefile.inc" 881.1SperryLIBSA= ${SALIB} 891.1Sperry 901.1Sperry### find out what to use for libi386 911.8SdrochnerI386DIR= ${I386_STAND_DIR}/lib 921.1Sperry.include "${I386DIR}/Makefile.inc" 931.1SperryLIBI386= ${I386LIB} 941.17Stron 951.18Stroncleandir distclean: cleanlibdir 961.17Stron 971.17Stroncleanlibdir: 981.17Stron rm -rf lib 991.16Schristos 1001.16Schristos.if ${OBJECT_FMT} == "ELF" 1011.16SchristosLDFLAGS=-M -e start # -N does not work properly. 1021.16Schristos.else 1031.16SchristosLDFLAGS=-N -M -e _start 1041.16Schristos.endif 1051.16Schristos 1061.22SchristosLIBLIST=${LIBI386} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} 1071.22Schristos 1081.36Sjdolecekvers.c: ${VERSIONFILE} ${SOURCES} 1091.26Sjdolecek sh ${S}conf/newvers_stand.sh ${.ALLSRC} 'i386' ${NEWVERSWHAT} 1101.7Sthorpej 1111.32SthorpejCLEANFILES+= ${BASE}.sym 1121.32Sthorpej${BASE}.sym: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 1131.39Sdsl @# A default link has a 4k gap between the rodata and data. 1141.39Sdsl @# We don't need it here - and are short of space! 1151.39Sdsl @# The -N option might work - but it puts the code at offset 1161.39Sdsl @# 0x80 in the file. 1171.39Sdsl @# Get linker to tell us its link script and remove the line. 1181.39Sdsl @rm -f ${BASE}.ldscript 1191.39Sdsl @ ${LD} --verbose >${BASE}.ldscript 1201.39Sdsl @ printf '%b' "1,/^===/d\nd\nd\n/ALIGN(0x1000)/\nd\n/^===/\nd\nwq\n" \ 1211.39Sdsl | ed -s ${BASE}.ldscript >/dev/null 1221.39Sdsl ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} -T ${BASE}.ldscript \ 1231.39Sdsl ${STARTFILE} ${OBJS} ${LIBLIST} >${BASE}.list 1241.39Sdsl @# The code, bss, data and stack are restricted to one 64k segment. 1251.39Sdsl @# Check there is a 'moderate' amount (4k) of stack space. 1261.39Sdsl @# 2k isn't enough, 3.5k might be (but harder to test for). 1271.39Sdsl @# If the stack is too small hair starts being pulled out. 1281.39Sdsl @ grep '^[ 0x]*[a-e].*PROVIDE (end, .)$$' ${BASE}.list >/dev/null || { \ 1291.39Sdsl echo "*** Less that 4k stack space in biosboot" >&2; \ 1301.39Sdsl rm -f ${BASE}.sym; \ 1311.39Sdsl false; } 1321.32Sthorpej 1331.32SthorpejCLEANFILES+= ${BASE}.rom 1341.32Sthorpej${BASE}.rom: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 1351.32Sthorpej ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} ${STARTFILE} ${OBJS} \ 1361.32Sthorpej ${LIBLIST} >${BASE}.list 1371.32Sthorpej ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin 1381.32Sthorpej ${GENPROM} ${ROM_SIZE} < ${BASE}.bin > ${BASE}.rom || \ 1391.32Sthorpej rm -f ${BASE}.rom 1401.9Sdrochner rm -f ${BASE}.bin 1411.9Sdrochner 1421.32SthorpejCLEANFILES+= ${BASE}.com 1431.32Sthorpej${BASE}.com: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 1441.32Sthorpej ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} ${STARTFILE} ${OBJS} \ 1451.32Sthorpej ${LIBLIST} >${BASE}.list 1461.32Sthorpej ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.com 1471.32Sthorpej 1481.32SthorpejCLEANFILES+= ${BASE}.bin 1491.32Sthorpej${BASE}.bin: ${STARTFILE} ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} 1501.32Sthorpej ${LD} -o ${BASE}.sym ${LDFLAGS} -Ttext ${RELOC} ${STARTFILE} ${OBJS} \ 1511.31Sthorpej ${LIBLIST} > ${BASE}.list 1521.32Sthorpej ${OBJCOPY} -O binary ${BASE}.sym ${BASE}.bin 1531.9Sdrochner 1541.9Sdrochner.include <bsd.prog.mk> 155