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