Makefile.i386 revision 1.95
1#	$NetBSD: Makefile.i386,v 1.95 1999/01/08 19:26:13 augustss 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		-Wpointer-arith
51.if (${HAVE_GCC28} != "")
52CWARNFLAGS+=	-Wno-main
53.endif
54CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
55AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
56LINKFLAGS=	-z -Ttext F0100000 -e start
57STRIPFLAGS=	-d
58
59### find out what to use for libkern
60KERN_AS=	obj
61.include "$S/lib/libkern/Makefile.inc"
62.ifndef PROF
63LIBKERN=	${KERNLIB}
64.else
65LIBKERN=	${KERNLIB_PROF}
66.endif
67
68### find out what to use for libcompat
69.include "$S/compat/common/Makefile.inc"
70.ifndef PROF
71LIBCOMPAT=	${COMPATLIB}
72.else
73LIBCOMPAT=	${COMPATLIB_PROF}
74.endif
75
76# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
77# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
78
79NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
80NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
81NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
82
83%OBJS
84
85%CFILES
86
87%SFILES
88
89# load lines for config "xxx" will be emitted as:
90# xxx: ${SYSTEM_DEP} swapxxx.o
91#	${SYSTEM_LD_HEAD}
92#	${SYSTEM_LD} swapxxx.o
93#	${SYSTEM_LD_TAIL}
94SYSTEM_OBJ=	locore.o \
95		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
96SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
97SYSTEM_LD_HEAD=	rm -f $@
98SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
99		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
100SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
101
102DEBUG?=
103.if ${DEBUG} == "-g"
104LINKFLAGS+=	-X
105SYSTEM_LD_TAIL+=; \
106		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
107		echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@
108.else
109LINKFLAGS+=	-X
110.endif
111
112%LOAD
113
114assym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
115	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
116	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
117	mv -f assym.h.tmp assym.h
118
119param.c: $S/conf/param.c
120	rm -f param.c
121	cp $S/conf/param.c .
122
123param.o: param.c Makefile
124	${NORMAL_C}
125
126ioconf.o: ioconf.c
127	${NORMAL_C}
128
129newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
130	sh $S/conf/newvers.sh
131	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
132
133
134__CLEANKERNEL: .USE
135	@echo "${.TARGET}ing the kernel objects"
136	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
137	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
138
139__CLEANDEPEND: .USE
140	rm -f .depend
141
142clean: __CLEANKERNEL
143
144cleandir distclean: __CLEANKERNEL __CLEANDEPEND
145
146lint:
147	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
148	    ${I386}/i386/Locore.c ${CFILES} \
149	    ioconf.c param.c | \
150	    grep -v 'static function .* unused'
151
152tags:
153	@echo "see $S/kern/Makefile for tags"
154
155links:
156	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
157	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
158	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
159	  sort -u | comm -23 - dontlink | \
160	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
161	sh makelinks && rm -f dontlink
162
163SRCS=	${I386}/i386/locore.s \
164	param.c ioconf.c ${CFILES} ${SFILES}
165depend: .depend
166.depend: ${SRCS} assym.h param.c
167	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
168	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
169	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
170	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
171	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
172	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
173	@rm -f assym.dep
174
175
176# depend on root or device configuration
177autoconf.o conf.o: Makefile
178
179# depend on network or filesystem configuration
180uipc_proto.o vfs_conf.o: Makefile
181
182# depend on maxusers
183machdep.o: Makefile
184
185# depend on CPU configuration
186locore.o machdep.o: Makefile
187
188
189locore.o: ${I386}/i386/locore.s assym.h
190	${NORMAL_S}
191
192%RULES
193