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