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