target/linux/*/image/Makefile: eliminate more LINUX_DIR users
[openwrt/openwrt.git] / target / linux / malta / image / Makefile
1 #
2 # Copyright (C) 2010 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 define get_kernel_entry
11 0x$(shell $(TARGET_CROSS)nm $(1) 2>/dev/null | grep " kernel_entry" | cut -f1 -d ' ')
12 endef
13
14 define CompressLzma
15 $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
16 endef
17
18 define CompressGzip
19 gzip -9 -c $(1) > $(2)
20 endef
21
22 define MkuImage
23 mkimage -A mips -O linux -T kernel -a 0x80100000 -C $(1) $(2) \
24 -e $(call get_kernel_entry,$(KDIR)/vmlinux.debug) -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
25 -d $(3) $(4)
26 endef
27
28 define Image/BuildKernel
29 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.elf
30 $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
31 $(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(BIN_DIR)/$(IMG_PREFIX)-uImage-lzma)
32 $(call CompressGzip,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.gz)
33 $(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(BIN_DIR)/$(IMG_PREFIX)-uImage-gzip)
34 endef
35
36 define Image/Build/squashfs
37 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
38 endef
39
40 define Image/Build
41 $(call Image/Build/$(1))
42 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
43 endef
44
45 $(eval $(call BuildImage))