USE_LLVM := 0 CROSS_GCC := armeb-openwrt-linux- ifeq ($(USE_LLVM),1) # lld does not support big endian COMPILER := LLVM=1 LD=ld.bfd else COMPILER := CROSS_COMPILE=$(CROSS_GCC) endif build_dir := $(CURDIR)/build-ixp4 output_dir := $(HOME) rootfs := $(HOME)/rootfs-ixp4.cpio rootfsbase := $(shell basename $(rootfs)) install_dir := $(build_dir)/install config_file := $(build_dir)/.config makejobs := $(shell grep '^processor' /proc/cpuinfo | sort -u | wc -l) makethreads := $(shell dc -e "$(makejobs) 1 + p") variant := ixp42x-linksys-nslu2 #variant := ixp42x-gateworks-gw2348 #variant := ixp43x-gateworks-gw2358 #variant := ixp42x-arcom-vulcan #variant := ixp42x-netgear-wg302v1 #variant := ixp42x-usrobotics-usr8200 dtb := $(build_dir)/arch/arm/boot/dts/intel/ixp/intel-$(variant).dtb tftp_dir := /var/lib/tftpboot nfs_dir := /mnt/storage/nfsroot/ixp4xx firmware_dir := /home/linus/src/firmware/ixp4xx-firmware make_parallel := -j$(makethreads) -l$(makejobs) make_options := -f Makefile \ ARCH=arm \ $(make_parallel) \ $(COMPILER) \ KBUILD_OUTPUT=$(build_dir) \ STAGING_DIR=/tmp .PHONY: help help: @echo "**** Common Makefile ****" @echo "make config - configure for platform " @echo "make build - build the kernel and produce a RAMdisk image" @echo @echo "example:" @echo "make -f ixp4.mak config" @echo "make -f ixp4.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) ixp4xx_defconfig $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_FS # --enable MTD_ROOTFS_ROOT_DEV # --enable MTD_SPLIT # --set-str MTD_SPLIT_FIRMWARE_NAME firmware # --enable MTD_SPLIT_SQUASHFS_ROOT # --enable MTD_SPLIT_SUPPORT config-openwrt: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable 32BIT \ --enable 64BIT_TIME \ --enable ADVISE_SYSCALLS \ --enable AEABI \ --enable AF_UNIX_OOB \ --enable AIO \ --enable ALLOW_DEV_COREDUMP \ --enable ANON_INODES \ --enable BLK_DEV \ --enable BLOCK \ --enable BPF \ --enable BPF_JIT \ --enable BPF_JIT_DEFAULT_ON \ --enable BPF_SYSCALL \ --enable BPF_UNPRIV_DEFAULT_OFF \ --enable BQL \ --enable BRANCH_PROFILE_NONE \ --enable BRIDGE \ --enable BRIDGE_IGMP_SNOOPING \ --enable BRIDGE_VLAN_FILTERING \ --enable CRC32 \ --enable CRC32_SARWATE \ --enable DEVPORT \ --enable EMBEDDED \ --enable EPOLL \ --enable EXPERT \ --enable EXPORTFS \ --enable EXT2_FS_XATTR \ --enable EXT4_USE_FOR_EXT2 \ --enable FSNOTIFY \ --enable FUTEX \ --enable FUTEX_PI \ --enable FW_LOADER \ --enable GENERIC_NET_UTILS \ --enable GENERIC_PTDUMP \ --enable HIGH_RES_TIMERS \ --enable INET \ --enable INOTIFY_USER \ --enable INPUT_EVDEV \ --enable IP_ADVANCED_ROUTER \ --enable IP_MROUTE_MULTIPLE_TABLES \ --enable IP_MULTICAST \ --enable IP_MULTIPLE_TABLES \ --enable IP_ROUTE_MULTIPATH \ --enable IP_ROUTE_VERBOSE \ --enable KUSER_HELPERS \ --enable MAY_USE_DEVLINK \ --enable MII \ --enable MTD \ --enable MTD_BLOCK \ --enable NET \ --enable NETDEVICES \ --enable NF_TABLES_ARP \ --enable NF_TABLES_BRIDGE \ --enable NF_TABLES_INET \ --enable NF_TABLES_IPV4 \ --enable NF_TABLES_IPV6 \ --enable NF_TABLES_NETDEV \ --enable JFFS2_FS \ --enable PACKET \ --enable POSIX_TIMERS \ --enable SIGNALFD \ --enable SQUASHFS \ --enable SQUASHFS_XZ \ --enable OVERLAY_FS \ --enable DEVTMPFS \ --enable CGROUPS \ --enable TIMERFD \ --enable TINY_RCU \ --enable TMPFS \ --enable TMPFS_XATTR \ --enable UNIX \ --enable SYSFS config-initramfs: config-base have-rootfs cp $(rootfs) $(build_dir)/$(rootfsbase) # Configure in the initramfs $(CURDIR)/scripts/config --file $(config_file) \ --enable BLK_DEV_RAM \ --enable BLK_DEV_INITRD \ --enable TMPFS \ --enable TMPFS_POSIX_ACL \ --set-str INITRAMFS_SOURCE $(rootfsbase) \ --enable INITRAMFS_COMPRESSION_XZ config-ext4-rootfs: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable PARTITION_ADVANCED \ --enable MSDOS_PARTITION \ --enable EFI_PARTITION \ --enable EXT3_FS \ --enable EXT4_FS \ --set-str CMDLINE "root=/dev/sda1 rw rootwait" \ --enable CONFIG_CMDLINE_EXTEND config-ksmbd: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable SMB_SERVER config-earlydebug: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable DEBUG_KERNEL \ --enable DEBUG_LL \ --enable EARLY_PRINTK config-cfi: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable CFI_CLANG \ --enable CFI_PERMISSIVE \ --enable LKDTM config-mainlined: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable NEW_LEDS \ --enable LEDS_CLASS \ --enable LEDS_GPIO \ --enable LEDS_TRIGGERS \ --enable LEDS_TRIGGER_HEARTBEAT \ --enable MTD \ --enable MTD_PHYSMAP \ --enable MTD_PHYSMAP_OF \ --enable MTD_CFI \ --enable MTD_CFI_INTELEXT \ --enable MTD_CFI_AMDSTD \ --enable MTD_CFI_ADV_OPTIONS \ --enable MTD_CFI_NOSWAP \ --enable MTD_OTP \ --enable MTD_REDBOOT_PARTS \ --enable PCI \ --enable PCI_IXP4XX \ --enable CRYPTO \ --enable CRYPTO_HW \ --enable CRYPTO_DEV_IXP4XX \ --enable HW_RANDOM \ --enable HW_RANDOM_IXP4XX \ --enable ATA \ --enable PATA_IXP4XX_CF \ --enable SERIAL_OF_PLATFORM \ --enable WAN \ --enable HDLC \ --enable IXP4XX_HSS config-nslu2: config-base config-ext4-rootfs config-ksmbd $(CURDIR)/scripts/config --file $(config_file) \ --enable RTC_DRV_X1205 \ --enable INPUT \ --enable INPUT_KEYBOARD \ --disable KEYBOARD_ATKBD \ --enable KEYBOARD_GPIO \ --enable POWER_RESET \ --enable POWER_RESET_GPIO \ --enable I2C \ --enable I2C_GPIO \ --enable PWM \ --enable PWM_GPIO \ --enable INPUT_MISC \ --enable INPUT_PWM_BEEPER config-avila: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable RTC_DRV_DS1672 \ --enable EEPROM_AT24 \ --disable EEPROM_LEGACY \ --enable SENSORS_AD7418 \ --enable GPIO_PCA953X \ --enable I2C \ --enable I2C_GPIO \ --enable NEW_LEDS \ --enable LEDS_CLASS \ --enable LEDS_GPIO \ --enable I2C_IOP3XX config-nas100d: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable RTC_DRV_PCF8563 \ --enable INPUT \ --enable INPUT_KEYBOARD \ --disable KEYBOARD_ATKBD \ --enable KEYBOARD_GPIO \ --enable POWER_RESET \ --enable POWER_RESET_GPIO \ --enable I2C \ --enable I2C_GPIO config-cambria: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable RTC_DRV_DS1672 \ --enable EEPROM_AT24 \ --disable EEPROM_LEGACY \ --enable SENSORS_AD7418 \ --enable GPIO_GW_PLD \ --enable I2C \ --enable I2C_GPIO \ --enable I2C_IOP3XX config-nfsroot: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable NFS_FS \ --disable NFS_V2 \ --enable ROOT_NFS \ --disable BLK_DEV_INITRD \ --set-str CMDLINE "root=/dev/nfs rw nfsroot=192.168.1.2:/var/lib/tftpboot/ixp4xx-root,tcp,v3 ip=dhcp" \ --enable CONFIG_CMDLINE_EXTEND # This requires the firmware files at the designated location # and will compile NPE firmware into the kernel. config-firmware: config-base $(CURDIR)/scripts/config --file $(config_file) \ --set-str EXTRA_FIRMWARE "NPE-A NPE-A-HSS NPE-B NPE-C" \ --set-str EXTRA_FIRMWARE_DIR "$(firmware_dir)" # This target has 64MB RAM and no space for initramfs, use NFS root! # This config will be hard to combine with support for other IXP4xx machines. config-wg302: config-base config-nfsroot config-firmware $(CURDIR)/scripts/config --file $(config_file) \ --enable PHYLIB \ --enable WIRELESS \ --enable CFG80211 \ --enable MAC80211 \ --enable CFG80211_WEXT \ --enable WLAN \ --enable WLAN_VENDOR_ATH \ --enable ATH5K \ --enable ATH5K_PCI \ --disable WLAN_VENDOR_ADMTEK \ --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 \ --disable WLAN_VENDOR_MICROCHIP \ --disable WLAN_VENDOR_PURELIFI \ --disable WLAN_VENDOR_QUANTENNA \ --disable WLAN_VENDOR_RALINK \ --disable WLAN_VENDOR_REALTEK \ --disable WLAN_VENDOR_RSI \ --disable WLAN_VENDOR_SILABS \ --disable WLAN_VENDOR_ST \ --disable WLAN_VENDOR_TI \ --disable WLAN_VENDOR_ZYDAS config-usr8200: config-base config-firmware $(CURDIR)/scripts/config --file $(config_file) \ --enable RTC_DRV_R7301 \ --enable HAVE_NET_DSA \ --enable NET_DSA \ --enable NET_DSA_MV88E6060 \ --enable FIREWIRE \ --enable FIREWIRE_OHCI \ --enable USB_EHCI_HCD \ --enable USB_PCI \ --enable USB_EHCI_PCI config-usb-gadget: config-base $(CURDIR)/scripts/config --file $(config_file) \ --enable USB_GADGET \ --enable USB_PXA25X # config-initramfs config-openwrt config-earlydebug # "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200" # Conflicts with config-initramfs: config-wg302 # config: config-base config-nslu2 config-openwrt config-ext4-rootfs config: config-base config-mainlined config-openwrt config-ext4-rootfs config-cambria config-nslu2 config-firmware config-ksmbd config-cfi $(CURDIR)/scripts/config --file $(config_file) \ --enable KERNEL_XZ yes "" | make $(make_options) oldconfig allconfig: config make $(make_options) allmodconfig menuconfig: FORCE if [ ! -d $(build_dir) ] ; then \ echo "no build dir" ; \ exit 1 ; \ fi $(MAKE) $(make_options) menuconfig #$(MAKE) $(make_options) savedefconfig #cp $(build_dir)/defconfig arch/arm/configs/ixp4xx_defconfig saveconfig: config-nslu2 config-nas100d yes "" | make $(make_options) oldconfig $(MAKE) $(make_options) savedefconfig cp $(build_dir)/defconfig arch/arm/configs/ixp4xx_defconfig build-zimage: have-crosscompiler $(MAKE) $(make_options) zImage build-zimage-no-dt: build-zimage @echo "Copy zImage to $(output_dir)/zImage" cp $(build_dir)/arch/arm/boot/zImage $(output_dir)/zImage @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 "Load:" @echo "ip_address -l 169.254.1.2 -h 169.254.1.1" @echo "load -r -v -b 0x00080000 -h 169.254.1.1 zImage" @echo "exec 0x00080000" 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 "Load:" @echo "ip_address -l 192.168.1.35 -h 192.168.1.2" @echo "load -r -v -b 0x00080000 -h 192.168.1.2 zImage" @echo "Boot:" @echo "exec 0x00080000" build: build-zimage-dt @echo "complete." build-modules: build $(MAKE) $(make_options) modules CONFIG_DEBUG_SECTION_MISMATCH=y 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: