xref: /netbsd-src/sys/arch/mips/conf/Makefile.mips (revision 75f6d617e282811cb173c2ccfbf5df0dd71f7045)
1#	$NetBSD: Makefile.mips,v 1.62 2015/08/24 14:04:24 uebayasi 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/mips/conf/Makefile.mips
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## (0) toolchain settings for things that aren't part of the standard
26## toolchain
27##
28ELF2ECOFF?=	elf2ecoff
29
30##
31## (1) port identification
32##
33.ifndef S
34S=		../../../..
35.endif
36THISMIPS=	$S/arch/${MACHINE}
37MIPS=		$S/arch/mips
38GENASSYM_CONF=	${MIPS}/mips/genassym.cf
39.-include "${THISMIPS}/conf/Makefile.${MACHINE}.inc"
40
41##
42## (2) compile settings
43##
44## Note: -ffixed-?? must be kept in sync with cpu.h.
45##
46CPPFLAGS+=	-D${MACHINE}
47DEFGP?=		-G 0
48GP?=		${DEFGP}
49CFLAGS+=	${GP} -mno-abicalls -msoft-float -ffixed-24
50.if defined(LP64) && ${LP64} == "yes"
51.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
52CFLAGS+=	-msym32 -mabi=64
53AFLAGS+=	-msym32 -mabi=64
54.endif
55.if ${MACHINE_ARCH} == "mips64eb"
56LDFLAGS+=	-m elf64btsmip
57LINKFORMAT+=	-m elf64btsmip
58SYSTEM_LD_TAIL_EXTRA+= \
59		;echo ${OBJCOPY} -O elf32-ntradbigmips $@ $@.elf32; \
60		${OBJCOPY} -O elf32-ntradbigmips $@ $@.elf32
61.endif
62.if ${MACHINE_ARCH} == "mips64el"
63LDFLAGS+=	-m elf64ltsmip
64LINKFORMAT+=	-m elf64ltsmip
65SYSTEM_LD_TAIL_EXTRA+= \
66		;echo ${OBJCOPY} -O elf32-ntradlittlemips $@ $@.elf32; \
67		${OBJCOPY} -O elf32-ntradlittlemips $@ $@.elf32
68.endif
69.endif # LP64=yes
70AFLAGS+=	-mno-abicalls -x assembler-with-cpp ${AOPTS}
71
72##
73## (3) libkern and compat
74##
75OPT_MODULAR=	%MODULAR%
76.if !empty(OPT_MODULAR)
77KERN_AS=	obj
78.else
79KERN_AS=	library
80.endif
81
82##
83## (4) local objects, compile rules, and dependencies
84##
85MD_OBJS=	locore.o locore_machdep.o
86MD_CFILES=
87MD_SFILES=	${MIPS}/mips/locore.S ${THISMIPS}/${MACHINE}/locore_machdep.S
88
89locore.o: ${MIPS}/mips/locore.S assym.h
90	${NORMAL_S}
91
92locore_machdep.o: ${THISMIPS}/${MACHINE}/locore_machdep.S assym.h
93	${NORMAL_S}
94
95##
96## (5) link settings
97##
98.if ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el"
99TEXTADDR?=              ${DEFTEXTADDR:C/0x8/0xFFFFFFFF8/}
100.else
101TEXTADDR?=		${DEFTEXTADDR}
102.endif
103KERNLDSCRIPT?=		${MIPS}/conf/kern.ldscript
104# some mips ports specify a "magic" format
105EXTRA_LINKFLAGS=	${GP} ${LDOPTS}
106LINKFLAGS_NORMAL=	-X
107STRIPFLAGS=		-g -X
108
109##
110## (6) port specific target dependencies
111##
112
113# depend on CPU configuration
114machdep.o mainbus.o trap.o: Makefile
115
116# depend on System V IPC/shmem options
117mips_machdep.o pmap.o: Makefile
118
119# various assembly files that depend on assym.h
120copy.o fp.o locore.o locore_mips1.o locore_mips3.o: assym.h
121lock_stubs.o mips32_subr.o mips3_subr.o: assym.h
122mips64_subr.o mipsX_subr.o sigcode.o: assym.h
123
124
125##
126## (7) misc settings
127##
128
129##
130## (8) config(8) generated machinery
131##
132%INCLUDES
133
134%OBJS
135
136%CFILES
137
138%SFILES
139
140%LOAD
141
142%RULES
143
144##
145## (9) port independent kernel machinery
146##
147.include "$S/conf/Makefile.kern.inc"
148
149##
150## (10) Appending make options.
151##
152%MAKEOPTIONSAPPEND
153