Makefile.powerpc revision 1.19
11.19Sjmc#	$NetBSD: Makefile.powerpc,v 1.19 2001/10/26 06:45:39 jmc 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.18Sthorpej
211.18SthorpejMACHINE_ARCH=powerpc
221.19SjmcUSETOOLS?=	no
231.14Smatt
241.16Sthorpej.include <bsd.own.mk>
251.1Sws
261.1Sws# DEBUG is set to -g if debugging.
271.1Sws# PROF is set to -pg if profiling.
281.1Sws
291.14SmattAR?=		ar
301.14SmattAS?=		as
311.14SmattCC?=		cc
321.14SmattCPP?=		cpp
331.14SmattLD?=		ld
341.14SmattLORDER?=	lorder
351.14SmattMKDEP?=		mkdep
361.14SmattNM?=		nm
371.14SmattOBJCOPY?=	objcopy
381.14SmattOBJDUMP?=	objdump
391.14SmattRANLIB?=	ranlib
401.14SmattSIZE?=		size
411.14SmattSTRIP?=		strip
421.14SmattTSORT?=		tsort -q
431.11Sthorpej
441.14SmattCOPTS?=		-O2
451.14SmattTEXTADDR?=	0x100000
461.1Sws
471.1Sws# source tree is located via $S relative to the compilation directory
481.14Smatt.ifndef S
491.14SmattS!=		cd ../../../..; pwd
501.1Sws.endif
511.17SthorpejTHISPPC=	$S/arch/${MACHINE}
521.14SmattPOWERPC=	$S/arch/powerpc
531.1Sws
541.1SwsINCLUDES=	-I. -I$S/arch -I$S -nostdinc
551.14SmattCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
561.17Sthorpej		-D_KERNEL -D_KERNEL_OPT -D${MACHINE}
571.14SmattCWARNFLAGS?=	-Werror -Wall -Wreturn-type -Wpointer-arith -Wno-main \
581.14Smatt		-Wmissing-prototypes -Wstrict-prototypes
591.14Smatt# XXX Delete -Wuninitialized for now, since the compiler doesn't
601.14Smatt# XXX always get it right.  --thorpej
611.14SmattCWARNFLAGS+=	-Wno-uninitialized
621.14SmattCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float ${CCPUOPTS}
631.14SmattAFLAGS=		-D_LOCORE ${AOPTS}
641.14SmattLINKFLAGS=	-N -Ttext ${TEXTADDR} -e __start
651.6SthorpejSTRIPFLAGS=	--strip-debug
661.15Ssimonb
671.17Sthorpej.if exists(${THISPPC}/conf/Makefile.${MACHINE}.inc)
681.17Sthorpej.include "${THISPPC}/conf/Makefile.${MACHINE}.inc"
691.15Ssimonb.endif
701.1Sws
711.14Smatt%INCLUDES
721.14Smatt
731.1Sws### find out what to use for libkern
741.1Sws.include "$S/lib/libkern/Makefile.inc"
751.1Sws.ifndef PROF
761.1SwsLIBKERN=	${KERNLIB}
771.1Sws.else
781.1SwsLIBKERN=	${KERNLIB_PROF}
791.1Sws.endif
801.1Sws
811.1Sws### find out what to use for libcompat
821.1Sws.include "$S/compat/common/Makefile.inc"
831.1Sws.ifndef PROF
841.1SwsLIBCOMPAT=	${COMPATLIB}
851.1Sws.else
861.1SwsLIBCOMPAT=	${COMPATLIB_PROF}
871.1Sws.endif
881.1Sws
891.1Sws# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
901.1Sws# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
911.1Sws
921.1SwsNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
931.14SmattNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
941.1SwsNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
951.1Sws
961.1Sws%OBJS
971.1Sws
981.1Sws%CFILES
991.1Sws
1001.1Sws%SFILES
1011.1Sws
1021.1Sws# load lines for config "xxx" will be emitted as:
1031.1Sws# xxx: ${SYSTEM_DEP} swapxxx.o
1041.1Sws#	${SYSTEM_LD_HEAD}
1051.1Sws#	${SYSTEM_LD} swapxxx.o
1061.1Sws#	${SYSTEM_LD_TAIL}
1071.1SwsSYSTEM_OBJ=	locore.o \
1081.14Smatt		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1091.1SwsSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1101.1SwsSYSTEM_LD_HEAD=	rm -f $@
1111.1SwsSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1121.1Sws		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1131.1SwsSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1141.1Sws
1151.1SwsDEBUG?=
1161.1Sws.if ${DEBUG} == "-g"
1171.1SwsLINKFLAGS+=	-X
1181.1SwsSYSTEM_LD_TAIL+=; \
1191.14Smatt		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1201.14Smatt		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1211.14Smatt		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1221.1Sws.else
1231.1SwsLINKFLAGS+=	-S
1241.1Sws.endif
1251.14Smatt.if defined(NEED_SREC)
1261.14SmattSYSTEM_LD_TAIL+=; \
1271.14Smatt		${OBJCOPY} -v -O srec $@ $@.srec
1281.14Smatt.endif
1291.1Sws
1301.1Sws%LOAD
1311.1Sws
1321.17Sthorpejassym.h: $S/kern/genassym.sh ${THISPPC}/${MACHINE}/genassym.cf
1331.6Sthorpej	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1341.17Sthorpej	    < ${THISPPC}/${MACHINE}/genassym.cf > assym.h.tmp && \
1351.6Sthorpej	mv -f assym.h.tmp assym.h
1361.1Sws
1371.1Swsparam.c: $S/conf/param.c
1381.1Sws	rm -f param.c
1391.1Sws	cp $S/conf/param.c .
1401.1Sws
1411.1Swsparam.o: param.c Makefile
1421.1Sws	${NORMAL_C}
1431.1Sws
1441.1Swsioconf.o: ioconf.c
1451.1Sws	${NORMAL_C}
1461.1Sws
1471.1Swsnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1481.1Sws	sh $S/conf/newvers.sh
1491.1Sws	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1501.1Sws
1511.9Schristos__CLEANKERNEL: .USE
1521.9Schristos	@echo "${.TARGET}ing the kernel objects"
1531.1Sws	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1541.9Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1551.9Schristos
1561.9Schristos__CLEANDEPEND: .USE
1571.9Schristos	rm -f .depend
1581.9Schristos
1591.9Schristosclean: __CLEANKERNEL
1601.9Schristos
1611.14Smattcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1621.1Sws
1631.1Swslint:
1641.3Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1651.17Sthorpej	    ${THISPPC}/${MACHINE}/Locore.c ${CFILES} \
1661.14Smatt	    ioconf.c param.c | \
1671.14Smatt	    grep -v 'static function .* unused'
1681.1Sws
1691.1Swstags:
1701.1Sws	@echo "see $S/kern/Makefile for tags"
1711.1Sws
1721.1Swslinks:
1731.1Sws	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1741.1Sws	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1751.1Sws	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1761.1Sws	  sort -u | comm -23 - dontlink | \
1771.1Sws	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1781.1Sws	sh makelinks && rm -f dontlink
1791.1Sws
1801.17SthorpejSRCS=	${THISPPC}/${MACHINE}/locore.S \
1811.1Sws	param.c ioconf.c ${CFILES} ${SFILES}
1821.6Sthorpejdepend: .depend
1831.1Sws.depend: ${SRCS} assym.h param.c
1841.17Sthorpej	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISPPC}/${MACHINE}/locore.S
1851.1Sws	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1861.1Sws.if ${SFILES} != ""
1871.1Sws	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1881.1Sws.endif
1891.8Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1901.17Sthorpej	  ${CPPFLAGS} < ${THISPPC}/${MACHINE}/genassym.cf
1911.8Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1921.8Sleo	@rm -f assym.dep
1931.1Sws
1941.14Smattdependall: depend all
1951.14Smatt
1961.1Sws# depend on root or device configuration
1971.1Swsautoconf.o conf.o: Makefile
1981.1Sws
1991.1Sws# depend on network or filesystem configuration
2001.1Swsuipc_proto.o vfs_conf.o: Makefile
2011.1Sws
2021.1Sws# depend on maxusers
2031.6Sthorpejmachdep.o: Makefile
2041.1Sws
2051.1Sws# depend on CPU configuration
2061.1Swslocore.o machdep.o: Makefile
2071.1Sws
2081.17Sthorpejlocore.o: ${THISPPC}/${MACHINE}/locore.S assym.h
2091.14Smatt	${NORMAL_S}
2101.1Sws
2111.14Smatt# The install target can be redefined by putting a
2121.14Smatt# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2131.14SmattMACHINE_NAME!=  uname -n
2141.14Smattinstall: install-kernel-${MACHINE_NAME}
2151.14Smatt.if !target(install-kernel-${MACHINE_NAME}})
2161.14Smattinstall-kernel-${MACHINE_NAME}:
2171.14Smatt	rm -f /onetbsd
2181.14Smatt	ln /netbsd /onetbsd
2191.14Smatt	cp netbsd /nnetbsd
2201.14Smatt	mv /nnetbsd /netbsd
2211.14Smatt.endif
2221.1Sws
2231.1Sws%RULES
224