perf: fix build on PowerPC
[openwrt/openwrt.git] / target / linux / apm821xx / image / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2
3 include $(TOPDIR)/rules.mk
4 include $(INCLUDE_DIR)/image.mk
5
6 define Build/boot-img
7 $(RM) -rf $@.bootdir
8 mkdir -p $@.bootdir/boot
9
10 $(CP) $@.scr $@.bootdir/boot/boot.scr
11 $(CP) $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@.bootdir/boot/$(DEVICE_DTB)
12 $(CP) $(IMAGE_KERNEL) $@.bootdir/boot/uImage
13
14 genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \
15 --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \
16 --root $@.bootdir $@.boot
17
18 # convert it to revision 1 - needed for u-boot ext2load
19 $(STAGING_DIR_HOST)/bin/tune2fs -O filetype $@.boot
20 $(STAGING_DIR_HOST)/bin/e2fsck -pDf $@.boot > /dev/null
21 endef
22
23 define Build/boot-script
24 $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
25 -d mbl_boot.scr \
26 $@.scr
27 endef
28
29 define Build/export-dtb
30 cp $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@
31 endef
32
33 define Build/MuImage-initramfs
34 rm -rf $@.fakerd $@.new
35
36 dd if=/dev/zero of=$@.fakerd bs=32 count=1 conv=sync
37
38 # Netgear used an old uboot that doesn't have FIT support.
39 # So we are stuck with either a full ext2/4 fs in a initrd.
40 # ... or we try to make the "multi" image approach to work
41 # for us.
42 #
43 # Sadly, the "multi" image has to consists of three
44 # "fixed" parts in the following "fixed" order:
45 # 1. The kernel which is in $@
46 # 2. The (fake) initrd which is in $@.fakerd
47 # 3. The device tree binary which is in $@.dtb
48 #
49 # Now, given that we use the function for the kernel which
50 # already has a initramfs image inside, we still have to
51 # add a "fake" initrd (which a mkimage header) in the second
52 # part of the legacy multi image. Since we need to put the
53 # device tree stuff into part 3.
54
55 -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi -C $(1) \
56 -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) -n '$(BOARD_NAME) initramfs' \
57 -d $@:$@.fakerd:$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@.new
58 mv $@.new $@
59 rm -rf $@.fakerd
60 endef
61
62 define Build/prepend-dtb
63 cat "$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb" "$@" > "$@.new"
64 mv "$@.new" "$@"
65 endef
66
67 define Image/cpiogz
68 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
69 endef
70
71 define Device/Default
72 PROFILES := Default
73 KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
74 DEVICE_DTS :=
75 KERNEL_ENTRY := 0x00000000
76 KERNEL_LOADADDR := 0x00000000
77 DEVICE_DTS_DIR := ../dts
78 DEVICE_DTS = $(subst _,-,$(1))
79 endef
80
81 include $(SUBTARGET).mk
82
83 $(eval $(call BuildImage))