Makefile.landisk revision 1.4
1#	$OpenBSD: Makefile.landisk,v 1.4 2007/07/30 16:23:33 thib 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### find out what to use for libkern
60.include "$S/lib/libkern/Makefile.inc"
61.ifndef PROF
62LIBKERN=	${KERNLIB}
63.else
64LIBKERN=	${KERNLIB_PROF}
65.endif
66
67### find out what to use for libcompat
68.include "$S/compat/common/Makefile.inc"
69.ifndef PROF
70LIBCOMPAT=	${COMPATLIB}
71.else
72LIBCOMPAT=	${COMPATLIB_PROF}
73.endif
74
75# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
76# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix,
77# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
78# is marked as config-dependent.
79
80USRLAND_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
81USRLAND_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
82
83NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
84NORMAL_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
85
86DRIVER_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
87DRIVER_C_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $<
88
89NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
90NORMAL_S_C=	${AS}  ${COPTS} ${PARAM} $< -o $@
91
92
93%OBJS
94
95%CFILES
96
97%SFILES
98
99# load lines for config "xxx" will be emitted as:
100# xxx: ${SYSTEM_DEP} swapxxx.o
101#	${SYSTEM_LD_HEAD}
102#	${SYSTEM_LD} swapxxx.o
103#	${SYSTEM_LD_TAIL}
104SYSTEM_OBJ=	locore.o param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
105SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
106SYSTEM_LD_HEAD=	rm -f $@
107SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
108		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
109SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
110
111DEBUG?=
112.if ${DEBUG} == "-g"
113LINKFLAGS+=	-X
114SYSTEM_LD_TAIL+=; \
115		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
116		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
117		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
118.else
119LINKFLAGS+=	-S -x
120.endif
121
122%LOAD
123
124assym.h: $S/kern/genassym.sh \
125	 ${SH}/sh/genassym.cf Makefile
126	cat ${SH}/sh/genassym.cf | \
127	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} \
128	    > assym.h.tmp && \
129	mv -f assym.h.tmp assym.h
130
131param.c: $S/conf/param.c
132	rm -f param.c
133	cp $S/conf/param.c .
134
135param.o: param.c Makefile
136	${NORMAL_C_C}
137
138ioconf.o: ioconf.c
139	${NORMAL_C}
140
141newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
142	sh $S/conf/newvers.sh
143	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
144
145clean::
146	rm -f eddep *bsd bsd.gdb tags *.[io] [a-z]*.s \
147		[Ee]rrs linterrs makelinks genassym genassym.o assym.h
148
149lint:
150	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB ${CFILES} \
151		ioconf.c param.c | \
152		grep -v 'static function .* unused'
153
154tags:
155	@echo "see $S/kern/Makefile for tags"
156
157links:
158	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
159	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
160	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
161	  sort -u | comm -23 - dontlink | \
162	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
163	sh makelinks && rm -f dontlink
164
165SRCS=	${LANDISK}/landisk/locore.S \
166	param.c ioconf.c ${CFILES} ${SFILES}
167depend:: .depend
168.depend: ${SRCS} assym.h param.c
169	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${LANDISK}/landisk/locore.S
170	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
171.if ${SFILES} != ""
172	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
173.endif
174	cat ${SH}/sh/genassym.cf | \
175	    sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} ${CPPFLAGS}
176	@sed -e 's/.*\.o:.* /assym.h: /' < assym.dep >> .depend
177	@rm -f assym.dep
178
179# depend on root or device configuration
180autoconf.o conf.o: Makefile
181
182# depend on network or filesystem configuration
183uipc_proto.o vfs_conf.o: Makefile
184
185# depend on maxusers
186assym.h machdep.o: Makefile
187
188# depend on CPU configuration
189locore.o machdep.o: Makefile
190
191
192locore.o: ${LANDISK}/landisk/locore.S assym.h
193	${NORMAL_S}
194
195# The install target can be redefined by putting a
196# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
197MACHINE_NAME!=  uname -n
198install: install-kernel-${MACHINE_NAME}
199.if !target(install-kernel-${MACHINE_NAME}})
200install-kernel-${MACHINE_NAME}:
201	rm -f /obsd
202	ln /bsd /obsd
203	cp bsd /nbsd
204	mv /nbsd /bsd
205.endif
206
207%RULES
208