Home | History | Annotate | Line # | Download | only in conf
      1 #	$NetBSD: Makefile.riscv,v 1.11 2024/02/25 14:27:41 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 .if !defined(LP64) && ${MACHINE_ARCH} == "riscv64"
     26 . info (Building GENERIC instead of GENERIC64?)
     27 . error Don't build 32-bit kernel with 64-bit toolchain
     28 .endif
     29 
     30 .if defined(LP64) && ${MACHINE_ARCH} == "riscv32"
     31 . info (Building GENERIC64 instead of GENERIC?)
     32 . error Don't build 64-bit kernel with 32-bit toolchain
     33 .endif
     34 
     35 
     36 ##
     37 ## (1) port identification
     38 ##
     39 .ifndef S
     40 S=		../../../..
     41 .endif
     42 THISRISCV=	$S/arch/${MACHINE}
     43 RISCV=		$S/arch/riscv
     44 GENASSYM_CONF=	${RISCV}/riscv/genassym.cf
     45 .-include "${THISRISCV}/conf/Makefile.${MACHINE}.inc"
     46 
     47 ##
     48 ## (2) compile settings
     49 ##
     50 ## Note: -ffixed-?? must be kept in sync with cpu.h.
     51 ##
     52 CPPFLAGS+=	-D${MACHINE}
     53 CFLAGS+=	-mcmodel=medany
     54 AFLAGS+=	-x assembler-with-cpp ${AOPTS}
     55 
     56 ##
     57 ## (3) libkern and compat
     58 ##
     59 OPT_MODULAR=	%MODULAR%
     60 
     61 ##
     62 ## (4) local objects, compile rules, and dependencies
     63 ##
     64 MD_OBJS=	locore.o
     65 MD_CFILES=
     66 MD_SFILES=	${RISCV}/riscv/locore.S
     67 
     68 locore.o: ${RISCV}/riscv/locore.S assym.h
     69 	${NORMAL_S}
     70 
     71 ##
     72 ## (5) link settings
     73 ##
     74 .if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes"
     75 TEXTADDR?=		0xFFFFFFC000000000
     76 .else
     77 TEXTADDR?=		0x80200000
     78 .endif
     79 KERNLDSCRIPT?=		${RISCV}/conf/kern.ldscript
     80 EXTRA_LINKFLAGS=	${LDOPTS} --relax
     81 LINKFLAGS_NORMAL=	-X
     82 OBJCOPY_STRIPFLAGS=	-g -X
     83 
     84 # Set the physical load address (aka LMA) to the address that OpenSBI's
     85 # fw_jump jumps to.  This allows us to load the kernel with the -kernel flag
     86 # in QEMU without having to embed it inside BBL or OpenSBI's fw_payload first.
     87 #
     88 KERNEL_PHYS?=		0x80200000
     89 EXTRA_LINKFLAGS+=	--defsym='KERNEL_PHYS=${KERNEL_PHYS}'
     90 
     91 ##
     92 ## (6) port specific target dependencies
     93 ##
     94 
     95 # depend on CPU configuration
     96 machdep.o mainbus.o trap.o: Makefile
     97 
     98 # depend on System V IPC/shmem options
     99 riscv_machdep.o pmap.o: Makefile
    100 
    101 # various assembly files that depend on assym.h
    102 locore.o: assym.h
    103 
    104 ##
    105 ## (7) misc settings
    106 ##
    107 RAMDISKDIR!=    cd ${NETBSDSRCDIR}/distrib/riscv/ramdisk && ${PRINTOBJDIR}
    108 
    109 .if defined(NEED_MDSETIMAGE) && ${NEED_MDSETIMAGE} != "no" \
    110     && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs)
    111 SYSTEM_DEP+=    ${RAMDISKDIR}/ramdisk.fs
    112 SYSTEM_LD_TAIL_EXTRA+=; \
    113 	echo ${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs; \
    114 	${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs
    115 .if !empty(DEBUG:M-g*)
    116 SYSTEM_LD_TAIL_EXTRA+=; \
    117 	echo ${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs; \
    118 	${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs
    119 .endif
    120 .endif
    121 
    122 ##
    123 ## (8) config(8) generated machinery
    124 ##
    125 %INCLUDES
    126 
    127 %OBJS
    128 
    129 %CFILES
    130 
    131 %SFILES
    132 
    133 %LOAD
    134 
    135 %RULES
    136 
    137 ##
    138 ## (9) port independent kernel machinery
    139 ##
    140 .include "$S/conf/Makefile.kern.inc"
    141 
    142 ##
    143 ## (10) Appending make options.
    144 ##
    145 %MAKEOPTIONSAPPEND
    146