Makefile.i386 revision 1.118
11.118Sjmc#	$NetBSD: Makefile.i386,v 1.118 2001/10/26 06:45:37 jmc 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.118SjmcUSETOOLS?=	no
171.42Smycroft
181.97Schristos.include <bsd.own.mk>
191.97Schristos
201.62Smycroft# DEBUG is set to -g if debugging.
211.62Smycroft# PROF is set to -pg if profiling.
221.62Smycroft
231.88SthorpejAR?=	ar
241.88SthorpejAS?=	as
251.65SmycroftCC?=	cc
261.88SthorpejCPP?=	cpp
271.65SmycroftLD?=	ld
281.87SthorpejLORDER?=lorder
291.68SmycroftMKDEP?=	mkdep
301.87SthorpejNM?=	nm
311.88SthorpejRANLIB?=ranlib
321.85SlukemSIZE?=	size
331.103StsutsuiSTRIP?=	strip
341.87SthorpejTSORT?=	tsort -q
351.88Sthorpej
361.110SfvdlCOPTS?=	-O2
371.1Scgd
381.42Smycroft# source tree is located via $S relative to the compilation directory
391.73Smycroft.ifndef S
401.68SmycroftS!=	cd ../../../..; pwd
411.73Smycroft.endif
421.68SmycroftI386=	$S/arch/i386
431.1Scgd
441.105SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
451.69SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
461.115SmrgCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Di386
471.95SaugustssCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
481.95Saugustss		-Wpointer-arith
491.105Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
501.105Sthorpej# XXX always get it right.  --thorpej
511.105SthorpejCWARNFLAGS+=	-Wno-uninitialized
521.105Sthorpej.if (${HAVE_EGCS} != "")
531.90StvCWARNFLAGS+=	-Wno-main
541.90Stv.endif
551.77SjonathanCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
561.64SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
571.116Sthorpej
581.116SthorpejTEXTADDR?=	c0100000
591.116SthorpejLINKFLAGS=	-Ttext ${TEXTADDR} -e start
601.111Sthorpej
611.97Schristos.if (${OBJECT_FMT} == "ELF")
621.111SthorpejKERN_LDSCRIPT?=	kern.ldscript
631.111SthorpejLINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
641.97Schristos.else
651.97SchristosLINKFLAGS+=	-z
661.107Sthorpej.endif
671.107Sthorpej
681.100StsutsuiSTRIPFLAGS=	-g
691.98Smrg
701.98Smrg%INCLUDES
711.74Smycroft
721.33Scgd### find out what to use for libkern
731.94SdrochnerKERN_AS=	obj
741.33Scgd.include "$S/lib/libkern/Makefile.inc"
751.33Scgd.ifndef PROF
761.33ScgdLIBKERN=	${KERNLIB}
771.33Scgd.else
781.33ScgdLIBKERN=	${KERNLIB_PROF}
791.33Scgd.endif
801.33Scgd
811.56Schristos### find out what to use for libcompat
821.56Schristos.include "$S/compat/common/Makefile.inc"
831.56Schristos.ifndef PROF
841.56SchristosLIBCOMPAT=	${COMPATLIB}
851.56Schristos.else
861.56SchristosLIBCOMPAT=	${COMPATLIB_PROF}
871.56Schristos.endif
881.56Schristos
891.71Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
901.71Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
911.42Smycroft
921.62SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
931.91SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
941.64SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
951.42Smycroft
961.1Scgd%OBJS
971.1Scgd
981.1Scgd%CFILES
991.1Scgd
1001.62Smycroft%SFILES
1011.62Smycroft
1021.42Smycroft# load lines for config "xxx" will be emitted as:
1031.42Smycroft# xxx: ${SYSTEM_DEP} swapxxx.o
1041.42Smycroft#	${SYSTEM_LD_HEAD}
1051.42Smycroft#	${SYSTEM_LD} swapxxx.o
1061.42Smycroft#	${SYSTEM_LD_TAIL}
1071.62SmycroftSYSTEM_OBJ=	locore.o \
1081.94Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1091.42SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1101.42SmycroftSYSTEM_LD_HEAD=	rm -f $@
1111.62SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1121.62Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1131.85SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1141.62Smycroft
1151.62SmycroftDEBUG?=
1161.62Smycroft.if ${DEBUG} == "-g"
1171.62SmycroftLINKFLAGS+=	-X
1181.62SmycroftSYSTEM_LD_TAIL+=; \
1191.99Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1201.103Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1211.103Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1221.62Smycroft.else
1231.89SmrgLINKFLAGS+=	-X
1241.62Smycroft.endif
1251.42Smycroft
1261.1Scgd%LOAD
1271.50Smycroft
1281.82Smycroftassym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
1291.82Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1301.82Smycroft	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
1311.82Smycroft	mv -f assym.h.tmp assym.h
1321.1Scgd
1331.62Smycroftparam.c: $S/conf/param.c
1341.62Smycroft	rm -f param.c
1351.62Smycroft	cp $S/conf/param.c .
1361.1Scgd
1371.62Smycroftparam.o: param.c Makefile
1381.71Smycroft	${NORMAL_C}
1391.1Scgd
1401.62Smycroftioconf.o: ioconf.c
1411.62Smycroft	${NORMAL_C}
1421.42Smycroft
1431.62Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1441.62Smycroft	sh $S/conf/newvers.sh
1451.62Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1461.1Scgd
1471.1Scgd
1481.84Schristos__CLEANKERNEL: .USE
1491.84Schristos	@echo "${.TARGET}ing the kernel objects"
1501.66Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1511.82Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1521.84Schristos
1531.84Schristos__CLEANDEPEND: .USE
1541.84Schristos	rm -f .depend
1551.84Schristos
1561.84Schristosclean: __CLEANKERNEL
1571.84Schristos
1581.93Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1591.1Scgd
1601.113SperryALLSFILES=	${I386}/i386/locore.s ${SFILES}
1611.113SperryLINTSTUBS=	${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
1621.113Sperry
1631.113Sperry.for _sfile in ${ALLSFILES}
1641.113SperryLintStub_${_sfile:T:R}.c: ${_sfile} assym.h
1651.113Sperry	${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
1661.113Sperry	      awk -f $S/kern/genlintstub.awk >${.TARGET}
1671.113Sperry.endfor
1681.113Sperry
1691.114Slukemlint: ${CFILES} ${LINTSTUBS} ioconf.c param.c
1701.114Slukem	@lint -bceghnxzF ${CPPFLAGS} -UKGDB \
1711.114Slukem	    ${CFILES} ${LINTSTUBS} ioconf.c param.c
1721.1Scgd
1731.62Smycrofttags:
1741.62Smycroft	@echo "see $S/kern/Makefile for tags"
1751.1Scgd
1761.1Scgdlinks:
1771.1Scgd	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1781.1Scgd	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1791.1Scgd	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1801.1Scgd	  sort -u | comm -23 - dontlink | \
1811.62Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1821.1Scgd	sh makelinks && rm -f dontlink
1831.1Scgd
1841.62SmycroftSRCS=	${I386}/i386/locore.s \
1851.66Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1861.78Scgddepend: .depend
1871.75Sjtk.depend: ${SRCS} assym.h param.c
1881.68Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
1891.68Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1901.68Smycroft	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
1911.83Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1921.83Sleo	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
1931.83Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1941.83Sleo	@rm -f assym.dep
1951.102Stron
1961.102Strondependall: depend all
1971.62Smycroft
1981.62Smycroft
1991.62Smycroft# depend on root or device configuration
2001.62Smycroftautoconf.o conf.o: Makefile
2011.92Senami
2021.92Senami# depend on network or filesystem configuration
2031.92Senamiuipc_proto.o vfs_conf.o: Makefile
2041.1Scgd
2051.62Smycroft# depend on maxusers
2061.82Smycroftmachdep.o: Makefile
2071.1Scgd
2081.92Senami# depend on CPU configuration
2091.62Smycroftlocore.o machdep.o: Makefile
2101.1Scgd
2111.62Smycroftlocore.o: ${I386}/i386/locore.s assym.h
2121.62Smycroft	${NORMAL_S}
2131.112Slukem
2141.112Slukemapmcall.o in_cksum.o pnpbioscall.o: assym.h
2151.112Slukem
2161.112Slukemfreebsd_sigcode.o ibcs2_sigcode.o linux_sigcode.o svr4_sigcode.o: assym.h
2171.106Shubertf
2181.106Shubertf# The install target can be redefined by putting a
2191.106Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2201.106ShubertfMACHINE_NAME!=  uname -n
2211.106Shubertfinstall: install-kernel-${MACHINE_NAME}
2221.106Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2231.106Shubertfinstall-kernel-${MACHINE_NAME}:
2241.106Shubertf	rm -f /onetbsd
2251.106Shubertf	ln /netbsd /onetbsd
2261.106Shubertf	cp netbsd /nnetbsd
2271.106Shubertf	mv /nnetbsd /netbsd
2281.106Shubertf.endif
2291.1Scgd
2301.1Scgd%RULES
231