Home | History | Annotate | Line # | Download | only in stand
Makefile.bootprogs revision 1.28
      1 # $NetBSD: Makefile.bootprogs,v 1.28 2009/01/12 07:10:13 tsutsui 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+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
     43 CFLAGS+=	-Werror ${CWARNFLAGS}
     44 
     45 # if there is a 'version' file, add rule for vers.c and add it to SRCS
     46 # and CLEANFILES
     47 .if exists(version)
     48 .PHONY: vers.c
     49 vers.c: version
     50 	${HOST_SH} ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "alpha"
     51 
     52 SRCS+=	vers.c
     53 CLEANFILES+= vers.c
     54 .endif
     55 
     56 # For descriptions of regions available to bootstrap programs, see
     57 # section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
     58 # the Alpha AXP Architecture Reference Manual.
     59 
     60 REGION1_START=		0x20000000		# "Region 1 start"
     61 REGION1_SIZE!=		expr 256 \* 1024	# 256k
     62 
     63 # our memory lauout:
     64 
     65 #	'unified' boot loaders (e.g. netboot) can consume all of region
     66 #	1 for their text+data, or text+data+bss.
     67 
     68 UNIFIED_LOAD_ADDRESS=	${REGION1_START}
     69 UNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
     70 UNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
     71 
     72 #UNIFIED_HEAP_START=	right after secondary bss
     73 UNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
     74 
     75 #	two-stage boot loaders must share region 1.  The first stage
     76 #	loads into the lowest portion, and uses the higest portion
     77 #	for its heap.  The second stage loads in between the primary image
     78 #	and the heap, and can reuse the memory after it (i.e. the primary's
     79 #	heap) for its own heap.
     80 
     81 PRIMARY_LOAD_ADDRESS=	${REGION1_START}
     82 #PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
     83 PRIMARY_MAX_TOTAL!=	expr 16 \* 1024
     84 
     85 # XXX SECONDARY_LOAD_ADDRESS should be
     86 # XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
     87 # XXX way to do that calculation and 'ld' wants a single number.
     88 SECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
     89 SECONDARY_MAX_LOAD!=	expr 112 \* 1024
     90 SECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
     91 
     92 PRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
     93 PRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
     94 
     95 #SECONDARY_HEAP_START=	right after secondary bss
     96 SECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
     97 
     98 #	standalone programs are like kernels.  They load at
     99 #	0xfffffc0000300000 and can use the rest of memory.
    100 
    101 STANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
    102 
    103 
    104 FILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
    105 
    106 UNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
    107 			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
    108 			${FILE_FORMAT_CPPFLAGS}
    109 
    110 PRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
    111 			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
    112 			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
    113 			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
    114 			-DHEAP_START="${PRIMARY_HEAP_START}"
    115 
    116 SECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
    117 			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
    118 			${FILE_FORMAT_CPPFLAGS}
    119 
    120 STANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
    121 
    122 .include <bsd.prog.mk>
    123 
    124 COPTS+=-Os	# override -O supplied by user
    125 
    126 ### find out what to use for libkern
    127 KERN_AS=	library
    128 .include "${S}/lib/libkern/Makefile.inc"
    129 LIBKERN=	${KERNLIB}
    130 
    131 ### find out what to use for libz
    132 Z_AS=		library
    133 .include "${S}/lib/libz/Makefile.inc"
    134 LIBZ=		${ZLIB}
    135 
    136 ### find out what to use for libsa
    137 SA_AS=		library
    138 SAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
    139 .include "${S}/lib/libsa/Makefile.inc"
    140 LIBSA=		${SALIB}
    141