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