xref: /openbsd-src/sys/arch/sparc64/conf/Makefile.sparc64 (revision dfe59edef63f32bf1301011034ee6b32a33019ae)
1#	$OpenBSD: Makefile.sparc64,v 1.109 2024/04/25 05:23:45 miod Exp $
2
3# For instructions on building kernels consult the config(8) and options(4)
4# manual pages.
5#
6# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
7#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
8# DEBUG is set to -g by config if debugging is requested (config -g).
9# PROF is set to -pg by config if profiling is requested (config -p).
10
11.include <bsd.own.mk>
12
13SIZE?=	size
14STRIP?=	ctfstrip
15
16# source tree is located via $S relative to the compilation directory
17.ifndef S
18S!=	cd ../../../..; pwd
19.endif
20
21_machdir?=	$S/arch/${_mach}
22_archdir?=	$S/arch/${_arch}
23
24INCLUDES=	-nostdinc -I$S -I${.OBJDIR} -I$S/arch \
25		-I$S/dev/pci/drm/include \
26		-I$S/dev/pci/drm/include/uapi
27CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP
28CWARNFLAGS=	-Werror -Wall -Wimplicit-function-declaration \
29		-Wno-uninitialized -Wno-pointer-sign \
30		-Wframe-larger-than=2047
31
32CMACHFLAGS=	-Wa,-Av9b -mno-fpu
33CMACHFLAGS+=	-ffreestanding ${NOPIE_FLAGS}
34SORTR=		sort -R
35.if ${IDENT:M-DNO_PROPOLICE}
36CMACHFLAGS+=	-fno-stack-protector
37.endif
38.if ${IDENT:M-DSMALL_KERNEL}
39SORTR=		cat
40COPTIMIZE?=	-Oz
41.endif
42.if ${COMPILER_VERSION:Mclang}
43NO_INTEGR_AS=	-no-integrated-as
44CWARNFLAGS+=	-Wno-unused-command-line-argument
45CWARNFLAGS+=	-Wno-address-of-packed-member -Wno-constant-conversion \
46		-Wno-unused-but-set-variable -Wno-gnu-folding-constant
47.endif
48
49DEBUG?=		-g
50COPTIMIZE?=	-O2
51CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTIMIZE} ${COPTS} ${PIPE}
52AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
53LINKFLAGS=	-n -T ld.script --warn-common -nopie
54
55HOSTCC?=	${CC}
56HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
57HOSTED_CFLAGS=	${CFLAGS}
58HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
59
60NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -fno-stack-protector -c $<
61NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
62NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c $<
63
64%OBJS
65
66%CFILES
67
68%SFILES
69
70# load lines for config "xxx" will be emitted as:
71# xxx: ${SYSTEM_DEP} swapxxx.o
72#	${SYSTEM_LD_HEAD}
73#	${SYSTEM_LD} swapxxx.o
74#	${SYSTEM_LD_TAIL}
75SYSTEM_HEAD=	locore.o gap.o
76SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS} param.o ioconf.o
77SYSTEM_DEP=	Makefile ${SYSTEM_OBJ} ld.script
78SYSTEM_LD_HEAD=	@rm -f $@
79SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
80		umask 007; \
81		echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \
82		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder`
83SYSTEM_LD_TAIL=	@${SIZE} $@
84
85.if ${DEBUG} == "-g"
86STRIPFLAGS=	-S
87SYSTEM_LD_TAIL+=; umask 007; \
88		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
89		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
90		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
91.else
92LINKFLAGS+=	-S
93.endif
94
95%LOAD
96
97# cc's -MD puts the source and output paths in the dependency file;
98# since those are temp files here we need to fix it up.  It also
99# puts the file in /tmp, so we use -MF to put it in the current
100# directory as assym.P and then generate assym.d from it with a
101# good target name
102assym.h: $S/kern/genassym.sh Makefile \
103	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
104	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
105	    sh $S/kern/genassym.sh ${CC} ${NO_INTEGR_AS} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
106	sed '1s/.*/assym.h: \\/' assym.P > assym.d
107	sort -u assym.h.tmp > assym.h
108
109param.c: $S/conf/param.c
110	rm -f param.c
111	cp $S/conf/param.c .
112
113param.o: param.c Makefile
114	${NORMAL_C}
115
116mcount.o: $S/lib/libkern/mcount.c Makefile
117	${NORMAL_C_NOP}
118
119ioconf.o: ioconf.c
120	${NORMAL_C}
121
122ld.script: ${_machdir}/conf/ld.script
123	cp ${_machdir}/conf/ld.script $@
124
125makegap.sh:
126	cp $S/conf/makegap.sh $@
127
128MAKE_GAP = LD="${LD}" sh makegap.sh 0x00000000
129
130gap.o:	Makefile makegap.sh vers.o
131	${MAKE_GAP}
132
133vers.o: ${SYSTEM_DEP:Ngap.o}
134	sh $S/conf/newvers.sh
135	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
136
137clean:
138	rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \
139	    gap.link ld.script lorder makegap.sh param.c
140
141cleandir: clean
142	rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c
143
144depend obj:
145
146locore.o: ${_machdir}/${_mach}/locore.s assym.h
147hvcall.o in_cksum.o mutex.o: assym.h
148
149hardlink-obsd:
150	[[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd
151
152newinstall:
153	install -F -m 700 bsd /bsd && sha256 -h /var/db/kernel.SHA256 /bsd
154
155install: update-link hardlink-obsd newinstall
156
157# pull in the dependency information
158.ifnmake clean
159. for o in ${SYSTEM_OBJ:Ngap.o} assym.h
160.  if exists(${o:R}.d)
161.   include "${o:R}.d"
162.  elif exists($o)
163    .PHONY: $o
164.  endif
165. endfor
166.endif
167
168%RULES
169