Makefile.powerpc revision 25202
140843Smsmith# Makefile.i386 -- with config changes.
240843Smsmith# Copyright 1990 W. Jolitz
340843Smsmith#	from: @(#)Makefile.i386	7.1 5/10/91
440843Smsmith#	$Id: Makefile.i386,v 1.94 1997/04/22 06:55:21 jdp Exp $
540843Smsmith#
694290Sdcs# Makefile for FreeBSD
776116Sdcs#
876116Sdcs# This makefile is constructed from a machine description:
976116Sdcs#	config machineid
1076116Sdcs# Most changes should be made in the machine description
1176116Sdcs#	/sys/i386/conf/``machineid''
1276116Sdcs# after which you should do
1376116Sdcs#	 config machineid
1494290Sdcs# Generic makefile changes should be made in
1594290Sdcs#	/sys/i386/conf/Makefile.i386
1694290Sdcs# after which config should be rerun for all machines.
1794290Sdcs#
1894290Sdcs
1976116SdcsBINFORMAT?=	aout
2040843Smsmith#BINFORMAT?=	elf
2176116Sdcs
2276116Sdcs.if exists(./@/.)
2376116SdcsS=	./@
2476116Sdcs.else
2576116SdcsS=	../..
2676116Sdcs.endif
2776116SdcsI386=	${S}/i386
2876116Sdcs
2976116SdcsCOPTFLAGS?=-O
3076116SdcsINCLUDES= -nostdinc -I- -I. -I$S
3176116Sdcs# This hack is to allow kernel compiles to succeed on machines w/out srcdist
3276116Sdcs.if exists($S/../include)
3376116SdcsINCLUDES+= -I$S/../include
3476116Sdcs.else
3576116SdcsINCLUDES+= -I/usr/include
3676116Sdcs.endif
3776116SdcsCOPTS=	${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h
3876116SdcsCFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
3976116SdcsLOAD_ADDRESS?=	F0100000
4076116Sdcs.if defined(PROF)
4176116SdcsPROF+=	-malign-functions=4
4240883Smsmith.if ${PROFLEVEL} >= 2
4351786SdcsIDENT+=	-DGPROF4 -DGUPROF
4451786SdcsPROF+=	-mprofiler-epilogue
4540883Smsmith.endif
4640843Smsmith.endif
4740883Smsmith
4840883SmsmithNORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
4940883SmsmithNORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
5040843Smsmith# XXX LOCORE means "don't declare C stuff" not "for locore.s".
5140843SmsmithNORMAL_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
5240843SmsmithDRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
5340843SmsmithDRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
5440843SmsmithDRIVER_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
5540843SmsmithPROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
5640843Smsmith
5740843SmsmithSYSTEM_CFILES= ${I386}/i386/setdef0.c ioconf.c param.c vnode_if.c config.c \
5840843Smsmith	${I386}/i386/setdef1.c
5940843SmsmithSYSTEM_SFILES= ${I386}/i386/locore.s
6040843SmsmithSYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
6140843Smsmith	setdef1.o
6240843SmsmithSYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
6340843Smsmith.if ${CFLAGS:M-g} == ""
6440843SmsmithSYMORDER_EXCLUDE=-x symbols.exclude
6540843Smsmith.endif
6640843SmsmithSYSTEM_LD_HEAD= @echo loading $@; rm -f $@
6740843Smsmith.if ${BINFORMAT} == aout
6840843SmsmithSYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
6940843SmsmithSYSTEM_LD_TAIL= @echo rearranging symbols; \
7040843Smsmith	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
7140843Smsmith	size $@; chmod 755 $@
7240843Smsmith.endif
7340843Smsmith.if ${BINFORMAT} == elf
7440843SmsmithSYSTEM_LD= @${LD} -Bstatic -Ttext ${LOAD_ADDRESS} -e btext -o $@ -X ${SYSTEM_OBJS} vers.o
7540843SmsmithSYSTEM_LD_TAIL= @size $@; chmod 755 $@
7640843Smsmith.endif
7740843Smsmith
7840843Smsmith%BEFORE_DEPEND
7940843Smsmith
8040843Smsmith%OBJS
8140843Smsmith
8240843Smsmith%CFILES
8340843Smsmith
8440843Smsmith%SFILES
8540843Smsmith
8640843Smsmith%LOAD
8740843Smsmith
8840843Smsmith%CLEAN
8940843Smsmith
9040843Smsmithclean:
9176116Sdcs	rm -f *.o *.s eddep errs genassym kernel linterrs \
9276116Sdcs	      makelinks param.c symbols.exclude symbols.sort tags \
9376116Sdcs	      vers.c vnode_if.c vnode_if.h ${CLEAN}
9476116Sdcs
9576116Sdcs#lint: /tmp param.c
9676116Sdcs#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
9776116Sdcs#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
9876116Sdcs#	    grep -v 'struct/union .* never defined' | \
9976116Sdcs#	    grep -v 'possible pointer alignment problem'
10076116Sdcs
10176116Sdcssymbols.exclude: Makefile
10276116Sdcs	echo "gcc2_compiled." >symbols.exclude
10376116Sdcs	echo "___gnu_compiled_c" >>symbols.exclude
10476116Sdcs
10576116Sdcssymbols.sort: ${I386}/i386/symbols.raw
10676116Sdcs	grep -v '^#' ${I386}/i386/symbols.raw \
10776116Sdcs	    | sed 's/^	//' | sort -u > symbols.sort
10876116Sdcs
10940843Smsmithlocore.o: ${I386}/i386/locore.s assym.s
11040843Smsmith	${NORMAL_S}
11140843Smsmith
11240843Smsmithsetdef0.o: ${I386}/i386/setdef0.c
11340843Smsmith	${NORMAL_C}
11440843Smsmith
11540843Smsmithsetdef1.o: ${I386}/i386/setdef1.c
11640843Smsmith	${NORMAL_C}
11740843Smsmith
11840843Smsmith# everything potentially depends on the Makefile since everything potentially
11940843Smsmith# depends on the options.  Some things are more dependent on the Makefile for
12040843Smsmith# historical reasons.
12140843Smsmithmachdep.o: Makefile
12240843Smsmith
12340843Smsmith# the following is necessary because autoconf.o depends on #if GENERIC
12440843Smsmithautoconf.o: Makefile
12540843Smsmith
12640843Smsmith# XXX - may no longer be needed
12740843Smsmithlocore.o: Makefile
12840843Smsmith
12940843Smsmith# depends on KDB (cons.o also depends on GENERIC)
13040843Smsmithtrap.o cons.o: Makefile
13140843Smsmith
13240843Smsmith# this rule stops ./assym.s in .depend from causing problems
13340843Smsmith./assym.s: assym.s
13440843Smsmith
13540843Smsmithassym.s: genassym
13640843Smsmith	./genassym >assym.s
13740843Smsmith
13840843Smsmith# Some of the defines that genassym outputs may well depend on the
13940843Smsmith# value of kernel options.
14040843Smsmithgenassym.o: ${I386}/i386/genassym.c Makefile opt_global.h
14140843Smsmith	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
14240843Smsmith
14340843Smsmithgenassym: genassym.o
14440843Smsmith	${CC} ${CFLAGS} ${PARAM} genassym.o -o $@
14540843Smsmith
14640843Smsmith${OBJS}: opt_global.h
14740843Smsmith
14840843Smsmith# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
14940843Smsmithdepend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
15040843Smsmith	rm -f .newdep
15140843Smsmith	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
15240843Smsmith	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
15340843Smsmith	MKDEP_CPP="${CC} -E -x assembler-with-cpp" ; export MKDEP_CPP ; \
15440843Smsmith	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
15540843Smsmith	rm -f .depend
15640843Smsmith	mv -f .newdep .depend
15740843Smsmith
15840843Smsmithlinks:
15940843Smsmith	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
16040843Smsmith	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
16140843Smsmith	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
16240843Smsmith	  sort -u | comm -23 - dontlink | \
16340843Smsmith	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
16440843Smsmith	sh makelinks && rm -f dontlink
16540843Smsmith
16640843Smsmithtags:
16740843Smsmith	@echo "see $S/kern/Makefile for tags"
16840843Smsmith
16940843Smsmithinstall:
17040843Smsmith	@if [ ! -f kernel ] ; then \
17140843Smsmith		echo "You must first build your kernel before trying to install." ; \
17240843Smsmith		exit 1 ; \
17340843Smsmith	fi
17440843Smsmith	chflags noschg /kernel
17540843Smsmith	mv /kernel /kernel.old
17640843Smsmith	if [ `/usr/sbin/sysctl -n kern.bootfile` = /kernel ] ; then \
17740843Smsmith		/usr/sbin/sysctl -w kern.bootfile=/kernel.old ; \
17840843Smsmith		mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \
17940843Smsmith	fi
18040843Smsmith	install -c -m 555 -o root -g wheel -fschg kernel /
18140843Smsmith
18240843Smsmithioconf.o: ioconf.c $S/sys/param.h $S/sys/buf.h \
18340843Smsmith    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
18440843Smsmith	${CC} -c ${CFLAGS} ioconf.c
18540843Smsmith
18640843Smsmithparam.c: $S/conf/param.c
18740843Smsmith	-rm -f param.c
18840843Smsmith	cp $S/conf/param.c .
18940843Smsmith
19040843Smsmithparam.o: param.c Makefile
19140843Smsmith	${CC} -c ${CFLAGS} ${PARAM} param.c
19240843Smsmith
19340843Smsmithvers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
19440843Smsmith	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
19540843Smsmith	${CC} ${CFLAGS} -c vers.c
19640843Smsmith
19740843Smsmithvnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
19840843Smsmith	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
19940843Smsmithvnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
20040843Smsmith	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
20140843Smsmith
20240843Smsmith.include <bsd.kern.mk>
20340843Smsmith
20440843Smsmith%RULES
20540843Smsmith
20640843Smsmith# DO NOT DELETE THIS LINE -- make depend uses it
20740843Smsmith