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