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