Makefile.landisk revision 1.6
1#	$OpenBSD: Makefile.landisk,v 1.6 2007/11/25 18:25:28 deraadt Exp $
2#
3# Makefile for OpenBSD/landisk
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/landisk/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/landisk/conf/Makefile.landisk
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.SUFFIXES:	.S .c .o
22
23# DEBUG is set to -g if debugging.
24# PROF is set to -pg if profiling.
25
26.include <bsd.own.mk>
27
28MKDEP?=	mkdep
29STRIP?=	strip
30SIZE?=	size
31
32# source tree is located via $S relative to the compilation directory
33.ifndef	S
34S!=	cd ../../../..; pwd
35.endif
36LANDISK=	$S/arch/landisk
37SH=		$S/arch/sh
38
39INCLUDES=	-I. -I$S -I$S/arch -nostdinc
40CPPFLAGS=	${INCLUDES} ${IDENT} -D_KERNEL -Dlandisk
41CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
42		-Wno-uninitialized -Wno-format -Wno-main \
43		-Wstack-larger-than-2047
44CMACHFLAGS=	-m4-nofpu \
45		-fno-builtin-printf -fno-builtin-log -fno-builtin-main
46.if ${IDENT:M-DNO_PROPOLICE}
47CMACHFLAGS+=	-fno-stack-protector
48.endif
49COPTS?=		-O2
50CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
51AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-little
52LINKFLAGS=	-N -Ttext 0x8c002000 -e start --warn-common
53STRIPFLAGS=	-g -X -x
54
55HOSTCC?=	${CC}
56HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
57HOSTED_CFLAGS=	${CFLAGS}
58
59# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
60# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix,
61# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
62# is marked as config-dependent.
63
64USRLAND_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
65USRLAND_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
66
67NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
68NORMAL_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
69
70DRIVER_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
71DRIVER_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
72
73NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
74NORMAL_S_C=	${AS}  ${COPTS} ${PARAM} $< -o $@
75
76
77%OBJS
78
79%CFILES
80
81%SFILES
82
83# load lines for config "xxx" will be emitted as:
84# xxx: ${SYSTEM_DEP} swapxxx.o
85#	${SYSTEM_LD_HEAD}
86#	${SYSTEM_LD} swapxxx.o
87#	${SYSTEM_LD_TAIL}
88SYSTEM_OBJ=	locore.o param.o ioconf.o ${OBJS}
89SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
90SYSTEM_LD_HEAD=	rm -f $@
91SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
92		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
93SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
94
95DEBUG?=
96.if ${DEBUG} == "-g"
97LINKFLAGS+=	-X
98SYSTEM_LD_TAIL+=; \
99		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
100		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
101		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
102.else
103LINKFLAGS+=	-S -x
104.endif
105
106%LOAD
107
108assym.h: $S/kern/genassym.sh \
109	 ${SH}/sh/genassym.cf Makefile
110	cat ${SH}/sh/genassym.cf | \
111	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} \
112	    > assym.h.tmp && \
113	mv -f assym.h.tmp assym.h
114
115param.c: $S/conf/param.c
116	rm -f param.c
117	cp $S/conf/param.c .
118
119param.o: param.c Makefile
120	${NORMAL_C_C}
121
122mcount.o: $S/lib/libkern/mcount.c Makefile
123	${NORMAL_C_NOP}
124
125ioconf.o: ioconf.c
126	${NORMAL_C}
127
128newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
129	sh $S/conf/newvers.sh
130	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
131
132clean::
133	rm -f eddep *bsd bsd.gdb tags *.[io] [a-z]*.s \
134		[Ee]rrs linterrs makelinks genassym genassym.o assym.h
135
136lint:
137	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB ${CFILES} \
138		ioconf.c param.c | \
139		grep -v 'static function .* unused'
140
141tags:
142	@echo "see $S/kern/Makefile for tags"
143
144links:
145	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
146	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
147	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
148	  sort -u | comm -23 - dontlink | \
149	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
150	sh makelinks && rm -f dontlink
151
152SRCS=	${LANDISK}/landisk/locore.S \
153	param.c ioconf.c ${CFILES} ${SFILES}
154depend:: .depend
155.depend: ${SRCS} assym.h param.c
156	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${LANDISK}/landisk/locore.S
157	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
158.if ${SFILES} != ""
159	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
160.endif
161	cat ${SH}/sh/genassym.cf | \
162	    sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} ${CPPFLAGS}
163	@sed -e 's/.*\.o:.* /assym.h: /' < assym.dep >> .depend
164	@rm -f assym.dep
165
166# depend on root or device configuration
167autoconf.o conf.o: Makefile
168
169# depend on network or filesystem configuration
170uipc_proto.o vfs_conf.o: Makefile
171
172# depend on maxusers
173assym.h machdep.o: Makefile
174
175# depend on CPU configuration
176locore.o machdep.o: Makefile
177
178locore.o: ${LANDISK}/landisk/locore.S assym.h
179	${NORMAL_S}
180
181# The install target can be redefined by putting a
182# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
183MACHINE_NAME!=  uname -n
184install: install-kernel-${MACHINE_NAME}
185.if !target(install-kernel-${MACHINE_NAME}})
186install-kernel-${MACHINE_NAME}:
187	rm -f /obsd
188	ln /bsd /obsd
189	cp bsd /nbsd
190	mv /nbsd /bsd
191.endif
192
193%RULES
194