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# "makeoptions KERNVIRTADDR=" is now optional, supply the default value. 57.if empty(KERNVIRTADDR) 58KERNVIRTADDR= 0xc0000000 59.endif 60 61# hack because genassym.c includes sys/bus.h which includes these. 62genassym.o: bus_if.h device_if.h 63 64SYSTEM_LD_ = ${LD} -m ${LD_EMULATION} -Bdynamic -T ldscript.$M.noheader \ 65 ${_LDFLAGS} --no-warn-mismatch --warn-common --export-dynamic \ 66 --dynamic-linker /red/herring \ 67 -o ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o 68SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\ 69 >ldscript.$M.noheader; \ 70 ${SYSTEM_LD_}; \ 71 ${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \ 72 ${KERNEL_KO}.bin; \ 73 rm ${FULLKERNEL}.noheader 74 75FILES_CPU_FUNC = \ 76 $S/$M/$M/cpufunc_asm_arm9.S \ 77 $S/$M/$M/cpufunc_asm_xscale.S $S/$M/$M/cpufunc_asm.S \ 78 $S/$M/$M/cpufunc_asm_xscale_c3.S $S/$M/$M/cpufunc_asm_armv5_ec.S \ 79 $S/$M/$M/cpufunc_asm_fa526.S $S/$M/$M/cpufunc_asm_sheeva.S 80 81.if ${MACHINE_ARCH:Marmv[67]*} == "" && defined(KERNPHYSADDR) 82KERNEL_EXTRA=trampoline 83KERNEL_EXTRA_INSTALL=kernel.gz.tramp 84trampoline: ${KERNEL_KO}.tramp 85${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c 86 echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h 87 sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp 88 sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \ 89 ldscript.$M.tramp.noheader 90 echo "#include <machine/asm.h>" >tmphack.S 91 echo "ENTRY(_start)" >>tmphack.S 92 echo "bl _startC" >>tmphack.S 93 ${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \ 94 -g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp 95 eval $$(stat -s ${KERNEL_KO}.tmp) && \ 96 echo "#define KERNSIZE $$st_size" >>opt_kernname.h 97 ${CC} -O -nostdlib -I. -I$S \ 98 -Xlinker -T -Xlinker ldscript.$M.tramp \ 99 -DELF_TRAMPOLINE \ 100 tmphack.S \ 101 $S/$M/$M/elf_trampoline.c \ 102 $S/$M/$M/inckern.S \ 103 ${FILES_CPU_FUNC} \ 104 -o ${KERNEL_KO}.tramp 105 ${CC} -O -nostdlib -I. -I$S \ 106 -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \ 107 -DELF_TRAMPOLINE \ 108 tmphack.S \ 109 $S/$M/$M/elf_trampoline.c \ 110 $S/$M/$M/inckern.S \ 111 ${FILES_CPU_FUNC} \ 112 -o ${KERNEL_KO}.tramp.noheader 113 ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \ 114 ${KERNEL_KO}.tramp.bin 115 ${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp 116 echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" >opt_kernname.h 117 eval $$(stat -s ${KERNEL_KO}.tmp) && \ 118 echo "#define KERNSIZE $$st_size" >>opt_kernname.h 119 gzip -f9 ${KERNEL_KO}.tmp 120 eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \ 121 echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h 122 ${CC} -O2 -ffreestanding -I. -I$S -c \ 123 -DKZIP -DELF_TRAMPOLINE \ 124 $S/kern/subr_inflate.c \ 125 -o inflate-tramp.o 126 ${CC} -O -nostdlib -I. -I$S \ 127 -Xlinker -T -Xlinker ldscript.$M.tramp \ 128 -DKZIP -DELF_TRAMPOLINE \ 129 tmphack.S \ 130 $S/$M/$M/elf_trampoline.c \ 131 inflate-tramp.o \ 132 $S/$M/$M/inckern.S \ 133 ${FILES_CPU_FUNC} \ 134 -o ${KERNEL_KO}.gz.tramp 135 ${CC} -O -nostdlib -I. -I$S \ 136 -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \ 137 -DKZIP -DELF_TRAMPOLINE \ 138 tmphack.S \ 139 $S/$M/$M/elf_trampoline.c \ 140 inflate-tramp.o \ 141 $S/$M/$M/inckern.S \ 142 ${FILES_CPU_FUNC} \ 143 -o ${KERNEL_KO}.tramp.noheader 144 ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \ 145 ${KERNEL_KO}.gz.tramp.bin 146 rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \ 147 inflate-tramp.o tmphack.S 148.endif 149 150%BEFORE_DEPEND 151 152%OBJS 153 154%FILES.c 155 156%FILES.s 157 158%FILES.m 159 160%CLEAN 161 162CLEAN+= ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader 163 164CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \ 165 ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \ 166 ${KERNEL_KO}.gz.tramp.bin 167 168ldscript.$M: $S/conf/ldscript.$M 169 cat $S/conf/ldscript.$M|sed s/KERNPHYSADDR/${KERNPHYSADDR}/g| \ 170 sed s/KERNVIRTADDR/${KERNVIRTADDR}/g > ldscript.$M 171%RULES 172 173.include "$S/conf/kern.post.mk" 174