xref: /openbsd/sys/arch/armv7/conf/Makefile.armv7 (revision 91f110e0)
1#	$OpenBSD: Makefile.armv7,v 1.3 2014/02/02 03:59:25 miod 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 -D__${_mach}__ -MD -MP
26CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
27		-Wno-main -Wno-uninitialized -Wno-format \
28		-Wstack-larger-than-2047
29
30CMACHFLAGS=	-ffreestanding -msoft-float -march=armv6
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}
41LINKFLAGS=	-T ldscript --warn-common -nopie
42
43.if ${IDENT:M-DDDB_STRUCT}
44DB_STRUCTINFO=	db_structinfo.h
45.else
46DB_STRUCTINFO=
47.endif
48
49HOSTCC?=	${CC}
50HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
51HOSTED_CFLAGS=	${CFLAGS}
52HOSTED_C=	${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
53
54NORMAL_C_NOP=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
55NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
56NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
57
58%OBJS
59
60%CFILES
61
62%SFILES
63
64# load lines for config "xxx" will be emitted as:
65# xxx: ${SYSTEM_DEP} swapxxx.o
66#	${SYSTEM_LD_HEAD}
67#	${SYSTEM_LD} swapxxx.o
68#	${SYSTEM_LD_TAIL}
69SYSTEM_HEAD=	${_mach}_start.o locore.o param.o ioconf.o
70SYSTEM_OBJ=	${SYSTEM_HEAD} ${OBJS}
71SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
72SYSTEM_LD_HEAD=	@rm -f $@
73SYSTEM_LD_HEAD+=; \
74		cat ${_archdir}/conf/ldscript.head ${_archdir}/conf/ldscript.tail | \
75		    sed -e 's/@KERNEL_BASE_PHYS@/${KERNEL_BASE_PHYS}/' \
76		    -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' > ldscript
77
78SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
79		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
80SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
81
82DEBUG?=
83.if ${DEBUG} == "-g"
84LINKFLAGS+=	-X
85STRIPFLAGS=	-g -x
86SYSTEM_LD_TAIL+=; \
87		echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
88		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
89		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
90.else
91LINKFLAGS+=	-x
92.endif
93
94%LOAD
95
96# cc's -MD puts the source and output paths in the dependency file;
97# since those are temp files here we need to fix it up.  It also
98# puts the file in /tmp, so we use -MF to put it in the current
99# directory as assym.P and then generate assym.d from it with a
100# good target name
101assym.h: $S/kern/genassym.sh Makefile \
102	 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
103	cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
104	    sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
105	sed '1s/.*/assym.h: \\/' assym.P > assym.d
106	sort -u assym.h.tmp > assym.h
107
108param.c: $S/conf/param.c
109	rm -f param.c
110	cp $S/conf/param.c .
111
112param.o: param.c Makefile
113	${NORMAL_C}
114
115mcount.o: $S/lib/libkern/mcount.c Makefile
116	${NORMAL_C_NOP}
117
118ioconf.o: ioconf.c
119	${NORMAL_C}
120
121vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
122	sh $S/conf/newvers.sh
123	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
124
125clean::
126	rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
127	    [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
128
129lint:
130	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
131	    ${CFILES} ioconf.c param.c | \
132	    grep -v 'static function .* unused'
133
134depend:
135	@touch $@
136
137tags:
138	@echo "see $S/kern/Makefile for tags"
139
140db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl
141	${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
142	objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
143	rm -f db_structinfo.o
144
145${_mach}_start.o: ${_machdir}/${_mach}/${_mach}_start.S
146locore.o: ${_archdir}/${_arch}/locore.S assym.h
147in_cksum_arm.o fiq_subr.o bcopyinout.o copystr.o sigcode.o: assym.h
148vectors.o cpuswitch7.o exception.o bcopy_page.o irq_dispatch.o: assym.h
149armv7_start.o: assym.h
150
151# The install target can be redefined by putting a
152# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
153MACHINE_NAME!=  uname -n
154install: install-kernel-${MACHINE_NAME}
155.if !target(install-kernel-${MACHINE_NAME}})
156install-kernel-${MACHINE_NAME}:
157	rm -f /obsd
158	ln /bsd /obsd
159	cp bsd /nbsd
160	mv /nbsd /bsd
161.endif
162
163# pull in the dependency information
164.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
165 ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
166.endif
167.ifnmake clean
168. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
169.  if exists(${o:R}.d)
170.   include "${o:R}.d"
171.  elif exists($o)
172    .PHONY: $o
173.  endif
174. endfor
175.endif
176
177
178# until we get native booting working, put this in the tree.
179
180bsdrd.umg: bsd.rd
181	mkuboot -a arm -o linux -e ${KERNEL_BASE_PHYS} -l ${KERNEL_BASE_PHYS} bsd.rd bsdrd.umg
182
183bsd.umg: bsd
184	mkuboot -a arm -o linux -e ${KERNEL_BASE_PHYS} -l ${KERNEL_BASE_PHYS} bsd bsd.umg
185
186bsd.rd: bsd
187	cp bsd bsd.rd
188	$S/../distrib/${_mach}/ramdisk/rdsetroot < $S/../distrib/${_mach}/ramdisk/mr.fs bsd.rd
189
190%RULES
191