Makefile.i386 revision 1.116
11.116Sthorpej#	$NetBSD: Makefile.i386,v 1.116 2001/06/05 05:05:46 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.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.115SmrgCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -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.116Sthorpej
551.116SthorpejTEXTADDR?=	c0100000
561.116SthorpejLINKFLAGS=	-Ttext ${TEXTADDR} -e start
571.111Sthorpej
581.97Schristos.if (${OBJECT_FMT} == "ELF")
591.111SthorpejKERN_LDSCRIPT?=	kern.ldscript
601.111SthorpejLINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
611.97Schristos.else
621.97SchristosLINKFLAGS+=	-z
631.107Sthorpej.endif
641.107Sthorpej
651.100StsutsuiSTRIPFLAGS=	-g
661.98Smrg
671.98Smrg%INCLUDES
681.74Smycroft
691.33Scgd### find out what to use for libkern
701.94SdrochnerKERN_AS=	obj
711.33Scgd.include "$S/lib/libkern/Makefile.inc"
721.33Scgd.ifndef PROF
731.33ScgdLIBKERN=	${KERNLIB}
741.33Scgd.else
751.33ScgdLIBKERN=	${KERNLIB_PROF}
761.33Scgd.endif
771.33Scgd
781.56Schristos### find out what to use for libcompat
791.56Schristos.include "$S/compat/common/Makefile.inc"
801.56Schristos.ifndef PROF
811.56SchristosLIBCOMPAT=	${COMPATLIB}
821.56Schristos.else
831.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
841.56Schristos.endif
851.56Schristos
861.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
871.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
881.42Smycroft
891.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
901.91SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
911.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
921.42Smycroft
931.1Scgd%OBJS
941.1Scgd
951.1Scgd%CFILES
961.1Scgd
971.62Smycroft%SFILES
981.62Smycroft
991.42Smycroft# load lines for config "xxx" will be emitted as:
1001.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
1011.42Smycroft#	${SYSTEM_LD_HEAD}
1021.42Smycroft#	${SYSTEM_LD} swapxxx.o
1031.42Smycroft#	${SYSTEM_LD_TAIL}
1041.62SmycroftSYSTEM_OBJ=	locore.o \
1051.94Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1061.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1071.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
1081.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1091.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1101.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1111.62Smycroft
1121.62SmycroftDEBUG?=
1131.62Smycroft.if ${DEBUG} == "-g"
1141.62SmycroftLINKFLAGS+=	-X
1151.62SmycroftSYSTEM_LD_TAIL+=; \
1161.99Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1171.103Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1181.103Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1191.62Smycroft.else
1201.89SmrgLINKFLAGS+=	-X
1211.62Smycroft.endif
1221.42Smycroft
1231.1Scgd%LOAD
1241.50Smycroft
1251.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1261.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1271.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1281.82Smycroft	mv -f assym.h.tmp assym.h
1291.1Scgd
1301.62Smycroftparam.c: $S/conf/param.c
1311.62Smycroft	rm -f param.c
1321.62Smycroft	cp $S/conf/param.c .
1331.1Scgd
1341.62Smycroftparam.o: param.c Makefile
1351.71Smycroft	${NORMAL_C}
1361.1Scgd
1371.62Smycroftioconf.o: ioconf.c
1381.62Smycroft	${NORMAL_C}
1391.42Smycroft
1401.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1411.62Smycroft	sh $S/conf/newvers.sh
1421.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1431.1Scgd
1441.1Scgd
1451.84Schristos__CLEANKERNEL: .USE
1461.84Schristos	@echo "${.TARGET}ing the kernel objects"
1471.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1481.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1491.84Schristos
1501.84Schristos__CLEANDEPEND: .USE
1511.84Schristos	rm -f .depend
1521.84Schristos
1531.84Schristosclean: __CLEANKERNEL
1541.84Schristos
1551.93Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1561.1Scgd
1571.113SperryALLSFILES=	${I386}/i386/locore.s ${SFILES}
1581.113SperryLINTSTUBS=	${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
1591.113Sperry
1601.113Sperry.for _sfile in ${ALLSFILES}
1611.113SperryLintStub_${_sfile:T:R}.c: ${_sfile} assym.h
1621.113Sperry	${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
1631.113Sperry	      awk -f $S/kern/genlintstub.awk >${.TARGET}
1641.113Sperry.endfor
1651.113Sperry
1661.114Slukemlint: ${CFILES} ${LINTSTUBS} ioconf.c param.c
1671.114Slukem	@lint -bceghnxzF ${CPPFLAGS} -UKGDB \
1681.114Slukem	    ${CFILES} ${LINTSTUBS} ioconf.c param.c
1691.1Scgd
1701.62Smycrofttags:
1711.62Smycroft	@echo "see $S/kern/Makefile for tags"
1721.1Scgd
1731.1Scgdlinks:
1741.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1751.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1761.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1771.1Scgd	  sort -u | comm -23 - dontlink | \
1781.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1791.1Scgd	sh makelinks && rm -f dontlink
1801.1Scgd
1811.62SmycroftSRCS=	${I386}/i386/locore.s \
1821.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1831.78Scgddepend: .depend
1841.75Sjtk.depend: ${SRCS} assym.h param.c
1851.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1861.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1871.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1881.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1891.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1901.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1911.83Sleo	@rm -f assym.dep
1921.102Stron
1931.102Strondependall: depend all
1941.62Smycroft
1951.62Smycroft
1961.62Smycroft# depend on root or device configuration
1971.62Smycroftautoconf.o conf.o: Makefile
1981.92Senami
1991.92Senami# depend on network or filesystem configuration
2001.92Senamiuipc_proto.o vfs_conf.o: Makefile
2011.1Scgd
2021.62Smycroft# depend on maxusers
2031.82Smycroftmachdep.o: Makefile
2041.1Scgd
2051.92Senami# depend on CPU configuration
2061.62Smycroftlocore.o machdep.o: Makefile
2071.1Scgd
2081.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
2091.62Smycroft	${NORMAL_S}
2101.112Slukem
2111.112Slukemapmcall.o in_cksum.o pnpbioscall.o: assym.h
2121.112Slukem
2131.112Slukemfreebsd_sigcode.o ibcs2_sigcode.o linux_sigcode.o svr4_sigcode.o: assym.h
2141.106Shubertf
2151.106Shubertf# The install target can be redefined by putting a
2161.106Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2171.106ShubertfMACHINE_NAME!=  uname -n
2181.106Shubertfinstall: install-kernel-${MACHINE_NAME}
2191.106Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2201.106Shubertfinstall-kernel-${MACHINE_NAME}:
2211.106Shubertf	rm -f /onetbsd
2221.106Shubertf	ln /netbsd /onetbsd
2231.106Shubertf	cp netbsd /nnetbsd
2241.106Shubertf	mv /nnetbsd /netbsd
2251.106Shubertf.endif
2261.1Scgd
2271.1Scgd%RULES
228