Makefile.i386 revision 1.51
1#	$NetBSD: Makefile.i386,v 1.51 1994/12/06 06:07:39 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 ]; then \
82			strip=-X; \
83		else \
84			strip=-x; \
85		fi; \
86		echo ${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start '$${SYSTEM_OBJ}' vers.o; \
87		${LD} $$strip -z -T ${LOAD_ADDRESS} -o $@ -e start ${SYSTEM_OBJ} vers.o
88SYSTEM_LD_TAIL=	@size $@; chmod 755 $@; \
89		if [ X${DEBUG} = X-g ]; then \
90			echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
91			echo strip -d $@; strip -d $@; \
92		fi
93
94%LOAD
95
96newvers: vers.o
97
98vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
99	sh $S/conf/newvers.sh
100	${CC} ${CFLAGS} -c vers.c
101
102clean:
103	rm -f eddep *netbsd netbsd.gdb tags vnode_if.[ch] *.o locore.i \
104		[a-z]*.s [Ee]rrs linterrs makelinks
105
106lint: /tmp param.c
107	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \
108	    ${I386}/i386/Locore.c ${CFILES} ${I386}/i386/swapgeneric.c \
109	    ioconf.c param.c | \
110	    grep -v 'struct/union .* never defined' | \
111	    grep -v 'possible pointer alignment problem'
112
113locore.o: assym.s ${I386}/i386/locore.s machine/trap.h machine/psl.h
114locore.o: machine/pte.h ${I386}/isa/vector.s ${I386}/isa/icu.s
115locore.o: $S/sys/errno.h machine/specialreg.h ${I386}/isa/debug.h
116locore.o: ${I386}/isa/icu.h ${I386}/isa/isareg.h $S/net/netisr.h
117	${CPP} -DLOCORE ${COPTS} ${I386}/i386/locore.s | ${AS} -o locore.o
118
119# the following is necessary because autoconf.o depends on #if GENERIC
120autoconf.o: Makefile
121
122# the following are necessary because the files depend on the types of
123# cpu's included in the system configuration
124locore.o machdep.o: Makefile
125
126# depend on network or filesystem configuration
127uipc_proto.o vfs_conf.o locore.o: Makefile
128
129# depend on maxusers
130assym.s: Makefile
131
132# depends on KDB (cons.o also depends on GENERIC)
133trap.o cons.o: Makefile
134
135assym.s: genassym
136	./genassym >assym.s
137
138genassym: ${I386}/i386/genassym.c
139	${CC} ${INCLUDES} ${IDENT} ${PARAM} -Di386 -o genassym \
140	    ${I386}/i386/genassym.c
141
142depend: assym.s param.c vnode_if.h
143	mkdep ${COPTS} ${CFILES} ioconf.c param.c
144	mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${I386}/i386/genassym.c
145
146links:
147	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
148	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
149	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
150	  sort -u | comm -23 - dontlink | \
151	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
152	sh makelinks && rm -f dontlink
153
154tags:
155	@echo "see $S/kern/Makefile for tags"
156
157ioconf.o: ioconf.c
158	${CC} -c ${CFLAGS} ioconf.c
159
160param.c: $S/conf/param.c
161	rm -f param.c
162	cp $S/conf/param.c .
163
164param.o: param.c Makefile
165	${CC} -c ${CFLAGS} ${PARAM} param.c
166
167vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
168	AWK="${AWK}" sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
169
170%RULES
171