Makefile.i386 revision 1.50
1#	$NetBSD: Makefile.i386,v 1.50 1994/11/04 01:22:26 mycroft 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
24# DEBUG is set to -g by config if debugging is requested (config -g).
25# PROF is set to -pg by config if profiling is requested (config -p).
26AS=	as ${DEBUG}
27CC=	cc ${DEBUG}
28CPP=	cpp
29LD=	ld
30TOUCH=	touch -f -c
31AWK=	awk
32
33# source tree is located via $S relative to the compilation directory
34S=	../../../..
35I386=	../..
36
37INCLUDES= -I. -I$S/arch -I$S -I$S/sys
38COPTS=	${INCLUDES} ${IDENT} -DKERNEL -Di386
39CFLAGS=	-O6 ${COPTS}
40LOAD_ADDRESS= F8100000
41
42### find out what to use for libkern
43.include "$S/lib/libkern/Makefile.inc"
44.ifndef PROF
45LIBKERN=	${KERNLIB}
46.else
47LIBKERN=	${KERNLIB_PROF}
48.endif
49
50# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
51# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix,
52# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
53# is marked as config-dependent.
54
55NORMAL_C=	${CC} -c ${CFLAGS} ${PROF} $<
56NORMAL_C_C=	${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
57
58DRIVER_C=	${CC} -c ${CFLAGS} ${PROF} $<
59DRIVER_C_C=	${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
60
61PROFILE_C=	${CC} -S -c ${CFLAGS} $< ; \
62		sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \
63		${AS} -o $@; \
64		rm -f $*.s
65
66NORMAL_S=	${CPP} -DLOCORE ${COPTS} $< | ${AS} -o $@
67NORMAL_S_C=	${CPP} -DLOCORE ${COPTS} ${PARAM} $< | ${AS} -o $@
68
69%OBJS
70
71%CFILES
72
73# load lines for config "xxx" will be emitted as:
74# xxx: ${SYSTEM_DEP} swapxxx.o
75#	${SYSTEM_LD_HEAD}
76#	${SYSTEM_LD} swapxxx.o
77#	${SYSTEM_LD_TAIL}
78SYSTEM_OBJ=	locore.o vnode_if.o ${OBJS} param.o ioconf.o ${LIBKERN}
79SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
80SYSTEM_LD_HEAD=	rm -f $@
81SYSTEM_LD=	-@if [ X${DEBUG} = X-g ]; \
82		then strip=-X; \
83		else strip=-x; \
84		fi; \
85		echo ${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start '$${SYSTEM_OBJ}' vers.o; \
86		${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start ${SYSTEM_OBJ} vers.o
87SYSTEM_LD_TAIL=	@size $@; chmod 755 $@; \
88		[ X${DEBUG} = X-g ] && { \
89		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
90		echo strip -d $@; strip -d $@; } || true
91
92%LOAD
93
94newvers: vers.o
95
96vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
97	sh $S/conf/newvers.sh
98	${CC} ${CFLAGS} -c vers.c
99
100clean:
101	rm -f eddep *netbsd netbsd.gdb tags vnode_if.[ch] *.o locore.i \
102		[a-z]*.s [Ee]rrs linterrs makelinks
103
104lint: /tmp param.c
105	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \
106	    ${I386}/i386/Locore.c ${CFILES} ${I386}/i386/swapgeneric.c \
107	    ioconf.c param.c | \
108	    grep -v 'struct/union .* never defined' | \
109	    grep -v 'possible pointer alignment problem'
110
111locore.o: assym.s ${I386}/i386/locore.s machine/trap.h machine/psl.h
112locore.o: machine/pte.h ${I386}/isa/vector.s ${I386}/isa/icu.s
113locore.o: $S/sys/errno.h machine/specialreg.h ${I386}/isa/debug.h
114locore.o: ${I386}/isa/icu.h ${I386}/isa/isareg.h $S/net/netisr.h
115	${CPP} -DLOCORE ${COPTS} ${I386}/i386/locore.s | ${AS} -o locore.o
116
117# the following is necessary because autoconf.o depends on #if GENERIC
118autoconf.o: Makefile
119
120# the following are necessary because the files depend on the types of
121# cpu's included in the system configuration
122locore.o machdep.o: Makefile
123
124# depend on network or filesystem configuration
125uipc_proto.o vfs_conf.o locore.o: Makefile
126
127# depend on maxusers
128assym.s: Makefile
129
130# depends on KDB (cons.o also depends on GENERIC)
131trap.o cons.o: Makefile
132
133assym.s: genassym
134	./genassym >assym.s
135
136genassym: ${I386}/i386/genassym.c
137	${CC} ${INCLUDES} ${IDENT} ${PARAM} -Di386 -o genassym \
138	    ${I386}/i386/genassym.c
139
140depend: assym.s param.c vnode_if.h
141	mkdep ${COPTS} ${CFILES} ioconf.c param.c
142	mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${I386}/i386/genassym.c
143
144links:
145	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
146	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
147	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
148	  sort -u | comm -23 - dontlink | \
149	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
150	sh makelinks && rm -f dontlink
151
152tags:
153	@echo "see $S/kern/Makefile for tags"
154
155ioconf.o: ioconf.c
156	${CC} -c ${CFLAGS} ioconf.c
157
158param.c: $S/conf/param.c
159	rm -f param.c
160	cp $S/conf/param.c .
161
162param.o: param.c Makefile
163	${CC} -c ${CFLAGS} ${PARAM} param.c
164
165vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
166	AWK="${AWK}" sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
167
168%RULES
169