xref: /freebsd/sys/conf/Makefile.i386 (revision 17ee9d00bc1ae1e598c38f25826f861e4bc6c3ce)
1# Copyright 1990 W. Jolitz
2#	from: @(#)Makefile.i386	7.1 5/10/91
3#	$Id: Makefile.i386,v 1.53 1995/01/25 21:40:00 bde 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
44INCLUDES= -I. -I$S -I$S/sys
45COPTS=	${INCLUDES} ${IDENT} -DKERNEL -Di386 -DLOAD_ADDRESS=0x${LOAD_ADDRESS}
46ASFLAGS=
47CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
48LOAD_ADDRESS?=	F0100000
49
50NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
51NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
52# XXX errors leak out of all the pipes.  Should use cc *.S.
53# XXX LOCORE means "don't declare C stuff" not "for locore.s".
54NORMAL_S= ${CPP} -DLOCORE ${COPTS} $< | ${AS} ${ASFLAGS} -o $*.o
55DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
56DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
57PROFILE_C= ${CC} -c ${CFLAGS} ${PARAM} $<
58
59SFILES=	${I386}/i386/exception.s ${I386}/i386/microtime.s \
60	${I386}/i386/support.s ${I386}/i386/swtch.s ${I386}/apm/apm_setup.s
61SYSTEM_CFILES= ioconf.c param.c vnode_if.c
62SYSTEM_SFILES= ${I386}/i386/locore.s
63SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o
64SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS} libkern.a
65SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
66SYSTEM_LD= @${LD} -Bstatic -Z -T ${LOAD_ADDRESS} -o $@ -X ${SYSTEM_OBJS} vers.o libkern.a
67.if ${CFLAGS:M-g} == ""
68SYMORDER_EXCLUDE=-x symbols.exclude
69.endif
70SYSTEM_LD_TAIL= @echo rearranging symbols; \
71	symorder -m ${SYMORDER_EXCLUDE} symbols.sort $@; \
72	size $@; chmod 755 $@
73
74%BEFORE_DEPEND
75
76%OBJS
77
78%CFILES
79
80%LOAD
81
82# This is slightly different from before in that if you define PROF
83# to anything, it will assume profiling.  Don't do "PROF=" to turn
84# profiling off!
85.if exists($S/libkern/obj)
86LIBKERNP=$S/libkern/obj
87.else
88LIBKERNP=$S/libkern
89.endif
90
91.if defined(PROF)
92LIBKERN=${LIBKERNP}/libkern_p.a
93.else
94LIBKERN=${LIBKERNP}/libkern.a
95.endif
96
97libkern.a: ${LIBKERN}
98	@rm -f libkern.a
99	ln -s ${LIBKERN} libkern.a
100
101${LIBKERN}:
102	@(cd $S/libkern; make)
103
104clean:
105	rm -f eddep kernel tags *.o *.s errs linterrs makelinks genassym \
106	      symbols.exclude symbols.sort
107
108#lint: /tmp param.c
109#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} \
110#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
111#	    grep -v 'struct/union .* never defined' | \
112#	    grep -v 'possible pointer alignment problem'
113
114symbols.exclude: Makefile
115	echo "gcc2_compiled." >symbols.exclude
116	echo "___gnu_compiled_c" >>symbols.exclude
117
118symbols.sort: ${I386}/i386/symbols.raw
119	grep -v '^#' ${I386}/i386/symbols.raw \
120	    | sed 's/^	//' | sort -u > symbols.sort
121
122locore.o: ${I386}/i386/locore.s assym.s
123	${NORMAL_S}
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# depend on network configuration
134af.o uipc_proto.o locore.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
148	${CC} -c ${CFLAGS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
149
150genassym: genassym.o
151	${CC} -static ${CFLAGS} ${PARAM} genassym.o -o $@
152
153# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
154depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
155	mkdep ${COPTS} ${CFILES} ${SYSTEM_CFILES}
156	mkdep -a ${COPTS} ${PARAM} -UKERNEL ${I386}/i386/genassym.c
157	MKDEP_CPP=${CPP} ; export MKDEP_CPP ; \
158	mkdep -a -DLOCORE ${COPTS} ${SFILES} ${SYSTEM_SFILES}
159
160links:
161	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
162	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
163	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
164	  sort -u | comm -23 - dontlink | \
165	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
166	sh makelinks && rm -f dontlink
167
168tags:
169	@echo "see $S/kern/Makefile for tags"
170
171install:
172	chflags noschg /kernel
173	mv /kernel /kernel.old
174	install -c -m 555 -o root -g wheel -fschg kernel /
175
176ioconf.o: ioconf.c $S/sys/param.h machine/pte.h $S/sys/buf.h \
177    ${I386}/isa/isa_device.h ${I386}/isa/isa.h ${I386}/isa/icu.h
178	${CC} -c ${CFLAGS} ioconf.c
179
180param.c: $S/conf/param.c
181	-rm -f param.c
182	cp $S/conf/param.c .
183
184param.o: param.c Makefile
185	${CC} -c ${CFLAGS} ${PARAM} param.c
186
187vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
188	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
189	${CC} ${CFLAGS} -c vers.c
190
191vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
192	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
193vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
194	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
195
196%RULES
197
198# DO NOT DELETE THIS LINE -- make depend uses it
199