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