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