1# Makefile.arm64 -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4#	from FreeBSD: src/sys/conf/Makefile.i386,v 1.255 2002/02/20 23:35:49
5# $FreeBSD$
6#
7# Makefile for FreeBSD
8#
9# This makefile is constructed from a machine description:
10#	config machineid
11# Most changes should be made in the machine description
12#	/sys/arm64/conf/``machineid''
13# after which you should do
14#	 config machineid
15# Generic makefile changes should be made in
16#	/sys/conf/Makefile.arm64
17# after which config should be rerun for all machines.
18#
19
20# Which version of config(8) is required.
21%VERSREQ=	600012
22
23.if !defined(S)
24S=	../../..
25.endif
26.include "$S/conf/kern.pre.mk"
27
28INCLUDES+= -I$S/contrib/libfdt -I$S/contrib/device-tree/include
29
30# Use a custom SYSTEM_LD command to generate the elf kernel, so we can
31# set the text segment start address, and also strip the "arm mapping
32# symbols" which have names like $a.0 and $d.2; see the document
33# "ELF for the ARM architecture" for more info on the mapping symbols.
34SYSTEM_LD= \
35	${SYSTEM_LD_BASECMD} \
36	    --defsym='text_start=kernbase + SIZEOF_HEADERS' \
37	    -o ${.TARGET} ${SYSTEM_OBJS} vers.o; \
38	$(OBJCOPY) \
39	    --wildcard \
40	    --strip-symbol='$$[adtx]*' \
41	    ${.TARGET}
42
43# Generate the .bin (booti images) kernel as an extra build output.
44# The targets and rules to generate these appear near the end of the file.
45KERNEL_EXTRA+= ${KERNEL_KO}.bin
46KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin
47
48.if !empty(DDB_ENABLED) || !empty(DTR_ENABLED) || !empty(HWPMC_ENABLED)
49CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
50.endif
51
52%BEFORE_DEPEND
53
54%OBJS
55
56%FILES.c
57
58%FILES.s
59
60%FILES.m
61
62%CLEAN
63CLEAN+=	${KERNEL_KO}.bin
64
65%RULES
66
67.include "$S/conf/kern.post.mk"
68
69# Create a kernel.bin file...
70# Copy the kernel to u-boot's booti image format (the elf headers are
71# stripped and a custom binary head blob is prepended), saving the
72# output in a temp file.  We also strip arm "marker" symbols which are
73# used only by elf toolchains.  Read the symbols from kernel.full and pass
74# them to arm_kernel_boothdr.awk, which generates a binary header blob
75# that goes on the front of the stripped kernel.  Cat the header blob
76# and the temp file together to make the kernel.bin file.
77${KERNEL_KO}.bin: ${FULLKERNEL}
78	@${OBJCOPY} --wildcard --strip-symbol='$$[adtx]*' \
79	    --output-target=binary ${.ALLSRC} ${.TARGET}.temp
80	@{ readelf -s ${.ALLSRC} | \
81	    ${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v8booti && \
82	    cat ${.TARGET}.temp; \
83	 } > ${.TARGET}
84	@rm ${.TARGET}.temp
85	@echo "created ${.TARGET} from ${.ALLSRC}"
86