Makefile.i386 revision 1.56
1#	$NetBSD: Makefile.i386,v 1.56 1995/06/24 20:39:42 christos Exp $
2# 	@(#)Makefile.hp300	8.2 (Berkeley) 1/23/94
3#
4# Makefile for NetBSD
5#
6# This makefile is constructed from a machine description:
7#	config machineid
8# Most changes should be made in the machine description
9#	/sys/arch/i386/conf/``machineid''
10# after which you should do
11#	 config machineid
12# Generic makefile changes should be made in
13#	/sys/arch/i386/conf/Makefile.i386
14# after which config should be rerun for all machines of that type.
15#
16# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
17#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
18#
19# -DTRACE	compile in kernel tracing hooks
20# -DQUOTA	compile in file system quotas
21#
22
23# DEBUG is set to -g by config if debugging is requested (config -g).
24# PROF is set to -pg by config if profiling is requested (config -p).
25AS?=	as
26AS+=	${DEBUG}
27CC?=	cc
28CC+=	${DEBUG}
29CPP?=	cpp
30LD?=	ld
31TOUCH?=	touch -f -c
32AWK?=	awk
33
34# source tree is located via $S relative to the compilation directory
35S=	../../../..
36I386=	../..
37
38INCLUDES= -I. -I$S/arch -I$S -I$S/sys
39COPTS=	${INCLUDES} ${IDENT} -D_KERNEL -Di386
40CFLAGS=	-O6 ${COPTS}
41LOAD_ADDRESS= F8100000
42
43### find out what to use for libkern
44.include "$S/lib/libkern/Makefile.inc"
45.ifndef PROF
46LIBKERN=	${KERNLIB}
47.else
48LIBKERN=	${KERNLIB_PROF}
49.endif
50
51### find out what to use for libcompat
52.include "$S/compat/common/Makefile.inc"
53.ifndef PROF
54LIBCOMPAT=	${COMPATLIB}
55.else
56LIBCOMPAT=	${COMPATLIB_PROF}
57.endif
58
59# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
60# where TYPE is NORMAL, DRIVER, or PROFILE; SUFFIX is the file suffix,
61# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
62# is marked as config-dependent.
63
64NORMAL_C=	${CC} -c ${CFLAGS} ${PROF} $<
65NORMAL_C_C=	${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
66
67DRIVER_C=	${CC} -c ${CFLAGS} ${PROF} $<
68DRIVER_C_C=	${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
69
70PROFILE_C=	${CC} -S -c ${CFLAGS} $< ; \
71		sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \
72		${AS} -o $@; \
73		rm -f $*.s
74
75NORMAL_S=	${CPP} -DLOCORE ${COPTS} $< | ${AS} -o $@
76NORMAL_S_C=	${CPP} -DLOCORE ${COPTS} ${PARAM} $< | ${AS} -o $@
77
78%OBJS
79
80%CFILES
81
82# load lines for config "xxx" will be emitted as:
83# xxx: ${SYSTEM_DEP} swapxxx.o
84#	${SYSTEM_LD_HEAD}
85#	${SYSTEM_LD} swapxxx.o
86#	${SYSTEM_LD_TAIL}
87SYSTEM_OBJ=	locore.o vnode_if.o ${OBJS} param.o ioconf.o ${LIBKERN} \
88		${LIBCOMPAT}
89SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
90SYSTEM_LD_HEAD=	rm -f $@
91SYSTEM_LD=	@if [ X${DEBUG} = X-g ]; then \
92			strip=-X; \
93		else \
94			strip=-x; \
95		fi; \
96		echo ${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start '$${SYSTEM_OBJ}' vers.o; \
97		${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start ${SYSTEM_OBJ} vers.o
98SYSTEM_LD_TAIL=	@size $@; chmod 755 $@; \
99		if [ X${DEBUG} = X-g ]; then \
100			echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
101			echo strip -d $@; strip -d $@; \
102		fi
103
104%LOAD
105
106newvers: vers.o
107
108vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
109	sh $S/conf/newvers.sh
110	${CC} ${CFLAGS} -c vers.c
111
112clean::
113	rm -f eddep *netbsd netbsd.gdb tags vnode_if.[ch] *.o locore.i \
114		[a-z]*.s [Ee]rrs linterrs makelinks genassym
115
116lint: /tmp param.c
117	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \
118	    ${I386}/i386/Locore.c ${CFILES} ${I386}/i386/swapgeneric.c \
119	    ioconf.c param.c | \
120	    grep -v 'struct/union .* never defined' | \
121	    grep -v 'possible pointer alignment problem'
122
123locore.o: assym.s ${I386}/i386/locore.s machine/trap.h machine/psl.h
124locore.o: machine/pte.h ${I386}/isa/vector.s ${I386}/isa/icu.s
125locore.o: $S/sys/errno.h machine/specialreg.h ${I386}/isa/debug.h
126locore.o: ${I386}/isa/icu.h $S/dev/isa/isareg.h $S/net/netisr.h
127	${CPP} -DLOCORE ${COPTS} ${I386}/i386/locore.s | ${AS} -o locore.o
128
129# the following is necessary because autoconf.o depends on #if GENERIC
130autoconf.o: Makefile
131
132# the following are necessary because the files depend on the types of
133# cpu's included in the system configuration
134locore.o machdep.o: Makefile
135
136# depend on network or filesystem configuration
137uipc_proto.o vfs_conf.o locore.o: Makefile
138
139# depend on maxusers
140assym.s: Makefile
141
142# depends on KDB (cons.o also depends on GENERIC)
143trap.o cons.o: Makefile
144
145assym.s: genassym
146	./genassym >assym.s
147
148genassym: ${I386}/i386/genassym.c
149	${CC} ${INCLUDES} ${IDENT} ${PARAM} -Di386 -o genassym \
150	    ${I386}/i386/genassym.c
151
152depend: assym.s param.c vnode_if.h
153	mkdep ${COPTS} ${CFILES} ioconf.c param.c
154	mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${I386}/i386/genassym.c
155
156links:
157	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
158	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
159	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
160	  sort -u | comm -23 - dontlink | \
161	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
162	sh makelinks && rm -f dontlink
163
164tags:
165	@echo "see $S/kern/Makefile for tags"
166
167ioconf.o: ioconf.c
168	${CC} -c ${CFLAGS} ioconf.c
169
170param.c: $S/conf/param.c
171	rm -f param.c
172	cp $S/conf/param.c .
173
174param.o: param.c Makefile
175	${CC} -c ${CFLAGS} ${PARAM} param.c
176
177vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
178	AWK="${AWK}" sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
179
180%RULES
181