Makefile.sh3 revision 1.12
1#	$NetBSD: Makefile.sh3,v 1.12 2001/05/29 02:20:25 mrg 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/sh3/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/sh3/conf/Makefile.sh3
13# after which config should be rerun for all machines of that type.
14
15.include <bsd.own.mk>
16
17# DEBUG is set to -g if debugging.
18# PROF is set to -pg if profiling.
19
20AR?=	ar
21AS?=	as
22CC?=	cc
23CPP?=	cpp
24LD?=	ld
25LORDER?=lorder
26MKDEP?=	mkdep
27NM?=	nm
28RANLIB?=ranlib
29SIZE?=	size
30STRIP?=	strip
31TSORT?=	tsort -q
32OBJCOPY?=objcopy
33
34# pkgsrc/cross/sh* dies with -O2, use -O1 for now
35#COPTS?=	-O2
36COPTS?=	-O1
37
38# source tree is located via $S relative to the compilation directory
39.ifndef S
40S!=	cd ../../../..; pwd
41.endif
42THISSH3=$S/arch/${TARGET_MACHINE}
43SH3=	$S/arch/sh3
44
45HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
46INCLUDES=	-I. -I$S/arch -I$S -nostdinc
47CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -D${TARGET_MACHINE}
48CWARNFLAGS=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes
49CWARNFLAGS+=	-Wpointer-arith -Wno-parentheses
50# XXX Delete -Wuninitialized for now, since the compiler doesn't
51# XXX always get it right.  --thorpej 
52CWARNFLAGS+=	-Wno-uninitialized
53.if (${HAVE_EGCS} != "")
54CWARNFLAGS+=	-Wno-main
55.endif
56CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
57AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
58LINKFLAGS?=	-e start -T ${THISSH3}/conf/${LDSCRIPTBASE}
59STRIPFLAGS=	--strip-debug
60
61.if exists(${THISSH3}/conf/Makefile.${TARGET_MACHINE}.inc)
62.include "${THISSH3}/conf/Makefile.${TARGET_MACHINE}.inc"
63.endif
64
65%INCLUDES
66
67### find out what to use for libkern
68.include "$S/lib/libkern/Makefile.inc"
69.ifndef PROF
70LIBKERN=	${KERNLIB}
71.else
72LIBKERN=	${KERNLIB_PROF}
73.endif
74
75### find out what to use for libcompat
76.include "$S/compat/common/Makefile.inc"
77.ifndef PROF
78LIBCOMPAT=	${COMPATLIB}
79.else
80LIBCOMPAT=	${COMPATLIB_PROF}
81.endif
82
83# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
84# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
85
86NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
87NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
88
89%OBJS
90
91%CFILES
92
93%SFILES
94
95# load lines for config "xxx" will be emitted as:
96# xxx: ${SYSTEM_DEP} swapxxx.o
97#	${SYSTEM_LD_HEAD}
98#	${SYSTEM_LD} swapxxx.o
99#	${SYSTEM_LD_TAIL}
100SYSTEM_OBJ=	locore.o \
101		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
102SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
103SYSTEM_LD_HEAD=	rm -f $@
104SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
105		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
106SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
107
108DEBUG?=
109.if ${DEBUG} == "-g"
110LINKFLAGS+=	-X
111SYSTEM_LD_TAIL+=; \
112		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
113		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
114		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
115.else
116LINKFLAGS+=
117.endif
118
119%LOAD
120
121assym.h: $S/kern/genassym.sh ${THISSH3}/${TARGET_MACHINE}/genassym.cf
122	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
123	    < ${THISSH3}/${TARGET_MACHINE}/genassym.cf > assym.h.tmp && \
124	mv -f assym.h.tmp assym.h
125
126param.c: $S/conf/param.c
127	rm -f param.c
128	cp $S/conf/param.c .
129
130param.o: param.c Makefile
131	${NORMAL_C}
132
133ioconf.o: ioconf.c
134	${NORMAL_C}
135
136newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
137	sh $S/conf/newvers.sh
138	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
139
140
141__CLEANKERNEL: .USE
142	@echo "${.TARGET}ing the kernel objects"
143	rm -f eddep *netbsd netbsd netbsd.gdb tags *.[io] [a-z]*.s \
144	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
145
146__CLEANDEPEND: .USE
147	rm -f .depend
148
149clean: __CLEANKERNEL
150
151cleandir: __CLEANKERNEL __CLEANDEPEND
152
153lint:
154	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
155	    ${SH3}/sh3/Locore.c ${CFILES} \
156	    ioconf.c param.c | \
157	    grep -v 'static function .* unused'
158
159tags:
160	@echo "see $S/kern/Makefile for tags"
161
162links:
163	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
164	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
165	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
166	  sort -u | comm -23 - dontlink | \
167	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
168	sh makelinks && rm -f dontlink
169
170# ${SH3}/sh3/locore.s ?
171SRCS=	${THISSH3}/${TARGET_MACHINE}/locore.s \
172	param.c ioconf.c ${CFILES} ${SFILES}
173depend: .depend
174.depend: ${SRCS} assym.h param.c
175	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISSH3}/${TARGET_MACHINE}/locore.s
176	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
177.if ${SFILES} != ""
178	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
179.endif
180	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
181	  ${CPPFLAGS} < ${THISSH3}/${TARGET_MACHINE}/genassym.cf
182	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
183	@rm -f assym.dep
184
185dependall: depend all
186
187
188# depend on root or device configuration
189autoconf.o conf.o: Makefile
190
191# depend on network or filesystem configuration
192uipc_proto.o vfs_conf.o: Makefile
193
194# depend on maxusers
195machdep.o: Makefile
196
197# depend on CPU configuration
198locore.o machdep.o: Makefile
199
200locore.o: ${THISSH3}/${TARGET_MACHINE}/locore.s assym.h
201	${NORMAL_S}
202
203# XXX compile ffs_inode.c always with -O0 to avoid egcs-1.1.2 bug.
204#ffs_inode.o: $S/ufs/ffs/ffs_inode.c
205#	${CC} ${CFLAGS} -O0 ${CPPFLAGS} ${PROF} -c $<
206
207# The install target can be redefined by putting a
208# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
209MACHINE_NAME!=  uname -n
210install: install-kernel-${MACHINE_NAME}
211.if !target(install-kernel-${MACHINE_NAME}})
212install-kernel-${MACHINE_NAME}:
213	rm -f /onetbsd
214	ln /netbsd /onetbsd
215	cp netbsd /nnetbsd
216	mv /nnetbsd /netbsd
217.endif
218
219%RULES
220