1 # $NetBSD: Makefile.bootxx,v 1.46 2013/11/01 00:18:24 christos Exp $
3 S= ${.CURDIR}/../../../../..
5 AFLAGS.bootxx.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
6 AFLAGS.label.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
7 AFLAGS.pbr.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
9 AFLAGS.bootxx.S+= -Wa,--divide
20 PRIMARY_LOAD_ADDRESS=0x1000
21 SECONDARY_LOAD_ADDRESS=0x10000
23 # We ought (need?) to fit into track 0 of a 1.2M floppy.
24 # This restricts us to 15 sectors (including pbr and label)
26 BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
28 SRCS= pbr.S label.S bootxx.S boot1.c
35 LIBCRTBEGIN= # nothing
42 .PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
44 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start
46 # CPPFLAGS+= -D__daddr_t=int32_t
47 CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
48 CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
49 CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
50 CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
51 CPPFLAGS+= -DXXfs_open=${FS}_open
52 CPPFLAGS+= -DXXfs_close=${FS}_close
53 CPPFLAGS+= -DXXfs_read=${FS}_read
54 CPPFLAGS+= -DXXfs_stat=${FS}_stat
56 # CPPFLAGS+= -DBOOT_MSG_COM0
58 # Make sure we override any optimization options specified by the user
59 .include "${.PARSEDIR}/../Makefile.inc"
60 COPTS= ${OPT_SIZE.${ACTIVE_CC}}
63 CPPFLAGS+= -DNO_LBA_CHECK
65 .if ${MACHINE_ARCH} == "x86_64"
66 LDFLAGS+= -Wl,-m,elf_i386
70 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
72 CPPFLAGS+= -DEPIA_HACK
73 CPUFLAGS= -march=i386 -mtune=i386
76 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
77 CPPFLAGS+= -nostdinc -D_STANDALONE
80 CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
82 -DLIBSA_NO_FD_CHECKING \
83 -DLIBSA_NO_RAW_ACCESS \
86 -DLIBSA_SINGLE_DEVICE=blkdev \
87 -DLIBKERN_OPTIMISE_SPACE \
88 -D"blkdevioctl(x,y,z)=EINVAL" \
89 -D"blkdevclose(f)=0" \
90 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
91 -DLIBSA_NO_DISKLABEL_MSGS
93 # -DLIBSA_FS_SINGLECOMPONENT
95 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
97 I386_STAND_DIR?= $S/arch/i386/stand
99 ### find out what to use for libi386
100 I386DIR= ${I386_STAND_DIR}/lib
101 .include "${I386DIR}/Makefile.inc"
104 ### find out what to use for libsa
106 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=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"
117 SAMISCMAKEFLAGS+="SA_INCLUDE_NET=no"
122 LIBKERN= ${DESTDIR}/usr/lib/libminc.a
125 LDSCRIPT ?= $S/arch/i386/conf/stand.ldscript
127 cleandir distclean: .WAIT cleanlibdir
132 LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
134 CLEANFILES+= ${PROG}.sym ${PROG}.map
136 ${PROG}: ${OBJS} ${LIBLIST}
139 ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,--section-start=.text=${PRIMARY_LOAD_ADDRESS} \
140 -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
142 ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
143 -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
145 ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
146 @ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
147 if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
148 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
152 : pad to sector boundary; \
153 pad=$$(( 512 - ( $$sz & 511 ) )); \
155 dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
156 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
159 .include <bsd.prog.mk>
161 .include <bsd.klinks.mk>