USE_LLVM := 0 CROSS_GCC := arm-none-eabi- ifeq ($(USE_LLVM),1) COMPILER := LLVM=1 else COMPILER := CROSS_COMPILE=$(CROSS_GCC) endif PATCHDIR := ${HOME}/linux-stericsson build_dir := $(CURDIR)/build-gemini output_dir := $(HOME) rootfs := $(HOME)/rootfs-gemini.cpio rootfsbase := $(shell basename $(rootfs)) install_dir := $(build_dir)/install tftp_dir := /var/lib/tftpboot nfs_dir := /mnt/storage/nfsroot/gemini 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") #variant := sq201 #variant := sl93512r #variant := dlink-dir-685 variant := dlink-dns-313 #variant := nas4220b dtb := $(build_dir)/arch/arm/boot/dts/gemini/gemini-$(variant).dtb cmdline := "console=ttyS0,19200n8 fotg210-udc,g_serial" make_parallel := -j$(makethreads) -l$(makejobs) make_options := -f Makefile \ ARCH=arm \ $(make_parallel) \ $(COMPILER) \ KBUILD_OUTPUT=$(build_dir) # make_flags := CONFIG_DEBUG_SECTION_MISMATCH=y .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config - configure the kernel" @echo "make build - build the kernel and produce a RAMdisk image" @echo @echo "example:" @echo "make -f gemini.mak config" @echo "make -f gemini.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) $(MAKE) $(make_options) gemini_defconfig config-initramfs: have-rootfs config-base FORCE @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-openwrt: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable PARTITION_ADVANCED \ --enable EXT4_FS \ --enable EXT4_POSIX_ACL \ --enable MTD_ROOTFS_ROOT_DEV \ --enable MTD_SPLIT \ --set-str MTD_SPLIT_FIRMWARE_NAME firmware \ --enable MTD_SPLIT_SQUASHFS_ROOT \ --enable MTD_SPLIT_SUPPORT \ --enable SQUASHFS \ --enable SQUASHFS_XZ \ --enable OVERLAY_FS \ --enable DEVTMPFS \ --enable CGROUPS \ --enable INOTIFY_USER \ --enable SIGNALFD \ --enable TIMERFD \ --enable EPOLL \ --enable NET \ --enable UNIX \ --enable SYSFS config-nas-features: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable CIFS \ --enable CIFS_SMB2 \ --enable TUN # Config options needed to bring up rootfs on distros config-distro: config-base config-openwrt $(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-earlydebug: config-base FORCE $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_KERNEL \ --enable DEBUG_LL \ --enable EARLY_PRINTK \ --set-str CMDLINE "earlyprintk" config-multiplatform: config-base $(CURDIR)/scripts/config --file $(config_file) \ --disable ARCH_MULTI_V7 \ --disable ARCH_MULTI_V6 \ --disable ARCH_MULTI_V5 \ --enable ARCH_MULTI_V4 \ --enable ARCH_GEMINI 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-gemini-features: config-base config-multiplatform $(CURDIR)/scripts/config --file $(config_file) \ --enable PREEMPT \ --enable NO_HZ_IDLE \ --enable DEVTMPFS \ --enable NEW_LEDS \ --enable LEDS_CLASS \ --enable LEDS_GPIO \ --enable LEDS_TRIGGERS \ --enable LEDS_TRIGGER_HEARTBEAT \ --enable SERIAL_OF_PLATFORM \ --enable INPUT \ --disable INPUT_MOUSEDEV \ --disable INPUT_MOUSEDEV_PSAUX \ --enable INPUT_EVDEV \ --enable INPUT_KEYBOARD \ --enable KEYBOARD_GPIO \ --enable RTC_CLASS \ --enable RTC_DRV_GEMINI \ --enable MTD \ --enable MTD_OF_PARTS \ --enable MTD_PHYSMAP \ --enable MTD_PHYSMAP_OF \ --enable MTD_CFI \ --enable MTD_OTP \ --enable MTD_CFI_INTELEXT \ --enable MTD_CFI_AMDSTD \ --enable MTD_CFI_STAA \ --enable WATCHDOG \ --enable PCI \ --enable ATA \ --enable ATA_BMDMA \ --enable PATA_FTIDE010 \ --enable AMBA_PL08X \ --enable DMATEST \ --enable CMA \ --disable CMA_SIZE_SEL_MBYTES \ --enable CMA_SIZE_SEL_PERCENTAGE \ --enable DRM \ --enable DRM_TVE200 \ --enable FB \ --enable FRAMEBUFFER_CONSOLE \ --enable LOGO \ --enable NET_VENDOR_CORTINA \ --enable GEMINI_ETHERNET \ --enable HIGH_RES_TIMERS \ --enable UNIX \ --enable HIGHMEM \ --enable CRYPTO_HW \ --enable CRYPTO_DEV_SL3516 \ --enable DEBUG_FS config-sq201-features: config-base config-multiplatform config-gemini-features $(CURDIR)/scripts/config --file $(config_file) \ --enable USB_EHCI_HCD \ --enable EHCI_ROOT_HUB_TT \ --enable USB_EHCI_PCI \ --enable USB_UHCI_HCD \ --enable PHYLIB \ --enable MDIO_BITBANG \ --enable MDIO_GPIO \ --enable MARVELL_PHY \ --enable SPI \ --enable SPI_MASTER \ --enable SPI_GPIO \ --enable HAVE_NET_DSA \ --enable NET_DSA \ --enable NET_DSA_VITESSE_VSC73XX \ --enable BRIDGE \ --enable VLAN_8021Q \ --enable BRIDGE_VLAN_FILTERING \ --enable WIRELESS \ --enable CFG80211 \ --enable MAC80211 \ --enable CFG80211_WEXT \ --enable NETDEVICES \ --enable NET_CORE \ --enable WLAN \ --enable WLAN_VENDOR_RALINK \ --disable USB_NET_DRIVERS \ --disable WLAN_VENDOR_ADMTEK \ --disable WLAN_VENDOR_ATH \ --disable WLAN_VENDOR_ATMEL \ --disable WLAN_VENDOR_BROADCOM \ --disable WLAN_VENDOR_CISCO \ --disable WLAN_VENDOR_INTEL \ --disable WLAN_VENDOR_INTERSIL \ --disable WLAN_VENDOR_MARVELL \ --disable WLAN_VENDOR_MEDIATEK \ --enable WLAN_VENDOR_RALINK \ --enable RT2X00 \ --enable RT61PCI \ --disable WLAN_VENDOR_REALTEK \ --disable WLAN_VENDOR_RSI \ --disable WLAN_VENDOR_ST \ --disable WLAN_VENDOR_TI \ --disable WLAN_VENDOR_ZYDAS \ --enable MTD_REDBOOT_PARTS config-dir685-features: config-base config-multiplatform config-gemini-features config-nas-features $(CURDIR)/scripts/config --file $(config_file) \ --enable DRM_PANEL_ILITEK_IL9322 \ --enable I2C \ --enable I2C_GPIO \ --enable SPI \ --enable SPI_MASTER \ --enable SPI_GPIO \ --enable INPUT \ --enable INPUT_KEYBOARD \ --enable KEYBOARD_DLINK_DIR685 \ --enable HWMON \ --enable SENSORS_GPIO_FAN \ --enable REGULATOR \ --enable REGULATOR_FIXED_VOLTAGE \ --enable NET \ --enable INET \ --enable WIRELESS \ --enable CFG80211 \ --enable MAC80211 \ --enable CFG80211_WEXT \ --enable NETDEVICES \ --enable NET_CORE \ --enable WLAN \ --enable WLAN_VENDOR_RALINK \ --enable PHYLIB \ --enable MDIO_BITBANG \ --enable MDIO_GPIO \ --enable HAVE_NET_DSA \ --enable NET_DSA \ --enable NET_DSA_REALTEK \ --enable NET_DSA_REALTEK_SMI \ --enable NET_DSA_REALTEK_RTL8366RB \ --enable BRIDGE \ --enable VLAN_8021Q \ --enable BRIDGE_VLAN_FILTERING \ --enable ETHERNET \ --enable NET_VENDOR_CORTINA \ --enable GEMINI_ETHERNET \ --disable USB_NET_DRIVERS \ --disable WLAN_VENDOR_ADMTEK \ --disable WLAN_VENDOR_ATH \ --disable WLAN_VENDOR_ATMEL \ --disable WLAN_VENDOR_BROADCOM \ --disable WLAN_VENDOR_CISCO \ --disable WLAN_VENDOR_INTEL \ --disable WLAN_VENDOR_INTERSIL \ --disable WLAN_VENDOR_MARVELL \ --disable WLAN_VENDOR_MEDIATEK \ --enable WLAN_VENDOR_RALINK \ --enable RT2X00 \ --enable RT2800PCI \ --disable WLAN_VENDOR_REALTEK \ --disable WLAN_VENDOR_RSI \ --disable WLAN_VENDOR_ST \ --disable WLAN_VENDOR_TI \ --disable WLAN_VENDOR_ZYDAS \ --enable THERMAL \ --enable THERMAL_HWMON \ --enable SENSORS_DRIVETEMP config-dns313-features: config-base config-multiplatform config-gemini-features config-nas-features $(CURDIR)/scripts/config --file $(config_file) \ --enable I2C \ --enable I2C_GPIO \ --enable HWMON \ --enable SENSORS_GPIO_FAN \ --enable SENSORS_LM75 \ --enable THERMAL \ --enable THERMAL_HWMON \ --enable NET \ --enable PHYLIB \ --enable MDIO_BITBANG \ --enable MDIO_GPIO \ --enable REALTEK_PHY \ --enable LEDS_TRIGGER_DISK \ --enable MTD_JEDECPROBE \ --enable SCSI_MQ_DEFAULT \ --enable IOSCHED_BFQ \ --enable MQ_IOSCHED_KYBER \ --enable MQ_IOSCHED_DEADLINE # --enable FUNCTION_TRACER # --enable FUNCTION_GRAPH_TRACER # --enable FTRACE # --enable FTRACE_SYSCALLS # CMDLINE "ftrace=events trace_event=syscalls\:*" config-trace: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable FTRACE \ --enable FTRACE_SYSCALLS \ --disable TRACING_EVENTS_GPIO 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-cfi: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable CFI_CLANG \ --enable CFI_PERMISSIVE \ --enable FTRACE \ --enable FUNCTION_TRACER \ --enable LKDTM config-ksmbd: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable SMB_SERVER config-usb-host: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable USB_FOTG210 \ --enable USB_FOTG210_HCD config-usb-device: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable USB_FOTG210 \ --enable USB_FOTG210_HCD \ --enable USB_GADGET \ --enable USB_G_SERIAL \ --enable U_SERIAL_CONSOLE \ --enable USB_FOTG210_UDC \ --disable USB_CONN_GPIO \ --enable USB_GPIO_VBUS config-rtl8366rb-dsatest: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable HAVE_NET_DSA \ --enable NET_DSA \ --enable NET_DSA_REALTEK \ --enable NET_DSA_REALTEK_SMI \ --enable NET_DSA_REALTEK_RTL8366RB \ --enable NET_DSA_LOOP # config-initramfs config-kasan config-earlydebug config-initramfs config: config-base config-gemini-features config-storage config-sq201-features config-dir685-features config-dns313-features config-multiplatform config-openwrt config-ksmbd config-usb-device $(CURDIR)/scripts/config --file $(config_file) \ --set-str CMDLINE $(cmdline) \ --disable CMDLINE_FROM_BOOTLOADER \ --disable CMDLINE_EXTEND \ --enable JFFS2_SUMMARY \ --enable JFFS2_COMPRESSION_OPTIONS \ --enable JFFS2_LZO \ --enable AEABI \ --enable OABI_COMPAT \ --enable NET_DSA_VITESSE_VSC73XX \ --enable NET_DSA_VITESSE_VSC73XX_SPI \ --enable CPU_IDLE \ --enable CPU_IDLE_GOV_TEO \ --disable CPU_IDLE_GOV_MENU \ --enable ARM_CPUIDLE \ --enable ARM_GEMINI_CPUIDLE \ --enable PACKET yes "" | make $(make_options) oldconfig # Russell is skeptic about these. # --enable AEABI # --enable OABI_COMPAT menuconfig: FORCE if [ ! -d $(build_dir) ] ; then \ echo "no build dir" ; \ exit 1 ; \ fi $(MAKE) $(make_options) menuconfig $(MAKE) $(make_options) savedefconfig saveconfig: config-base config-gemini-features config-sq201-features config-dir685-features config-dns313-features FORCE yes "" | make $(make_options) oldconfig $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm/configs/gemini_defconfig # Tag on KBUILD_VERBOSE=1 to get verbose build output build-zimage: have-crosscompiler $(MAKE) $(make_options) zImage $(make_flags) build-modules: build-zimage $(MAKE) $(make_options) modules $(make_flags) rm -rf /tmp/gemini-modules mkdir -p /tmp/gemini-modules $(MAKE) $(make_options) INSTALL_MOD_PATH=/tmp/gemini-modules \ modules_install $(make_flags) cd /tmp/gemini-modules && tar cf $(output_dir)/gemini-modules.tar lib if [ -f $(output_dir)/gemini-modules.tar.gz ] ; then \ rm -f $(output_dir)/gemini-modules.tar.gz ; \ fi gzip -9 $(output_dir)/gemini-modules.tar build-dtbs: FORCE $(MAKE) $(make_options) dtbs W=1 $(make_flags) check-bindings: FORCE $(MAKE) $(make_options) dt_binding_check $(make_flags) $(MAKE) $(make_options) dtbs_check $(make_flags) build-zimage-dt: build-zimage build-dtbs @if [ ! -r $(dtb) ] ; then \ echo "NO DTB in $(dtb)!" ; \ exit 1 ; \ fi @echo "Copy zImage to $(output_dir)/zImage" cp $(build_dir)/arch/arm/boot/zImage $(output_dir)/zImage @echo "Catenate DTB onto zImage $(output_dir)/zImage..." cat $(dtb) >> $(output_dir)/zImage # If we have a TFTP boot directory @if [ -w $(tftp_dir) ] ; then \ echo "copy zImage to $(tftp_dir)" ; \ cp $(output_dir)/zImage $(tftp_dir) ; \ fi @if [ -w $(nfs_dir) ] ; then \ echo "copy zImage to $(nfs_dir)" ; \ cp $(output_dir)/zImage $(nfs_dir) ; \ fi @echo "Boot sequence:" @echo @echo "load -m tftp -b 0x400000" # @echo "169.254.1.1" @echo "192.168.1.2" @echo "zImage" @echo "go 0x400000" build-nas4220b-image: build-zimage-dt @echo "Create a NAS4220B image" echo -en "\x07\x1c\xa0\xe3\xf6\x10\x81\xe3" > $(output_dir)/nas4220-zImage cat $(output_dir)/zImage >> $(output_dir)/nas4220-zImage build-dns313-images: build-zimage-dt @echo "Create a HDD image" if [ -d $(output_dir)/dns313-images/.boot ] ; then \ rm -rf $(output_dir)/dns313-images/.boot ; \ fi mkdir -p $(output_dir)/dns313-images/.boot dns313-header $(output_dir)/zImage \ $(output_dir)/dns313-images/.boot/zImage echo "dummy" > $(output_dir)/dns313-images/dummyfile dns313-header $(output_dir)/dns313-images/dummyfile \ $(output_dir)/dns313-images/.boot/rootfs.tgz dns313-header $(output_dir)/dns313-images/dummyfile \ $(output_dir)/dns313-images/.boot/rd.gz rm $(output_dir)/dns313-images/dummyfile cd $(output_dir)/dns313-images && tar -cvf dlink-dns313-bootpart.tar .boot && mv dlink-dns313-bootpart.tar $(output_dir) if [ -f $(output_dir)/dlink-dns313-bootpart.tar.gz ] ; then \ rm $(output_dir)/dlink-dns313-bootpart.tar.gz ; \ fi gzip -9 $(output_dir)/dlink-dns313-bootpart.tar @echo "complete." build: build-zimage-dt @echo "complete." headers: have-rootfs have-crosscompiler build-zimage FORCE $(MAKE) $(make_options) headers_install INSTALL_HDR_PATH=/tmp 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: