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