Makefile.landisk revision 1.32
1#	$OpenBSD: Makefile.landisk,v 1.32 2010/05/25 02:35:02 deraadt Exp $
2
3# For instructions on building kernels consult the config(8) and options(4)
4# manual pages.
5#
6# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
7#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
8# DEBUG is set to -g by config if debugging is requested (config -g).
9# PROF is set to -pg by config if profiling is requested (config -p).
10
11.include <bsd.own.mk>
12
13MKDEP?=	mkdep
14SIZE?=	size
15STRIP?=	strip
16
17# source tree is located via $S relative to the compilation directory
18.ifndef S
19S!=	cd ../../../..; pwd
20.endif
21
22_mach?=		landisk
23_arch?=		sh
24_machdir?=	$S/arch/${_mach}
25_archdir?=	$S/arch/${_arch}
26
27INCLUDES=	-nostdinc -I. -I$S -I$S/arch
28CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__
29CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
30		-Wno-main -Wno-uninitialized -Wno-format \
31		-Wstack-larger-than-2047
32
33CMACHFLAGS=	-m4-nofpu
34CMACHFLAGS+=	-fno-builtin-printf -fno-builtin-snprintf \
35		-fno-builtin-vsnprintf -fno-builtin-log \
36		-fno-builtin-log2 -fno-builtin-malloc 
37.if ${IDENT:M-DNO_PROPOLICE}
38CMACHFLAGS+=	-fno-stack-protector
39.endif
40
41COPTS?=		-O2
42CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
43AFLAGS=		-D_LOCORE -x assembler-with-cpp -traditional-cpp ${CMACHFLAGS}
44LINKFLAGS=	-N -Ttext 0x8c002000 -e start --warn-common
45STRIPFLAGS=	-g -x
46
47.if ${IDENT:M-DDDB_STRUCT}
48DB_STRUCTINFO=	db_structinfo.h
49.else
50DB_STRUCTINFO=
51.endif
52
53HOSTCC?=	${CC}
54HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
55HOSTED_CFLAGS=	${CFLAGS}
56HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
57
58NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
59NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
60NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
61
62%OBJS
63
64%CFILES
65
66%SFILES
67
68# load lines for config "xxx" will be emitted as:
69# xxx: ${SYSTEM_DEP} swapxxx.o
70#	${SYSTEM_LD_HEAD}
71#	${SYSTEM_LD} swapxxx.o
72#	${SYSTEM_LD_TAIL}
73SYSTEM_OBJ=	locore.o param.o ioconf.o ${OBJS}
74SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
75SYSTEM_LD_HEAD=	@rm -f $@
76SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
77		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
78SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
79
80DEBUG?=
81.if ${DEBUG} == "-g"
82LINKFLAGS+=	-X
83SYSTEM_LD_TAIL+=; \
84		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
85		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
86		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
87.else
88LINKFLAGS+=	-S -x
89.endif
90
91%LOAD
92
93assym.h: $S/kern/genassym.sh Makefile \
94	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
95	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
96	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PARAM} | \
97	    sort -u > assym.h.tmp && \
98	    mv -f assym.h.tmp assym.h
99
100param.c: $S/conf/param.c
101	rm -f param.c
102	cp $S/conf/param.c .
103
104param.o: param.c Makefile
105	${NORMAL_C}
106
107mcount.o: $S/lib/libkern/mcount.c Makefile
108	${NORMAL_C_NOP}
109
110ioconf.o: ioconf.c
111	${NORMAL_C}
112
113vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
114	sh $S/conf/newvers.sh
115	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
116
117clean::
118	rm -f eddep *bsd *bsd.gdb tags *.[io] [a-z]*.s \
119	    [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
120
121lint:
122	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
123	    ${CFILES} ioconf.c param.c | \
124	    grep -v 'static function .* unused'
125
126tags:
127	@echo "see $S/kern/Makefile for tags"
128
129AFILES=	${_machdir}/${_mach}/locore.S
130depend:: .depend
131.depend: ${AFILES} param.c ioconf.c ${CFILES} ${SFILES} assym.h ${DB_STRUCTINFO}
132	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${AFILES}
133	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
134.if !empty(SFILES)
135	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
136.endif
137	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
138	    sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} ${CPPFLAGS}
139	@sed -e 's/.*\.o: /assym.h: /' -e 's/\/tmp\/genassym_c.[^ ]*//' \
140	    < assym.dep >> .depend
141	@rm -f assym.dep
142
143db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk
144	${CC} ${CFLAGS} ${CPPFLAGS} -gstabs -c $S/ddb/db_structinfo.c
145	objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@
146	rm -f db_structinfo.o
147
148locore.o: ${_machdir}/${_mach}/locore.S assym.h
149	${NORMAL_S}
150
151# The install target can be redefined by putting a
152# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
153MACHINE_NAME!=  uname -n
154install: install-kernel-${MACHINE_NAME}
155.if !target(install-kernel-${MACHINE_NAME}})
156install-kernel-${MACHINE_NAME}:
157	rm -f /obsd
158	ln /bsd /obsd
159	cp bsd /nbsd
160	mv /nbsd /bsd
161.endif
162
163%RULES
164