Makefile.i386 revision 1.92
1#	$NetBSD: Makefile.i386,v 1.92 1998/06/07 03:01:06 enami Exp $
2
3# Makefile for NetBSD
4#
5# This makefile is constructed from a machine description:
6#	config machineid
7# Most changes should be made in the machine description
8#	/sys/arch/i386/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/i386/conf/Makefile.i386
13# after which config should be rerun for all machines of that type.
14#
15# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
16#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
17#
18# -DTRACE	compile in kernel tracing hooks
19# -DQUOTA	compile in file system quotas
20
21# DEBUG is set to -g if debugging.
22# PROF is set to -pg if profiling.
23
24AR?=	ar
25AS?=	as
26CC?=	cc
27CPP?=	cpp
28LD?=	ld
29LORDER?=lorder
30MKDEP?=	mkdep
31NM?=	nm
32RANLIB?=ranlib
33SIZE?=	size
34STRIP?=	strip
35TSORT?=	tsort -q
36
37COPTS?=	-O2
38
39# source tree is located via $S relative to the compilation directory
40.ifndef S
41S!=	cd ../../../..; pwd
42.endif
43I386=	$S/arch/i386
44
45HAVE_GCC28!=	${CC} --version | egrep "^(2\.8|egcs)" ; echo
46INCLUDES=	-I. -I$S/arch -I$S -nostdinc
47CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
48		-Di386
49CWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes
50.if (${HAVE_GCC28} != "")
51CWARNFLAGS+=	-Wno-main
52.endif
53CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
54AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
55LINKFLAGS=	-z -Ttext F0100000 -e start
56STRIPFLAGS=	-d
57
58### find out what to use for libkern
59.include "$S/lib/libkern/Makefile.inc"
60.ifndef PROF
61LIBKERN=	${KERNLIB}
62.else
63LIBKERN=	${KERNLIB_PROF}
64.endif
65
66### find out what to use for libcompat
67.include "$S/compat/common/Makefile.inc"
68.ifndef PROF
69LIBCOMPAT=	${COMPATLIB}
70.else
71LIBCOMPAT=	${COMPATLIB_PROF}
72.endif
73
74# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
75# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
76
77NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
78NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
79NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
80
81%OBJS
82
83%CFILES
84
85%SFILES
86
87# load lines for config "xxx" will be emitted as:
88# xxx: ${SYSTEM_DEP} swapxxx.o
89#	${SYSTEM_LD_HEAD}
90#	${SYSTEM_LD} swapxxx.o
91#	${SYSTEM_LD_TAIL}
92SYSTEM_OBJ=	locore.o \
93		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
94SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
95SYSTEM_LD_HEAD=	rm -f $@
96SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
97		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
98SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
99
100DEBUG?=
101.if ${DEBUG} == "-g"
102LINKFLAGS+=	-X
103SYSTEM_LD_TAIL+=; \
104		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
105		echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@
106.else
107LINKFLAGS+=	-X
108.endif
109
110%LOAD
111
112assym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
113	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
114	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
115	mv -f assym.h.tmp assym.h
116
117param.c: $S/conf/param.c
118	rm -f param.c
119	cp $S/conf/param.c .
120
121param.o: param.c Makefile
122	${NORMAL_C}
123
124ioconf.o: ioconf.c
125	${NORMAL_C}
126
127newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
128	sh $S/conf/newvers.sh
129	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
130
131
132__CLEANKERNEL: .USE
133	@echo "${.TARGET}ing the kernel objects"
134	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
135	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
136
137__CLEANDEPEND: .USE
138	rm -f .depend
139
140clean: __CLEANKERNEL
141
142cleandir: __CLEANKERNEL __CLEANDEPEND
143
144lint:
145	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
146	    ${I386}/i386/Locore.c ${CFILES} \
147	    ioconf.c param.c | \
148	    grep -v 'static function .* unused'
149
150tags:
151	@echo "see $S/kern/Makefile for tags"
152
153links:
154	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
155	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
156	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
157	  sort -u | comm -23 - dontlink | \
158	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
159	sh makelinks && rm -f dontlink
160
161SRCS=	${I386}/i386/locore.s \
162	param.c ioconf.c ${CFILES} ${SFILES}
163depend: .depend
164.depend: ${SRCS} assym.h param.c
165	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
166	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
167	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
168	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
169	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
170	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
171	@rm -f assym.dep
172
173
174# depend on root or device configuration
175autoconf.o conf.o: Makefile
176
177# depend on network or filesystem configuration
178uipc_proto.o vfs_conf.o: Makefile
179
180# depend on maxusers
181machdep.o: Makefile
182
183# depend on CPU configuration
184locore.o machdep.o: Makefile
185
186
187locore.o: ${I386}/i386/locore.s assym.h
188	${NORMAL_S}
189
190%RULES
191