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