Home | History | Annotate | Line # | Download | only in stand
Makefile.bootprogs revision 1.11
      1 # $NetBSD: Makefile.bootprogs,v 1.11 2013/08/21 06:27:54 matt Exp $
      2 
      3 .include <bsd.own.mk>
      4 .include <bsd.klinks.mk>
      5 .include <bsd.sys.mk>		# for HOST_SH
      6 
      7 S=	${.CURDIR}/../../../..
      8 
      9 .PATH:	${.CURDIR}/../common
     10 
     11 STRIPFLAG=
     12 BINMODE= 444
     13 
     14 # XXX SHOULD NOT NEED TO DEFINE THESE!
     15 LIBCRT0=
     16 LIBC=
     17 LIBCRTBEGIN=
     18 LIBCRTEND=
     19 
     20 STRIP?=	strip
     21 
     22 CHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
     23 
     24 AFLAGS+=	-DASSEMBLER -D_LOCORE -mno-abicalls -mips64
     25 # -I${.CURDIR}/../.. done by Makefile.inc
     26 CPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
     27 CFLAGS=		-Os -g -ffreestanding -mno-abicalls -msoft-float -G 0
     28 CFLAGS+=	-mips64
     29 CFLAGS+=	-Werror ${CWARNFLAGS}
     30 
     31 NETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
     32 CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
     33 
     34 CWARNFLAGS+=	-Wno-main 
     35 CWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
     36 CWARNFLAGS+=	-Wno-pointer-sign
     37 
     38 # if there is a 'version' file, add rule for vers.c and add it to SRCS
     39 # and CLEANFILES
     40 .if exists(version)
     41 .PHONY: vers.c
     42 vers.c: version
     43 	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
     44 	    -N ${.CURDIR}/version "sbmips"
     45 
     46 SRCS+=	vers.c
     47 CLEANFILES+= vers.c
     48 .endif
     49 
     50 # 
     51 # Refer to CFE documentation for a description of these regions.
     52 # 
     53 
     54 REGION1_START=		0x20000000		# "Region 1 start"
     55 REGION1_SIZE!=		expr 256 \* 1024	# 256k
     56 
     57 LDSCRIPT=		${.CURDIR}/../common/boot.ldscript
     58 
     59 # our memory lauout:
     60 
     61 #	'unified' boot loaders (e.g. netboot) can consume all of region
     62 #	1 for their text+data, or text+data+bss.
     63 
     64 UNIFIED_LOAD_ADDRESS=	${REGION1_START}
     65 UNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
     66 UNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
     67 
     68 #UNIFIED_HEAP_START=	right after secondary bss
     69 UNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
     70 
     71 #	two-stage boot loaders must share region 1.  The first stage
     72 #	loads into the lowest portion, and uses the higest portion
     73 #	for its heap.  The second stage loads in between the primary image
     74 #	and the heap, and can reuse the memory after it (i.e. the primary's
     75 #	heap) for its own heap.
     76 
     77 PRIMARY_LOAD_ADDRESS=	${REGION1_START}
     78 #PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
     79 PRIMARY_MAX_TOTAL!=	expr 16 \* 1024
     80 
     81 # XXX SECONDARY_LOAD_ADDRESS should be
     82 # XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
     83 # XXX way to do that calculation and 'ld' wants a single number.
     84 SECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
     85 SECONDARY_MAX_LOAD!=	expr 112 \* 1024
     86 SECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
     87 
     88 PRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
     89 PRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
     90 
     91 #SECONDARY_HEAP_START=	right after secondary bss
     92 SECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
     93 
     94 #	standalone programs are like kernels.  They load at
     95 #	0xfffffc0000300000 and can use the rest of memory.
     96 
     97 STANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
     98 
     99 
    100 FILE_FORMAT_CPPFLAGS=	-DBOOT_ELF
    101 
    102 UNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
    103 			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
    104 			${FILE_FORMAT_CPPFLAGS}
    105 
    106 PRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
    107 			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
    108 			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
    109 			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
    110 			-DHEAP_START="${PRIMARY_HEAP_START}"
    111 
    112 SECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
    113 			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
    114 			${FILE_FORMAT_CPPFLAGS}
    115 
    116 STANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
    117 
    118 .include <bsd.prog.mk>
    119 
    120 ### find out what to use for libkern
    121 KERN_AS=	library
    122 .include "${S}/lib/libkern/Makefile.inc"
    123 LIBKERN=	${KERNLIB}
    124 
    125 ### find out what to use for libz
    126 Z_AS=		library
    127 .include "${S}/lib/libz/Makefile.inc"
    128 LIBZ=		${ZLIB}
    129 
    130 ### find out what to use for libsa
    131 SA_AS=		library
    132 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
    133 .include "${S}/lib/libsa/Makefile.inc"
    134 LIBSA=		${SALIB}
    135 
    136 /usr/lib/crt0.o:
    137 	true
    138 
    139 /usr/lib/crtbegin.o:
    140 	true
    141 
    142 /usr/lib/crtend.o:
    143 	true
    144 
    145 cleandir: .WAIT cleandirlocal
    146 cleandirlocal:
    147 	-rm -rf lib
    148