build system cleanup/restructuring as described in http://lists.openwrt.org/pipermail...
[openwrt/staging/chunkeey.git] / target / linux / ar7-2.6 / image / Makefile
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 DROP_SECTIONS := .reginfo .mdebug .comment .note .pdr .options .MIPS.options
11 OBJCOPY_SREC := $(TARGET_CROSS)objcopy -S -O srec $(addprefix --remove-section=,$(DROP_SECTIONS))
12
13 LOADADDR := 0x94600000
14 KERNEL_ENTRY := 0x94100000
15 RAMSTART := 0x94000000
16 RAMSIZE := 0x00100000
17
18 LOADER_MAKEOPTS= \
19 KDIR=$(KDIR) \
20 LOADADDR=$(LOADADDR) \
21 KERNEL_ENTRY=$(KERNEL_ENTRY) \
22 RAMSTART=$(RAMSTART) \
23 RAMSIZE=$(RAMSIZE)
24
25 CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
26 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \
27 -pipe -mlong-calls -fno-common \
28 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap \
29 -DLOADADDR=$(LOADADDR)
30
31 define Build/Clean
32 $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
33 endef
34
35 define Image/Prepare
36 cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
37
38 $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
39 $(LOADER_MAKEOPTS) \
40 clean compile
41 $(OBJCOPY_SREC) $(KDIR)/loader.elf $(KDIR)/loader.srec
42 srec2bin $(KDIR)/loader.srec $(KDIR)/loader.bin
43 endef
44
45 define align/jffs2-64k
46 bs=65536 conv=sync
47 endef
48
49 define align/jffs2-128k
50 bs=131072 conv=sync
51 endef
52
53 define Image/Build/CyberTAN
54 (dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin) | \
55 $(STAGING_DIR_HOST)/bin/addpattern -p $(3) -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(4).bin
56 endef
57
58 #define Image/Build/sErCoMm
59 # cat sercomm/adam2.bin "$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin" > "$(KDIR)/dgfw.tmp"
60 # dd if=sercomm/$(2) of="$(KDIR)/dgfw.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc
61 # $(STAGING_DIR_HOST)/bin/dgfirmware -f -w "$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(3).img" "$(KDIR)/dgfw.tmp"
62 # rm -f "$(KDIR)/dgfw.tmp"
63 #endef
64
65 define Image/Build
66 dd if=$(KDIR)/loader.bin $(call align/$(1)) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin
67 cat $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/root.$(1) >> $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin
68 $(call prepare_generic_squashfs,$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin)
69 $(call Image/Build/CyberTAN,$(1),AG1B,AG1B,$(1))
70 $(call Image/Build/CyberTAN,$(1),WA21,WA21,$(1))
71 $(call Image/Build/CyberTAN,$(1),WA22,WA22,$(1))
72 $(call Image/Build/CyberTAN,$(1),WAG2,WAG2,$(1))
73 $(call Image/Build/CyberTAN,$(1),WA31,WA31 -b,$(1))
74 $(call Image/Build/CyberTAN,$(1),WA32,WA32 -b,$(1))
75 $(call Image/Build/CyberTAN,$(1),WA7A,WA7A -b,$(1))
76 $(call Image/Build/CyberTAN,$(1),WA7B,WA7B -b,$(1))
77 # $(call Image/Build/sErCoMm,$(1),dg834,$(1))
78 # $(call Image/Build/sErCoMm,$(1),jdr454wb,$(1))
79 endef
80
81 $(eval $(call BuildImage))