xref: /netbsd-src/sys/arch/mips/conf/Makefile.mips (revision 62f324d0121177eaf2e0384f92fd9ca2a751c795)
1#	$NetBSD: Makefile.mips,v 1.59 2013/03/10 07:18:20 christos 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
105LINKFORMAT+=		-T ${KERNLDSCRIPT}
106EXTRA_LINKFLAGS=	${GP} ${LDOPTS}
107LINKFLAGS_NORMAL=	-X
108STRIPFLAGS=		-g -X
109
110##
111## (6) port specific target dependencies
112##
113
114# depend on CPU configuration
115machdep.o mainbus.o trap.o: Makefile
116
117# depend on System V IPC/shmem options
118mips_machdep.o pmap.o: Makefile
119
120# various assembly files that depend on assym.h
121copy.o fp.o locore.o locore_mips1.o locore_mips3.o: assym.h
122lock_stubs.o mips32_subr.o mips3_subr.o: assym.h
123mips64_subr.o mipsX_subr.o sigcode.o: assym.h
124
125
126##
127## (7) misc settings
128##
129
130##
131## (8) config(8) generated machinery
132##
133%INCLUDES
134
135%OBJS
136
137%CFILES
138
139%SFILES
140
141%LOAD
142
143%RULES
144
145##
146## (9) port independent kernel machinery
147##
148.include "$S/conf/Makefile.kern.inc"
149
150##
151## (10) Appending make options.
152##
153%MAKEOPTIONSAPPEND
154