xref: /freebsd/sys/conf/Makefile.arm64 (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
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#
6# Makefile for FreeBSD
7#
8# This makefile is constructed from a machine description:
9#	config machineid
10# Most changes should be made in the machine description
11#	/sys/arm64/conf/``machineid''
12# after which you should do
13#	 config machineid
14# Generic makefile changes should be made in
15#	/sys/conf/Makefile.arm64
16# after which config should be rerun for all machines.
17#
18
19# Which version of config(8) is required.
20%VERSREQ=	600012
21
22.if !defined(S)
23S=	../../..
24.endif
25.include "$S/conf/kern.pre.mk"
26
27INCLUDES+= -I$S/contrib/libfdt -I$S/contrib/device-tree/include
28
29LINUX_DTS_VERSION!=	awk '/freebsd,dts-version/ { sub(/;$$/,"", $$NF); print $$NF }' $S/dts/freebsd-compatible.dts
30CFLAGS += -DLINUX_DTS_VERSION=\"${LINUX_DTS_VERSION}\"
31
32PERTHREAD_SSP_ENABLED!=	grep PERTHREAD_SSP opt_global.h || true ; echo
33.if !empty(PERTHREAD_SSP_ENABLED)
34. if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000
35ARM64_SSP_CFLAGS = -mstack-protector-guard=sysreg
36ARM64_SSP_CFLAGS += -mstack-protector-guard-reg=sp_el0
37ARM64_SSP_CFLAGS += -mstack-protector-guard-offset=0
38. else
39ARM64_SSP_CFLAGS += -DPERTHREAD_SSP_WARNING
40.  warning "Compiler is too old to support PERTHREAD_SSP"
41. endif
42CFLAGS += ${ARM64_SSP_CFLAGS}
43ARCH_FLAGS += ${ARM64_SSP_CFLAGS}
44.endif
45
46# Use a custom SYSTEM_LD command to generate the elf kernel, so we can
47# set the text segment start address, and also strip the "arm mapping
48# symbols" which have names like $a.0 and $d.2; see the document
49# "ELF for the ARM architecture" for more info on the mapping symbols.
50SYSTEM_LD= \
51	${SYSTEM_LD_BASECMD} \
52	    --defsym='text_start=kernbase + SIZEOF_HEADERS' \
53	    -o ${.TARGET} ${SYSTEM_OBJS} vers.o; \
54	$(OBJCOPY) \
55	    --wildcard \
56	    --strip-symbol='$$[adtx]*' \
57	    ${.TARGET}
58
59# Generate the .bin (booti images) kernel as an extra build output.
60# The targets and rules to generate these appear near the end of the file.
61KERNEL_EXTRA+= ${KERNEL_KO}.bin
62KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin
63
64.if !empty(DDB_ENABLED) || !empty(DTRACE_ENABLED) || !empty(HWPMC_ENABLED)
65CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
66.endif
67
68%BEFORE_DEPEND
69
70%OBJS
71
72%FILES.c
73
74%FILES.s
75
76%FILES.m
77
78%CLEAN
79CLEAN+=	${KERNEL_KO}.bin
80
81%RULES
82
83.include "$S/conf/kern.post.mk"
84
85# Create a kernel.bin file...
86# Copy the kernel to u-boot's booti image format (the elf headers are
87# stripped and a custom binary head blob is prepended), saving the
88# output in a temp file.  We also strip arm "marker" symbols which are
89# used only by elf toolchains.  Read the symbols from kernel.full and pass
90# them to arm_kernel_boothdr.awk, which generates a binary header blob
91# that goes on the front of the stripped kernel.  Cat the header blob
92# and the temp file together to make the kernel.bin file.
93${KERNEL_KO}.bin: ${FULLKERNEL}
94	@${OBJCOPY} --wildcard --strip-symbol='$$[adtx]*' \
95	    --output-target=binary ${FULLKERNEL} ${.TARGET}.temp
96	@{ ${NM} ${FULLKERNEL} | \
97	    ${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v8booti && \
98	    cat ${.TARGET}.temp; \
99	 } > ${.TARGET}
100	@rm ${.TARGET}.temp
101	@echo "created ${.TARGET} from ${.ALLSRC}"
102