Makefile.powerpc revision 6733
1# Copyright 1990 W. Jolitz
2#	from: @(#)Makefile.i386	7.1 5/10/91
3#	$Id: Makefile.i386,v 1.54 1995/01/29 23:42:11 phk Exp $
4#
5# Makefile for FreeBSD
6#
7# This makefile is constructed from a machine description:
8#	config machineid
9# Most changes should be made in the machine description
10#	/sys/i386/conf/``machineid''
11# after which you should do
12#	 config machineid
13# Generic makefile changes should be made in
14#	/sys/i386/conf/Makefile.i386
15# after which config should be rerun for all machines.
16#
17# N.B.: DEPENDENCIES ON FOLLOWING FLAGS ARE INVISIBLE TO MAKEFILE
18#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
19#
20# -DTRACE	compile in kernel tracing hooks
21# -DQUOTA	compile in file system quotas
22# -DFOO		almost all options
23#
24CC?=	cc 
25CPP?=	cpp
26LD?=	/usr/bin/ld
27
28.if exists(./@/.)
29S=	./@
30.else
31S=	../..
32.endif
33I386=	${S}/i386
34
35CWARNFLAGS?=-W -Wreturn-type -Wcomment -Wredundant-decls
36#
37# The following flags are next up for working on:
38# -Wimplicit -Wnested-externs 
39#
40# When working on removing warnings from code, the `-Werror' flag should be
41# of material assistance.
42#
43COPTFLAGS?=-O
44# Not ready for -I- yet.  #include "foo.h" where foo.h is in the srcdir fails.
45INCLUDES= -nostdinc -I. -I$S -I$S/sys -I$S/../include
46COPTS=	${INCLUDES} ${IDENT} -DKERNEL -Di386 -DLOAD_ADDRESS=0x${LOAD_ADDRESS}
47ASFLAGS=
48CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
49LOAD_ADDRESS?=	F0100000
50
51NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
52NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
53# XXX errors leak out of all the pipes.  Should use cc *.S.
54# XXX LOCORE means "don't declare C stuff" not "for locore.s".
55NORMAL_S= ${CPP} -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
56DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
57DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
58PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
59
60SFILES=	${I386}/i386/exception.s ${I386}/i386/microtime.s \
61	${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s
62SYSTEM_CFILES= ioconf.c param.c vnode_if.c
63SYSTEM_SFILES= ${I386}/i386/locore.s
64SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o 
65SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a
66SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
67SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a
68.if ${CFLAGS:M-g} == ""
69SYMORDER_EXCLUDE=-x symbols.exclude
70.endif
71SYSTEM_LD_TAIL= @echo rearranging symbols; \
72	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
73	size $@; chmod 755 $@
74
75%BEFORE_DEPEND
76
77%OBJS
78
79%CFILES
80
81%LOAD
82
83# This is slightly different from before in that if you define PROF
84# to anything, it will assume profiling.  Don't do "PROF=" to turn
85# profiling off!
86.if exists($S/libkern/obj)
87LIBKERNP=$S/libkern/obj
88.else
89LIBKERNP=$S/libkern
90.endif
91
92.if defined(PROF)
93LIBKERN=${LIBKERNP}/libkern_p.a
94.else
95LIBKERN=${LIBKERNP}/libkern.a
96.endif
97
98libkern.a: ${LIBKERN}
99	@rm -f libkern.a
100	ln -s ${LIBKERN} libkern.a
101
102${LIBKERN}:
103	@(cd $S/libkern; make)
104
105clean:
106	rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym \
107	      symbols.exclude symbols.sort
108
109#lint: /tmp param.c
110#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
111#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
112#	    grep -v 'struct/union .* never defined' | \
113#	    grep -v 'possible pointer alignment problem'
114
115symbols.exclude: Makefile
116	echo "gcc2_compiled." >symbols.exclude
117	echo "___gnu_compiled_c" >>symbols.exclude
118
119symbols.sort: ${I386}/i386/symbols.raw
120	grep -v '^#' ${I386}/i386/symbols.raw \
121	    | sed 's/^	//' | sort -u > symbols.sort
122
123locore.o: ${I386}/i386/locore.s assym.s
124	${NORMAL_S}
125
126# everything potentially depends on the Makefile since everything potentially
127# depends on the options.  Some things are more dependent on the Makefile for
128# historical reasons.
129machdep.o: Makefile
130
131# the following is necessary because autoconf.o depends on #if GENERIC
132autoconf.o: Makefile
133
134# depend on network configuration
135af.o uipc_proto.o locore.o: Makefile
136
137# depends on KDB (cons.o also depends on GENERIC)
138trap.o cons.o: Makefile
139
140# this rule stops ./assym.s in .depend from causing problems
141./assym.s: assym.s
142
143assym.s: genassym
144	./genassym >assym.s
145
146# Some of the defines that genassym outputs may well depend on the 
147# value of kernel options.
148genassym.o: ${I386}/i386/genassym.c Makefile
149	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
150
151genassym: genassym.o
152	${CC} -static ${CFLAGS} ${PARAM} genassym.o -o $@
153
154# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
155depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
156	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
157	mkdep -a ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
158	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
159	mkdep -a -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
160
161links:
162	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
163	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
164	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
165	  sort -u | comm -23 - dontlink | \
166	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
167	sh makelinks && rm -f dontlink
168
169tags:
170	@echo "see $S/kern/Makefile for tags"
171
172install:
173	chflags noschg /kernel
174	mv /kernel /kernel.old
175	install -c -m 555 -o root -g wheel -fschg kernel /
176
177ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
178    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
179	${CC} -c ${CFLAGS} ioconf.c
180
181param.c: $S/conf/param.c
182	-rm -f param.c
183	cp $S/conf/param.c .
184
185param.o: param.c Makefile
186	${CC} -c ${CFLAGS} ${PARAM} param.c
187
188vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
189	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
190	${CC} ${CFLAGS} -c vers.c
191
192vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
193	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
194vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
195	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
196
197%RULES
198
199# DO NOT DELETE THIS LINE -- make depend uses it
200