xref: /openbsd/sys/arch/sparc64/conf/Makefile.sparc64 (revision cecf84d4)
1#	$OpenBSD: Makefile.sparc64,v 1.72 2015/01/13 01:12:50 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
13SIZE?=	size
14STRIP?=	strip
15
16# source tree is located via $S relative to the compilation directory
17.ifndef S
18S!=	cd ../../../..; pwd
19.endif
20
21_machdir?=	$S/arch/${_mach}
22_archdir?=	$S/arch/${_arch}
23
24INCLUDES=	-nostdinc -I$S -I. -I$S/arch
25CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP
26CWARNFLAGS=	-Werror -Wall -Wimplicit-function-declaration \
27		-Wno-main -Wno-uninitialized \
28		-Wframe-larger-than=2047
29
30CMACHFLAGS=	-Wa,-Av9b, -mno-fpu
31CMACHFLAGS+=	-fno-builtin-printf -fno-builtin-snprintf \
32		-fno-builtin-vsnprintf -fno-builtin-log \
33		-fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS}
34.if ${IDENT:M-DNO_PROPOLICE}
35CMACHFLAGS+=	-fno-stack-protector
36.endif
37
38COPTS?=		-O2
39CFLAGS=		${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
40AFLAGS=		-D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
41LDSCRIPT=	${_machdir}/conf/ld.script
42LINKFLAGS=	-n -T ${LDSCRIPT} --warn-common -nopie
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} ${LDSCRIPT}
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.pl
137	${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
138	objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
139	rm -f db_structinfo.o
140
141locore.o: ${_machdir}/${_mach}/locore.s assym.h
142hvcall.o in_cksum.o mutex.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	cmp -s bsd /bsd || ln -f /bsd /obsd
151	cp bsd /nbsd
152	mv /nbsd /bsd
153.endif
154
155# pull in the dependency information
156.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
157 ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
158.endif
159.ifnmake clean
160. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
161.  if exists(${o:R}.d)
162.   include "${o:R}.d"
163.  elif exists($o)
164    .PHONY: $o
165.  endif
166. endfor
167.endif
168
169%RULES
170