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