]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/conf/Makefile.arm
Support armv7 builds for userland
[FreeBSD/FreeBSD.git] / sys / conf / Makefile.arm
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
22 STD8X16FONT?=   iso
23
24 .if !defined(S)
25 .if exists(./@/.)
26 S=      ./@
27 .else
28 S=      ../../..
29 .endif
30 .endif
31 .include "$S/conf/kern.pre.mk"
32
33 INCLUDES+= -I$S/contrib/libfdt -I$S/gnu/dts/include 
34
35 SYSTEM_LD:= ${SYSTEM_LD:$S/conf/ldscript.$M=ldscript.$M}
36 SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M}
37
38 .if !defined(DEBUG) && !defined(PROFLEVEL)
39 STRIP_FLAGS = -S
40 .endif
41
42 # We don't support gcc's thump interwork stuff, so disable it
43 CFLAGS.gcc += -mno-thumb-interwork
44
45 # We generally don't want fpu instructions in the kernel.
46 CFLAGS.clang += -mfpu=none
47
48 .if !empty(DDB_ENABLED)
49 CFLAGS += -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
52 CFLAGS += -mllvm -arm-enable-ehabi
53 .endif
54 .endif
55
56 # hack because genassym.c includes sys/bus.h which includes these.
57 genassym.o: bus_if.h device_if.h
58
59 SYSTEM_LD_ = ${LD} -m ${LD_EMULATION} -Bdynamic -T ldscript.$M.noheader \
60         ${_LDFLAGS} --no-warn-mismatch --warn-common --export-dynamic \
61         --dynamic-linker /red/herring \
62         -o ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o
63 SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\
64                 >ldscript.$M.noheader; \
65                 ${SYSTEM_LD_}; \
66                 ${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \
67                 ${KERNEL_KO}.bin; \
68                 rm ${FULLKERNEL}.noheader
69
70 FILES_CPU_FUNC = \
71         $S/$M/$M/cpufunc_asm_arm9.S \
72         $S/$M/$M/cpufunc_asm_xscale.S $S/$M/$M/cpufunc_asm.S \
73         $S/$M/$M/cpufunc_asm_xscale_c3.S $S/$M/$M/cpufunc_asm_armv5_ec.S \
74         $S/$M/$M/cpufunc_asm_fa526.S $S/$M/$M/cpufunc_asm_sheeva.S \
75         $S/$M/$M/cpufunc_asm_pj4b.S $S/$M/$M/cpufunc_asm_armv6.S \
76         $S/$M/$M/cpufunc_asm_armv7.S
77
78 .if ${MACHINE_ARCH:Marmv[67]*} == "" && defined(KERNPHYSADDR)
79 KERNEL_EXTRA=trampoline
80 KERNEL_EXTRA_INSTALL=kernel.gz.tramp
81 trampoline: ${KERNEL_KO}.tramp
82 ${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
83         echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h 
84         sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
85         sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
86             ldscript.$M.tramp.noheader
87         echo "#include <machine/asm.h>" >tmphack.S
88         echo "ENTRY(_start)" >>tmphack.S
89         echo "bl _startC" >>tmphack.S
90         ${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
91             -g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
92         eval $$(stat -s ${KERNEL_KO}.tmp) && \
93             echo "#define KERNSIZE $$st_size" >>opt_kernname.h
94         ${CC} -O -nostdlib -I. -I$S \
95             -Xlinker -T -Xlinker ldscript.$M.tramp \
96             -DELF_TRAMPOLINE \
97             tmphack.S \
98             $S/$M/$M/elf_trampoline.c \
99             $S/$M/$M/inckern.S \
100             ${FILES_CPU_FUNC} \
101             -o ${KERNEL_KO}.tramp
102         ${CC} -O -nostdlib -I. -I$S \
103             -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
104             -DELF_TRAMPOLINE \
105             tmphack.S \
106             $S/$M/$M/elf_trampoline.c \
107             $S/$M/$M/inckern.S \
108             ${FILES_CPU_FUNC} \
109             -o ${KERNEL_KO}.tramp.noheader 
110         ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
111             ${KERNEL_KO}.tramp.bin 
112         ${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp 
113         echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" >opt_kernname.h 
114         eval $$(stat -s ${KERNEL_KO}.tmp) && \
115             echo "#define KERNSIZE $$st_size" >>opt_kernname.h
116         gzip -f9 ${KERNEL_KO}.tmp
117         eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
118             echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
119         ${CC} -O2 -ffreestanding -I. -I$S -c \
120             -DKZIP -DELF_TRAMPOLINE \
121             $S/kern/inflate.c \
122             -o inflate-tramp.o
123         ${CC} -O -nostdlib -I. -I$S \
124             -Xlinker -T -Xlinker ldscript.$M.tramp \
125             -DKZIP -DELF_TRAMPOLINE \
126             tmphack.S \
127             $S/$M/$M/elf_trampoline.c \
128             inflate-tramp.o \
129             $S/$M/$M/inckern.S \
130             ${FILES_CPU_FUNC} \
131             -o ${KERNEL_KO}.gz.tramp
132         ${CC} -O -nostdlib -I. -I$S \
133             -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
134             -DKZIP -DELF_TRAMPOLINE \
135             tmphack.S \
136             $S/$M/$M/elf_trampoline.c \
137             inflate-tramp.o \
138             $S/$M/$M/inckern.S \
139             ${FILES_CPU_FUNC} \
140             -o ${KERNEL_KO}.tramp.noheader
141         ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
142             ${KERNEL_KO}.gz.tramp.bin
143         rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
144             inflate-tramp.o tmphack.S
145 .endif
146
147 %BEFORE_DEPEND
148
149 %OBJS
150
151 %FILES.c
152
153 %FILES.s
154
155 %FILES.m
156
157 %CLEAN
158
159 CLEAN+= ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader
160
161 CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \
162         ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \
163         ${KERNEL_KO}.gz.tramp.bin
164
165 ldscript.$M: $S/conf/ldscript.$M
166         cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \
167           sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M
168 %RULES
169         
170 .include "$S/conf/kern.post.mk"