xref: /openbsd/sys/arch/luna88k/conf/Makefile.luna88k (revision 898184e3)
1#	$OpenBSD: Makefile.luna88k,v 1.46 2013/01/07 13:05:14 aoyama 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
13SIZE?=	size
14STRIP?=	strip
15OBJCOPY?= objcopy
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=	-mno-check-zero-division -mmemcpy
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 -traditional-cpp ${CMACHFLAGS}
42LINKFLAGS=	-T ${_machdir}/conf/ld.script -Ttext 0x20000 -e __start -X -N \
43		    --warn-common -nopie
44
45.if ${IDENT:M-DDDB_STRUCT}
46DB_STRUCTINFO=	db_structinfo.h
47.else
48DB_STRUCTINFO=
49.endif
50
51HOSTCC?=	${CC}
52HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
53HOSTED_CFLAGS=	${CFLAGS}
54HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
55
56NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
57NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
58NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
59PROFILE_C=	${CC} -S -c ${CFLAGS} ${CPPFLAGS} $<; \
60		sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \
61		${AS} -o $@; \
62		rm -f $*.s
63
64%OBJS
65
66%CFILES
67
68%SFILES
69
70# load lines for config "xxx" will be emitted as:
71# xxx: ${SYSTEM_DEP} swapxxx.o
72#	${SYSTEM_LD_HEAD}
73#	${SYSTEM_LD} swapxxx.o
74#	${SYSTEM_LD_TAIL}
75SYSTEM_HEAD=	locore.o param.o ioconf.o
76SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS}
77SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
78SYSTEM_LD_HEAD=	@rm -f $@
79SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
80		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
81SYSTEM_LD_TAIL=	@${SIZE} $@
82
83DEBUG?=
84.if ${DEBUG} == "-g"
85LINKFLAGS+=	-X
86STRIPFLAGS=	-g -x
87SYSTEM_LD_TAIL+=; \
88		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
89		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
90		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
91.else
92LINKFLAGS+=	-S -x
93.endif
94SYSTEM_LD_TAIL+=; \
95		echo ${OBJCOPY} -O a.out-m88k-openbsd --impure $@; \
96		${OBJCOPY} -O a.out-m88k-openbsd --impure $@; \
97		chmod 755 $@
98
99%LOAD
100
101# cc's -MD puts the source and output paths in the dependency file;
102# since those are temp files here we need to fix it up.  It also
103# puts the file in /tmp, so we use -MF to put it in the current
104# directory as assym.P and then generate assym.d from it with a
105# good target name
106assym.h: $S/kern/genassym.sh Makefile \
107	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
108	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
109	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
110	sed '1s/.*/assym.h: \\/' assym.P > assym.d
111	sort -u assym.h.tmp > assym.h
112
113param.c: $S/conf/param.c
114	rm -f param.c
115	cp $S/conf/param.c .
116
117param.o: param.c Makefile
118	${NORMAL_C}
119
120mcount.o: $S/lib/libkern/mcount.c Makefile
121	${NORMAL_C_NOP}
122
123ioconf.o: ioconf.c
124	${NORMAL_C}
125
126vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
127	sh $S/conf/newvers.sh
128	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
129
130clean::
131	rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
132	    [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
133
134lint:
135	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
136	    ${CFILES} ioconf.c param.c | \
137	    grep -v 'static function .* unused'
138
139depend:
140	@touch $@
141
142tags:
143	@echo "see $S/kern/Makefile for tags"
144
145db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk
146	${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
147	objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@
148	rm -f db_structinfo.o
149
150locore.o: ${_machdir}/${_mach}/locore.S assym.h
151eh.o m88100_fp.o mutex.o process.o subr.o: assym.h
152
153# The install target can be redefined by putting a
154# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
155MACHINE_NAME!=  uname -n
156install: install-kernel-${MACHINE_NAME}
157.if !target(install-kernel-${MACHINE_NAME}})
158install-kernel-${MACHINE_NAME}:
159	rm -f /obsd
160	ln /bsd /obsd
161	cp bsd /nbsd
162	mv /nbsd /bsd
163.endif
164
165# pull in the dependency information
166.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
167 ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
168.endif
169.ifnmake clean
170. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
171.  if exists(${o:R}.d)
172.   include "${o:R}.d"
173.  elif exists($o)
174    .PHONY: $o
175.  endif
176. endfor
177.endif
178
179%RULES
180