Makefile.i386 revision 1.112
11.112Slukem#	$NetBSD: Makefile.i386,v 1.112 2001/01/20 07:18:06 lukem 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.42Smycroft
151.97Schristos.include <bsd.own.mk>
161.97Schristos
171.62Smycroft# DEBUG is set to -g if debugging.
181.62Smycroft# PROF is set to -pg if profiling.
191.62Smycroft
201.88SthorpejAR?=	ar
211.88SthorpejAS?=	as
221.65SmycroftCC?=	cc
231.88SthorpejCPP?=	cpp
241.65SmycroftLD?=	ld
251.87SthorpejLORDER?=lorder
261.68SmycroftMKDEP?=	mkdep
271.87SthorpejNM?=	nm
281.88SthorpejRANLIB?=ranlib
291.85SlukemSIZE?=	size
301.103StsutsuiSTRIP?=	strip
311.87SthorpejTSORT?=	tsort -q
321.88Sthorpej
331.110SfvdlCOPTS?=	-O2
341.1Scgd
351.42Smycroft# source tree is located via $S relative to the compilation directory
361.73Smycroft.ifndef S
371.68SmycroftS!=	cd ../../../..; pwd
381.73Smycroft.endif
391.68SmycroftI386=	$S/arch/i386
401.1Scgd
411.105SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
421.69SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
431.96SthorpejCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Di386
441.95SaugustssCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
451.95Saugustss		-Wpointer-arith
461.105Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
471.105Sthorpej# XXX always get it right.  --thorpej
481.105SthorpejCWARNFLAGS+=	-Wno-uninitialized
491.105Sthorpej.if (${HAVE_EGCS} != "")
501.90StvCWARNFLAGS+=	-Wno-main
511.90Stv.endif
521.77SjonathanCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
531.64SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
541.104SthorpejLINKFLAGS=	-Ttext c0100000 -e start
551.111Sthorpej
561.97Schristos.if (${OBJECT_FMT} == "ELF")
571.111SthorpejKERN_LDSCRIPT?=	kern.ldscript
581.111SthorpejLINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
591.97Schristos.else
601.97SchristosLINKFLAGS+=	-z
611.107Sthorpej.endif
621.107Sthorpej
631.100StsutsuiSTRIPFLAGS=	-g
641.98Smrg
651.98Smrg%INCLUDES
661.74Smycroft
671.33Scgd### find out what to use for libkern
681.94SdrochnerKERN_AS=	obj
691.33Scgd.include "$S/lib/libkern/Makefile.inc"
701.33Scgd.ifndef PROF
711.33ScgdLIBKERN=	${KERNLIB}
721.33Scgd.else
731.33ScgdLIBKERN=	${KERNLIB_PROF}
741.33Scgd.endif
751.33Scgd
761.56Schristos### find out what to use for libcompat
771.56Schristos.include "$S/compat/common/Makefile.inc"
781.56Schristos.ifndef PROF
791.56SchristosLIBCOMPAT=	${COMPATLIB}
801.56Schristos.else
811.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
821.56Schristos.endif
831.56Schristos
841.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
851.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
861.42Smycroft
871.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
881.91SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
891.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
901.42Smycroft
911.1Scgd%OBJS
921.1Scgd
931.1Scgd%CFILES
941.1Scgd
951.62Smycroft%SFILES
961.62Smycroft
971.42Smycroft# load lines for config "xxx" will be emitted as:
981.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
991.42Smycroft#	${SYSTEM_LD_HEAD}
1001.42Smycroft#	${SYSTEM_LD} swapxxx.o
1011.42Smycroft#	${SYSTEM_LD_TAIL}
1021.62SmycroftSYSTEM_OBJ=	locore.o \
1031.94Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1041.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1051.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
1061.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1071.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1081.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1091.62Smycroft
1101.62SmycroftDEBUG?=
1111.62Smycroft.if ${DEBUG} == "-g"
1121.62SmycroftLINKFLAGS+=	-X
1131.62SmycroftSYSTEM_LD_TAIL+=; \
1141.99Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1151.103Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1161.103Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1171.62Smycroft.else
1181.89SmrgLINKFLAGS+=	-X
1191.62Smycroft.endif
1201.42Smycroft
1211.1Scgd%LOAD
1221.50Smycroft
1231.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1241.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1251.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1261.82Smycroft	mv -f assym.h.tmp assym.h
1271.1Scgd
1281.62Smycroftparam.c: $S/conf/param.c
1291.62Smycroft	rm -f param.c
1301.62Smycroft	cp $S/conf/param.c .
1311.1Scgd
1321.62Smycroftparam.o: param.c Makefile
1331.71Smycroft	${NORMAL_C}
1341.1Scgd
1351.62Smycroftioconf.o: ioconf.c
1361.62Smycroft	${NORMAL_C}
1371.42Smycroft
1381.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1391.62Smycroft	sh $S/conf/newvers.sh
1401.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1411.1Scgd
1421.1Scgd
1431.84Schristos__CLEANKERNEL: .USE
1441.84Schristos	@echo "${.TARGET}ing the kernel objects"
1451.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1461.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1471.84Schristos
1481.84Schristos__CLEANDEPEND: .USE
1491.84Schristos	rm -f .depend
1501.84Schristos
1511.84Schristosclean: __CLEANKERNEL
1521.84Schristos
1531.93Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1541.1Scgd
1551.62Smycroftlint:
1561.79Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1571.80Sperry	    ${I386}/i386/Locore.c ${CFILES} \
1581.62Smycroft	    ioconf.c param.c | \
1591.62Smycroft	    grep -v 'static function .* unused'
1601.1Scgd
1611.62Smycrofttags:
1621.62Smycroft	@echo "see $S/kern/Makefile for tags"
1631.1Scgd
1641.1Scgdlinks:
1651.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1661.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1671.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1681.1Scgd	  sort -u | comm -23 - dontlink | \
1691.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1701.1Scgd	sh makelinks && rm -f dontlink
1711.1Scgd
1721.62SmycroftSRCS=	${I386}/i386/locore.s \
1731.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1741.78Scgddepend: .depend
1751.75Sjtk.depend: ${SRCS} assym.h param.c
1761.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1771.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1781.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1791.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1801.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1811.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1821.83Sleo	@rm -f assym.dep
1831.102Stron
1841.102Strondependall: depend all
1851.62Smycroft
1861.62Smycroft
1871.62Smycroft# depend on root or device configuration
1881.62Smycroftautoconf.o conf.o: Makefile
1891.92Senami
1901.92Senami# depend on network or filesystem configuration
1911.92Senamiuipc_proto.o vfs_conf.o: Makefile
1921.1Scgd
1931.62Smycroft# depend on maxusers
1941.82Smycroftmachdep.o: Makefile
1951.1Scgd
1961.92Senami# depend on CPU configuration
1971.62Smycroftlocore.o machdep.o: Makefile
1981.1Scgd
1991.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
2001.62Smycroft	${NORMAL_S}
2011.112Slukem
2021.112Slukemapmcall.o in_cksum.o pnpbioscall.o: assym.h
2031.112Slukem
2041.112Slukemfreebsd_sigcode.o ibcs2_sigcode.o linux_sigcode.o svr4_sigcode.o: assym.h
2051.106Shubertf
2061.106Shubertf# The install target can be redefined by putting a
2071.106Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2081.106ShubertfMACHINE_NAME!=  uname -n
2091.106Shubertfinstall: install-kernel-${MACHINE_NAME}
2101.106Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2111.106Shubertfinstall-kernel-${MACHINE_NAME}:
2121.106Shubertf	rm -f /onetbsd
2131.106Shubertf	ln /netbsd /onetbsd
2141.106Shubertf	cp netbsd /nnetbsd
2151.106Shubertf	mv /nnetbsd /netbsd
2161.106Shubertf.endif
2171.1Scgd
2181.1Scgd%RULES
219