Makefile.i386 revision 1.72
1#	$NetBSD: Makefile.i386,v 1.72 1996/08/25 23:39:29 jtk 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
32S!=	cd ../../../..; pwd
33I386=	$S/arch/i386
34
35INCLUDES=	-I. -I$S/arch -I$S -nostdinc
36CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
37		-Di386
38CWARNFLAGS=	-Werror -Wreturn-type
39CFLAGS=		${DEBUG} ${CWARNFLAGS} -O2 
40AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
41LINKFLAGS=	-z -Ttext F8100000 -e start
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### find out what to use for libcompat
52.include "$S/compat/common/Makefile.inc"
53.ifndef PROF
54LIBCOMPAT=	${COMPATLIB}
55.else
56LIBCOMPAT=	${COMPATLIB_PROF}
57.endif
58
59# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
60# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
61
62NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
63NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
64
65HOSTED_C=	${NORMAL_C:S/^-pg$//:S/^-p$//:S/^-nostdinc$//}
66
67%OBJS
68
69%CFILES
70
71%SFILES
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 \
79		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
80SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
81SYSTEM_LD_HEAD=	rm -f $@
82SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
83		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
84SYSTEM_LD_TAIL=	@size $@; chmod 755 $@
85
86DEBUG?=
87.if ${DEBUG} == "-g"
88LINKFLAGS+=	-X
89SYSTEM_LD_TAIL+=; \
90		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
91		echo ${STRIP} $@; ${STRIP} $@
92.else
93LINKFLAGS+=	-S
94.endif
95
96%LOAD
97
98assym.h: genassym
99	./genassym >assym.h
100
101genassym: genassym.o
102	${CC} -o $@ genassym.o
103
104genassym.o: ${I386}/i386/genassym.c
105	${HOSTED_C}
106
107param.c: $S/conf/param.c
108	rm -f param.c
109	cp $S/conf/param.c .
110
111param.o: param.c Makefile
112	${NORMAL_C}
113
114ioconf.o: ioconf.c
115	${NORMAL_C}
116
117newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
118	sh $S/conf/newvers.sh
119	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
120
121
122clean::
123	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
124	    [Ee]rrs linterrs makelinks genassym genassym.o assym.h
125
126lint:
127	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB \
128	    ${I386}/i386/Locore.c ${CFILES} ${I386}/i386/swapgeneric.c \
129	    ioconf.c param.c | \
130	    grep -v 'static function .* unused'
131
132tags:
133	@echo "see $S/kern/Makefile for tags"
134
135links:
136	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
137	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
138	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
139	  sort -u | comm -23 - dontlink | \
140	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
141	sh makelinks && rm -f dontlink
142
143# depend on APM
144.include "${I386}/apm_init/Makefile.inc"
145locore.o: ${APMINC}
146
147SRCS=	${I386}/i386/locore.s \
148	param.c ioconf.c ${CFILES} ${SFILES}
149depend:: .depend
150.depend: ${SRCS} assym.h param.c ${APMINC}
151	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
152	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
153	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
154	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} ${I386}/i386/genassym.c
155
156
157# depend on root or device configuration
158autoconf.o conf.o: Makefile
159 
160# depend on network or filesystem configuration 
161uipc_proto.o vfs_conf.o: Makefile 
162
163# depend on maxusers
164genassym.o machdep.o: Makefile
165
166# depend on CPU configuration 
167locore.o machdep.o: Makefile
168
169
170locore.o: ${I386}/i386/locore.s assym.h
171	${NORMAL_S}
172
173%RULES
174