Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # Copyright (C) 2006-2015 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)/kernel.mk
  9. include $(INCLUDE_DIR)/host.mk
  10. include $(INCLUDE_DIR)/version.mk
  11. include $(INCLUDE_DIR)/feeds.mk
  12. override MAKEFLAGS=
  13. IB_NAME:=$(VERSION_DIST)-ImageBuilder-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET)).$(HOST_OS)-$(HOST_ARCH)
  14. PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
  15. IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR))
  16. IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))
  17. IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(ARCH)/boot/dts/
  18. all: compile
  19. $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
  20. rm -rf $(PKG_BUILD_DIR)
  21. mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \
  22. $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR)
  23. -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
  24. $(CP) \
  25. $(INCLUDE_DIR) $(SCRIPT_DIR) \
  26. $(TOPDIR)/rules.mk \
  27. ./files/Makefile \
  28. ./files/repositories.conf \
  29. $(TMP_DIR)/.targetinfo \
  30. $(TMP_DIR)/.packageinfo \
  31. $(PKG_BUILD_DIR)/
  32. ifeq ($(CONFIG_IB_STANDALONE),)
  33. echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf
  34. $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf)
  35. endif
  36. echo '' >> $(PKG_BUILD_DIR)/repositories.conf
  37. echo '## This is the local package repository, do not remove!' >> $(PKG_BUILD_DIR)/repositories.conf
  38. echo 'src imagebuilder file:packages' >> $(PKG_BUILD_DIR)/repositories.conf
  39. $(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf
  40. ifeq ($(CONFIG_IB_STANDALONE),)
  41. (cd $(PACKAGE_DIR); $(FIND) -type f -name 'libc_*.ipk' -or -name 'kernel_*.ipk' -or -name 'kmod-*.ipk') | \
  42. while read path; do \
  43. mkdir -p "$(PKG_BUILD_DIR)/packages/$${path%/*}"; \
  44. cp "$(PACKAGE_DIR)/$$path" "$(PKG_BUILD_DIR)/packages/$$path"; \
  45. done
  46. else
  47. $(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages
  48. endif
  49. $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
  50. if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \
  51. $(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \
  52. fi
  53. rm -rf \
  54. $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
  55. $(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
  56. -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
  57. -cp $(LINUX_DIR)/.config $(IB_LDIR)/
  58. -$(SCRIPT_DIR)/bundle-libraries.sh $(IB_LDIR)/scripts/dtc \
  59. $(LINUX_DIR)/scripts/dtc/dtc
  60. if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \
  61. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \
  62. fi
  63. $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
  64. find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
  65. | $(XARGS) rm -rf
  66. find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \
  67. | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
  68. STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
  69. $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | bzip2 -c > $@
  70. download:
  71. prepare:
  72. compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
  73. install: compile
  74. clean: FORCE
  75. rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2