USE_LLVM := 1 CROSS_GCC := arm-none-eabi- ifeq ($(USE_LLVM),1) COMPILER := LLVM=1 else COMPILER := CROSS_COMPILE=$(CROSS_GCC) endif build_dir := $(CURDIR)/build-kirkwood output_dir := $(HOME) rootfs := $(HOME)/rootfs-kirkwood.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/kirkwood-pogoplug-series-4.dtb makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) makethreads := $(shell dc -e "$(makejobs) 1 + p") make_parallel := -j$(makethreads) -l$(makejobs) make_options := -f Makefile \ ARCH=arm \ $(make_parallel) \ $(COMPILER) \ 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:" @echo "make -f kirkwood.mak config" @echo "make -f kirkwood.mak 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) @if [ -r $(config_file) ] ; then \ rm $(config_file) ; \ fi $(MAKE) $(make_options) mvebu_v5_defconfig config-initramfs: config-base have-rootfs @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 # For early printk config-earlydebug: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_LL \ --enable EARLY_PRINTK \ --enable DEBUG_MVEBU_UART0_ALTERNATE \ --set-str CMDLINE "root=/dev/ram0 console=ttyS0,115200n8 earlyprintk" config-devicetree: config-base # Configure in the optional device tree if available if [ -r $(dtb) ] ; then \ $(CURDIR)/scripts/config --file $(config_file) \ --enable USE_OF \ --enable ARM_APPENDED_DTB \ --enable ARM_ATAG_DTB_COMPAT \ --enable ATAGS \ --enable PROC_DEVICETREE ; \ fi config-bfq: config-base @echo "Enabling BFQ" $(CURDIR)/scripts/config --file $(config_file) \ --enable MQ_IOSCHED_DEADLINE \ --enable MQ_IOSCHED_KYBER \ --enable IOSCHED_BFQ \ --enable BFQ_GROUP_IOSCHED config-cfi: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable CFI_CLANG \ --enable CFI_PERMISSIVE \ --enable LKDTM # Config options needed to bring up rootfs on distros config-distro: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable PARTITION_ADVANCED \ --enable LDM_PARTITION \ --enable MSDOS_PARTITION \ --enable EXT4_FS \ --enable EXT4_POSIX_ACL \ --enable DEVTMPFS \ --enable CGROUPS \ --enable INOTIFY_USER \ --enable SIGNALFD \ --enable TIMERFD \ --enable EPOLL \ --enable NET \ --enable SYSFS \ --disable SYSFS_DEPRECATED \ --enable PROC_FS \ --enable FHANDLE \ --enable TMPFS_XATTR \ --enable TMPFS_POSIX_ACL \ --enable CGROUP_SCHED \ --enable FAIR_GROUP_SCHED \ --enable CFS_BANDWIDTH \ --disable RT_GROUP_SCHED \ --enable SECCOMP \ --enable SECCOMP_FILTER \ --enable CHECKPOINT_RESTORE \ --enable CGROUP_FREEZER \ --enable CGROUP_DEVICE \ --enable CPUSETS \ --enable PROC_PID_CPUSET \ --enable CGROUP_CPUACCT \ --enable RESOURCE_COUNTERS \ --enable CGROUP_MEM_RES_CTLR \ --enable CGROUP_MEM_RES_CTLR_DISABLED \ --enable CGROUP_MEM_RES_CTLR_SWAP \ --enable CGROUP_SCHED \ --enable FAIR_GROUP_SCHED \ --enable BLK_CGROUP \ --enable NAMESPACES \ --enable SCHED_AUTOGROUP \ --enable FHANDLE \ --enable SWAP \ --enable AUTOFS4_FS \ --enable BSD_PROCESS_ACCT \ --enable BSD_PROCESS_ACCT_V3 \ --enable TASKSTATS \ --enable TASK_DELAY_ACCT \ --enable TASK_XACCT \ --enable TASK_IO_ACCOUNTING \ --enable BUILD_BIN2C \ --enable IKCONFIG \ --enable IKCONFIG_PROC \ --enable PAGE_COUNTER \ --enable MEMCG \ --enable MEMCG_SWAP \ --enable MEMCG_SWAP_ENABLED \ --enable MEMCG_KMEM \ --enable CGROUP_PERF \ --enable CGROUP_WRITEBACK \ --enable USER_NS \ --enable BLK_DEV_BSG \ --enable BLK_DEV_BSGLIB \ --enable BLK_DEV_INTEGRITY \ --enable NET_INGRESS \ --enable IP_ADVANCED_ROUTER \ --set-str UEVENT_HELPER_PATH "" \ --enable WANT_DEV_COREDUMP \ --enable DEV_COREDUMP \ --enable CHR_DEV_SG \ --enable KEYS \ --enable ENCRYPTED_KEYS \ --enable SECURITY \ --enable SECURITYFS \ --enable SECURITY_NETWORK \ --enable SECURITY_NETWORK_XFRM \ --enable SECURITY_PATH \ --enable INTEGRITY \ --enable CRYPTO_USER_API \ --enable CRYPTO_USER_API_HASH \ --enable CRYPTO_USER_API_SKCIPHER \ --enable CRYPTO_USER_API_AEAD \ --enable ARM_CRYPTO \ --enable CRYPTO_SHA1_ARM \ --enable CRYPTO_SHA256_ARM \ --enable CRYPTO_SHA512_ARM \ --enable CRYPTO_AES_ARM \ --enable BINARY_PRINTF \ --enable MD \ --enable BLK_DEV_DM_BUILTIN \ --enable BLK_DEV_DM \ --enable DM_CRYPT \ --enable DM_UEVENT \ --enable SCSI \ --enable USB_STORAGE config-mainlined-features: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable ARM_KIRKWOOD_CPUIDLE \ --enable MTD_UBI \ --enable UBIFS_FS \ --enable NO_HZ_COMMON \ --enable NO_HZ_IDLE \ --enable TICK_ONESHOT config-nas-features: config-base config-mainlined-features config-distro $(CURDIR)/scripts/config --file $(config_file) \ --enable CIFS \ --enable CIFS_SMB2 \ --enable TUN \ --enable CRYPTO_SHA256 \ --enable CRYPTO_SHA512 \ --enable CRYPTO_XTS # config-initramfs config: config-base config-mainlined-features config-devicetree config-distro config-nas-features config-bfq config-cfi # Reconfigure a bit $(CURDIR)/scripts/config --file $(config_file) \ --set-str CMDLINE "root=/dev/sda1 rw rootwait console=ttyS0,115200n8" \ --enable DEBUG_FS 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/mvebu_v5_defconfig updateconfig: config-base FORCE yes "" | make $(make_options) oldconfig $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm/configs/mvebu_v5_defconfig build-zimage: have-crosscompiler FORCE $(MAKE) $(make_options) zImage build-dtbs: FORCE $(MAKE) $(make_options) dtbs build: have-rootfs have-crosscompiler build-zimage build-dtbs FORCE @echo "Copy zImage to $(output_dir)/zImage..." @if [ -r $(build_dir)/arch/arm/boot/zImage ] ; then \ cp $(build_dir)/arch/arm/boot/zImage $(output_dir)/zImage ; \ fi @if [ -r $(dtb) ] ; then \ echo "Catenate DTB onto zImage ..." ; \ cat $(dtb) >> $(output_dir)/zImage ; \ fi # Generate uImage mkimage \ -A arm \ -O linux \ -T kernel \ -C none \ -a 0x00008000 \ -e 0x00008000 \ -n "Kirkwood Linux kernel" \ -d $(output_dir)/zImage \ $(output_dir)/uImage # If we have a TFTP boot directory @if [ -w /var/lib/tftpboot ] ; then \ echo "copy uImage to /var/lib/tftpboot" ; \ cp $(output_dir)/uImage /var/lib/tftpboot ; \ fi @echo "Boot from ethernet:" @echo "setenv bootargs console=ttyS0,115200n8 root=/dev/sda1 rw rootwait rootfstype=ext4;setenv serverip 192.168.1.170;setenv ipaddr 192.168.1.180;setenv bootfile uImage;tftpboot 0x00800000;bootm 0x00800000" TAGS: FORCE $(MAKE) $(make_options) TAGS clean: $(MAKE) -f Makefile clean rm -f $(module_files) rm -rf build # 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: