Makefile.powerpc revision 1.15
11.15Ssimonb#	$NetBSD: Makefile.powerpc,v 1.15 2001/08/26 10:59:26 simonb 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.1Sws# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
161.1Sws#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
171.1Sws#
181.1Sws# -DTRACE	compile in kernel tracing hooks
191.1Sws# -DQUOTA	compile in file system quotas
201.14Smatt
211.1Sws.SUFFIXES:	.S .c .o
221.1Sws
231.1Sws# DEBUG is set to -g if debugging.
241.1Sws# PROF is set to -pg if profiling.
251.1Sws
261.14SmattAR?=		ar
271.14SmattAS?=		as
281.14SmattCC?=		cc
291.14SmattCPP?=		cpp
301.14SmattLD?=		ld
311.14SmattLORDER?=	lorder
321.14SmattMKDEP?=		mkdep
331.14SmattNM?=		nm
341.14SmattOBJCOPY?=	objcopy
351.14SmattOBJDUMP?=	objdump
361.14SmattRANLIB?=	ranlib
371.14SmattSIZE?=		size
381.14SmattSTRIP?=		strip
391.14SmattTSORT?=		tsort -q
401.11Sthorpej
411.14SmattCOPTS?=		-O2
421.14SmattTEXTADDR?=	0x100000
431.1Sws
441.1Sws# source tree is located via $S relative to the compilation directory
451.14Smatt.ifndef S
461.14SmattS!=		cd ../../../..; pwd
471.1Sws.endif
481.14SmattTHISPPC=	$S/arch/${TARGET_MACHINE}
491.14SmattPOWERPC=	$S/arch/powerpc
501.1Sws
511.1SwsINCLUDES=	-I. -I$S/arch -I$S -nostdinc
521.14SmattCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
531.14Smatt		-D_KERNEL -D_KERNEL_OPT -D${TARGET_MACHINE}
541.14SmattCWARNFLAGS?=	-Werror -Wall -Wreturn-type -Wpointer-arith -Wno-main \
551.14Smatt		-Wmissing-prototypes -Wstrict-prototypes
561.14Smatt# XXX Delete -Wuninitialized for now, since the compiler doesn't
571.14Smatt# XXX always get it right.  --thorpej
581.14SmattCWARNFLAGS+=	-Wno-uninitialized
591.14SmattCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float ${CCPUOPTS}
601.14SmattAFLAGS=		-D_LOCORE ${AOPTS}
611.14SmattLINKFLAGS=	-N -Ttext ${TEXTADDR} -e __start
621.6SthorpejSTRIPFLAGS=	--strip-debug
631.15Ssimonb
641.15Ssimonb.if exists(${THISPPC}/conf/Makefile.${TARGET_MACHINE}.inc)
651.15Ssimonb.include "${THISPPC}/conf/Makefile.${TARGET_MACHINE}.inc"
661.15Ssimonb.endif
671.1Sws
681.14Smatt%INCLUDES
691.14Smatt
701.1Sws### find out what to use for libkern
711.1Sws.include "$S/lib/libkern/Makefile.inc"
721.1Sws.ifndef PROF
731.1SwsLIBKERN=	${KERNLIB}
741.1Sws.else
751.1SwsLIBKERN=	${KERNLIB_PROF}
761.1Sws.endif
771.1Sws
781.1Sws### find out what to use for libcompat
791.1Sws.include "$S/compat/common/Makefile.inc"
801.1Sws.ifndef PROF
811.1SwsLIBCOMPAT=	${COMPATLIB}
821.1Sws.else
831.1SwsLIBCOMPAT=	${COMPATLIB_PROF}
841.1Sws.endif
851.1Sws
861.1Sws# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
871.1Sws# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
881.1Sws
891.1SwsNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
901.14SmattNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
911.1SwsNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
921.1Sws
931.1Sws%OBJS
941.1Sws
951.1Sws%CFILES
961.1Sws
971.1Sws%SFILES
981.1Sws
991.1Sws# load lines for config "xxx" will be emitted as:
1001.1Sws# xxx: ${SYSTEM_DEP} swapxxx.o
1011.1Sws#	${SYSTEM_LD_HEAD}
1021.1Sws#	${SYSTEM_LD} swapxxx.o
1031.1Sws#	${SYSTEM_LD_TAIL}
1041.1SwsSYSTEM_OBJ=	locore.o \
1051.14Smatt		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1061.1SwsSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1071.1SwsSYSTEM_LD_HEAD=	rm -f $@
1081.1SwsSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1091.1Sws		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1101.1SwsSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1111.1Sws
1121.1SwsDEBUG?=
1131.1Sws.if ${DEBUG} == "-g"
1141.1SwsLINKFLAGS+=	-X
1151.1SwsSYSTEM_LD_TAIL+=; \
1161.14Smatt		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1171.14Smatt		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1181.14Smatt		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1191.1Sws.else
1201.1SwsLINKFLAGS+=	-S
1211.1Sws.endif
1221.14Smatt.if defined(NEED_SREC)
1231.14SmattSYSTEM_LD_TAIL+=; \
1241.14Smatt		${OBJCOPY} -v -O srec $@ $@.srec
1251.14Smatt.endif
1261.1Sws
1271.1Sws%LOAD
1281.1Sws
1291.14Smattassym.h: $S/kern/genassym.sh ${THISPPC}/${TARGET_MACHINE}/genassym.cf
1301.6Sthorpej	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1311.14Smatt	    < ${THISPPC}/${TARGET_MACHINE}/genassym.cf > assym.h.tmp && \
1321.6Sthorpej	mv -f assym.h.tmp assym.h
1331.1Sws
1341.1Swsparam.c: $S/conf/param.c
1351.1Sws	rm -f param.c
1361.1Sws	cp $S/conf/param.c .
1371.1Sws
1381.1Swsparam.o: param.c Makefile
1391.1Sws	${NORMAL_C}
1401.1Sws
1411.1Swsioconf.o: ioconf.c
1421.1Sws	${NORMAL_C}
1431.1Sws
1441.1Swsnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1451.1Sws	sh $S/conf/newvers.sh
1461.1Sws	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1471.1Sws
1481.9Schristos__CLEANKERNEL: .USE
1491.9Schristos	@echo "${.TARGET}ing the kernel objects"
1501.1Sws	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1511.9Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1521.9Schristos
1531.9Schristos__CLEANDEPEND: .USE
1541.9Schristos	rm -f .depend
1551.9Schristos
1561.9Schristosclean: __CLEANKERNEL
1571.9Schristos
1581.14Smattcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1591.1Sws
1601.1Swslint:
1611.3Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1621.14Smatt	    ${THISPPC}/${TARGET_MACHINE}/Locore.c ${CFILES} \
1631.14Smatt	    ioconf.c param.c | \
1641.14Smatt	    grep -v 'static function .* unused'
1651.1Sws
1661.1Swstags:
1671.1Sws	@echo "see $S/kern/Makefile for tags"
1681.1Sws
1691.1Swslinks:
1701.1Sws	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1711.1Sws	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1721.1Sws	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1731.1Sws	  sort -u | comm -23 - dontlink | \
1741.1Sws	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1751.1Sws	sh makelinks && rm -f dontlink
1761.1Sws
1771.14SmattSRCS=	${THISPPC}/${TARGET_MACHINE}/locore.S \
1781.1Sws	param.c ioconf.c ${CFILES} ${SFILES}
1791.6Sthorpejdepend: .depend
1801.1Sws.depend: ${SRCS} assym.h param.c
1811.14Smatt	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISPPC}/${TARGET_MACHINE}/locore.S
1821.1Sws	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1831.1Sws.if ${SFILES} != ""
1841.1Sws	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1851.1Sws.endif
1861.8Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1871.14Smatt	  ${CPPFLAGS} < ${THISPPC}/${TARGET_MACHINE}/genassym.cf
1881.8Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1891.8Sleo	@rm -f assym.dep
1901.1Sws
1911.14Smattdependall: depend all
1921.14Smatt
1931.1Sws# depend on root or device configuration
1941.1Swsautoconf.o conf.o: Makefile
1951.1Sws
1961.1Sws# depend on network or filesystem configuration
1971.1Swsuipc_proto.o vfs_conf.o: Makefile
1981.1Sws
1991.1Sws# depend on maxusers
2001.6Sthorpejmachdep.o: Makefile
2011.1Sws
2021.1Sws# depend on CPU configuration
2031.1Swslocore.o machdep.o: Makefile
2041.1Sws
2051.14Smattlocore.o: ${THISPPC}/${TARGET_MACHINE}/locore.S assym.h
2061.14Smatt	${NORMAL_S}
2071.1Sws
2081.14Smatt# The install target can be redefined by putting a
2091.14Smatt# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2101.14SmattMACHINE_NAME!=  uname -n
2111.14Smattinstall: install-kernel-${MACHINE_NAME}
2121.14Smatt.if !target(install-kernel-${MACHINE_NAME}})
2131.14Smattinstall-kernel-${MACHINE_NAME}:
2141.14Smatt	rm -f /onetbsd
2151.14Smatt	ln /netbsd /onetbsd
2161.14Smatt	cp netbsd /nnetbsd
2171.14Smatt	mv /nnetbsd /netbsd
2181.14Smatt.endif
2191.1Sws
2201.1Sws%RULES
221