CROSS_COMPILE ?= arm-linux-gnueabihf- build_dir := $(CURDIR)/build-u300 output_dir := $(HOME) rootfs := $(HOME)/rootfs-u300.cpio install_dir := $(build_dir)/install config_file := $(build_dir)/.config strip := $(CROSS_COMPILE)strip objcopy := $(CROSS_COMPILE)objcopy rootfsbase := $(shell basename $(rootfs)) dtb := $(build_dir)/arch/arm/boot/dts/ste-u300.dtb make_options := -f Makefile \ ARCH=arm \ CROSS_COMPILE=$(CROSS_COMPILE) \ KBUILD_OUTPUT=$(build_dir) .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config [PLATFORM=foo] - configure for platform \"foo\"" @echo "make build - build the kernel and produce a RAMdisk image" @echo @echo "example for ATAG boot:" @echo "make -f u300.mak config && make -f u300.mak build" @echo "example for appended devicetree boot:" @echo "make -f u300.mak config-dt && make -f u300.mak build-dt" .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 @if [ ! -r $(rootfs) ] ; then \ echo "ERROR: rootfs at $(rootfs) not readable" ; \ echo "ABORTING." ; \ exit 1 ; \ fi .PHONY: have-crosscompiler have-crosscompiler: @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 config-base: have-rootfs FORCE @mkdir -p $(build_dir) @cp $(rootfs) $(build_dir)/$(rootfsbase) $(MAKE) $(make_options) u300_defconfig config-initramfs: config-base FORCE # 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-mainlined-features: config-base FORCE $(CURDIR)/scripts/config --file $(config_file) \ --enable PM \ --enable DEBUG_FS \ --enable MMC_CLKGATE \ --disable MMC_DEBUG \ --enable MTD \ --enable MTD_PARTITIONS \ --enable MTD_CMDLINE_PARTS \ --enable MTD_NAND \ --enable MTD_NAND_FSMC \ --disable ARCH_MULTI_V7 config-common: have-rootfs config-base config-initramfs FORCE # Reconfigure a bit $(CURDIR)/scripts/config --file $(config_file) \ --set-str CMDLINE "root=/dev/ram0 console=ttyAMA0,115200n8 lpj=515072 earlyprintk" \ --enable DEBUG_LL \ --enable EARLY_PRINTK \ --enable COMMON_CLK_DEBUG \ --enable ARM_TEST \ --enable ARM_TCM_TEST config: config-common FORCE yes "" | make $(make_options) oldconfig config-dt: config-common FORCE $(CURDIR)/scripts/config --file $(config_file) \ --enable USE_OF \ --enable OF_GPIO \ --enable ARM_APPENDED_DTB \ --enable ARM_ATAG_DTB_COMPAT \ --enable PROC_DEVICETREE yes "" | make $(make_options) oldconfig menuconfig: FORCE $(MAKE) $(make_options) menuconfig saveconfig: config-base config-mainlined-features FORCE yes "" | make $(make_options) oldconfig $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm/configs/u300_defconfig build-zimage: have-crosscompiler FORCE $(MAKE) $(make_options) -j 4 zImage CONFIG_DEBUG_SECTION_MISMATCH=y @echo "Copy zImage to $(output_dir)/vmlinux.bin" @cp -f $(build_dir)/arch/arm/boot/zImage $(output_dir)/vmlinux.bin build-dtbs: FORCE $(MAKE) $(make_options) -j 4 dtbs CONFIG_DEBUG_SECTION_MISMATCH=y build: build-zimage build-dtbs FORCE @if [ ! -r $(dtb) ] ; then \ echo "NO DTB in $(dtb)!" ; \ exit 1 ; \ fi @echo "Catenate DTB onto zImage $(output_dir)/vmlinux.bin" cat $(dtb) >> $(output_dir)/vmlinux.bin @echo "DONE" clean: $(MAKE) -f Makefile mrproper 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: