Makefile.i386 revision 1.117
11.117Sthorpej#	$NetBSD: Makefile.i386,v 1.117 2001/10/23 19:26:45 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.117Sthorpej
151.117SthorpejMACHINE_ARCH=i386
161.42Smycroft
171.97Schristos.include <bsd.own.mk>
181.97Schristos
191.62Smycroft# DEBUG is set to -g if debugging.
201.62Smycroft# PROF is set to -pg if profiling.
211.62Smycroft
221.88SthorpejAR?=	ar
231.88SthorpejAS?=	as
241.65SmycroftCC?=	cc
251.88SthorpejCPP?=	cpp
261.65SmycroftLD?=	ld
271.87SthorpejLORDER?=lorder
281.68SmycroftMKDEP?=	mkdep
291.87SthorpejNM?=	nm
301.88SthorpejRANLIB?=ranlib
311.85SlukemSIZE?=	size
321.103StsutsuiSTRIP?=	strip
331.87SthorpejTSORT?=	tsort -q
341.88Sthorpej
351.110SfvdlCOPTS?=	-O2
361.1Scgd
371.42Smycroft# source tree is located via $S relative to the compilation directory
381.73Smycroft.ifndef S
391.68SmycroftS!=	cd ../../../..; pwd
401.73Smycroft.endif
411.68SmycroftI386=	$S/arch/i386
421.1Scgd
431.105SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
441.69SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
451.115SmrgCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Di386
461.95SaugustssCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
471.95Saugustss		-Wpointer-arith
481.105Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
491.105Sthorpej# XXX always get it right.  --thorpej
501.105SthorpejCWARNFLAGS+=	-Wno-uninitialized
511.105Sthorpej.if (${HAVE_EGCS} != "")
521.90StvCWARNFLAGS+=	-Wno-main
531.90Stv.endif
541.77SjonathanCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
551.64SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
561.116Sthorpej
571.116SthorpejTEXTADDR?=	c0100000
581.116SthorpejLINKFLAGS=	-Ttext ${TEXTADDR} -e start
591.111Sthorpej
601.97Schristos.if (${OBJECT_FMT} == "ELF")
611.111SthorpejKERN_LDSCRIPT?=	kern.ldscript
621.111SthorpejLINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
631.97Schristos.else
641.97SchristosLINKFLAGS+=	-z
651.107Sthorpej.endif
661.107Sthorpej
671.100StsutsuiSTRIPFLAGS=	-g
681.98Smrg
691.98Smrg%INCLUDES
701.74Smycroft
711.33Scgd### find out what to use for libkern
721.94SdrochnerKERN_AS=	obj
731.33Scgd.include "$S/lib/libkern/Makefile.inc"
741.33Scgd.ifndef PROF
751.33ScgdLIBKERN=	${KERNLIB}
761.33Scgd.else
771.33ScgdLIBKERN=	${KERNLIB_PROF}
781.33Scgd.endif
791.33Scgd
801.56Schristos### find out what to use for libcompat
811.56Schristos.include "$S/compat/common/Makefile.inc"
821.56Schristos.ifndef PROF
831.56SchristosLIBCOMPAT=	${COMPATLIB}
841.56Schristos.else
851.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
861.56Schristos.endif
871.56Schristos
881.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
891.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
901.42Smycroft
911.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
921.91SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
931.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
941.42Smycroft
951.1Scgd%OBJS
961.1Scgd
971.1Scgd%CFILES
981.1Scgd
991.62Smycroft%SFILES
1001.62Smycroft
1011.42Smycroft# load lines for config "xxx" will be emitted as:
1021.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
1031.42Smycroft#	${SYSTEM_LD_HEAD}
1041.42Smycroft#	${SYSTEM_LD} swapxxx.o
1051.42Smycroft#	${SYSTEM_LD_TAIL}
1061.62SmycroftSYSTEM_OBJ=	locore.o \
1071.94Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1081.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1091.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
1101.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1111.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1121.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1131.62Smycroft
1141.62SmycroftDEBUG?=
1151.62Smycroft.if ${DEBUG} == "-g"
1161.62SmycroftLINKFLAGS+=	-X
1171.62SmycroftSYSTEM_LD_TAIL+=; \
1181.99Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1191.103Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1201.103Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1211.62Smycroft.else
1221.89SmrgLINKFLAGS+=	-X
1231.62Smycroft.endif
1241.42Smycroft
1251.1Scgd%LOAD
1261.50Smycroft
1271.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1281.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1291.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1301.82Smycroft	mv -f assym.h.tmp assym.h
1311.1Scgd
1321.62Smycroftparam.c: $S/conf/param.c
1331.62Smycroft	rm -f param.c
1341.62Smycroft	cp $S/conf/param.c .
1351.1Scgd
1361.62Smycroftparam.o: param.c Makefile
1371.71Smycroft	${NORMAL_C}
1381.1Scgd
1391.62Smycroftioconf.o: ioconf.c
1401.62Smycroft	${NORMAL_C}
1411.42Smycroft
1421.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1431.62Smycroft	sh $S/conf/newvers.sh
1441.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1451.1Scgd
1461.1Scgd
1471.84Schristos__CLEANKERNEL: .USE
1481.84Schristos	@echo "${.TARGET}ing the kernel objects"
1491.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1501.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1511.84Schristos
1521.84Schristos__CLEANDEPEND: .USE
1531.84Schristos	rm -f .depend
1541.84Schristos
1551.84Schristosclean: __CLEANKERNEL
1561.84Schristos
1571.93Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1581.1Scgd
1591.113SperryALLSFILES=	${I386}/i386/locore.s ${SFILES}
1601.113SperryLINTSTUBS=	${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
1611.113Sperry
1621.113Sperry.for _sfile in ${ALLSFILES}
1631.113SperryLintStub_${_sfile:T:R}.c: ${_sfile} assym.h
1641.113Sperry	${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
1651.113Sperry	      awk -f $S/kern/genlintstub.awk >${.TARGET}
1661.113Sperry.endfor
1671.113Sperry
1681.114Slukemlint: ${CFILES} ${LINTSTUBS} ioconf.c param.c
1691.114Slukem	@lint -bceghnxzF ${CPPFLAGS} -UKGDB \
1701.114Slukem	    ${CFILES} ${LINTSTUBS} ioconf.c param.c
1711.1Scgd
1721.62Smycrofttags:
1731.62Smycroft	@echo "see $S/kern/Makefile for tags"
1741.1Scgd
1751.1Scgdlinks:
1761.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1771.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1781.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1791.1Scgd	  sort -u | comm -23 - dontlink | \
1801.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1811.1Scgd	sh makelinks && rm -f dontlink
1821.1Scgd
1831.62SmycroftSRCS=	${I386}/i386/locore.s \
1841.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1851.78Scgddepend: .depend
1861.75Sjtk.depend: ${SRCS} assym.h param.c
1871.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1881.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1891.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1901.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1911.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1921.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1931.83Sleo	@rm -f assym.dep
1941.102Stron
1951.102Strondependall: depend all
1961.62Smycroft
1971.62Smycroft
1981.62Smycroft# depend on root or device configuration
1991.62Smycroftautoconf.o conf.o: Makefile
2001.92Senami
2011.92Senami# depend on network or filesystem configuration
2021.92Senamiuipc_proto.o vfs_conf.o: Makefile
2031.1Scgd
2041.62Smycroft# depend on maxusers
2051.82Smycroftmachdep.o: Makefile
2061.1Scgd
2071.92Senami# depend on CPU configuration
2081.62Smycroftlocore.o machdep.o: Makefile
2091.1Scgd
2101.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
2111.62Smycroft	${NORMAL_S}
2121.112Slukem
2131.112Slukemapmcall.o in_cksum.o pnpbioscall.o: assym.h
2141.112Slukem
2151.112Slukemfreebsd_sigcode.o ibcs2_sigcode.o linux_sigcode.o svr4_sigcode.o: assym.h
2161.106Shubertf
2171.106Shubertf# The install target can be redefined by putting a
2181.106Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2191.106ShubertfMACHINE_NAME!=  uname -n
2201.106Shubertfinstall: install-kernel-${MACHINE_NAME}
2211.106Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2221.106Shubertfinstall-kernel-${MACHINE_NAME}:
2231.106Shubertf	rm -f /onetbsd
2241.106Shubertf	ln /netbsd /onetbsd
2251.106Shubertf	cp netbsd /nnetbsd
2261.106Shubertf	mv /nnetbsd /netbsd
2271.106Shubertf.endif
2281.1Scgd
2291.1Scgd%RULES
230