1 # $NetBSD: Makefile.boot,v 1.67 2015/08/20 11:39:28 uebayasi Exp $
3 S= ${.CURDIR}/../../../../..
7 NEWVERSWHAT?= "BIOS Boot"
8 VERSIONFILE?= ${.CURDIR}/../version
10 AFLAGS.biosboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
12 SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c
28 LIBCRTBEGIN= # nothing
35 .PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
37 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start
38 CPPFLAGS+= -I ${.CURDIR}/.. -I ${.CURDIR}/../../lib -I ${S}/lib/libsa
39 CPPFLAGS+= -I ${.OBJDIR}
40 # Make sure we override any optimization options specified by the user
43 .if ${MACHINE_ARCH} == "x86_64"
44 LDFLAGS+= -Wl,-m,elf_i386
48 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
50 CPUFLAGS= -march=i386 -mtune=i386
53 CFLAGS+= -mno-sse -mno-sse2 -mno-sse3
55 COPTS+= -ffreestanding
56 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
57 CPPFLAGS+= -nostdinc -D_STANDALONE
60 CPPFLAGS+= -DSUPPORT_PS2
61 CPPFLAGS+= -DDIRECT_SERIAL
62 CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
64 CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed
65 CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr
66 CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap
68 CPPFLAGS+= -DSUPPORT_CD9660
69 CPPFLAGS+= -DSUPPORT_USTARFS
70 CPPFLAGS+= -DSUPPORT_DOSFS
71 CPPFLAGS+= -DSUPPORT_EXT2FS
72 CPPFLAGS+= -DSUPPORT_MINIXFS3
73 CPPFLAGS+= -DPASS_BIOSGEOM
74 CPPFLAGS+= -DPASS_MEMMAP
75 #CPPFLAGS+= -DBOOTPASSWD
76 CPPFLAGS+= -DEPIA_HACK
77 #CPPFLAGS+= -DDEBUG_MEMSIZE
78 #CPPFLAGS+= -DBOOT_MSG_COM0
79 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
81 CPPFLAGS+= -DLIBSA_ENABLE_LOAD_MODS_OP
82 .endif # defined(__MINIX)
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.
87 SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000
88 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
89 SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels
90 SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
92 CPPFLAGS+= -Wno-pointer-sign
94 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
96 I386_STAND_DIR?= $S/arch/i386/stand
98 ### find out what to use for libi386
99 I386DIR= ${I386_STAND_DIR}/lib
100 .include "${I386DIR}/Makefile.inc"
103 ### find out what to use for libsa
105 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
106 SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
107 .include "${S}/lib/libsa/Makefile.inc"
110 .if !defined(__MINIX)
111 ### find out what to use for libkern
113 .include "${S}/lib/libkern/Makefile.inc"
120 LIBKERN= ${DESTDIR}/usr/lib/libminc.a
121 .endif # !defined(__MINIX)
123 ### find out what to use for libz
125 .include "${S}/lib/libz/Makefile.inc"
128 LDSCRIPT ?= $S/arch/i386/conf/stand.ldscript
130 cleandir distclean: .WAIT cleanlibdir
135 LIBLIST= ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} ${LIBSA}
136 # LIBLIST= ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN}
138 CLEANFILES+= ${PROG}.tmp ${PROG}.map ${PROG}.sym vers.c
140 vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
141 ${HOST_SH} ${S}/conf/newvers_stand.sh ${VERSIONFILE} x86 ${NEWVERSWHAT}
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)
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
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; \
165 [ -n "$$2" ] && echo "${I386DST}/$$2"; \
166 read file rest && [ -z "$$rest" ]; \
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}
174 .include <bsd.prog.mk>
176 .include <bsd.klinks.mk>