Makefile.i386 revision 1.73
1#	$NetBSD: Makefile.i386,v 1.73 1996/08/31 21:41:16 mycroft Exp $
2
3# Makefile for NetBSD
4#
5# This makefile is constructed from a machine description:
6#	config machineid
7# Most changes should be made in the machine description
8#	/sys/arch/i386/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/i386/conf/Makefile.i386
13# after which config should be rerun for all machines of that type.
14#
15# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
16#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
17#
18# -DTRACE	compile in kernel tracing hooks
19# -DQUOTA	compile in file system quotas
20
21# DEBUG is set to -g if debugging.
22# PROF is set to -pg if profiling.
23
24CC?=	cc
25LD?=	ld
26MKDEP?=	mkdep
27STRIP?=	strip -d
28APMSTRIP?=	strip
29TOUCH?=	touch -f -c
30
31# source tree is located via $S relative to the compilation directory
32.ifndef S
33S!=	cd ../../../..; pwd
34.endif
35I386=	$S/arch/i386
36
37INCLUDES=	-I. -I$S/arch -I$S -nostdinc
38CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
39		-Di386
40CWARNFLAGS=	-Werror -Wreturn-type
41CFLAGS=		${DEBUG} ${CWARNFLAGS} -O2 
42AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
43LINKFLAGS=	-z -Ttext F8100000 -e start
44
45### find out what to use for libkern
46.include "$S/lib/libkern/Makefile.inc"
47.ifndef PROF
48LIBKERN=	${KERNLIB}
49.else
50LIBKERN=	${KERNLIB_PROF}
51.endif
52
53### find out what to use for libcompat
54.include "$S/compat/common/Makefile.inc"
55.ifndef PROF
56LIBCOMPAT=	${COMPATLIB}
57.else
58LIBCOMPAT=	${COMPATLIB_PROF}
59.endif
60
61# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
62# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
63
64NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
65NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
66
67HOSTED_C=	${NORMAL_C:S/^-pg$//:S/^-p$//:S/^-nostdinc$//}
68
69%OBJS
70
71%CFILES
72
73%SFILES
74
75# load lines for config "xxx" will be emitted as:
76# xxx: ${SYSTEM_DEP} swapxxx.o
77#	${SYSTEM_LD_HEAD}
78#	${SYSTEM_LD} swapxxx.o
79#	${SYSTEM_LD_TAIL}
80SYSTEM_OBJ=	locore.o \
81		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
82SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
83SYSTEM_LD_HEAD=	rm -f $@
84SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
85		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
86SYSTEM_LD_TAIL=	@size $@; chmod 755 $@
87
88DEBUG?=
89.if ${DEBUG} == "-g"
90LINKFLAGS+=	-X
91SYSTEM_LD_TAIL+=; \
92		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
93		echo ${STRIP} $@; ${STRIP} $@
94.else
95LINKFLAGS+=	-S
96.endif
97
98%LOAD
99
100assym.h: genassym
101	./genassym >assym.h
102
103genassym: genassym.o
104	${CC} -o $@ genassym.o
105
106genassym.o: ${I386}/i386/genassym.c
107	${HOSTED_C}
108
109param.c: $S/conf/param.c
110	rm -f param.c
111	cp $S/conf/param.c .
112
113param.o: param.c Makefile
114	${NORMAL_C}
115
116ioconf.o: ioconf.c
117	${NORMAL_C}
118
119newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
120	sh $S/conf/newvers.sh
121	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
122
123
124clean::
125	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
126	    [Ee]rrs linterrs makelinks genassym genassym.o assym.h
127
128lint:
129	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB \
130	    ${I386}/i386/Locore.c ${CFILES} ${I386}/i386/swapgeneric.c \
131	    ioconf.c param.c | \
132	    grep -v 'static function .* unused'
133
134tags:
135	@echo "see $S/kern/Makefile for tags"
136
137links:
138	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
139	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
140	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
141	  sort -u | comm -23 - dontlink | \
142	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
143	sh makelinks && rm -f dontlink
144
145# depend on APM
146.include "${I386}/apm_init/Makefile.inc"
147locore.o: ${APMINC}
148
149SRCS=	${I386}/i386/locore.s \
150	param.c ioconf.c ${CFILES} ${SFILES}
151depend:: .depend
152.depend: ${SRCS} assym.h param.c ${APMINC}
153	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
154	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
155	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
156	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} ${I386}/i386/genassym.c
157
158
159# depend on root or device configuration
160autoconf.o conf.o: Makefile
161 
162# depend on network or filesystem configuration 
163uipc_proto.o vfs_conf.o: Makefile 
164
165# depend on maxusers
166genassym.o machdep.o: Makefile
167
168# depend on CPU configuration 
169locore.o machdep.o: Makefile
170
171
172locore.o: ${I386}/i386/locore.s assym.h
173	${NORMAL_S}
174
175%RULES
176