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