xref: /freebsd/sys/conf/Makefile.i386 (revision ce834215a70ff69e7e222827437116eee2f9ac6f)
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.99 1997/05/31 17:59:56 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
41DEFINED_PROF=	${PROF}
42.if defined(PROF)
43CFLAGS+=	-malign-functions=4
44.if ${PROFLEVEL} >= 2
45IDENT+=	-DGPROF4 -DGUPROF
46PROF+=	-mprofiler-epilogue
47.endif
48.endif
49
50NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
51NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
52# XXX LOCORE means "don't declare C stuff" not "for locore.s".
53NORMAL_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
54DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
55DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
56DRIVER_S= ${CC} -c -x assembler-with-cpp -DLOCORE ${COPTS} $<
57PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
58
59# ${I386}/i386/setdef0.c and ${I386}/i386/setdef1.c are intentionally
60# omitted from SYSTEM_CFILES.  They depend on setdefs.h, a header which
61# is generated from all of ${OBJS}.  We don't want to have to compile
62# everything just to do a make depend.
63SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c
64SYSTEM_SFILES= ${I386}/i386/locore.s
65SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
66.if ${CFLAGS:M-g} == ""
67SYMORDER_EXCLUDE=-x symbols.exclude
68.endif
69SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
70.if ${BINFORMAT} == aout
71SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
72SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
73SYSTEM_LD_TAIL= @echo rearranging symbols; \
74	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
75	size $@; chmod 755 $@
76.endif
77.if ${BINFORMAT} == aoutkld
78SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
79SYSTEM_LD= @${LD} -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o
80SYSTEM_LD_TAIL= @echo rearranging symbols; \
81	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
82	size $@; chmod 755 $@
83.endif
84.if ${BINFORMAT} == elf
85SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
86	setdef1.o
87SYSTEM_LD= @${LD} -Bstatic -Ttext ${LOAD_ADDRESS} -e btext -defsym _DYNAMIC=0 \
88	-o $@ -X ${SYSTEM_OBJS} vers.o
89SYSTEM_LD_TAIL= @size $@; chmod 755 $@
90.endif
91
92%BEFORE_DEPEND
93
94%OBJS
95
96%CFILES
97
98%SFILES
99
100%LOAD
101
102%CLEAN
103
104clean:
105	rm -f *.o *.s eddep errs genassym gensetdefs kernel linterrs \
106	      makelinks param.c setdefs.h symbols.exclude symbols.sort tags \
107	      vers.c vnode_if.c vnode_if.h ${CLEAN}
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
126setdef0.o: ${I386}/i386/setdef0.c setdefs.h
127	${NORMAL_C}
128
129setdef1.o: ${I386}/i386/setdef1.c setdefs.h
130	${NORMAL_C}
131
132setdefs.h: gensetdefs ${OBJS}
133	./gensetdefs ${OBJS} >setdefs.h
134
135gensetdefs: gensetdefs.o
136	${CC} ${CFLAGS} gensetdefs.o -o $@
137
138gensetdefs.o: ${I386}/i386/gensetdefs.c
139	${CC} -c ${CFLAGS} ${I386}/i386/gensetdefs.c
140
141# everything potentially depends on the Makefile since everything potentially
142# depends on the options.  Some things are more dependent on the Makefile for
143# historical reasons.
144machdep.o: Makefile
145
146# the following is necessary because autoconf.o depends on #if GENERIC
147autoconf.o: Makefile
148
149# XXX - may no longer be needed
150locore.o: Makefile
151
152# depends on KDB (cons.o also depends on GENERIC)
153trap.o cons.o: Makefile
154
155# this rule stops ./assym.s in .depend from causing problems
156./assym.s: assym.s
157
158assym.s: genassym
159	./genassym >assym.s
160
161# Some of the defines that genassym outputs may well depend on the
162# value of kernel options.
163genassym.o: ${I386}/i386/genassym.c Makefile opt_global.h
164	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
165
166genassym: genassym.o
167	${CC} ${CFLAGS} ${PARAM} genassym.o -o $@
168
169${OBJS}: opt_global.h
170
171# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
172depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
173	rm -f .newdep
174	mkdep -a -f .newdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
175	mkdep -a -f .newdep ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
176	MKDEP_CPP="${CC} -E -x assembler-with-cpp" ; export MKDEP_CPP ; \
177	mkdep -a -f .newdep -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
178	rm -f .depend
179	mv -f .newdep .depend
180
181links:
182	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
183	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
184	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
185	  sort -u | comm -23 - dontlink | \
186	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
187	sh makelinks && rm -f dontlink
188
189tags:
190	@echo "see $S/kern/Makefile for tags"
191
192install:
193	@if [ ! -f kernel ] ; then \
194		echo "You must first build your kernel before trying to install." ; \
195		exit 1 ; \
196	fi
197	chflags noschg /kernel
198	mv /kernel /kernel.old
199	if [ `/usr/sbin/sysctl -n kern.bootfile` = /kernel ] ; then \
200		/usr/sbin/sysctl -w kern.bootfile=/kernel.old ; \
201		mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \
202	fi
203	install -c -m 555 -o root -g wheel -fschg kernel /
204
205ioconf.o: ioconf.c $S/sys/param.h $S/sys/buf.h \
206    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
207	${CC} -c ${CFLAGS} ioconf.c
208
209param.c: $S/conf/param.c
210	-rm -f param.c
211	cp $S/conf/param.c .
212
213param.o: param.c Makefile
214	${CC} -c ${CFLAGS} ${PARAM} param.c
215
216vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
217	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
218	${CC} ${CFLAGS} -c vers.c
219
220vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
221	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
222vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
223	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
224
225.include <bsd.kern.mk>
226
227%RULES
228
229# DO NOT DELETE THIS LINE -- make depend uses it
230