11.62Schristos#	$NetBSD: Makefile.powerpc,v 1.62 2024/03/20 00:35:21 christos Exp $
21.1Sws#
31.1Sws# Makefile for NetBSD
41.1Sws#
51.1Sws# This makefile is constructed from a machine description:
61.1Sws#	config machineid
71.1Sws# Most changes should be made in the machine description
81.1Sws#	/sys/arch/powerpc/conf/``machineid''
91.1Sws# after which you should do
101.1Sws#	config machineid
111.1Sws# Machine generic makefile changes should be made in
121.1Sws#	/sys/arch/powerpc/conf/Makefile.powerpc
131.1Sws# after which config should be rerun for all machines of that type.
141.1Sws#
151.20Satatat# To specify debugging, add the config line: makeoptions DEBUG="-g"
161.20Satatat# A better way is to specify -g only for a few files.
171.1Sws#
181.20Satatat#	makeoptions DEBUGLIST="uvm* trap if_*"
191.18Sthorpej
201.53SmattMACHINE_ARCH?=powerpc
211.19SjmcUSETOOLS?=	no
221.20SatatatNEED_OWN_INSTALL_TARGET?=no
231.16Sthorpej.include <bsd.own.mk>
241.1Sws
251.20Satatat##
261.20Satatat## (1) port identification
271.20Satatat##
281.17SthorpejTHISPPC=	$S/arch/${MACHINE}
291.14SmattPOWERPC=	$S/arch/powerpc
301.46SmattGENASSYM_CONF=	${POWERPC}/powerpc/genassym.cf
311.46SmattGENASSYM_CONF+=	${POWERPC}/${PPCDIR}/genassym.cf
321.22Smatt.if exists(${THISPPC}/${MACHINE}/genassym.cf)
331.46SmattGENASSYM_CONF+=	${THISPPC}/${MACHINE}/genassym.cf
341.22Smatt.endif
351.20Satatat.-include "${THISPPC}/conf/Makefile.${MACHINE}.inc"
361.1Sws
371.20Satatat##
381.20Satatat## (2) compile settings
391.20Satatat##
401.29SbriggsCPPFLAGS+=	-D${MACHINE}=${MACHINE}
411.20SatatatCWARNFLAGS+=	-Wreturn-type
421.32Smatt.if ${PPCDIR} == "oea"
431.57SjoergCFLAGS+=	${${ACTIVE_CC} == "gcc":? -mno-strict-align :}
441.57SjoergCFLAGS+=	${${ACTIVE_CC} == "gcc":? -Wa,-maltivec :}
451.32Smatt.endif
461.50Smatt.if ${PPCDIR} == "booke"
471.50SmattDEFCOPTS=	-O2
481.50SmattCFLAGS+=	-fstack-protector
491.57SjoergCFLAGS+=	${${ACTIVE_CC} == "gcc":? -misel :}
501.50Smatt.endif
511.60SjoergCFLAGS+=	${${ACTIVE_CC} == "gcc":? -msdata=none :}
521.60SjoergCFLAGS+=	-msoft-float
531.57SjoergCFLAGS+=	${CCPUOPTS}
541.44SmattAFLAGS+=	${AOPTS} -D_NOREGNAMES
551.20Satatat
561.20Satatat##
571.20Satatat## (3) libkern and compat
581.20Satatat##
591.43ScubeOPT_MODULAR=	%MODULAR%
601.20Satatat
611.20Satatat##
621.20Satatat## (4) local objects, compile rules, and dependencies
631.20Satatat##
641.24Sscw.if !defined(SYSTEM_FIRST_OBJ)
651.24SscwSYSTEM_FIRST_OBJ= locore.o
661.24Sscw.endif
671.24Sscw.if !defined(SYSTEM_FIRST_SFILE)
681.24SscwSYSTEM_FIRST_SFILE= ${THISPPC}/${MACHINE}/locore.S
691.24Sscw.endif
701.24SscwMD_OBJS=	${SYSTEM_FIRST_OBJ}
711.20SatatatMD_CFILES=
721.24SscwMD_SFILES=	${SYSTEM_FIRST_SFILE}
731.15Ssimonb
741.24Sscw${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
751.20Satatat	${NORMAL_S}
761.1Sws
771.20Satatat##
781.20Satatat## (5) link settings
791.20Satatat##
801.44SmattKERNLDSCRIPT?=	${POWERPC}/conf/kern.ldscript
811.20SatatatTEXTADDR?=	0x100000
821.58SuebayasiLINKFORMAT=	-N
831.44Smatt
841.20SatatatENTRYPOINT=	__start
851.14Smatt
861.47Smatt.if defined(NEED_MDSETIMAGE) && $(NEED_MDSETIMAGE) != "no" \
871.47Smatt    && defined(RAMDISKDIR) && exists(${RAMDISKDIR}/ramdisk.fs)
881.52SmattSYSTEM_DEP+=	${RAMDISKDIR}/ramdisk.fs
891.25SaugustssSYSTEM_LD_TAIL_EXTRA+=; \
901.47Smatt	echo ${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs; \
911.47Smatt	${TOOL_MDSETIMAGE} -s $@ ${RAMDISKDIR}/ramdisk.fs
921.54Smatt.if !empty(DEBUG:M-g*)
931.54SmattSYSTEM_LD_TAIL_EXTRA+=; \
941.54Smatt	echo ${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs; \
951.54Smatt	${TOOL_MDSETIMAGE} -s $@.gdb ${RAMDISKDIR}/ramdisk.fs
961.54Smatt.endif
971.23Saugustss.endif
981.23Saugustss
991.47Smatt.if defined(NEED_SREC) && ${NEED_SREC} != "no"
1001.25SaugustssSYSTEM_LD_TAIL_EXTRA+=; \
1011.47Smatt	echo ${OBJCOPY} -O srec $@ $@.srec; \
1021.47Smatt	${OBJCOPY} -O srec $@ $@.srec
1031.47Smatt.endif
1041.47Smatt
1051.47Smatt.if defined(NEED_BINARY) && ${NEED_BINARY} != "no"
1061.47SmattSYSTEM_LD_TAIL_EXTRA+=; \
1071.47Smatt	echo ${OBJCOPY} -S -O binary $@ $@.bin; \
1081.47Smatt	${OBJCOPY} -S -O binary $@ $@.bin
1091.47Smatt
1101.47SmattEXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.bin@}
1111.47Smatt
1121.47Smatt.if defined(NEED_UBOOTIMAGE) && ${NEED_UBOOTIMAGE} != "no"
1131.47Smatt_OSRELEASE!=		${HOST_SH} $S/conf/osrelease.sh
1141.47SmattMKUBOOTIMAGEARGS=       -A powerpc -T kernel -C gz
1151.47SmattMKUBOOTIMAGEARGS+=      -a ${TEXTADDR:C/....$/0000/} -e $(TEXTADDR)
1161.47SmattMKUBOOTIMAGEARGS+=      -n "NetBSD/$(MACHINE) ${_OSRELEASE} ($(KERNEL_BUILD:T))"
1171.62Schristos.if ${MKREPRO_TIMESTAMP:Uno} != "no"
1181.62SchristosMKUBOOTIMAGEARGS+=	-t "${MKREPRO_TIMESTAMP}"
1191.62Schristos.endif
1201.47Smatt
1211.47SmattSYSTEM_LD_TAIL_EXTRA+=; \
1221.55Sapb	echo ${TOOL_GZIP_N} -9c $@.bin '>' $@.bin.gz; \
1231.55Sapb	${TOOL_GZIP_N} -9c $@.bin > $@.bin.gz; \
1241.47Smatt	echo ${TOOL_MKUBOOTIMAGE} ${MKUBOOTIMAGEARGS} $@.bin.gz $@.ub; \
1251.47Smatt	${TOOL_MKUBOOTIMAGE} ${MKUBOOTIMAGEARGS} $@.bin.gz $@.ub
1261.47Smatt
1271.47SmattEXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.bin.gz@}
1281.47SmattEXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.ub@}
1291.47Smatt.endif
1301.1Sws.endif
1311.1Sws
1321.49Smatt.if !empty(SYSTEM_LD_TAIL_EXTRA_EXTRA)
1331.49SmattSYSTEM_LD_TAIL_EXTRA+= ${SYSTEM_LD_TAIL_EXTRA_EXTRA}
1341.49Smatt.endif
1351.49Smatt
1361.20Satatat##
1371.20Satatat## (6) port specific target dependencies
1381.20Satatat##
1391.1Sws
1401.20Satatat# depend on CPU configuration
1411.20Satatatlocore.o machdep.o: Makefile
1421.28Ssimonb
1431.40Sphxlock_stubs.o setfault.o: assym.h
1441.1Sws
1451.20Satatat##
1461.20Satatat## (7) misc settings
1471.20Satatat##
1481.20Satatat
1491.20Satatat##
1501.20Satatat## (8) config(8) generated machinery
1511.20Satatat##
1521.20Satatat%INCLUDES
1531.1Sws
1541.1Sws%OBJS
1551.1Sws
1561.1Sws%CFILES
1571.1Sws
1581.1Sws%SFILES
1591.1Sws
1601.1Sws%LOAD
1611.1Sws
1621.20Satatat%RULES
1631.1Sws
1641.20Satatat##
1651.20Satatat## (9) port independent kernel machinery
1661.20Satatat##
1671.20Satatat.include "$S/conf/Makefile.kern.inc"
1681.39Smatt${KERNLIB} ${KERNLIB_PROF} ${KERNLIBLN}: assym.h
1691.30Sthorpej
1701.30Sthorpej##
1711.30Sthorpej## (10) Appending make options.
1721.30Sthorpej##
1731.30Sthorpej%MAKEOPTIONSAPPEND
174