1 # $NetBSD: Makefile.booters,v 1.50 2009/04/23 16:35:20 tsutsui Exp $
3 .include <bsd.sys.mk> # for HOST_SH
5 # $S must correspond to the top of the 'sys' tree
6 S= ${.CURDIR}/../../../..
10 # XXX SHOULD NOT NEED TO DEFINE THESE!
16 .PATH: ${.CURDIR}/../common
17 AFLAGS+= -D_LOCORE -D_KERNEL -mno-abicalls
18 # -I${.CURDIR}/../.. done by Makefile.inc
19 CPPFLAGS+= -nostdinc -D_STANDALONE -DNO_ABICALLS -D_NO_PROM_DEFINES \
21 # compiler flags for smallest code size
22 CFLAGS= -ffreestanding -Os -g -mmemcpy -mno-abicalls -G 128
23 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
25 LDBUG= -T $S/arch/mips/conf/stand.ldscript
27 NETBSD_VERS!= ${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
28 CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
30 PRIMARY_LOAD_ADDRESS?= 0x80700000
31 SECONDARY_LOAD_ADDRESS?=0x80710000
35 .if defined(PRIMARY_PROG)
37 SRCS = start.S bootxx.c callvec.c
38 SRCS+= devopen.c conf.c rz.c
39 SRCS+= bootinit.S bootread.S clear_cache.S printf.S
41 LOAD_ADDRESS= ${PRIMARY_LOAD_ADDRESS}
42 # Pick a number, any number...
43 PRIMARY_MAX_TOTAL!= expr 16 \* 1024
45 CPPFLAGS+= -DPRIMARY_BOOTBLOCK \
46 -DPRIMARY_LOAD_ADDRESS="${PRIMARY_LOAD_ADDRESS}" \
48 -DLIBSA_NO_FS_SYMLINK -DLIBSA_NO_FS_WRITE \
50 -DLIBSA_NO_DEV_CLOSE \
51 -DLIBSA_NO_DEV_IOCTL \
52 -DLIBSA_SINGLE_DEVICE=rz \
53 -D"rzioctl(x,y,z)=EINVAL" -D"rzclose(f)=0" \
55 -DLIBSA_NO_FD_CHECKING \
56 -DLIBSA_NO_RAW_ACCESS \
57 -DLIBSA_NO_DISKLABEL_MSGS \
60 CHECKSIZE_CMD?= SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
62 .elif defined(SECONDARY_PROG)
63 PROG= ${SECONDARY_PROG}
64 LOAD_ADDRESS= ${SECONDARY_LOAD_ADDRESS}
65 CPPFLAGS+= -DSECONDARY_BOOTBLOCK
72 ### find out what to use for libkern
74 .include "${S}/lib/libkern/Makefile.inc"
77 ### find out what to use for libz
78 .if defined(PRIMARY_PROG)
82 .include "${S}/lib/libz/Makefile.inc"
86 ### find out what to use for libsa
88 .if defined(PRIMARY_PROG)
89 SAMISCMAKEFLAGS+=SA_INCLUDE_NET=no
91 .if defined(SECONDARY_PROG)
92 SAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes SA_USE_CREAD=yes
93 SAMISCMAKEFLAGS+=SA_INCLUDE_NET=yes
95 .include "${S}/lib/libsa/Makefile.inc"
98 LIBS= ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}
100 .include <bsd.own.mk>
102 vers.c: ${.CURDIR}/version
103 ${HOST_SH} ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "pmax"
105 ${PROG}: ${OBJS} ${LIBS}
106 ${LD} -Map ${PROG}.map -N -x -Ttext ${LOAD_ADDRESS} \
107 ${LDBUG} -e start -o ${PROG} ${OBJS} ${LIBS}
109 .if defined(CHECKSIZE_CMD)
110 @${CHECKSIZE_CMD} ${PROG} ${PRIMARY_MAX_LOAD} ${PRIMARY_MAX_TOTAL} || \
111 (rm -f ${PROG} ; false)
113 .if defined(DO_ECOFF_BINARY)
114 @echo -n "Creating ECOFF binary... "
115 @mv ${PROG} ${PROG}.elf
116 @${ELF2ECOFF} ${PROG}.elf ${PROG}
120 .include <bsd.klinks.mk>
121 .include <bsd.prog.mk>
123 CLEANFILES+= ${PROG}.map ${PROG}.elf
125 cleandir distclean: cleanlibdir