Makefile.powerpc revision 1.18
11.18Sthorpej#	$NetBSD: Makefile.powerpc,v 1.18 2001/10/23 19:26:46 thorpej 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.14Smatt
231.16Sthorpej.include <bsd.own.mk>
241.1Sws
251.1Sws# DEBUG is set to -g if debugging.
261.1Sws# PROF is set to -pg if profiling.
271.1Sws
281.14SmattAR?=		ar
291.14SmattAS?=		as
301.14SmattCC?=		cc
311.14SmattCPP?=		cpp
321.14SmattLD?=		ld
331.14SmattLORDER?=	lorder
341.14SmattMKDEP?=		mkdep
351.14SmattNM?=		nm
361.14SmattOBJCOPY?=	objcopy
371.14SmattOBJDUMP?=	objdump
381.14SmattRANLIB?=	ranlib
391.14SmattSIZE?=		size
401.14SmattSTRIP?=		strip
411.14SmattTSORT?=		tsort -q
421.11Sthorpej
431.14SmattCOPTS?=		-O2
441.14SmattTEXTADDR?=	0x100000
451.1Sws
461.1Sws# source tree is located via $S relative to the compilation directory
471.14Smatt.ifndef S
481.14SmattS!=		cd ../../../..; pwd
491.1Sws.endif
501.17SthorpejTHISPPC=	$S/arch/${MACHINE}
511.14SmattPOWERPC=	$S/arch/powerpc
521.1Sws
531.1SwsINCLUDES=	-I. -I$S/arch -I$S -nostdinc
541.14SmattCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
551.17Sthorpej		-D_KERNEL -D_KERNEL_OPT -D${MACHINE}
561.14SmattCWARNFLAGS?=	-Werror -Wall -Wreturn-type -Wpointer-arith -Wno-main \
571.14Smatt		-Wmissing-prototypes -Wstrict-prototypes
581.14Smatt# XXX Delete -Wuninitialized for now, since the compiler doesn't
591.14Smatt# XXX always get it right.  --thorpej
601.14SmattCWARNFLAGS+=	-Wno-uninitialized
611.14SmattCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float ${CCPUOPTS}
621.14SmattAFLAGS=		-D_LOCORE ${AOPTS}
631.14SmattLINKFLAGS=	-N -Ttext ${TEXTADDR} -e __start
641.6SthorpejSTRIPFLAGS=	--strip-debug
651.15Ssimonb
661.17Sthorpej.if exists(${THISPPC}/conf/Makefile.${MACHINE}.inc)
671.17Sthorpej.include "${THISPPC}/conf/Makefile.${MACHINE}.inc"
681.15Ssimonb.endif
691.1Sws
701.14Smatt%INCLUDES
711.14Smatt
721.1Sws### find out what to use for libkern
731.1Sws.include "$S/lib/libkern/Makefile.inc"
741.1Sws.ifndef PROF
751.1SwsLIBKERN=	${KERNLIB}
761.1Sws.else
771.1SwsLIBKERN=	${KERNLIB_PROF}
781.1Sws.endif
791.1Sws
801.1Sws### find out what to use for libcompat
811.1Sws.include "$S/compat/common/Makefile.inc"
821.1Sws.ifndef PROF
831.1SwsLIBCOMPAT=	${COMPATLIB}
841.1Sws.else
851.1SwsLIBCOMPAT=	${COMPATLIB_PROF}
861.1Sws.endif
871.1Sws
881.1Sws# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
891.1Sws# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
901.1Sws
911.1SwsNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
921.14SmattNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
931.1SwsNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
941.1Sws
951.1Sws%OBJS
961.1Sws
971.1Sws%CFILES
981.1Sws
991.1Sws%SFILES
1001.1Sws
1011.1Sws# load lines for config "xxx" will be emitted as:
1021.1Sws# xxx: ${SYSTEM_DEP} swapxxx.o
1031.1Sws#	${SYSTEM_LD_HEAD}
1041.1Sws#	${SYSTEM_LD} swapxxx.o
1051.1Sws#	${SYSTEM_LD_TAIL}
1061.1SwsSYSTEM_OBJ=	locore.o \
1071.14Smatt		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1081.1SwsSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1091.1SwsSYSTEM_LD_HEAD=	rm -f $@
1101.1SwsSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1111.1Sws		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1121.1SwsSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1131.1Sws
1141.1SwsDEBUG?=
1151.1Sws.if ${DEBUG} == "-g"
1161.1SwsLINKFLAGS+=	-X
1171.1SwsSYSTEM_LD_TAIL+=; \
1181.14Smatt		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1191.14Smatt		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1201.14Smatt		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1211.1Sws.else
1221.1SwsLINKFLAGS+=	-S
1231.1Sws.endif
1241.14Smatt.if defined(NEED_SREC)
1251.14SmattSYSTEM_LD_TAIL+=; \
1261.14Smatt		${OBJCOPY} -v -O srec $@ $@.srec
1271.14Smatt.endif
1281.1Sws
1291.1Sws%LOAD
1301.1Sws
1311.17Sthorpejassym.h: $S/kern/genassym.sh ${THISPPC}/${MACHINE}/genassym.cf
1321.6Sthorpej	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1331.17Sthorpej	    < ${THISPPC}/${MACHINE}/genassym.cf > assym.h.tmp && \
1341.6Sthorpej	mv -f assym.h.tmp assym.h
1351.1Sws
1361.1Swsparam.c: $S/conf/param.c
1371.1Sws	rm -f param.c
1381.1Sws	cp $S/conf/param.c .
1391.1Sws
1401.1Swsparam.o: param.c Makefile
1411.1Sws	${NORMAL_C}
1421.1Sws
1431.1Swsioconf.o: ioconf.c
1441.1Sws	${NORMAL_C}
1451.1Sws
1461.1Swsnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1471.1Sws	sh $S/conf/newvers.sh
1481.1Sws	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1491.1Sws
1501.9Schristos__CLEANKERNEL: .USE
1511.9Schristos	@echo "${.TARGET}ing the kernel objects"
1521.1Sws	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1531.9Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1541.9Schristos
1551.9Schristos__CLEANDEPEND: .USE
1561.9Schristos	rm -f .depend
1571.9Schristos
1581.9Schristosclean: __CLEANKERNEL
1591.9Schristos
1601.14Smattcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1611.1Sws
1621.1Swslint:
1631.3Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1641.17Sthorpej	    ${THISPPC}/${MACHINE}/Locore.c ${CFILES} \
1651.14Smatt	    ioconf.c param.c | \
1661.14Smatt	    grep -v 'static function .* unused'
1671.1Sws
1681.1Swstags:
1691.1Sws	@echo "see $S/kern/Makefile for tags"
1701.1Sws
1711.1Swslinks:
1721.1Sws	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1731.1Sws	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1741.1Sws	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1751.1Sws	  sort -u | comm -23 - dontlink | \
1761.1Sws	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1771.1Sws	sh makelinks && rm -f dontlink
1781.1Sws
1791.17SthorpejSRCS=	${THISPPC}/${MACHINE}/locore.S \
1801.1Sws	param.c ioconf.c ${CFILES} ${SFILES}
1811.6Sthorpejdepend: .depend
1821.1Sws.depend: ${SRCS} assym.h param.c
1831.17Sthorpej	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISPPC}/${MACHINE}/locore.S
1841.1Sws	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1851.1Sws.if ${SFILES} != ""
1861.1Sws	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1871.1Sws.endif
1881.8Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1891.17Sthorpej	  ${CPPFLAGS} < ${THISPPC}/${MACHINE}/genassym.cf
1901.8Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1911.8Sleo	@rm -f assym.dep
1921.1Sws
1931.14Smattdependall: depend all
1941.14Smatt
1951.1Sws# depend on root or device configuration
1961.1Swsautoconf.o conf.o: Makefile
1971.1Sws
1981.1Sws# depend on network or filesystem configuration
1991.1Swsuipc_proto.o vfs_conf.o: Makefile
2001.1Sws
2011.1Sws# depend on maxusers
2021.6Sthorpejmachdep.o: Makefile
2031.1Sws
2041.1Sws# depend on CPU configuration
2051.1Swslocore.o machdep.o: Makefile
2061.1Sws
2071.17Sthorpejlocore.o: ${THISPPC}/${MACHINE}/locore.S assym.h
2081.14Smatt	${NORMAL_S}
2091.1Sws
2101.14Smatt# The install target can be redefined by putting a
2111.14Smatt# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2121.14SmattMACHINE_NAME!=  uname -n
2131.14Smattinstall: install-kernel-${MACHINE_NAME}
2141.14Smatt.if !target(install-kernel-${MACHINE_NAME}})
2151.14Smattinstall-kernel-${MACHINE_NAME}:
2161.14Smatt	rm -f /onetbsd
2171.14Smatt	ln /netbsd /onetbsd
2181.14Smatt	cp netbsd /nnetbsd
2191.14Smatt	mv /nnetbsd /netbsd
2201.14Smatt.endif
2211.1Sws
2221.1Sws%RULES
223