Home | History | Annotate | Line # | Download | only in conf
Makefile.riscv revision 1.6.8.1
      1  1.6.8.1  thorpej #	$NetBSD: Makefile.riscv,v 1.6.8.1 2021/05/13 00:47:27 thorpej Exp $
      2      1.1     matt 
      3      1.1     matt # Makefile for NetBSD
      4      1.1     matt #
      5      1.1     matt # This makefile is constructed from a machine description:
      6      1.1     matt #	config machineid
      7      1.1     matt # Most changes should be made in the machine description
      8      1.1     matt #	/sys/arch/<machine>/conf/``machineid''
      9      1.1     matt # after which you should do
     10      1.1     matt #	config machineid
     11      1.1     matt # Machine generic makefile changes should be made in
     12      1.1     matt #	/sys/arch/riscv/conf/Makefile.riscv
     13      1.1     matt # after which config should be rerun for all machines of that type.
     14      1.1     matt #
     15      1.1     matt # To specify debugging, add the config line: makeoptions DEBUG="-g"
     16      1.1     matt # A better way is to specify -g only for a few files.
     17      1.1     matt #
     18      1.1     matt #	makeoptions DEBUGLIST="uvm* trap if_*"
     19      1.1     matt 
     20      1.1     matt USETOOLS?=	no
     21      1.1     matt NEED_OWN_INSTALL_TARGET?=no
     22      1.1     matt .include <bsd.own.mk>
     23      1.1     matt 
     24      1.1     matt ##
     25      1.1     matt ## (1) port identification
     26      1.1     matt ##
     27      1.1     matt .ifndef S
     28      1.1     matt S=		../../../..
     29      1.1     matt .endif
     30      1.1     matt THISRISCV=	$S/arch/${MACHINE}
     31      1.1     matt RISCV=		$S/arch/riscv
     32      1.1     matt GENASSYM_CONF=	${RISCV}/riscv/genassym.cf
     33      1.1     matt .-include "${THISRISCV}/conf/Makefile.${MACHINE}.inc"
     34      1.1     matt 
     35      1.1     matt ##
     36      1.1     matt ## (2) compile settings
     37      1.1     matt ##
     38      1.1     matt ## Note: -ffixed-?? must be kept in sync with cpu.h.
     39      1.1     matt ##
     40      1.1     matt CPPFLAGS+=	-D${MACHINE}
     41      1.2     matt CFLAGS+=	-mcmodel=medany
     42      1.1     matt .if !defined(LP64) || ${LP64} == "no"
     43      1.1     matt CFLAGS+=	-m32
     44      1.1     matt AFLAGS+=	-m32
     45      1.1     matt LDFLAGS+=	-m elf32lriscv
     46      1.1     matt LINKFORMAT+=	-m elf32lriscv
     47      1.1     matt SYSTEM_LD_TAIL_EXTRA+= \
     48      1.1     matt 		;echo ${OBJCOPY} -O elf32-littleriscv $@ $@.elf32; \
     49      1.1     matt 		${OBJCOPY} -O elf32-littleriscv $@ $@.elf32
     50      1.1     matt .endif # LP64=no
     51      1.1     matt AFLAGS+=	-x assembler-with-cpp ${AOPTS}
     52      1.1     matt 
     53      1.1     matt ##
     54      1.1     matt ## (3) libkern and compat
     55      1.1     matt ##
     56      1.1     matt OPT_MODULAR=	%MODULAR%
     57      1.1     matt 
     58      1.1     matt ##
     59      1.1     matt ## (4) local objects, compile rules, and dependencies
     60      1.1     matt ##
     61      1.1     matt MD_OBJS=	locore.o
     62      1.1     matt MD_CFILES=
     63      1.1     matt MD_SFILES=	${RISCV}/riscv/locore.S
     64      1.1     matt 
     65      1.1     matt locore.o: ${RISCV}/riscv/locore.S assym.h
     66      1.1     matt 	${NORMAL_S}
     67      1.1     matt 
     68      1.1     matt ##
     69      1.1     matt ## (5) link settings
     70      1.1     matt ##
     71      1.1     matt .if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
     72      1.5     maxv TEXTADDR?=		0xFFFFFFC000000000
     73      1.5     maxv .else
     74      1.1     matt TEXTADDR?=		0xC0001000
     75      1.1     matt .endif
     76      1.1     matt KERNLDSCRIPT?=		${RISCV}/conf/kern.ldscript
     77      1.1     matt EXTRA_LINKFLAGS=	${LDOPTS} --relax
     78      1.1     matt LINKFLAGS_NORMAL=	-X
     79      1.1     matt STRIPFLAGS=		-g -X
     80      1.1     matt 
     81  1.6.8.1  thorpej # Set the physical load address (aka LMA) to the address that OpenSBI's
     82  1.6.8.1  thorpej # fw_jump jumps to.  This allows us to load the kernel with the -kernel flag
     83  1.6.8.1  thorpej # in QEMU without having to embed it inside BBL or OpenSBI's fw_payload first.
     84  1.6.8.1  thorpej #
     85  1.6.8.1  thorpej KERNEL_PHYS?=		0x80200000
     86  1.6.8.1  thorpej EXTRA_LINKFLAGS+=	--defsym='KERNEL_PHYS=${KERNEL_PHYS}'
     87  1.6.8.1  thorpej 
     88      1.1     matt ##
     89      1.1     matt ## (6) port specific target dependencies
     90      1.1     matt ##
     91      1.1     matt 
     92      1.1     matt # depend on CPU configuration
     93      1.1     matt machdep.o mainbus.o trap.o: Makefile
     94      1.1     matt 
     95      1.1     matt # depend on System V IPC/shmem options
     96      1.1     matt riscv_machdep.o pmap.o: Makefile
     97      1.1     matt 
     98      1.1     matt # various assembly files that depend on assym.h
     99      1.1     matt locore.o: assym.h
    100      1.1     matt 
    101      1.1     matt ##
    102      1.1     matt ## (7) misc settings
    103      1.1     matt ##
    104      1.1     matt RAMDISKDIR!=    cd ${NETBSDSRCDIR}/distrib/riscv/ramdisk && ${PRINTOBJDIR}
    105      1.1     matt 
    106      1.1     matt .if defined(NEED_MDSETIMAGE) && ${NEED_MDSETIMAGE} != "no" \
    107      1.1     matt     && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs)
    108      1.6    skrll SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs
    109      1.1     matt SYSTEM_LD_TAIL_EXTRA+=; \
    110      1.1     matt 	echo ${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs; \
    111      1.1     matt 	${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs
    112      1.1     matt .if !empty(DEBUG:M-g*)
    113      1.1     matt SYSTEM_LD_TAIL_EXTRA+=; \
    114      1.1     matt 	echo ${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs; \
    115      1.1     matt 	${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs
    116      1.1     matt .endif
    117      1.1     matt .endif
    118      1.1     matt 
    119      1.1     matt ##
    120      1.1     matt ## (8) config(8) generated machinery
    121      1.1     matt ##
    122      1.1     matt %INCLUDES
    123      1.1     matt 
    124      1.1     matt %OBJS
    125      1.1     matt 
    126      1.1     matt %CFILES
    127      1.1     matt 
    128      1.1     matt %SFILES
    129      1.1     matt 
    130      1.1     matt %LOAD
    131      1.1     matt 
    132      1.1     matt %RULES
    133      1.1     matt 
    134      1.1     matt ##
    135      1.1     matt ## (9) port independent kernel machinery
    136      1.1     matt ##
    137      1.1     matt .include "$S/conf/Makefile.kern.inc"
    138      1.1     matt 
    139      1.1     matt ##
    140      1.1     matt ## (10) Appending make options.
    141      1.1     matt ##
    142      1.1     matt %MAKEOPTIONSAPPEND
    143