fix more typos
[openwrt.git] / target / linux / image / ar7 / Makefile
1 include $(TOPDIR)/rules.mk
2
3 KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
4
5 PKG_BUILD_DIR:=$(BUILD_DIR)/ar7loader
6
7 ifeq ($(IB),)
8 LOADADDR := 0x94020000
9 KERNEL_ENTRY := 0x${shell nm $(KDIR)/linux-$(KERNEL)*/vmlinux | grep kernel_entry | cut -d' ' -f1}
10 OUTPUT_FORMAT := elf32-tradlittlemips
11
12 CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
13 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \
14 -pipe -mlong-calls -fno-common \
15 -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap \
16 -DLOADADDR=$(LOADADDR)
17
18
19 $(PKG_BUILD_DIR):
20 mkdir -p $(PKG_BUILD_DIR)
21
22 $(PKG_BUILD_DIR)/zimage.script: src/zimage.script.in
23 sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \
24 -e 's/@@LOADADDR@@/$(LOADADDR)/' <$< >$@
25
26 $(PKG_BUILD_DIR)/ld.script: src/ld.script.in
27 sed -e 's/@@OUTPUT_FORMAT@@/$(OUTPUT_FORMAT)/' \
28 -e 's/@@LOADADDR@@/$(LOADADDR)/' <$< >$@
29
30 $(PKG_BUILD_DIR)/LzmaDecode.o: src/LzmaDecode.c
31 $(TARGET_CC) $(CFLAGS) -c -o $@ $<
32
33 $(PKG_BUILD_DIR)/loader.o: src/loader.c
34 $(TARGET_CC) $(CFLAGS) -c -o $@ $<
35
36 $(STAGING_DIR)/bin/srec2bin: src/srec2bin.c
37 $(HOSTCC) -o $@ $<
38
39 $(KDIR)/vmlinux.lzma: $(KDIR)/vmlinux
40 cat $^ | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $@ || (rm -f $@ && false)
41
42 $(KDIR)/vmlinux.bin: $(KDIR)/vmlinux.lzma compile
43 $(TARGET_CROSS)ld -T $(PKG_BUILD_DIR)/zimage.script -r -b binary $< -o $(KDIR)/zimage.o
44 $(TARGET_CROSS)ld -static -G 0 --defsym kernel_entry=$(KERNEL_ENTRY) -T $(PKG_BUILD_DIR)/ld.script \
45 $(PKG_BUILD_DIR)/loader.o \
46 $(PKG_BUILD_DIR)/LzmaDecode.o \
47 $(KDIR)/zimage.o \
48 -o $(KDIR)/loader
49 $(TARGET_CROSS)objcopy -O srec $(KDIR)/loader $(KDIR)/ram_zimage.sre
50 $(STAGING_DIR)/bin/srec2bin $(KDIR)/ram_zimage.sre $@
51
52 $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin: $(KDIR)/vmlinux.bin
53 endif
54
55 $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin:
56 cp $(KDIR)/vmlinux.bin $@
57
58 ifeq ($(FS),jffs2-8MB)
59 ALIGN:=bs=131072 conv=sync
60 endif
61 ifeq ($(FS),jffs2-4MB)
62 ALIGN:=bs=65536 conv=sync
63 endif
64
65 $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin
66 dd if=$< $(ALIGN) > $@
67 cat $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/root.$(FS) >> $@
68
69 define pattern_template
70 $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin
71 (dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin) | \
72 $(STAGING_DIR)/bin/addpattern -p $(1) $(2) -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin
73
74 install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin
75 endef
76
77 $(eval $(call pattern_template,AG1B))
78 $(eval $(call pattern_template,WA22))
79 $(eval $(call pattern_template,WAG2))
80 $(eval $(call pattern_template,WA21))
81 $(eval $(call pattern_template,WA31,-b))
82 $(eval $(call pattern_template,WA32,-b))
83
84 ifeq ($(IB),)
85 clean:
86 rm -rf $(PKG_BUILD_DIR)
87 rm -f $(BIN_DIR)/openwrt-$(BOARD)*
88
89 prepare: $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/zimage.script $(PKG_BUILD_DIR)/ld.script
90 compile: prepare $(PKG_BUILD_DIR)/loader.o $(PKG_BUILD_DIR)/LzmaDecode.o $(STAGING_DIR)/bin/srec2bin
91 else
92 clean:
93 prepare:
94 compile:
95 endif
96
97 install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin
98 install-ib:
99 mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)
100 cp -fpR $(KDIR)/vmlinux.bin $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/
101 mkdir -p $(IB_DIR)/staging_dir_$(ARCH)
102 cp -fpR $(STAGING_DIR)/bin/addpattern $(IB_DIR)/staging_dir_$(ARCH)/bin/
103
This page took 0.046053 seconds and 5 git commands to generate.