USE_LLVM := 1 CROSS_GCC := arm-none-eabi- ifeq ($(USE_LLVM),1) COMPILER := LLVM=1 else COMPILER := CROSS_COMPILE=$(CROSS_GCC) endif ARMMACHINE ?= multi_v7 CROSS_COMPILE ?= arm-none-eabi- PATCHDIR := ${HOME}/linux-stericsson build_dir := $(CURDIR)/build-$(ARMMACHINE) output_dir := $(HOME) #rootfs := $(HOME)/rootfs-msm8660.cpio rootfs := $(HOME)/rootfs-vexpress.cpio rootfsbase := $(shell basename $(rootfs)) install_dir := $(build_dir)/install config_file := $(build_dir)/.config strip := $(CROSS_COMPILE)strip objcopy := $(CROSS_COMPILE)objcopy makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) makethreads := $(shell dc -e "$(makejobs) 1 + p") tftproot := /var/lib/tftpboot ifeq ($(ARMMACHINE),stm32) kernelobject := xipImage else kernelobject := zImage endif make_options := -f Makefile \ -j$(makethreads) -l$(makejobs) \ ARCH=arm \ $(COMPILER) \ KBUILD_OUTPUT=$(build_dir) #make_flags := CONFIG_DEBUG_SECTION_MISMATCH=y .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config [ARMMACHINE=foo] - configure for platform \"foo\"" @echo "make build - build the kernel and produce a RAMdisk image" @echo @echo "example:" @echo "make -f $(ARMMACHINE).mak ARMMACHINE=foo config" @echo "make -f $(ARMMACHINE).mak ARMMACHINE=foo build" .PHONY: have-rootfs have-rootfs: @if [ ! -f $(rootfs) ] ; then \ echo "ERROR: no rootfs at $(rootfs)" ; \ echo "This is needed to boot the system." ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "Rootfs available at $(rootfs)" ; \ fi .PHONY: have-crosscompiler have-crosscompiler: @if [ $(USE_LLVM) -eq 1 ] ; then \ echo "LLVM OK" ; \ else \ echo -n "Check that $(CROSS_COMPILE)gcc is available..." ; \ which $(CROSS_COMPILE)gcc > /dev/null ; \ if [ ! $$? -eq 0 ] ; then \ echo "ERROR: cross-compiler $(CROSS_COMPILE)gcc not in PATH=$$PATH!" ; \ echo "ABORTING." ; \ exit 1 ; \ else \ echo "OK" ;\ fi \ fi config-base: FORCE @mkdir -p $(build_dir) $(MAKE) $(make_options) $(ARMMACHINE)_defconfig $(CURDIR)/scripts/config --file $(config_file) \ --enable PREEMPT \ --enable DEBUG_FS config-initramfs: config-base @cp $(rootfs) $(build_dir)/$(rootfsbase) # Configure in the initramfs $(CURDIR)/scripts/config --file $(config_file) \ --enable BLK_DEV_INITRD \ --set-str INITRAMFS_SOURCE $(rootfsbase) \ --enable RD_GZIP \ --enable INITRAMFS_COMPRESSION_GZIP config-earlydebug: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_KERNEL \ --enable DEBUG_LL \ --enable EARLY_PRINTK \ --enable DEBUG_VEXPRESS_UART0_RS1 \ --enable DEBUG_UNCOMPRESS \ --set-str CMDLINE "earlyprintk" config-cfi: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable CFI_CLANG \ --enable CFI_PERMISSIVE \ --enable FTRACE \ --enable FUNCTION_TRACER \ --enable LKDTM config: have-rootfs config-base config-initramfs config-cfi yes "" | make $(make_options) oldconfig allmodconfig: config make $(make_options) allmodconfig allyesconfig: config make $(make_options) allyesconfig menuconfig: FORCE if [ ! -d $(build_dir) ] ; then \ echo "no build dir" ; \ exit 1 ; \ fi $(MAKE) $(make_options) menuconfig $(MAKE) $(make_options) savedefconfig saveconfig: FORCE # yes "" | make $(make_options) oldconfig # $(CURDIR)/scripts/config --file $(config_file) \ # --enable PREEMPT $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm/configs/$(ARMMACHINE)_defconfig build-dtbs: FORCE $(MAKE) $(make_options) dtbs $(make_flags) check-bindings: FORCE $(MAKE) $(make_options) dt_binding_check $(make_flags) $(MAKE) $(make_options) dtbs_check $(make_flags) build-kernelobject: have-crosscompiler $(MAKE) $(make_options) $(kernelobject) $(make_flags) build-modules: build-kernelobject $(MAKE) $(make_options) modules $(make_flags) build: have-rootfs have-crosscompiler build-kernelobject @echo "Copy vmlinux to $(output_dir)/vmlinux" @cp -f $(build_dir)/vmlinux $(output_dir)/vmlinux ifeq ($(ARMMACHINE),stm32) @echo "Copy xipImage to $(output_dir)/xipImage" @cp -f $(build_dir)/arch/arm/boot/xipImage $(output_dir)/xipImage else @echo "Copy zImage to $(output_dir)/zImage" @cp -f $(build_dir)/arch/arm/boot/zImage $(output_dir)/zImage endif @which mkimage > /dev/null ; \ if [ ! $$? -eq 0 ] ; then \ echo "mkimage not in PATH=$$PATH" ; \ echo "This tool creates the uImage and comes from the uboot tools" ; \ echo "On Ubuntu/Debian sudo apt-get install uboot-mkimage" ; \ echo "SKIPPING uImage GENERATION" ; \ else \ mkimage \ -A arm \ -O linux \ -T kernel \ -C none \ -a 0x00008000 \ -e 0x00008000 \ -n "$(ARMMACHINE) kernel" \ -d $(output_dir)/zImage \ $(output_dir)/uImage ; \ fi # If we have a TFTP boot directory if [ -w $(tftproot) ] ; then \ cp $(output_dir)/vmlinux $(tftproot) ; \ cp $(output_dir)/$(kernelobject) $(tftproot) ; \ fi clean: $(MAKE) -f Makefile clean rm -rf $(build_dir) # Rules without commands or prerequisites that do not match a file name # are considered to always change when make runs. This means that any rule # that depends on FORCE will always be remade also. FORCE: