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