xref: /freebsd/sys/conf/Makefile.arm (revision 1f4bcc459a76b7aa664f3fd557684cd0ba6da352)
1# Makefile.arm -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4# $FreeBSD$
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/arm/conf/``machineid''
12# after which you should do
13#	 config machineid
14# Generic makefile changes should be made in
15#	/sys/conf/Makefile.arm
16# after which config should be rerun for all machines.
17#
18
19# Which version of config(8) is required.
20%VERSREQ=	600013
21
22STD8X16FONT?=	iso
23
24.if !defined(S)
25.if exists(./@/.)
26S=	./@
27.else
28S=	../../..
29.endif
30.endif
31.include "$S/conf/kern.pre.mk"
32
33INCLUDES+= -I$S/contrib/libfdt -I$S/gnu/dts/include
34
35SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M}
36SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M}
37
38.if !defined(DEBUG) && !defined(PROFLEVEL)
39STRIP_FLAGS = -S
40.endif
41
42# We don't support gcc's thump interwork stuff, so disable it
43CFLAGS.gcc += -mno-thumb-interwork
44
45# We generally don't want fpu instructions in the kernel.
46CFLAGS.clang += -mfpu=none
47
48.if !empty(DDB_ENABLED)
49CFLAGS += -funwind-tables
50.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30500
51# clang < 3.5.0 requires us to tell it to emit assembly with unwind information
52CFLAGS += -mllvm -arm-enable-ehabi
53.endif
54.endif
55
56# hack because genassym.c includes sys/bus.h which includes these.
57genassym.o: bus_if.h device_if.h
58
59SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader ${_LDFLAGS} \
60	  -warn-common -export-dynamic -dynamic-linker /red/herring -o \
61	   ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o
62SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\
63		>ldscript.$M.noheader; \
64		${SYSTEM_LD_}; \
65		${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \
66		${KERNEL_KO}.bin; \
67		rm ${FULLKERNEL}.noheader
68
69FILES_CPU_FUNC = \
70	$S/$M/$M/cpufunc_asm_arm9.S \
71	$S/$M/$M/cpufunc_asm_xscale.S $S/$M/$M/cpufunc_asm.S \
72	$S/$M/$M/cpufunc_asm_xscale_c3.S $S/$M/$M/cpufunc_asm_armv5_ec.S \
73	$S/$M/$M/cpufunc_asm_fa526.S $S/$M/$M/cpufunc_asm_sheeva.S \
74	$S/$M/$M/cpufunc_asm_pj4b.S $S/$M/$M/cpufunc_asm_armv6.S \
75	$S/$M/$M/cpufunc_asm_armv7.S
76
77.if defined(KERNPHYSADDR)
78KERNEL_EXTRA=trampoline
79KERNEL_EXTRA_INSTALL=kernel.gz.tramp
80trampoline: ${KERNEL_KO}.tramp
81${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
82	echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h
83	sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
84	sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
85	    ldscript.$M.tramp.noheader
86	echo "#include <machine/asm.h>" >tmphack.S
87	echo "ENTRY(_start)" >>tmphack.S
88	echo "bl _startC" >>tmphack.S
89	${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
90	    -g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
91	eval $$(stat -s ${KERNEL_KO}.tmp) && \
92	    echo "#define KERNSIZE $$st_size" >>opt_kernname.h
93	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
94	    tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
95	    ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp
96	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \
97	    ldscript.$M.tramp.noheader \
98	    tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
99	    ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
100	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
101	    ${KERNEL_KO}.tramp.bin
102	${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp
103	echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" >opt_kernname.h
104	eval $$(stat -s ${KERNEL_KO}.tmp) && \
105	    echo "#define KERNSIZE $$st_size" >>opt_kernname.h
106	gzip -f9 ${KERNEL_KO}.tmp
107	eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
108	    echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
109	${CC} -O2 -ffreestanding -DKZIP -I. -I$S -c $S/kern/inflate.c -o \
110	    inflate-tramp.o
111	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
112	    -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
113	    $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
114	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \
115	    ldscript.$M.tramp.noheader \
116	    -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
117	    $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
118	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
119	    ${KERNEL_KO}.gz.tramp.bin
120	rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
121	    inflate-tramp.o tmphack.S
122.endif
123
124%BEFORE_DEPEND
125
126%OBJS
127
128%FILES.c
129
130%FILES.s
131
132%FILES.m
133
134%CLEAN
135
136CLEAN+=	ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader
137
138CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \
139	ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \
140	${KERNEL_KO}.gz.tramp.bin
141
142ldscript.$M: $S/conf/ldscript.$M
143	cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \
144	  sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M
145%RULES
146
147.include "$S/conf/kern.post.mk"
148