1 # $NetBSD: Makefile.boot,v 1.60 2013/08/21 17:15:26 matt 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
27 LIBCRTBEGIN= # nothing
34 .PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
36 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start
37 CPPFLAGS+= -I ${.CURDIR}/.. -I ${.CURDIR}/../../lib -I ${S}/lib/libsa
38 CPPFLAGS+= -I ${.OBJDIR}
39 # Make sure we override any optimization options specified by the user
42 .if ${MACHINE_ARCH} == "x86_64"
43 LDFLAGS+= -Wl,-m,elf_i386
47 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
49 CPUFLAGS= -march=i386 -mtune=i386
52 CFLAGS+= -mno-sse -mno-sse2 -mno-sse3
54 COPTS+= -ffreestanding
55 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
56 CPPFLAGS+= -nostdinc -D_STANDALONE
59 CPPFLAGS+= -DSUPPORT_PS2
60 CPPFLAGS+= -DDIRECT_SERIAL
61 CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
63 CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed
64 CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr
65 CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap
67 CPPFLAGS+= -DSUPPORT_CD9660
68 CPPFLAGS+= -DSUPPORT_USTARFS
69 CPPFLAGS+= -DSUPPORT_DOSFS
70 CPPFLAGS+= -DSUPPORT_EXT2FS
71 CPPFLAGS+= -DSUPPORT_MINIXFS3
72 CPPFLAGS+= -DPASS_BIOSGEOM
73 CPPFLAGS+= -DPASS_MEMMAP
74 #CPPFLAGS+= -DBOOTPASSWD
75 CPPFLAGS+= -DEPIA_HACK
76 #CPPFLAGS+= -DDEBUG_MEMSIZE
77 #CPPFLAGS+= -DBOOT_MSG_COM0
78 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
80 # The biosboot code is linked to 'virtual' address of zero and is
81 # loaded at physical address 0x10000.
82 # XXX The heap values should be determined from _end.
83 SAMISCCPPFLAGS+= -DHEAP_START=0x40000 -DHEAP_LIMIT=0x70000
84 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
85 SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels
86 SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
88 CPPFLAGS+= -Wno-pointer-sign
90 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
92 I386_STAND_DIR?= $S/arch/i386/stand
94 ### find out what to use for libi386
95 I386DIR= ${I386_STAND_DIR}/lib
96 .include "${I386DIR}/Makefile.inc"
99 ### find out what to use for libsa
101 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
102 SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
103 .include "${S}/lib/libsa/Makefile.inc"
107 ### find out what to use for libkern
109 .include "${S}/lib/libkern/Makefile.inc"
116 LIBKERN= ${DESTDIR}/usr/lib/libminc.a
119 ### find out what to use for libz
121 .include "${S}/lib/libz/Makefile.inc"
125 cleandir distclean: .WAIT cleanlibdir
130 LIBLIST= ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} ${LIBSA}
131 # LIBLIST= ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN}
133 CLEANFILES+= ${PROG}.tmp ${PROG}.map ${PROG}.syms vers.c
135 vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
136 ${HOST_SH} ${S}/conf/newvers_stand.sh ${VERSIONFILE} x86 ${NEWVERSWHAT}
140 # -Wl,-Ttext,0 changed to --section-start=.text=0 twice below of a gold problem.
141 # did not leave both versions in because of the huge continued line.
144 # Anything that calls 'real_to_prot' must have a %pc < 0x10000.
145 # We link the program, find the callers (all in libi386), then
146 # explicitly pull in the required objects before any other library code.
147 ${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
149 bb="$$( ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,--section-start=.text=0 -Wl,-cref \
150 ${OBJS} ${LIBLIST} | ( \
151 while read symbol file; do \
152 [ -z "$$file" ] && continue; \
153 [ "$$symbol" = real_to_prot ] && break; \
160 [ -n "$$2" ] && echo "${I386DST}/$$2"; \
161 read file rest && [ -z "$$rest" ]; \
165 ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,--section-start=.text=0 \
166 -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST}
167 ${OBJCOPY} -O binary ${PROG}.syms ${PROG}
169 .include <bsd.prog.mk>
171 .include <bsd.klinks.mk>