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