Makefile 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. define Image/Prepare
  10. $(CP) $(LINUX_DIR)/arch/x86/boot/bzImage $(KDIR)/bzImage
  11. endef
  12. define trxalign/jffs2-128k
  13. bs=128k
  14. endef
  15. define trxalign/jffs2-64k
  16. bs=64k
  17. endef
  18. define trxalign/squashfs
  19. bs=1024
  20. endef
  21. define Image/Build/ar525w
  22. touch $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  23. touch $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2)-web.img
  24. dd if=$(KDIR)/root.$(1) of=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
  25. mv $(KDIR)/root.tmp $(KDIR)/root.$(1)
  26. $(STAGING_DIR_HOST)/bin/airlink -b 1 -j $(shell bash -c 'echo $$[$(3)]') $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  27. $(STAGING_DIR_HOST)/bin/airlink -e -b 1 -j $(shell bash -c 'echo $$[$(3)]') $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2)-web.img
  28. endef
  29. define Image/Build/wl153
  30. ls -l $(KDIR)/bzImage | sed -r 's/^[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+([^[:blank:]]+).+$$$$/\1/' | xargs printf '%.8x' > $(KDIR)/bzSize
  31. gzip -9c $(KDIR)/root.$(1) > $(KDIR)/root.$(1).gz
  32. ls -l $(KDIR)/root.$(1).gz | sed -r 's/^[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+([^[:blank:]]+).+$$$$/\1/' | xargs printf '%.8x' > $(KDIR)/rdSize
  33. echo -ne "\x$$$$(cut -c 7,8 < $(KDIR)/bzSize)\x$$$$(cut -c 5,6 < $(KDIR)/bzSize)\x$$$$(cut -c 3,4 < $(KDIR)/bzSize)\x$$$$(cut -c 1,2 < $(KDIR)/bzSize)" > $(KDIR)/bzSize.tmp
  34. echo -n 'CSYS' > $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  35. cat $(KDIR)/bzSize.tmp >> $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  36. echo -ne "\x$$$$(cut -c 7,8 < $(KDIR)/rdSize)\x$$$$(cut -c 5,6 < $(KDIR)/rdSize)\x$$$$(cut -c 3,4 < $(KDIR)/rdSize)\x$$$$(cut -c 1,2 < $(KDIR)/rdSize)WRRM" >> $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  37. cat $(KDIR)/bzSize.tmp $(KDIR)/bzImage $(KDIR)/root.$(1).gz >> $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  38. $(RM) $(KDIR)/bzSize.tmp $(KDIR)/bzSize $(KDIR)/rdSize
  39. if [ `ls -l $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img | sed -r 's/^[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+[^[:blank:]]+[[:blank:]]+([^[:blank:]]+).+$$$$/\1/'` -gt $$$$((0xffff0000-0xffe08000)) ]; then mv $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img.too_big; echo "#ERR image too big"; fi
  40. endef
  41. define Image/Build/dir450
  42. touch $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
  43. dd if=$(KDIR)/root.$(1) of=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
  44. mv $(KDIR)/root.tmp $(KDIR)/root.$(1)
  45. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/onlyrootfs-$(BOARD)-$(1)-$(2).img
  46. endef
  47. define Image/Build/g570s
  48. mv $(KDIR)/root.$(1) $(KDIR)/root.tmp
  49. dd of=$(KDIR)/root.$(1) if=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
  50. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-tftp-$(BOARD)-$(1)-$(2).img
  51. dd of=$(BIN_DIR)/openwrt-tftp-$(BOARD)-$(1)-$(2).img if=/dev/null bs=1024 seek=1024
  52. cat $(KDIR)/root.$(1) >> $(BIN_DIR)/openwrt-tftp-$(BOARD)-$(1)-$(2).img
  53. if [ ! -x $(STAGING_DIR_HOST)/bin/zyxel_combine ]; then echo "#ERR Please copy the ZyXEL \"combine\" tool as $(STAGING_DIR_HOST)/bin/zyxel_combine to build."; fi
  54. sh -c "mkdir $(KDIR)/zyxel.tmp && cd $(KDIR)/zyxel.tmp && mv ../root.tmp initrd.bin && cp ../bzImage kernel.bin && $(STAGING_DIR_HOST)/bin/zyxel_combine -mcf kernel.bin initrd.bin && mv image $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).rmt" || :
  55. $(RM) -r $(KDIR)/zyxel.tmp
  56. endef
  57. define Image/Build/amit
  58. if [ ! -x $(STAGING_DIR_HOST)/bin/amit_makebin ]; then echo "#ERR Please copy the AMIT \"makebin\" tool from http://mgb111.pradnik.net/ as $(STAGING_DIR_HOST)/bin/amit_makebin to build."; fi
  59. sh -c "mkdir -p $(KDIR)/amit.tmp/linux_src/arch/i386/boot $(KDIR)/amit.tmp/rom_disk && cd $(KDIR)/amit.tmp && ln -s ../../root.$(1) rom_disk/fs.img && ln -s ../../../../../bzImage linux_src/arch/i386/boot && $(STAGING_DIR_HOST)/bin/amit_makebin && mv upgrade.img $(BIN_DIR)/openwrt-$(BOARD)-$(1)-anas350.bin" || :
  60. $(RM) -r $(KDIR)/amit.tmp
  61. $(STAGING_DIR_HOST)/bin/makeamitbin -o $(BIN_DIR)/openwrt-$(BOARD)-$(1)-ar360w3g.bin -1 ALK_ATG001 -2 Atropos linux3g $(KDIR)/bzImage ramdisk3g $(KDIR)/root.$(1)
  62. endef
  63. define Image/Build/Initramfs
  64. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-ramfs.bzImage
  65. endef
  66. define Image/Build
  67. $(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD).bzImage
  68. $(call Image/Build/$(PROFILE),$(1),$(PROFILE),$(patsubst jffs2-%k,%,$(1)))
  69. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  70. $(call Image/Build/Initramfs)
  71. endif
  72. endef
  73. $(eval $(call BuildImage))