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(ARM_BIG_ENDIAN) 39CC += -mbig-endian 40SYSTEM_LD += -EB 41LD += -EB 42.else 43CC += -mlittle-endian 44SYSTEM_LD += -EL 45LD += -EL 46.endif 47 48 49.if !defined(DEBUG) && !defined(PROFLEVEL) 50STRIP_FLAGS = -S 51.endif 52 53DDB_ENABLED!= grep DDB opt_ddb.h || true 54 55.if empty(DDB_ENABLED) 56CFLAGS += -mno-apcs-frame 57.endif 58 59SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader \ 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 69.if defined(MFS_IMAGE) 70SYSTEM_LD_TAIL += ;sh ${S}/tools/embed_mfs.sh ${KERNEL_KO}.bin ${MFS_IMAGE}; 71.endif 72 73FILES_CPU_FUNC = $S/$M/$M/cpufunc_asm_arm7tdmi.S \ 74 $S/$M/$M/cpufunc_asm_arm8.S $S/$M/$M/cpufunc_asm_arm9.S \ 75 $S/$M/$M/cpufunc_asm_sa1.S $S/$M/$M/cpufunc_asm_arm10.S \ 76 $S/$M/$M/cpufunc_asm_xscale.S $S/$M/$M/cpufunc_asm.S \ 77 $S/$M/$M/cpufunc_asm_xscale_c3.S $S/$M/$M/cpufunc_asm_armv5_ec.S \ 78 $S/$M/$M/cpufunc_asm_sheeva.S $S/$M/$M/cpufunc_asm_fa526.S 79KERNEL_EXTRA=trampoline 80KERNEL_EXTRA_INSTALL=kernel.gz.tramp 81trampoline: ${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 -Xlinker -T -Xlinker ldscript.$M.tramp \ 95 tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \ 96 ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp 97 ${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \ 98 ldscript.$M.tramp.noheader \ 99 tmphack.S $S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S \ 100 ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader 101 ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \ 102 ${KERNEL_KO}.tramp.bin 103 ${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp 104 echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" \ 105 >opt_kernname.h 106 eval $$(stat -s ${KERNEL_KO}.tmp) && \ 107 echo "#define KERNSIZE $$st_size" >>opt_kernname.h 108 gzip -9 ${KERNEL_KO}.tmp 109 eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \ 110 echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h 111 ${CC} -O2 -DKZIP -I. -I$S -c $S/kern/inflate.c -o inflate-tramp.o 112 ${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \ 113 -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \ 114 $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp 115 ${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker \ 116 ldscript.$M.tramp.noheader \ 117 -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \ 118 $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.tramp.noheader 119 ${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \ 120 ${KERNEL_KO}.gz.tramp.bin 121 rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \ 122 inflate-tramp.o tmphack.S 123 124MKMODULESENV+= MACHINE=${MACHINE} 125 126%BEFORE_DEPEND 127 128%OBJS 129 130%FILES.c 131 132%FILES.s 133 134%FILES.m 135 136%CLEAN 137 138CLEAN+= ldscript.$M ${KERNEL_KO}.bin ldscript.$M.noheader 139 140.if ${DDB_ENABLED} != "" 141CLEAN+= ${KERNEL_KO}.tramp ${KERNEL_KO}.tramp.bin ldscript.$M.tramp \ 142 ldscript.$M.tramp.noheader ${KERNEL_KO}.gz.tramp \ 143 ${KERNEL_KO}.gz.tramp.bin 144 145.endif 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