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