Makefile.i386 revision 1.55
1#	$NetBSD: Makefile.i386,v 1.55 1995/05/16 22:24:50 jtc 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# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
52# where TYPE is NORMAL, DRIVER, or PROFILE; SUFFIX is the file suffix,
53# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
54# is marked as config-dependent.
55
56NORMAL_C=	${CC} -c ${CFLAGS} ${PROF} $<
57NORMAL_C_C=	${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
58
59DRIVER_C=	${CC} -c ${CFLAGS} ${PROF} $<
60DRIVER_C_C=	${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
61
62PROFILE_C=	${CC} -S -c ${CFLAGS} $< ; \
63		sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \
64		${AS} -o $@; \
65		rm -f $*.s
66
67NORMAL_S=	${CPP} -DLOCORE ${COPTS} $< | ${AS} -o $@
68NORMAL_S_C=	${CPP} -DLOCORE ${COPTS} ${PARAM} $< | ${AS} -o $@
69
70%OBJS
71
72%CFILES
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 vnode_if.o ${OBJS} param.o ioconf.o ${LIBKERN}
80SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
81SYSTEM_LD_HEAD=	rm -f $@
82SYSTEM_LD=	@if [ X${DEBUG} = X-g ]; then \
83			strip=-X; \
84		else \
85			strip=-x; \
86		fi; \
87		echo ${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start '$${SYSTEM_OBJ}' vers.o; \
88		${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start ${SYSTEM_OBJ} vers.o
89SYSTEM_LD_TAIL=	@size $@; chmod 755 $@; \
90		if [ X${DEBUG} = X-g ]; then \
91			echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
92			echo strip -d $@; strip -d $@; \
93		fi
94
95%LOAD
96
97newvers: vers.o
98
99vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
100	sh $S/conf/newvers.sh
101	${CC} ${CFLAGS} -c vers.c
102
103clean:
104	rm -f eddep *netbsd netbsd.gdb tags vnode_if.[ch] *.o locore.i \
105		[a-z]*.s [Ee]rrs linterrs makelinks
106
107lint: /tmp param.c
108	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \
109	    ${I386}/i386/Locore.c ${CFILES} ${I386}/i386/swapgeneric.c \
110	    ioconf.c param.c | \
111	    grep -v 'struct/union .* never defined' | \
112	    grep -v 'possible pointer alignment problem'
113
114locore.o: assym.s ${I386}/i386/locore.s machine/trap.h machine/psl.h
115locore.o: machine/pte.h ${I386}/isa/vector.s ${I386}/isa/icu.s
116locore.o: $S/sys/errno.h machine/specialreg.h ${I386}/isa/debug.h
117locore.o: ${I386}/isa/icu.h $S/dev/isa/isareg.h $S/net/netisr.h
118	${CPP} -DLOCORE ${COPTS} ${I386}/i386/locore.s | ${AS} -o locore.o
119
120# the following is necessary because autoconf.o depends on #if GENERIC
121autoconf.o: Makefile
122
123# the following are necessary because the files depend on the types of
124# cpu's included in the system configuration
125locore.o machdep.o: Makefile
126
127# depend on network or filesystem configuration
128uipc_proto.o vfs_conf.o locore.o: Makefile
129
130# depend on maxusers
131assym.s: Makefile
132
133# depends on KDB (cons.o also depends on GENERIC)
134trap.o cons.o: Makefile
135
136assym.s: genassym
137	./genassym >assym.s
138
139genassym: ${I386}/i386/genassym.c
140	${CC} ${INCLUDES} ${IDENT} ${PARAM} -Di386 -o genassym \
141	    ${I386}/i386/genassym.c
142
143depend: assym.s param.c vnode_if.h
144	mkdep ${COPTS} ${CFILES} ioconf.c param.c
145	mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${I386}/i386/genassym.c
146
147links:
148	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
149	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
150	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
151	  sort -u | comm -23 - dontlink | \
152	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
153	sh makelinks && rm -f dontlink
154
155tags:
156	@echo "see $S/kern/Makefile for tags"
157
158ioconf.o: ioconf.c
159	${CC} -c ${CFLAGS} ioconf.c
160
161param.c: $S/conf/param.c
162	rm -f param.c
163	cp $S/conf/param.c .
164
165param.o: param.c Makefile
166	${CC} -c ${CFLAGS} ${PARAM} param.c
167
168vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
169	AWK="${AWK}" sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
170
171%RULES
172