Makefile.i386 revision 1.107
11.107Sthorpej#	$NetBSD: Makefile.i386,v 1.107 2000/09/07 06:39:36 thorpej Exp $
21.62Smycroft
31.8Scgd# 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.36Sderaadt#	/sys/arch/i386/conf/``machineid''
91.1Scgd# after which you should do
101.62Smycroft#	config machineid
111.62Smycroft# Machine generic makefile changes should be made in
121.36Sderaadt#	/sys/arch/i386/conf/Makefile.i386
131.42Smycroft# after which config should be rerun for all machines of that type.
141.1Scgd#
151.42Smycroft# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
161.1Scgd#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
171.1Scgd#
181.1Scgd# -DTRACE	compile in kernel tracing hooks
191.1Scgd# -DQUOTA	compile in file system quotas
201.42Smycroft
211.97Schristos.include <bsd.own.mk>
221.97Schristos
231.62Smycroft# DEBUG is set to -g if debugging.
241.62Smycroft# PROF is set to -pg if profiling.
251.62Smycroft
261.88SthorpejAR?=	ar
271.88SthorpejAS?=	as
281.65SmycroftCC?=	cc
291.88SthorpejCPP?=	cpp
301.65SmycroftLD?=	ld
311.87SthorpejLORDER?=lorder
321.68SmycroftMKDEP?=	mkdep
331.87SthorpejNM?=	nm
341.88SthorpejRANLIB?=ranlib
351.85SlukemSIZE?=	size
361.103StsutsuiSTRIP?=	strip
371.87SthorpejTSORT?=	tsort -q
381.88Sthorpej
391.85SlukemCOPTS?=	-O2
401.1Scgd
411.42Smycroft# source tree is located via $S relative to the compilation directory
421.73Smycroft.ifndef S
431.68SmycroftS!=	cd ../../../..; pwd
441.73Smycroft.endif
451.68SmycroftI386=	$S/arch/i386
461.1Scgd
471.105SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
481.69SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
491.96SthorpejCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Di386
501.95SaugustssCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
511.95Saugustss		-Wpointer-arith
521.105Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
531.105Sthorpej# XXX always get it right.  --thorpej
541.105SthorpejCWARNFLAGS+=	-Wno-uninitialized
551.105Sthorpej.if (${HAVE_EGCS} != "")
561.90StvCWARNFLAGS+=	-Wno-main
571.90Stv.endif
581.77SjonathanCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
591.64SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
601.104SthorpejLINKFLAGS=	-Ttext c0100000 -e start
611.97Schristos.if (${OBJECT_FMT} == "ELF")
621.97Schristos#LINKFLAGS+=	-N
631.97Schristos.else
641.97SchristosLINKFLAGS+=	-z
651.97Schristos.endif
661.107Sthorpej
671.107Sthorpej.if defined(KERN_LDSCRIPT)
681.107SthorpejLINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
691.107Sthorpej.endif
701.107Sthorpej
711.100StsutsuiSTRIPFLAGS=	-g
721.98Smrg
731.98Smrg%INCLUDES
741.74Smycroft
751.33Scgd### find out what to use for libkern
761.94SdrochnerKERN_AS=	obj
771.33Scgd.include "$S/lib/libkern/Makefile.inc"
781.33Scgd.ifndef PROF
791.33ScgdLIBKERN=	${KERNLIB}
801.33Scgd.else
811.33ScgdLIBKERN=	${KERNLIB_PROF}
821.33Scgd.endif
831.33Scgd
841.56Schristos### find out what to use for libcompat
851.56Schristos.include "$S/compat/common/Makefile.inc"
861.56Schristos.ifndef PROF
871.56SchristosLIBCOMPAT=	${COMPATLIB}
881.56Schristos.else
891.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
901.56Schristos.endif
911.56Schristos
921.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
931.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
941.42Smycroft
951.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
961.91SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
971.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
981.42Smycroft
991.1Scgd%OBJS
1001.1Scgd
1011.1Scgd%CFILES
1021.1Scgd
1031.62Smycroft%SFILES
1041.62Smycroft
1051.42Smycroft# load lines for config "xxx" will be emitted as:
1061.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
1071.42Smycroft#	${SYSTEM_LD_HEAD}
1081.42Smycroft#	${SYSTEM_LD} swapxxx.o
1091.42Smycroft#	${SYSTEM_LD_TAIL}
1101.62SmycroftSYSTEM_OBJ=	locore.o \
1111.94Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1121.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1131.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
1141.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1151.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1161.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1171.62Smycroft
1181.62SmycroftDEBUG?=
1191.62Smycroft.if ${DEBUG} == "-g"
1201.62SmycroftLINKFLAGS+=	-X
1211.62SmycroftSYSTEM_LD_TAIL+=; \
1221.99Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1231.103Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1241.103Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1251.62Smycroft.else
1261.89SmrgLINKFLAGS+=	-X
1271.62Smycroft.endif
1281.42Smycroft
1291.1Scgd%LOAD
1301.50Smycroft
1311.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1321.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1331.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1341.82Smycroft	mv -f assym.h.tmp assym.h
1351.1Scgd
1361.62Smycroftparam.c: $S/conf/param.c
1371.62Smycroft	rm -f param.c
1381.62Smycroft	cp $S/conf/param.c .
1391.1Scgd
1401.62Smycroftparam.o: param.c Makefile
1411.71Smycroft	${NORMAL_C}
1421.1Scgd
1431.62Smycroftioconf.o: ioconf.c
1441.62Smycroft	${NORMAL_C}
1451.42Smycroft
1461.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1471.62Smycroft	sh $S/conf/newvers.sh
1481.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1491.1Scgd
1501.1Scgd
1511.84Schristos__CLEANKERNEL: .USE
1521.84Schristos	@echo "${.TARGET}ing the kernel objects"
1531.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1541.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1551.84Schristos
1561.84Schristos__CLEANDEPEND: .USE
1571.84Schristos	rm -f .depend
1581.84Schristos
1591.84Schristosclean: __CLEANKERNEL
1601.84Schristos
1611.93Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1621.1Scgd
1631.62Smycroftlint:
1641.79Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1651.80Sperry	    ${I386}/i386/Locore.c ${CFILES} \
1661.62Smycroft	    ioconf.c param.c | \
1671.62Smycroft	    grep -v 'static function .* unused'
1681.1Scgd
1691.62Smycrofttags:
1701.62Smycroft	@echo "see $S/kern/Makefile for tags"
1711.1Scgd
1721.1Scgdlinks:
1731.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1741.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1751.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1761.1Scgd	  sort -u | comm -23 - dontlink | \
1771.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1781.1Scgd	sh makelinks && rm -f dontlink
1791.1Scgd
1801.62SmycroftSRCS=	${I386}/i386/locore.s \
1811.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1821.78Scgddepend: .depend
1831.75Sjtk.depend: ${SRCS} assym.h param.c
1841.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1851.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1861.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1871.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1881.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1891.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1901.83Sleo	@rm -f assym.dep
1911.102Stron
1921.102Strondependall: depend all
1931.62Smycroft
1941.62Smycroft
1951.62Smycroft# depend on root or device configuration
1961.62Smycroftautoconf.o conf.o: Makefile
1971.92Senami
1981.92Senami# depend on network or filesystem configuration
1991.92Senamiuipc_proto.o vfs_conf.o: Makefile
2001.1Scgd
2011.62Smycroft# depend on maxusers
2021.82Smycroftmachdep.o: Makefile
2031.1Scgd
2041.92Senami# depend on CPU configuration
2051.62Smycroftlocore.o machdep.o: Makefile
2061.1Scgd
2071.2Scgd
2081.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
2091.62Smycroft	${NORMAL_S}
2101.106Shubertf
2111.106Shubertf# The install target can be redefined by putting a
2121.106Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2131.106ShubertfMACHINE_NAME!=  uname -n
2141.106Shubertfinstall: install-kernel-${MACHINE_NAME}
2151.106Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2161.106Shubertfinstall-kernel-${MACHINE_NAME}:
2171.106Shubertf	rm -f /onetbsd
2181.106Shubertf	ln /netbsd /onetbsd
2191.106Shubertf	cp netbsd /nnetbsd
2201.106Shubertf	mv /nnetbsd /netbsd
2211.106Shubertf.endif
2221.1Scgd
2231.1Scgd%RULES
224