Makefile.i386 revision 1.85
1#	$NetBSD: Makefile.i386,v 1.85 1997/10/03 07:17:39 lukem 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
24CC?=	cc
25LD?=	ld
26MKDEP?=	mkdep
27SIZE?=	size
28STRIP?=	strip
29COPTS?=	-O2
30
31# source tree is located via $S relative to the compilation directory
32.ifndef S
33S!=	cd ../../../..; pwd
34.endif
35I386=	$S/arch/i386
36
37INCLUDES=	-I. -I$S/arch -I$S -nostdinc
38CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
39		-Di386
40CWARNFLAGS=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes
41CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
42AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
43LINKFLAGS=	-z -Ttext F8100000 -e start
44STRIPFLAGS=	-d
45
46### find out what to use for libkern
47.include "$S/lib/libkern/Makefile.inc"
48.ifndef PROF
49LIBKERN=	${KERNLIB}
50.else
51LIBKERN=	${KERNLIB_PROF}
52.endif
53
54### find out what to use for libcompat
55.include "$S/compat/common/Makefile.inc"
56.ifndef PROF
57LIBCOMPAT=	${COMPATLIB}
58.else
59LIBCOMPAT=	${COMPATLIB_PROF}
60.endif
61
62# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
63# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
64
65NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
66NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
67
68%OBJS
69
70%CFILES
71
72%SFILES
73
74# load lines for config "xxx" will be emitted as:
75# xxx: ${SYSTEM_DEP} swapxxx.o
76#	${SYSTEM_LD_HEAD}
77#	${SYSTEM_LD} swapxxx.o
78#	${SYSTEM_LD_TAIL}
79SYSTEM_OBJ=	locore.o \
80		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
81SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
82SYSTEM_LD_HEAD=	rm -f $@
83SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
84		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
85SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
86
87DEBUG?=
88.if ${DEBUG} == "-g"
89LINKFLAGS+=	-X
90SYSTEM_LD_TAIL+=; \
91		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
92		echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@
93.else
94LINKFLAGS+=	-S
95.endif
96
97%LOAD
98
99assym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
100	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
101	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
102	mv -f assym.h.tmp assym.h
103
104param.c: $S/conf/param.c
105	rm -f param.c
106	cp $S/conf/param.c .
107
108param.o: param.c Makefile
109	${NORMAL_C}
110
111ioconf.o: ioconf.c
112	${NORMAL_C}
113
114newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
115	sh $S/conf/newvers.sh
116	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
117
118
119__CLEANKERNEL: .USE
120	@echo "${.TARGET}ing the kernel objects"
121	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
122	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
123
124__CLEANDEPEND: .USE
125	rm -f .depend
126
127clean: __CLEANKERNEL
128
129cleandir: __CLEANKERNEL __CLEANDEPEND
130
131lint:
132	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
133	    ${I386}/i386/Locore.c ${CFILES} \
134	    ioconf.c param.c | \
135	    grep -v 'static function .* unused'
136
137tags:
138	@echo "see $S/kern/Makefile for tags"
139
140links:
141	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
142	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
143	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
144	  sort -u | comm -23 - dontlink | \
145	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
146	sh makelinks && rm -f dontlink
147
148SRCS=	${I386}/i386/locore.s \
149	param.c ioconf.c ${CFILES} ${SFILES}
150depend: .depend
151.depend: ${SRCS} assym.h param.c
152	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
153	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
154	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
155	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
156	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
157	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
158	@rm -f assym.dep
159
160
161# depend on root or device configuration
162autoconf.o conf.o: Makefile
163 
164# depend on network or filesystem configuration 
165uipc_proto.o vfs_conf.o: Makefile 
166
167# depend on maxusers
168machdep.o: Makefile
169
170# depend on CPU configuration 
171locore.o machdep.o: Makefile
172
173
174locore.o: ${I386}/i386/locore.s assym.h
175	${NORMAL_S}
176
177%RULES
178