1# $NetBSD: Makefile.boot,v 1.73 2019/09/13 02:19:45 manu Exp $ 2 3S= ${.CURDIR}/../../../../.. 4 5NOMAN= 6NOLIBCSANITIZER= 7NOSANITIZER= 8NOPIE= 9PROG?= boot 10NEWVERSWHAT?= "BIOS Boot" 11 12AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:} 13 14SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c \ 15 exec_multiboot1.c exec_multiboot2.c 16SRCS= ${SOURCES} 17 18.include <bsd.init.mk> 19 20STRIPFLAG= # nothing 21 22LIBCRT0= # nothing 23LIBCRTI= # nothing 24LIBCRTBEGIN= # nothing 25LIBCRTEND= # nothing 26LIBC= # nothing 27 28BINDIR=/usr/mdec 29BINMODE=444 30 31.PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib 32 33LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start 34CPPFLAGS+= -I ${.CURDIR}/.. -I ${.CURDIR}/../../lib -I ${S}/lib/libsa 35CPPFLAGS+= -I ${.OBJDIR} 36# Make sure we override any optimization options specified by the user 37COPTS= -Os 38 39.if ${MACHINE_ARCH} == "x86_64" 40LDFLAGS+= -Wl,-m,elf_i386 41AFLAGS+= -m32 42CPUFLAGS= -m32 43LIBKERN_ARCH=i386 44KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386" 45.else 46CPUFLAGS= -march=i386 -mtune=i386 47.endif 48 49CFLAGS+= -mno-sse -mno-sse2 -mno-sse3 50 51COPTS+= -ffreestanding 52CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes 53CPPFLAGS+= -nostdinc -D_STANDALONE 54CPPFLAGS+= -I$S 55 56CPPFLAGS+= -DSUPPORT_PS2 57CPPFLAGS+= -DDIRECT_SERIAL 58CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev 59 60CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed 61CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr 62CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap 63 64CPPFLAGS+= -DSUPPORT_CD9660 65CPPFLAGS+= -DSUPPORT_USTARFS 66CPPFLAGS+= -DSUPPORT_DOSFS 67CPPFLAGS+= -DSUPPORT_EXT2FS 68#CPPFLAGS+= -DSUPPORT_MINIXFS3 69CPPFLAGS+= -DPASS_BIOSGEOM 70CPPFLAGS+= -DPASS_MEMMAP 71#CPPFLAGS+= -DBOOTPASSWD 72CPPFLAGS+= -DEPIA_HACK 73#CPPFLAGS+= -DDEBUG_MEMSIZE 74#CPPFLAGS+= -DBOOT_MSG_COM0 75CPPFLAGS+= -DLIBSA_ENABLE_LS_OP 76 77# The biosboot code is linked to 'virtual' address of zero and is 78# loaded at physical address 0x10000. 79# XXX The heap values should be determined from _end. 80SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000 81SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT 82SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels 83SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS 84 85CPPFLAGS+= -Wno-pointer-sign 86 87# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT 88 89I386_STAND_DIR?= $S/arch/i386/stand 90 91### find out what to use for libi386 92I386DIR= ${I386_STAND_DIR}/lib 93.include "${I386DIR}/Makefile.inc" 94LIBI386= ${I386LIB} 95 96### find out what to use for libsa 97SA_AS= library 98SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" 99SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" 100.include "${S}/lib/libsa/Makefile.inc" 101LIBSA= ${SALIB} 102 103### find out what to use for libkern 104KERN_AS= library 105.include "${S}/lib/libkern/Makefile.inc" 106LIBKERN= ${KERNLIB} 107 108### find out what to use for libz 109Z_AS= library 110.include "${S}/lib/libz/Makefile.inc" 111LIBZ= ${ZLIB} 112 113LDSCRIPT ?= $S/arch/i386/conf/stand.ldscript 114 115cleandir distclean: .WAIT cleanlibdir 116 117cleanlibdir: 118 -rm -rf lib 119 120LIBLIST= ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} ${LIBSA} 121# LIBLIST= ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} 122 123CLEANFILES+= ${PROG}.tmp ${PROG}.map ${PROG}.sym 124 125VERSIONMACHINE=x86 126.include "${S}/conf/newvers_stand.mk" 127 128# Anything that calls 'real_to_prot' must have a %pc < 0x10000. 129# We link the program, find the callers (all in libi386), then 130# explicitly pull in the required objects before any other library code. 131${PROG}: ${OBJS} ${LIBLIST} ${LDSCRIPT} ${.CURDIR}/../Makefile.boot 132 ${_MKTARGET_LINK} 133 bb="$$( ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \ 134 ${OBJS} ${LIBLIST} | ( \ 135 while read symbol file; do \ 136 [ -z "$$file" ] && continue; \ 137 [ "$$symbol" = real_to_prot ] && break; \ 138 done; \ 139 while \ 140 oifs="$$IFS"; \ 141 IFS='()'; \ 142 set -- $$file; \ 143 IFS="$$oifs"; \ 144 [ -n "$$2" ] && echo "${I386DST}/$$2"; \ 145 read file rest && [ -z "$$rest" ]; \ 146 do :; \ 147 done; \ 148 ) )"; \ 149 ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,0 -T ${LDSCRIPT} \ 150 -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST} 151 ${OBJCOPY} -O binary ${PROG}.sym ${PROG} 152 153.include <bsd.prog.mk> 154KLINK_MACHINE= i386 155.include <bsd.klinks.mk> 156