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