Makefile.powerpc revision 25537
1# Makefile.i386 -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4#	$Id: Makefile.i386,v 1.95 1997/04/27 20:01:47 peter Exp $
5#
6# Makefile for FreeBSD
7#
8# This makefile is constructed from a machine description:
9#	config machineid
10# Most changes should be made in the machine description
11#	/sys/i386/conf/``machineid''
12# after which you should do
13#	 config machineid
14# Generic makefile changes should be made in
15#	/sys/i386/conf/Makefile.i386
16# after which config should be rerun for all machines.
17#
18
19BINFORMAT?=	aout
20#BINFORMAT?=	aoutkld
21#BINFORMAT?=	elf
22
23.if exists(./@/.)
24S=	./@
25.else
26S=	../..
27.endif
28I386=	${S}/i386
29
30COPTFLAGS?=-O
31INCLUDES= -nostdinc -I- -I. -I$S
32# This hack is to allow kernel compiles to succeed on machines w/out srcdist
33.if exists($S/../include)
34INCLUDES+= -I$S/../include
35.else
36INCLUDES+= -I/usr/include
37.endif
38COPTS=	${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h
39CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
40LOAD_ADDRESS?=	F0100000
41.if defined(PROF)
42PROF+=	-malign-functions=4
43.if ${PROFLEVEL} >= 2
44IDENT+=	-DGPROF4 -DGUPROF
45PROF+=	-mprofiler-epilogue
46.endif
47.endif
48
49NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
50NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
51# XXX LOCORE means "don't declare C stuff" not "for locore.s".
52NORMAL_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
53DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
54DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
55DRIVER_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
56PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
57
58SYSTEM_CFILES= ${I386}/i386/setdef0.c ioconf.c param.c vnode_if.c config.c \
59	${I386}/i386/setdef1.c
60SYSTEM_SFILES= ${I386}/i386/locore.s
61SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
62	setdef1.o
63SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
64.if ${CFLAGS:M-g} == ""
65SYMORDER_EXCLUDE=-x symbols.exclude
66.endif
67SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
68.if ${BINFORMAT} == aout
69SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
70SYSTEM_LD_TAIL= @echo rearranging symbols; \
71	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
72	size $@; chmod 755 $@
73.endif
74.if ${BINFORMAT} == aoutkld
75SYSTEM_LD= @${LD} -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
76SYSTEM_LD_TAIL= @echo rearranging symbols; \
77	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
78	size $@; chmod 755 $@
79.endif
80.if ${BINFORMAT} == elf
81SYSTEM_LD= @${LD} -Bstatic -Ttext ${LOAD_ADDRESS} -e btext -o $@ -X ${SYSTEM_OBJS} vers.o
82SYSTEM_LD_TAIL= @size $@; chmod 755 $@
83.endif
84
85%BEFORE_DEPEND
86
87%OBJS
88
89%CFILES
90
91%SFILES
92
93%LOAD
94
95%CLEAN
96
97clean:
98	rm -f *.o *.s eddep errs genassym kernel linterrs \
99	      makelinks param.c symbols.exclude symbols.sort tags \
100	      vers.c vnode_if.c vnode_if.h ${CLEAN}
101
102#lint: /tmp param.c
103#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
104#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
105#	    grep -v 'struct/union .* never defined' | \
106#	    grep -v 'possible pointer alignment problem'
107
108symbols.exclude: Makefile
109	echo "gcc2_compiled." >symbols.exclude
110	echo "___gnu_compiled_c" >>symbols.exclude
111
112symbols.sort: ${I386}/i386/symbols.raw
113	grep -v '^#' ${I386}/i386/symbols.raw \
114	    | sed 's/^	//' | sort -u > symbols.sort
115
116locore.o: ${I386}/i386/locore.s assym.s
117	${NORMAL_S}
118
119setdef0.o: ${I386}/i386/setdef0.c
120	${NORMAL_C}
121
122setdef1.o: ${I386}/i386/setdef1.c
123	${NORMAL_C}
124
125# everything potentially depends on the Makefile since everything potentially
126# depends on the options.  Some things are more dependent on the Makefile for
127# historical reasons.
128machdep.o: Makefile
129
130# the following is necessary because autoconf.o depends on #if GENERIC
131autoconf.o: Makefile
132
133# XXX - may no longer be needed
134locore.o: Makefile
135
136# depends on KDB (cons.o also depends on GENERIC)
137trap.o cons.o: Makefile
138
139# this rule stops ./assym.s in .depend from causing problems
140./assym.s: assym.s
141
142assym.s: genassym
143	./genassym >assym.s
144
145# Some of the defines that genassym outputs may well depend on the
146# value of kernel options.
147genassym.o: ${I386}/i386/genassym.c Makefile opt_global.h
148	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
149
150genassym: genassym.o
151	${CC} ${CFLAGS} ${PARAM} genassym.o -o $@
152
153${OBJS}: opt_global.h
154
155# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
156depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
157	rm -f .newdep
158	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
159	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
160	MKDEP_CPP="${CC} -E -x assembler-with-cpp" ; export MKDEP_CPP ; \
161	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
162	rm -f .depend
163	mv -f .newdep .depend
164
165links:
166	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
167	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
168	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
169	  sort -u | comm -23 - dontlink | \
170	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
171	sh makelinks && rm -f dontlink
172
173tags:
174	@echo "see $S/kern/Makefile for tags"
175
176install:
177	@if [ ! -f kernel ] ; then \
178		echo "You must first build your kernel before trying to install." ; \
179		exit 1 ; \
180	fi
181	chflags noschg /kernel
182	mv /kernel /kernel.old
183	if [ `/usr/sbin/sysctl -n kern.bootfile` = /kernel ] ; then \
184		/usr/sbin/sysctl -w kern.bootfile=/kernel.old ; \
185		mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \
186	fi
187	install -c -m 555 -o root -g wheel -fschg kernel /
188
189ioconf.o: ioconf.c $S/sys/param.h $S/sys/buf.h \
190    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
191	${CC} -c ${CFLAGS} ioconf.c
192
193param.c: $S/conf/param.c
194	-rm -f param.c
195	cp $S/conf/param.c .
196
197param.o: param.c Makefile
198	${CC} -c ${CFLAGS} ${PARAM} param.c
199
200vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
201	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
202	${CC} ${CFLAGS} -c vers.c
203
204vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
205	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
206vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
207	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
208
209.include <bsd.kern.mk>
210
211%RULES
212
213# DO NOT DELETE THIS LINE -- make depend uses it
214