1 # $NetBSD: Makefile.riscv,v 1.5 2019/06/16 07:42:52 maxv 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 .if !defined(LP64) || ${LP64} == "no" 43 CFLAGS+= -m32 44 AFLAGS+= -m32 45 LDFLAGS+= -m elf32lriscv 46 LINKFORMAT+= -m elf32lriscv 47 SYSTEM_LD_TAIL_EXTRA+= \ 48 ;echo ${OBJCOPY} -O elf32-littleriscv $@ $@.elf32; \ 49 ${OBJCOPY} -O elf32-littleriscv $@ $@.elf32 50 .endif # LP64=no 51 AFLAGS+= -x assembler-with-cpp ${AOPTS} 52 53 ## 54 ## (3) libkern and compat 55 ## 56 OPT_MODULAR= %MODULAR% 57 58 ## 59 ## (4) local objects, compile rules, and dependencies 60 ## 61 MD_OBJS= locore.o 62 MD_CFILES= 63 MD_SFILES= ${RISCV}/riscv/locore.S 64 65 locore.o: ${RISCV}/riscv/locore.S assym.h 66 ${NORMAL_S} 67 68 ## 69 ## (5) link settings 70 ## 71 .if ${MACHINE_ARCH} == "riscv64" && ${LP64:Uyes} == "yes" 72 TEXTADDR?= 0xFFFFFFC000000000 73 .else 74 TEXTADDR?= 0xC0001000 75 .endif 76 KERNLDSCRIPT?= ${RISCV}/conf/kern.ldscript 77 LINKFORMAT+= -T ${KERNLDSCRIPT} 78 EXTRA_LINKFLAGS= ${LDOPTS} --relax 79 LINKFLAGS_NORMAL= -X 80 STRIPFLAGS= -g -X 81 82 ## 83 ## (6) port specific target dependencies 84 ## 85 86 # depend on CPU configuration 87 machdep.o mainbus.o trap.o: Makefile 88 89 # depend on System V IPC/shmem options 90 riscv_machdep.o pmap.o: Makefile 91 92 # various assembly files that depend on assym.h 93 locore.o: assym.h 94 95 ## 96 ## (7) misc settings 97 ## 98 RAMDISKDIR!= cd ${NETBSDSRCDIR}/distrib/riscv/ramdisk && ${PRINTOBJDIR} 99 100 .if defined(NEED_MDSETIMAGE) && ${NEED_MDSETIMAGE} != "no" \ 101 && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs) 102 SYSTEM_DEP+= ${RAMDISKDIR}/ramdisk.fs 103 SYSTEM_LD_TAIL_EXTRA+=; \ 104 echo ${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs; \ 105 ${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs 106 .if !empty(DEBUG:M-g*) 107 SYSTEM_LD_TAIL_EXTRA+=; \ 108 echo ${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs; \ 109 ${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs 110 .endif 111 .endif 112 113 ## 114 ## (8) config(8) generated machinery 115 ## 116 %INCLUDES 117 118 %OBJS 119 120 %CFILES 121 122 %SFILES 123 124 %LOAD 125 126 %RULES 127 128 ## 129 ## (9) port independent kernel machinery 130 ## 131 .include "$S/conf/Makefile.kern.inc" 132 133 ## 134 ## (10) Appending make options. 135 ## 136 %MAKEOPTIONSAPPEND 137