xref: /openbsd/sys/arch/sparc64/conf/Makefile.sparc64 (revision d415bd75)
1#	$OpenBSD: Makefile.sparc64,v 1.106 2023/09/06 01:47:38 jsg 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
32.if ${COMPILER_VERSION:Mclang}
33CMACHFLAGS=	-Wa,-Av9b -msoft-float
34.else
35CMACHFLAGS=	-Wa,-Av9b, -mno-fpu
36.endif
37CMACHFLAGS+=	-ffreestanding ${NOPIE_FLAGS}
38SORTR=		sort -R
39.if ${IDENT:M-DNO_PROPOLICE}
40CMACHFLAGS+=	-fno-stack-protector
41.endif
42.if ${IDENT:M-DSMALL_KERNEL}
43SORTR=		cat
44COPTIMIZE?=	-Oz
45.endif
46.if ${COMPILER_VERSION:Mclang}
47CWARNFLAGS+=	-Wno-unused-command-line-argument
48CWARNFLAGS+=	-Wno-address-of-packed-member -Wno-constant-conversion \
49		-Wno-unused-but-set-variable -Wno-gnu-folding-constant
50.endif
51
52DEBUG?=		-g
53COPTIMIZE?=	-O2
54CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTIMIZE} ${COPTS} ${PIPE}
55AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
56LINKFLAGS=	-n -T ld.script --warn-common -nopie
57
58HOSTCC?=	${CC}
59HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
60HOSTED_CFLAGS=	${CFLAGS}
61HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
62
63NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
64NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
65NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c $<
66
67%OBJS
68
69%CFILES
70
71%SFILES
72
73# load lines for config "xxx" will be emitted as:
74# xxx: ${SYSTEM_DEP} swapxxx.o
75#	${SYSTEM_LD_HEAD}
76#	${SYSTEM_LD} swapxxx.o
77#	${SYSTEM_LD_TAIL}
78SYSTEM_HEAD=	locore.o gap.o
79SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS} param.o ioconf.o
80SYSTEM_DEP=	Makefile ${SYSTEM_OBJ} ld.script
81SYSTEM_LD_HEAD=	@rm -f $@
82SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
83		umask 007; \
84		echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \
85		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder`
86SYSTEM_LD_TAIL=	@${SIZE} $@
87
88.if ${DEBUG} == "-g"
89STRIPFLAGS=	-S
90SYSTEM_LD_TAIL+=; umask 007; \
91		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
92		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
93		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
94.else
95LINKFLAGS+=	-S
96.endif
97
98%LOAD
99
100# cc's -MD puts the source and output paths in the dependency file;
101# since those are temp files here we need to fix it up.  It also
102# puts the file in /tmp, so we use -MF to put it in the current
103# directory as assym.P and then generate assym.d from it with a
104# good target name
105assym.h: $S/kern/genassym.sh Makefile \
106	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
107	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
108	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
109	sed '1s/.*/assym.h: \\/' assym.P > assym.d
110	sort -u assym.h.tmp > assym.h
111
112param.c: $S/conf/param.c
113	rm -f param.c
114	cp $S/conf/param.c .
115
116param.o: param.c Makefile
117	${NORMAL_C}
118
119mcount.o: $S/lib/libkern/mcount.c Makefile
120	${NORMAL_C_NOP}
121
122ioconf.o: ioconf.c
123	${NORMAL_C}
124
125ld.script: ${_machdir}/conf/ld.script
126	cp ${_machdir}/conf/ld.script $@
127
128makegap.sh:
129	cp $S/conf/makegap.sh $@
130
131MAKE_GAP = LD="${LD}" sh makegap.sh 0x00000000
132
133gap.o:	Makefile makegap.sh vers.o
134	${MAKE_GAP}
135
136vers.o: ${SYSTEM_DEP:Ngap.o}
137	sh $S/conf/newvers.sh
138	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
139
140clean:
141	rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \
142	    gap.link ld.script lorder makegap.sh param.c
143
144cleandir: clean
145	rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c
146
147depend obj:
148
149locore.o: ${_machdir}/${_mach}/locore.s assym.h
150hvcall.o in_cksum.o mutex.o: assym.h
151
152hardlink-obsd:
153	[[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd
154
155newinstall:
156	install -m 700 -F bsd /bsd && sha256 -h /var/db/kernel.SHA256 /bsd
157
158install: update-link hardlink-obsd newinstall
159
160# pull in the dependency information
161.ifnmake clean
162. for o in ${SYSTEM_OBJ:Ngap.o} assym.h
163.  if exists(${o:R}.d)
164.   include "${o:R}.d"
165.  elif exists($o)
166    .PHONY: $o
167.  endif
168. endfor
169.endif
170
171%RULES
172