1 # $NetBSD: Makefile.bootxx,v 1.37 2009/11/20 17:28:19 dsl Exp $
3 S= ${.CURDIR}/../../../../..
13 PRIMARY_LOAD_ADDRESS=0x1000
14 SECONDARY_LOAD_ADDRESS=0x10000
16 # We ought (need?) to fit into track 0 of a 1.2M floppy.
17 # This restricts us to 15 sectors (including pbr and label)
19 BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
21 SRCS= pbr.S label.S bootxx.S boot1.c
28 LIBCRTBEGIN= # nothing
35 .PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
37 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start
39 # CPPFLAGS+= -D__daddr_t=int32_t
40 CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
41 CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
42 CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
43 CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
44 CPPFLAGS+= -DXXfs_open=${FS}_open
45 CPPFLAGS+= -DXXfs_close=${FS}_close
46 CPPFLAGS+= -DXXfs_read=${FS}_read
47 CPPFLAGS+= -DXXfs_stat=${FS}_stat
49 # CPPFLAGS+= -DBOOT_MSG_COM0
51 # Make sure we override any optimization options specified by the user
52 COPTS= -Os -momit-leaf-frame-pointer
55 CPPFLAGS+= -DNO_LBA_CHECK
58 .if ${MACHINE_ARCH} == "x86_64"
59 LDFLAGS+= -Wl,-m,elf_i386
63 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
65 CPPFLAGS+= -DEPIA_HACK
69 CPUFLAGS= -march=i386 -mtune=i386
74 COPTS+= -ffreestanding
75 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
76 CPPFLAGS+= -nostdinc -D_STANDALONE
79 CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
81 -DLIBSA_NO_FD_CHECKING \
82 -DLIBSA_NO_RAW_ACCESS \
85 -DLIBSA_SINGLE_DEVICE=blkdev \
86 -DLIBKERN_OPTIMISE_SPACE \
87 -D"blkdevioctl(x,y,z)=EINVAL" \
88 -D"blkdevclose(f)=0" \
89 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
90 -DLIBSA_NO_DISKLABEL_MSGS
92 # -DLIBSA_FS_SINGLECOMPONENT
94 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
96 I386_STAND_DIR?= $S/arch/i386/stand
98 CLEANFILES+= machine x86
100 .if !make(obj) && !make(clean) && !make(cleandir)
102 -rm -f machine && ln -s $S/arch/i386/include machine
103 -rm -f x86 && ln -s $S/arch/x86/include x86
105 -rm -f lib && ln -s ${LIBOBJ}/lib lib
106 mkdir -p ${LIBOBJ}/lib
110 ### find out what to use for libi386
111 I386DIR= ${I386_STAND_DIR}/lib
112 .include "${I386DIR}/Makefile.inc"
115 ### find out what to use for libsa
117 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
118 .include "${S}/lib/libsa/Makefile.inc"
121 ### find out what to use for libkern
123 .include "${S}/lib/libkern/Makefile.inc"
127 cleandir distclean: cleanlibdir
132 LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
134 CLEANFILES+= ${PROG}.sym ${PROG}.map
136 ${PROG}: ${OBJS} ${LIBLIST}
138 ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
139 -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
140 ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
141 @ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
142 if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
143 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
147 : pad to sector boundary; \
148 pad=$$(( 512 - ( $$sz & 511 ) )); \
150 dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
151 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
154 .include <bsd.prog.mk>