Makefile.landisk revision 1.43
1#	$OpenBSD: Makefile.landisk,v 1.43 2011/07/07 22:28:18 guenther 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_machdir?=	$S/arch/${_mach}
23_archdir?=	$S/arch/${_arch}
24
25INCLUDES=	-nostdinc -I. -I$S -I$S/arch
26CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP
27CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
28		-Wno-main -Wno-uninitialized -Wno-format \
29		-Wstack-larger-than-2047
30
31CMACHFLAGS=	-m4-nofpu
32CMACHFLAGS+=	-fno-builtin-printf -fno-builtin-snprintf \
33		-fno-builtin-vsnprintf -fno-builtin-log \
34		-fno-builtin-log2 -fno-builtin-malloc 
35.if ${IDENT:M-DNO_PROPOLICE}
36CMACHFLAGS+=	-fno-stack-protector
37.endif
38
39COPTS?=		-O2
40CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
41AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CMACHFLAGS}
42LINKFLAGS=	-N -Ttext 0x8c002000 -e start --warn-common
43
44.if ${IDENT:M-DDDB_STRUCT}
45DB_STRUCTINFO=	db_structinfo.h
46.else
47DB_STRUCTINFO=
48.endif
49
50HOSTCC?=	${CC}
51HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
52HOSTED_CFLAGS=	${CFLAGS}
53HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
54
55NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
56NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
57NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
58
59%OBJS
60
61%CFILES
62
63%SFILES
64
65# load lines for config "xxx" will be emitted as:
66# xxx: ${SYSTEM_DEP} swapxxx.o
67#	${SYSTEM_LD_HEAD}
68#	${SYSTEM_LD} swapxxx.o
69#	${SYSTEM_LD_TAIL}
70SYSTEM_HEAD=	locore.o param.o ioconf.o
71SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS}
72SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
73SYSTEM_LD_HEAD=	@rm -f $@
74SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
75		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
76SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
77
78DEBUG?=
79.if ${DEBUG} == "-g"
80LINKFLAGS+=	-X
81STRIPFLAGS=	-g -x
82SYSTEM_LD_TAIL+=; \
83		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
84		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
85		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
86.else
87LINKFLAGS+=	-S -x
88.endif
89
90%LOAD
91
92# cc's -MD puts the source and output paths in the dependency file;
93# since those are temp files here we need to fix it up.  It also
94# puts the file in /tmp, so we use -MF to put it in the current
95# directory as assym.P and then generate assym.d from it with a
96# good target name
97assym.h: $S/kern/genassym.sh Makefile \
98	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
99	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
100	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
101	sed '1s/.*/assym.h: \\/' assym.P > assym.d
102	sort -u assym.h.tmp > assym.h
103
104param.c: $S/conf/param.c
105	rm -f param.c
106	cp $S/conf/param.c .
107
108param.o: param.c Makefile
109	${NORMAL_C}
110
111mcount.o: $S/lib/libkern/mcount.c Makefile
112	${NORMAL_C_NOP}
113
114ioconf.o: ioconf.c
115	${NORMAL_C}
116
117vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
118	sh $S/conf/newvers.sh
119	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
120
121clean::
122	rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
123	    [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
124
125lint:
126	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
127	    ${CFILES} ioconf.c param.c | \
128	    grep -v 'static function .* unused'
129
130depend:
131	@touch $@
132
133tags:
134	@echo "see $S/kern/Makefile for tags"
135
136db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk
137	${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
138	objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@
139	rm -f db_structinfo.o
140
141locore.o: ${_machdir}/${_mach}/locore.S assym.h
142locore_subr.o vectors.o in_cksum.o: assym.h
143
144# The install target can be redefined by putting a
145# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
146MACHINE_NAME!=  uname -n
147install: install-kernel-${MACHINE_NAME}
148.if !target(install-kernel-${MACHINE_NAME}})
149install-kernel-${MACHINE_NAME}:
150	rm -f /obsd
151	ln /bsd /obsd
152	cp bsd /nbsd
153	mv /nbsd /bsd
154.endif
155
156# pull in the dependency information
157.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
158 ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
159.endif
160.ifnmake clean
161. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
162.  if exists(${o:R}.d)
163.   include "${o:R}.d"
164.  elif exists($o)
165    .PHONY: $o
166.  endif
167. endfor
168.endif
169
170%RULES
171