ar71xx: move DomyWifi DW33D to nand subtarget
[openwrt/openwrt.git] / target / linux / ar71xx / image / Makefile
1 #
2 # Copyright (C) 2008-2011 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 JFFS2_BLOCKSIZE = 64k 128k 256k
9
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/image.mk
12
13 KERNEL_LOADADDR = 0x80060000
14
15 DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD_ID NETGEAR_HW_ID CMDLINE CONSOLE IMAGE_SIZE BOARDNAME LOADER_FLASH_OFFS LOADER_TYPE
16
17 ifeq ($(SUBTARGET),generic)
18 include ./tp-link.mk
19 include ./ubnt.mk
20 include ./generic.mk
21 include ./legacy-devices.mk
22 endif
23 ifeq ($(SUBTARGET),nand)
24 include ./nand.mk
25 endif
26 include ./legacy.mk
27
28 define Build/netgear-squashfs
29 rm -rf $@.fs $@.squashfs
30 mkdir -p $@.fs/image
31 cp $@ $@.fs/image/uImage
32 $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
33 $@.fs $@.squashfs \
34 -noappend -root-owned -be -b 65536 \
35 $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
36
37 dd if=/dev/zero bs=1k count=1 >> $@.squashfs
38 mkimage \
39 -A mips -O linux -T filesystem -C none \
40 -M $(NETGEAR_KERNEL_MAGIC) \
41 -a 0xbf070000 -e 0xbf070000 \
42 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
43 -d $@.squashfs $@
44 rm -rf $@.squashfs $@.fs
45 endef
46
47 define Build/netgear-uImage
48 $(call Build/uImage,$(1) -M $(NETGEAR_KERNEL_MAGIC))
49 endef
50
51 define Build/loader-common
52 rm -rf $@.src
53 $(MAKE) -C lzma-loader \
54 PKG_BUILD_DIR="$@.src" \
55 TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
56 BOARD="$(BOARDNAME)" \
57 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
58 $(1) compile loader.$(LOADER_TYPE)
59 mv "$@.$(LOADER_TYPE)" "$@"
60 rm -rf $@.src
61 endef
62
63 define Build/loader-okli-compile
64 $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
65 endef
66
67 define Build/loader-kernel
68 $(call Build/loader-common,LOADER_DATA="$@")
69 endef
70
71 define Build/loader-kernel-cmdline
72 $(call Build/loader-common,LOADER_DATA="$@" KERNEL_CMDLINE="$(CMDLINE)")
73 endef
74
75 define Build/loader-okli
76 dd if=$(KDIR)/loader-$(1).gz bs=7680 conv=sync of="$@.new"
77 cat "$@" >> "$@.new"
78 mv "$@.new" "$@"
79 endef
80
81 define Build/relocate-kernel
82 rm -rf $@.relocate
83 $(CP) ../../generic/image/relocate $@.relocate
84 $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
85 ( \
86 dd if=$@.relocate/loader.bin bs=32 conv=sync && \
87 perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
88 cat "$@" \
89 ) > "$@.new"
90 mv "$@.new" "$@"
91 rm -rf $@.relocate
92 endef
93
94 define Build/copy-file
95 cat "$(1)" > "$@"
96 endef
97
98 define Device/Default
99 BOARDNAME :=
100 DEVICE_PROFILE = $$(BOARDNAME)
101 PROFILES = Default Minimal $$(DEVICE_PROFILE)
102 MTDPARTS :=
103 BLOCKSIZE := 64k
104 FILESYSTEMS = $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-$$(BLOCKSIZE)
105 CONSOLE = ttyS0,115200
106 CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
107 KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
108 COMPILE :=
109 IMAGES := sysupgrade.bin
110 IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
111 endef
112
113 $(eval $(call BuildImage))