xref: /freebsd/sys/conf/Makefile.arm (revision 2f02600abfddfc4e9f20dd384a2e729b451e16bd)
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=	600004
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
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.if ${COMPILER_TYPE} != "clang"
43CFLAGS += -mno-thumb-interwork
44.endif
45
46.if empty(DDB_ENABLED)
47.if defined(WITHOUT_ARM_EABI) && ${COMPILER_TYPE} != "clang"
48CFLAGS += -mno-apcs-frame
49.endif
50.elif !defined(WITHOUT_ARM_EABI)
51CFLAGS += -funwind-tables
52.if ${COMPILER_TYPE} == "clang"
53# clang requires us to tell it to emit assembly with unwind information
54CFLAGS += -mllvm -arm-enable-ehabi
55.endif
56.endif
57
58SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader ${LDFLAGS} \
59	  -warn-common -export-dynamic -dynamic-linker /red/herring -o \
60	   ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o
61SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\
62		>ldscript.$M.noheader; \
63		${SYSTEM_LD_}; \
64		${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \
65		${KERNEL_KO}.bin; \
66		rm ${FULLKERNEL}.noheader
67
68.if defined(MFS_IMAGE)
69SYSTEM_LD_TAIL += ;sh ${S}/tools/embed_mfs.sh ${KERNEL_KO}.bin ${MFS_IMAGE};
70.endif
71
72FILES_CPU_FUNC =	$S/$M/$M/cpufunc_asm_arm7tdmi.S \
73	$S/$M/$M/cpufunc_asm_arm8.S $S/$M/$M/cpufunc_asm_arm9.S \
74	$S/$M/$M/cpufunc_asm_sa1.S $S/$M/$M/cpufunc_asm_arm10.S \
75	$S/$M/$M/cpufunc_asm_xscale.S $S/$M/$M/cpufunc_asm.S \
76	$S/$M/$M/cpufunc_asm_xscale_c3.S $S/$M/$M/cpufunc_asm_armv5_ec.S \
77	$S/$M/$M/cpufunc_asm_fa526.S $S/$M/$M/cpufunc_asm_sheeva.S \
78	$S/$M/$M/cpufunc_asm_pj4b.S $S/$M/$M/cpufunc_asm_armv6.S \
79	$S/$M/$M/cpufunc_asm_armv7.S
80
81KERNEL_EXTRA=trampoline
82KERNEL_EXTRA_INSTALL=kernel.gz.tramp
83trampoline: ${KERNEL_KO}.tramp
84${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
85	echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h
86	sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
87	sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
88	    ldscript.$M.tramp.noheader
89	echo "#include <machine/asm.h>" >tmphack.S
90	echo "ENTRY(_start)" >>tmphack.S
91	echo "bl _startC" >>tmphack.S
92	${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
93	    -g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
94	eval $$(stat -s ${KERNEL_KO}.tmp) && \
95	    echo "#define KERNSIZE $$st_size" >>opt_kernname.h
96	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
97	    tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
98	    ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp
99	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \
100	    ldscript.$M.tramp.noheader \
101	    tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \
102	    ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
103	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
104	    ${KERNEL_KO}.tramp.bin
105	${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp
106	echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" >opt_kernname.h
107	eval $$(stat -s ${KERNEL_KO}.tmp) && \
108	    echo "#define KERNSIZE $$st_size" >>opt_kernname.h
109	gzip -f9 ${KERNEL_KO}.tmp
110	eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
111	    echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
112	${CC} -O2 -ffreestanding -DKZIP -I. -I$S -c $S/kern/inflate.c -o \
113	    inflate-tramp.o
114	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
115	    -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
116	    $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp
117	${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \
118	    ldscript.$M.tramp.noheader \
119	    -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
120	    $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader
121	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
122	    ${KERNEL_KO}.gz.tramp.bin
123	rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
124	    inflate-tramp.o tmphack.S
125
126MKMODULESENV+=	MACHINE=${MACHINE}
127
128%BEFORE_DEPEND
129
130%OBJS
131
132%FILES.c
133
134%FILES.s
135
136%FILES.m
137
138%CLEAN
139
140CLEAN+=	ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader
141
142CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \
143	ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \
144	${KERNEL_KO}.gz.tramp.bin
145
146ldscript.$M: $S/conf/ldscript.$M
147	cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \
148	  sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M
149%RULES
150
151.include "$S/conf/kern.post.mk"
152