USE_LLVM := 1 CROSS_GCC := aarch64-none-linux-gnu- ifeq ($(USE_LLVM),1) COMPILER := LLVM=1 else COMPILER := CROSS_COMPILE=$(CROSS_GCC) endif build_dir := $(CURDIR)/build-aarch64 output_dir := $(HOME) output_nfs := /mnt/storage/nfsroot/aarch64 rootfs := $(HOME)/rootfs-aarch64.cpio rootfsbase := $(shell basename $(rootfs)) config_file := $(build_dir)/.config makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) makethreads := $(shell dc -e "$(makejobs) 1 + p") tftproot := /var/lib/tftpboot make_options := -f Makefile \ -j$(makethreads) -l$(makejobs) \ ARCH=arm64 \ $(COMPILER) \ KBUILD_OUTPUT=$(build_dir) .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config - configure for aarch64" @echo "make build - build the kernel with initramfs" .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 options needed to bring up rootfs on distros config-distro: FORCE $(CURDIR)/scripts/config --file $(config_file) \ --enable PARTITION_ADVANCED \ --enable LDM_PARTITION \ --enable MSDOS_PARTITION \ --enable DEVTMPFS \ --enable CGROUPS \ --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 NET \ --disable ETHTOOL_NETLINK \ --disable WIRELESS \ --enable UNIX \ --disable BQL \ --enable FILE_LOCKING config-base: FORCE @mkdir -p $(build_dir) $(MAKE) $(make_options) defconfig config-renesas-hack: FORCE @mkdir -p $(build_dir) $(MAKE) $(make_options) renesas_defconfig config-tiny: config-base no "" | make $(make_options) oldconfig $(MAKE) $(make_options) tinyconfig config-mtd: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable MTD \ --enable MTD_CFI \ --enable MTD_PHYSMAP \ --enable MTD_PHYSMAP_OF \ --enable MTD_CFI_INTELEXT \ --enable MTD_AFS_PARTS \ --enable DEBUG_FS config-initramfs: 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 config-earlydebug: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_KERNEL \ --enable EARLY_PRINTK \ --enable SERIAL_EARLYCON \ --set-str CMDLINE "earlyprintk" config-ftrace: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable FTRACE \ --enable FUNCTION_TRACER config-kasan: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable KASAN \ --enable KASAN_OUTLINE \ --enable STACKTRACE \ --enable SLUB_DEBUG_ON \ --enable TEST_KASAN config-storage: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable PARTITION_ADVANCED \ --enable LDM_PARTITION \ --enable MSDOS_PARTITION \ --enable EXT4_FS \ --enable EXT4_USE_FOR_EXT2 \ --enable FAT_FS \ --enable VFAT_FS config-virtio-root: config-base config-storage $(CURDIR)/scripts/config --file $(config_file) \ --enable VIRTIO_MENU \ --enable VIRTIO_MMIO \ --enable VIRTIO_MMIO_CMDLINE_DEVICES \ --enable VIRTIO_BLK \ --enable BLK_DEV_SD \ --enable SCSI_LOWLEVEL \ --enable SCSI_VIRTIO config-graphics: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DRM \ --enable DRM_VIRTIO_GPU \ --enable DRM_PL111 \ --enable DRM_SII902X \ --enable DRM_HDLCD \ --enable DRM_I2C_NXP_TDA998X \ --enable FB_DEVICE \ --enable LOGO \ --enable FRAMEBUFFER_CONSOLE \ --enable VIRTIO_INPUT # These are needed so that we don't get a gazillion deferred probes # when using a kernel without any modules. config-coresight: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable CORESIGHT \ --enable CORESIGHT_LINKS_AND_SINKS \ --enable CORESIGHT_LINK_AND_SINK_TMC \ --enable CORESIGHT_CATU \ --enable CORESIGHT_SINK_TPIU \ --enable CORESIGHT_SINK_ETBV10 \ --enable CORESIGHT_SOURCE_ETM4X \ --enable CORESIGHT_STM \ --enable CORESIGHT_CTCU \ --enable CORESIGHT_CPU_DEBUG \ --enable CORESIGHT_CTI config-jc-base: FORCE mkdir -p $(build_dir) #cp ~/config-jc $(config_file) cp ~/config-jc-normal $(config_file) config-jc: config-jc-base config-distro config-initramfs yes "" | make $(make_options) oldconfig @echo "CONFIGURED" config-iob: config-renesas-hack yes "" | make $(make_options) oldconfig $(CURDIR)/scripts/config --file $(config_file) \ --disable RANDOMIZE_BASE # config-virtio-root for QEMU # config-initramfs # config: config-base config-ftrace config: config-base config-distro config-graphics config-virtio-root #config: config-base config-distro config-earlydebug config-initramfs yes "" | make $(make_options) oldconfig $(CURDIR)/scripts/config --file $(config_file) \ --disable RANDOMIZE_BASE \ --enable TTY menuconfig: FORCE if [ ! -d $(build_dir) ] ; then \ echo "no build dir" ; \ exit 1 ; \ fi $(MAKE) $(make_options) menuconfig $(MAKE) $(make_options) savedefconfig saveconfig: FORCE $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm64/configs/defconfig saveconfig-bfq: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable IOSCHED_BFQ $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm64/configs/defconfig build-dtbs: FORCE $(MAKE) $(make_options) dtbs @echo "Copy Juno DTB to $(output_dir)/juno.dtb" @cp -f $(build_dir)/arch/arm64/boot/dts/arm/juno.dtb $(output_dir)/juno.dtb @cp -f $(build_dir)/arch/arm64/boot/dts/arm/foundation-v8.dtb $(output_dir)/foundation-v8.dtb # If we have a TFTP boot directory if [ -w $(tftproot) ] ; then \ cp -f $(build_dir)/arch/arm64/boot/dts/arm/juno.dtb $(tftproot) ; \ fi check-bindings: FORCE $(MAKE) $(make_options) dt_binding_check -k $(make_flags) $(MAKE) $(make_options) dtbs_check -k $(make_flags) build-zimage: have-crosscompiler FORCE $(MAKE) $(make_options) Image build: have-crosscompiler build-dtbs build-zimage FORCE @echo "Copy vmlinux to $(output_dir)/vmlinux" @cp -f $(build_dir)/vmlinux $(output_dir)/vmlinux @echo "Copy Image to $(output_dir)/Image" @cp -f $(build_dir)/arch/arm64/boot/Image $(output_dir)/Image @which fnord > /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 arm64 \ -O linux \ -T kernel \ -C none \ -a 0x80080000 \ -e 0x80080000 \ -n "AARCH64 kernel" \ -d $(output_dir)/Image \ $(output_dir)/uImage ; \ fi # If we have a TFTP boot directory if [ -w $(tftproot) ] ; then \ cp $(output_dir)/vmlinux $(tftproot) ; \ cp $(output_dir)/Image $(tftproot) ; \ fi if [ -w $(output_nfs) ]; then \ echo "Copying to NFS root $(output_nfs)" ; \ cp -f $(output_dir)/vmlinux $(output_nfs) ; \ cp -f $(output_dir)/Image $(output_nfs) ; \ fi @echo "TFTP boot:" @echo "setenv bootargs console=ttyAMA0,115200n8 root=/dev/sda1 rw rootwait rootfstype=ext4 init=/sbin/init earlycon=pl011,0x7ff80000 debug ; setenv serverip 192.168.1.140 ; setenv ipaddr 192.168.1.35 ; tftpboot 0x80000000 Image ; tftpboot 0x84000000 juno.dtb ; booti 0x80000000 - 0x84000000" @echo "local link:" @echo "setenv bootargs console=ttyAMA0,115200n8 root=/dev/sda1 rw rootwait rootfstype=ext4 init=/sbin/init earlycon=pl011,0x7ff80000 debug ; setenv serverip 169.254.1.1 ; setenv ipaddr 169.254.1.2 ; tftpboot 0x80000000 Image ; tftpboot 0x84000000 juno.dtb ; booti 0x80000000 - 0x84000000" clean: $(MAKE) -f Makefile clean rm -rf $(build_dir) FORCE: