1 # $NetBSD: Makefile.boot,v 1.41 2009/11/18 20:33:39 dsl Exp $
3 S= ${.CURDIR}/../../../../..
7 NEWVERSWHAT?= "BIOS Boot"
8 VERSIONFILE?= ${.CURDIR}/../version
10 SOURCES?= biosboot.S boot2.c conf.c devopen.c exec.c
25 LIBCRTBEGIN= # nothing
32 .PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
34 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,boot_start
35 # CPPFLAGS+= -D__daddr_t=int32_t
36 CPPFLAGS+= -I ${.CURDIR}/.. -I ${.CURDIR}/../../lib -I ${S}/lib/libsa
37 CPPFLAGS+= -I ${.OBJDIR}
38 #CPPFLAGS+= -DDEBUG_MEMSIZE
39 #CPPFLAGS+= -DBOOT_MSG_COM0
40 # Make sure we override any optimization options specified by the user
44 .if ${MACHINE_ARCH} == "x86_64"
45 LDFLAGS+= -Wl,-m,elf_i386
49 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
54 CPUFLAGS= -march=i386 -mtune=i386
59 COPTS+= -ffreestanding
60 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
61 CPPFLAGS+= -nostdinc -D_STANDALONE
64 CPPFLAGS+= -DSUPPORT_PS2
65 CPPFLAGS+= -DDIRECT_SERIAL
66 CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
68 CPPFLAGS+= -DCONSPEED=boot_params.bp_conspeed
69 CPPFLAGS+= -DCONSADDR=boot_params.bp_consaddr
70 CPPFLAGS+= -DCONSOLE_KEYMAP=boot_params.bp_keymap
72 CPPFLAGS+= -DSUPPORT_CD9660
73 CPPFLAGS+= -DSUPPORT_USTARFS
74 CPPFLAGS+= -DSUPPORT_DOSFS
75 #CPPFLAGS+= -DSUPPORT_EXT2FS
76 CPPFLAGS+= -DPASS_BIOSGEOM
77 CPPFLAGS+= -DPASS_MEMMAP
78 #CPPFLAGS+= -DBOOTPASSWD
79 CPPFLAGS+= -DEPIA_HACK
81 # The biosboot code is linked to 'virtual' address of zero and is
82 # loaded at physical address 0x10000.
83 # XXX The heap values should be determined from _end.
84 SAMISCCPPFLAGS+= -DHEAP_START=0x30000 -DHEAP_LIMIT=0x50000
85 SAMISCMAKEFLAGS+= SA_USE_CREAD=yes # Read compressed kernels
86 SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
88 .if (defined(HAVE_GCC) && ${HAVE_GCC} == 4) || defined(HAVE_PCC)
89 CPPFLAGS+= -Wno-pointer-sign
92 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
94 I386_STAND_DIR?= $S/arch/i386/stand
96 CLEANFILES+= machine x86
98 .if !make(obj) && !make(clean) && !make(cleandir)
100 -rm -f machine && ln -s $S/arch/i386/include machine
101 -rm -f x86 && ln -s $S/arch/x86/include x86
103 -rm -f lib && ln -s ${LIBOBJ}/lib lib
104 mkdir -p ${LIBOBJ}/lib
108 ### find out what to use for libi386
109 I386DIR= ${I386_STAND_DIR}/lib
110 .include "${I386DIR}/Makefile.inc"
113 ### find out what to use for libsa
115 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
116 .include "${S}/lib/libsa/Makefile.inc"
119 ### find out what to use for libkern
121 .include "${S}/lib/libkern/Makefile.inc"
124 ### find out what to use for libz
126 .include "${S}/lib/libz/Makefile.inc"
130 cleandir distclean: cleanlibdir
135 LIBLIST= ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBI386} ${LIBSA}
136 # LIBLIST= ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA} ${LIBZ} ${LIBKERN}
138 CLEANFILES+= ${PROG}.tmp ${PROG}.map vers.c
140 vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
141 ${HOST_SH} ${S}/conf/newvers_stand.sh -DM ${VERSIONFILE} x86 ${NEWVERSWHAT}
143 # Anything that calls 'real_to_prot' must have a %pc < 0x10000.
144 # We link the program, find the callers (all in libi386), then
145 # explicitly pull in the required objects before any other library code.
146 ${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
148 bb="$$( ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \
149 ${OBJS} ${LIBLIST} | ( \
150 while read symbol file; do \
151 [ -z "$$file" ] && continue; \
152 [ "$$symbol" = real_to_prot ] && break; \
159 [ -n "$$2" ] && echo "${I386DST}/$$2"; \
160 read file rest && [ -z "$$rest" ]; \
164 ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 \
165 -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST}
166 ${OBJCOPY} -O binary ${PROG}.syms ${PROG}
168 .include <bsd.prog.mk>