Makefile.bootxx revision 1.1
1# $NetBSD: Makefile.bootxx,v 1.1 2003/04/16 22:17:44 dsl Exp $
2
3S=	${.CURDIR}/../../../../../
4
5NOMAN=
6STRIPFLAG=
7PROG= bootxx_${FS}
8PRIMARY_LOAD_ADDRESS=0x600
9SECONDARY_LOAD_ADDRESS=0x10000
10
11# We ought (need?) to fit into track 0 of a 1.2M floppy.
12# This restricts us to 15 sectors (including pbr and label)
13BOOTXX_SECTORS?=15
14BOOTXX_MAXSIZE?= $$(( ${BOOTXX_SECTORS} * 512 ))
15
16SRCS= pbr.S label.S bootxx.S boot1.c
17
18.include <bsd.own.mk>
19
20LIBCRT0=	# nothing
21LIBCRTBEGIN=	# nothing
22LIBCRTEND=	# nothing
23LIBC=		# nothing
24
25BINDIR=/usr/mdec
26BINMODE=444
27
28.PATH:	${.CURDIR}/.. ${.CURDIR}/../../lib
29
30LDFLAGS+= -N -e start
31CPPFLAGS+= -DBOOTXX
32# CPPFLAGS+= -D__daddr_t=int32_t
33CPPFLAGS+= -I ${.CURDIR}/../../lib -I ${.OBJDIR}
34CPPFLAGS+= -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
35CPPFLAGS+= -DPRIMARY_LOAD_ADDRESS=${PRIMARY_LOAD_ADDRESS}
36CPPFLAGS+= -DSECONDARY_LOAD_ADDRESS=${SECONDARY_LOAD_ADDRESS}
37# Magic number also known by usr.sbin/installboot/arch/i386.c
38CPPFLAGS+= -DX86_BOOT_MAGIC_1="('x' << 24 | 0x86b << 12 | 'm' << 4 | 1)"
39CPPFLAGS+= -DXXfs_open=${FS}_open
40CPPFLAGS+= -DXXfs_close=${FS}_close
41CPPFLAGS+= -DXXfs_read=${FS}_read
42CPPFLAGS+= -DXXfs_stat=${FS}_stat
43
44# Make sure we override any optimization options specified by the user
45COPTS=  -Os
46
47.if ${MACHINE} == "x86_64"
48LDFLAGS+=  -m elf_i386
49AFLAGS+=   -m32
50COPTS+=    -m32
51LIBKERN_ARCH=i386
52KERNMISCMAKEFLAGS="LIBKERN_ARCH=i386"
53.else
54COPTS+=    -mcpu=i386
55.endif
56
57COPTS+=    -ffreestanding
58CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
59CPPFLAGS+= -nostdinc -D_STANDALONE
60CPPFLAGS+= -I$S
61
62CPPFLAGS+= -DLIBSA_SINGLE_FILESYSTEM=xxfs \
63		-DLIBSA_NO_TWIDDLE \
64		-DLIBSA_NO_FD_CHECKING \
65		-DLIBSA_NO_RAW_ACCESS \
66		-DLIBSA_NO_FS_WRITE \
67		-DLIBSA_NO_FS_SEEK \
68		-DLIBSA_USE_MEMCPY \
69		-DLIBSA_USE_MEMSET \
70		-DLIBSA_SINGLE_DEVICE=blkdev \
71		-DLIBKERN_OPTIMISE_SPACE \
72		-D"blkdevioctl(x,y,z)=EINVAL" \
73		-D"blkdevclose(f)=0" \
74		-D"devopen(f,n,fl)=(*(fl)=(void *)n,0)" \
75		-DLIBSA_NO_DISKLABEL_MSGS
76
77# -DLIBSA_FS_SINGLECOMPONENT 
78
79# CPPFLAGS+= -DBOOTXX_RAID1_SUPPORT
80
81I386_STAND_DIR?= $S/arch/i386/stand
82
83.if !make(obj) && !make(clean) && !make(cleandir)
84.BEGIN: machine
85.NOPATH: machine
86.endif
87
88realdepend realall: machine
89CLEANFILES+= machine
90
91machine::
92	-rm -f $@
93	ln -s $S/arch/i386/include $@
94
95${OBJS}: machine
96
97### find out what to use for libi386
98I386DIR= ${I386_STAND_DIR}/lib
99I386DST= ${.OBJDIR}/../lib/i386
100.include "${I386DIR}/Makefile.inc"
101LIBI386= ${I386LIB}
102
103### find out what to use for libsa
104SA_AS= library
105SADST= ${.OBJDIR}/../lib/libsa
106SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
107.include "${S}/lib/libsa/Makefile.inc"
108LIBSA= ${SALIB}
109
110### find out what to use for libkern
111KERN_AS=        library
112KERNDST= ${.OBJDIR}/../lib/libkern
113.include "${S}/lib/libkern/Makefile.inc"
114LIBKERN=        ${KERNLIB}
115
116
117cleandir distclean: cleanlibdir
118
119cleanlibdir:
120	rm -rf lib
121
122LIBLIST= ${LIBI386} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
123
124CLEANFILES+= ${PROG}.tmp ${PROG}.map
125
126${PROG}: ${OBJS} ${LIBLIST}
127	${LD} -o ${PROG}.tmp ${LDFLAGS} -Ttext ${PRIMARY_LOAD_ADDRESS} \
128		-Map ${PROG}.map -cref ${OBJS} ${LIBLIST}
129	${OBJCOPY} -O binary ${PROG}.tmp ${PROG}
130	# rm -f ${PROG}.tmp
131	@ sz=$$(ls -ln ${PROG}|tr -s ' '|cut -d' ' -f5); \
132	if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
133		echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2; \
134		rm ${PROG}; \
135		! :; \
136	else \
137		: pad to sector boundary; \
138		pad=$$(( 512 - ( $$sz & 511 ) )); \
139		[ $$pad != 512 ] && \
140		    dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
141		echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
142	fi
143
144.include <bsd.prog.mk>
145