1 # $NetBSD: Makefile.bootxx,v 1.49 2015/08/20 11:38:27 uebayasi 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:}
17 PRIMARY_LOAD_ADDRESS=0x1000
18 SECONDARY_LOAD_ADDRESS=0x10000
20 # We ought (need?) to fit into track 0 of a 1.2M floppy.
21 # This restricts us to 15 sectors (including pbr and label)
23 BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
25 SRCS= pbr.S label.S bootxx.S boot1.c
33 LIBCRTBEGIN= # nothing
40 .PATH: ${.CURDIR}/.. ${.CURDIR}/../../lib
42 LDFLAGS+= -nostdlib -Wl,-N -Wl,-e,start
44 # CPPFLAGS+= -D__daddr_t=int32_t
45 CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
46 CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
47 CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
48 CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
49 CPPFLAGS+= -DXXfs_open=${FS}_open
50 CPPFLAGS+= -DXXfs_close=${FS}_close
51 CPPFLAGS+= -DXXfs_read=${FS}_read
52 CPPFLAGS+= -DXXfs_stat=${FS}_stat
54 # CPPFLAGS+= -DBOOT_MSG_COM0
56 # Make sure we override any optimization options specified by the user
57 .include "${.PARSEDIR}/../Makefile.inc"
58 COPTS= ${OPT_SIZE.${ACTIVE_CC}}
61 CPPFLAGS+= -DNO_LBA_CHECK
63 .if ${MACHINE_ARCH} == "x86_64"
64 LDFLAGS+= -Wl,-m,elf_i386
68 KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
70 CPPFLAGS+= -DEPIA_HACK
71 CPUFLAGS= -march=i386 -mtune=i386
74 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
75 CPPFLAGS+= -nostdinc -D_STANDALONE
78 CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
80 -DLIBSA_NO_FD_CHECKING \
81 -DLIBSA_NO_RAW_ACCESS \
84 -DLIBSA_SINGLE_DEVICE=blkdev \
85 -DLIBKERN_OPTIMISE_SPACE \
86 -D"blkdevioctl(x,y,z)=EINVAL" \
87 -D"blkdevclose(f)=0" \
88 -D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
89 -DLIBSA_NO_DISKLABEL_MSGS
91 # -DLIBSA_FS_SINGLECOMPONENT
93 # CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
95 I386_STAND_DIR?= $S/arch/i386/stand
97 ### find out what to use for libi386
98 I386DIR= ${I386_STAND_DIR}/lib
99 .include "${I386DIR}/Makefile.inc"
102 ### find out what to use for libsa
104 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
105 .include "${S}/lib/libsa/Makefile.inc"
108 .if !defined(__MINIX)
109 ### find out what to use for libkern
111 .include "${S}/lib/libkern/Makefile.inc"
115 SAMISCMAKEFLAGS+="SA_INCLUDE_NET=no"
120 LIBKERN= ${DESTDIR}/usr/lib/libminc.a
121 .endif # !defined(__MINIX)
123 LDSCRIPT ?= $S/arch/i386/conf/stand.ldscript
125 cleandir distclean: .WAIT cleanlibdir
130 LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
132 CLEANFILES+= ${PROG}.sym ${PROG}.map
134 ${PROG}: ${OBJS} ${LIBLIST} ${LDSCRIPT}
137 ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,--section-start=.text=${PRIMARY_LOAD_ADDRESS} \
138 -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
140 ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
141 -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
142 .endif # defined(__MINIX)
143 ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
144 @ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
145 if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
146 echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
150 : pad to sector boundary; \
151 pad=$$(( 512 - ( $$sz & 511 ) )); \
153 dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
154 echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
157 .include <bsd.prog.mk>
159 .include <bsd.klinks.mk>