Makefile.alpha revision 1.63
11.63Sross# $NetBSD: Makefile.alpha,v 1.63 2001/05/08 05:47:35 ross Exp $
21.10Smycroft
31.1Scgd# Makefile for NetBSD
41.1Scgd#
51.1Scgd# This makefile is constructed from a machine description:
61.1Scgd#	config machineid
71.1Scgd# Most changes should be made in the machine description
81.10Smycroft#	/sys/arch/alpha/conf/``machineid''
91.1Scgd# after which you should do
101.10Smycroft#	config machineid
111.1Scgd# Machine generic makefile changes should be made in
121.10Smycroft#	/sys/arch/alpha/conf/Makefile.alpha
131.1Scgd# after which config should be rerun for all machines of that type.
141.1Scgd
151.1Scgd# DEBUG is set to -g if debugging.
161.1Scgd# PROF is set to -pg if profiling.
171.63Sross#
181.63Sross# To specify debugging, add the config line: makeoptions DEBUG="-g" 
191.63Sross# A better way is to specify -g only for a few files.
201.63Sross#
211.63Sross#	makeoptions DEBUGLIST="uvm* trap if_*"
221.1Scgd
231.40SthorpejAR?=	ar
241.40SthorpejAS?=	as
251.13SmycroftCC?=	cc
261.34ScgdCPP?=	cpp
271.13SmycroftLD?=	ld
281.39SthorpejLORDER?=lorder
291.19SmycroftMKDEP?=	mkdep
301.39SthorpejNM?=	nm
311.40SthorpejRANLIB?=ranlib
321.34ScgdSIZE?=	size
331.56StsutsuiSTRIP?=	strip
341.39SthorpejTSORT?=	tsort -q
351.1Scgd
361.1Scgd# source tree is located via $S relative to the compilation directory
371.23Smycroft.ifndef S
381.19SmycroftS!=	cd ../../../..; pwd
391.23Smycroft.endif
401.19SmycroftALPHA=	$S/arch/alpha
411.1Scgd
421.57SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
431.20SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
441.47SthorpejCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Dalpha
451.34ScgdCOPTS?=		-O2
461.26ScgdCWARNFLAGS?=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
471.49Sthorpej		-Wpointer-arith
481.57Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
491.57Sthorpej# XXX always get it right.  --thorpej 
501.57SthorpejCWARNFLAGS+=	-Wno-uninitialized
511.57Sthorpej.if (${HAVE_EGCS} != "")
521.42StvCWARNFLAGS+=	-Wno-main
531.42Stv.endif
541.63SrossCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -mno-fp-regs ${${<:T:R}_G} 
551.25ScgdAFLAGS=		-traditional -D_LOCORE
561.41SrossLOADADDRESS?=	fffffc0000300000
571.38SrossLINKFLAGS=	-N -Ttext ${LOADADDRESS} -e __transfer -G 4
581.51SrossSTRIPFLAGS=	-g -X
591.52Smrg
601.52Smrg%INCLUDES
611.24Smycroft
621.1Scgd### find out what to use for libkern
631.1Scgd.include "$S/lib/libkern/Makefile.inc"
641.1Scgd.ifndef PROF
651.1ScgdLIBKERN=	${KERNLIB}
661.1Scgd.else
671.1ScgdLIBKERN=	${KERNLIB_PROF}
681.1Scgd.endif
691.1Scgd
701.5Schristos### find out what to use for libcompat
711.5Schristos.include "$S/compat/common/Makefile.inc"
721.5Schristos.ifndef PROF
731.5SchristosLIBCOMPAT=	${COMPATLIB}
741.5Schristos.else
751.5SchristosLIBCOMPAT=	${COMPATLIB_PROF}
761.5Schristos.endif
771.5Schristos
781.21Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
791.21Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
801.1Scgd
811.10SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
821.43SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
831.25ScgdNORMAL_S=	${CPP} ${AFLAGS} ${CPPFLAGS} $< | sed -e 's,^\#.*,,' | ${AS} -o ${.TARGET}
841.1Scgd
851.1Scgd%OBJS
861.1Scgd
871.1Scgd%CFILES
881.1Scgd
891.10Smycroft%SFILES
901.10Smycroft
911.63Sross#
921.63Sross# Define a set of xxx_G variables that will add -g to just those
931.63Sross# files that match the shell patterns given in ${DEBUGLIST}
941.63Sross#
951.63Sross
961.63Sross.for i in ${DEBUGLIST}
971.63Sross.for j in ${CFILES:T:M$i.c}
981.63Sross${j:R}_G= -g
991.63Sross.endfor
1001.63Sross.endfor
1011.63Sross
1021.1Scgd# load lines for config "xxx" will be emitted as:
1031.1Scgd# xxx: ${SYSTEM_DEP} swapxxx.o
1041.1Scgd#	${SYSTEM_LD_HEAD}
1051.1Scgd#	${SYSTEM_LD} swapxxx.o
1061.1Scgd#	${SYSTEM_LD_TAIL}
1071.38SrossSYSTEM_OBJ=	locore.o transfer.o \
1081.45Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1091.1ScgdSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1101.10SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1111.10SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1121.10Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1131.34ScgdSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1141.10Smycroft
1151.10SmycroftDEBUG?=
1161.63Sross.if ${DEBUG} == "-g" || defined(DEBUGLIST)
1171.10SmycroftLINKFLAGS+=	-X
1181.10SmycroftSYSTEM_LD_TAIL+=; \
1191.53Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1201.56Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1211.56Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1221.8Scgd.else
1231.19SmycroftLINKFLAGS+=	-S
1241.8Scgd.endif
1251.1Scgd
1261.1Scgd%LOAD
1271.1Scgd
1281.34Scgd# Use awk to cross-build assym.h from the genassym.s file.
1291.59Sjdolecekassym.h: $S/kern/genassym.sh ${ALPHA}/alpha/genassym.cf
1301.59Sjdolecek	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1311.59Sjdolecek	    < ${ALPHA}/alpha/genassym.cf > assym.h.tmp && \
1321.59Sjdolecek	mv -f assym.h.tmp assym.h
1331.34Scgd
1341.10Smycroftparam.c: $S/conf/param.c
1351.10Smycroft	rm -f param.c
1361.10Smycroft	cp $S/conf/param.c .
1371.1Scgd
1381.10Smycroftparam.o: param.c Makefile
1391.21Smycroft	${NORMAL_C}
1401.1Scgd
1411.10Smycroftioconf.o: ioconf.c
1421.10Smycroft	${NORMAL_C}
1431.1Scgd
1441.10Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1451.10Smycroft	sh $S/conf/newvers.sh
1461.10Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1471.1Scgd
1481.1Scgd
1491.36Schristos__CLEANKERNEL: .USE
1501.36Schristos	@echo "${.TARGET}ing the kernel objects"
1511.14Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1521.36Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1531.36Schristos
1541.36Schristos__CLEANDEPEND: .USE
1551.36Schristos	rm -f .depend
1561.36Schristos
1571.36Schristosclean: __CLEANKERNEL
1581.36Schristos
1591.44Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1601.1Scgd
1611.10Smycroftlint:
1621.31Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1631.32Sperry	    ${ALPHA}/alpha/Locore.c ${CFILES} \
1641.10Smycroft	    ioconf.c param.c | \
1651.10Smycroft	    grep -v 'static function .* unused'
1661.1Scgd
1671.10Smycrofttags:
1681.10Smycroft	@echo "see $S/kern/Makefile for tags"
1691.1Scgd
1701.1Scgdlinks:
1711.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1721.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1731.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1741.1Scgd	  sort -u | comm -23 - dontlink | \
1751.10Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1761.1Scgd	sh makelinks && rm -f dontlink
1771.1Scgd
1781.38SrossSRCS=	${ALPHA}/alpha/locore.s ${ALPHA}/alpha/transfer.s \
1791.14Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1801.30Scgddepend: .depend
1811.14Scgd.depend: ${SRCS} assym.h param.c
1821.35Scgd	${MKDEP} -x assembler-with-cpp ${AFLAGS} ${CPPFLAGS} \
1831.35Scgd	    ${ALPHA}/alpha/locore.s
1841.50Sross	${MKDEP} -a -x assembler-with-cpp ${AFLAGS} ${CPPFLAGS} \
1851.38Sross	    ${ALPHA}/alpha/transfer.s
1861.19Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1871.48Stron	test -z "${SFILES}" || \
1881.35Scgd	${MKDEP} -a -x assembler-with-cpp ${AFLAGS} ${CPPFLAGS} ${SFILES}
1891.61Sjdolecek	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1901.61Sjdolecek	  ${CPPFLAGS} < ${ALPHA}/alpha/genassym.cf
1911.61Sjdolecek	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1921.61Sjdolecek	@rm -f assym.dep
1931.55Stron
1941.55Strondependall: depend all
1951.10Smycroft
1961.1Scgd
1971.10Smycroft# depend on root or device configuration
1981.10Smycroftautoconf.o conf.o: Makefile
1991.10Smycroft 
2001.10Smycroft# depend on network or filesystem configuration 
2011.10Smycroftuipc_proto.o vfs_conf.o: Makefile 
2021.10Smycroft
2031.10Smycroft# depend on maxusers
2041.61Sjdolecekassym.h machdep.o: Makefile
2051.1Scgd
2061.10Smycroft# depend on CPU configuration 
2071.10Smycroftclock.o machdep.o apecs.o cia.o lca.o ioasic.o scc.o icasic.o: Makefile
2081.1Scgd
2091.10Smycroftlocore.o: ${ALPHA}/alpha/locore.s assym.h
2101.38Sross	${NORMAL_S}
2111.38Sross
2121.38Srosstransfer.o: ${ALPHA}/alpha/transfer.s
2131.10Smycroft	${NORMAL_S}
2141.58Shubertf
2151.58Shubertf# The install target can be redefined by putting a
2161.58Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2171.58ShubertfMACHINE_NAME!=  uname -n
2181.58Shubertfinstall: install-kernel-${MACHINE_NAME}
2191.58Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2201.58Shubertfinstall-kernel-${MACHINE_NAME}:
2211.58Shubertf	rm -f /onetbsd
2221.58Shubertf	ln /netbsd /onetbsd
2231.58Shubertf	cp netbsd /nnetbsd
2241.58Shubertf	mv /nnetbsd /netbsd
2251.58Shubertf.endif
2261.1Scgd
2271.1Scgd%RULES
228